-
Notifications
You must be signed in to change notification settings - Fork 1
/
ia64.c
4449 lines (3820 loc) · 125 KB
/
ia64.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* ia64.c - core analysis suite
*
* Copyright (C) 1999, 2000, 2001, 2002 Mission Critical Linux, Inc.
* Copyright (C) 2002-2013 David Anderson
* Copyright (C) 2002-2013 Red Hat, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifdef IA64
#include "defs.h"
#include "xen_hyper_defs.h"
#include <sys/prctl.h>
static int ia64_verify_symbol(const char *, ulong, char);
static int ia64_eframe_search(struct bt_info *);
static void ia64_back_trace_cmd(struct bt_info *);
static void ia64_old_unwind(struct bt_info *);
static void ia64_old_unwind_init(void);
static void try_old_unwind(struct bt_info *);
static void ia64_dump_irq(int);
static ulong ia64_processor_speed(void);
static int ia64_vtop_4l(ulong, physaddr_t *paddr, ulong *pgd, int, int);
static int ia64_vtop(ulong, physaddr_t *paddr, ulong *pgd, int, int);
static int ia64_uvtop(struct task_context *, ulong, physaddr_t *, int);
static int ia64_kvtop(struct task_context *, ulong, physaddr_t *, int);
static ulong ia64_get_task_pgd(ulong);
static ulong ia64_get_pc(struct bt_info *);
static ulong ia64_get_sp(struct bt_info *);
static ulong ia64_get_thread_ksp(ulong);
static void ia64_get_stack_frame(struct bt_info *, ulong *, ulong *);
static int ia64_translate_pte(ulong, void *, ulonglong);
static ulong ia64_vmalloc_start(void);
static int ia64_is_task_addr(ulong);
static int ia64_dis_filter(ulong, char *, unsigned int);
static void ia64_dump_switch_stack(ulong, ulong);
static void ia64_cmd_mach(void);
static int ia64_get_smp_cpus(void);
static void ia64_display_machine_stats(void);
static void ia64_display_cpu_data(unsigned int);
static void ia64_display_memmap(void);
static void ia64_create_memmap(void);
static ulong check_mem_limit(void);
static int ia64_verify_paddr(uint64_t);
static int ia64_available_memory(struct efi_memory_desc_t *);
static void ia64_post_init(void);
static ulong ia64_in_per_cpu_mca_stack(void);
static struct line_number_hook ia64_line_number_hooks[];
static ulong ia64_get_stackbase(ulong);
static ulong ia64_get_stacktop(ulong);
static void parse_cmdline_args(void);
static void ia64_calc_phys_start(void);
static int ia64_get_kvaddr_ranges(struct vaddr_range *);
struct unw_frame_info;
static void dump_unw_frame_info(struct unw_frame_info *);
static int old_unw_unwind(struct unw_frame_info *);
static void unw_init_from_blocked_task(struct unw_frame_info *, ulong);
static ulong ia64_rse_slot_num(ulong *);
static ulong *ia64_rse_skip_regs(ulong *, long);
static ulong *ia64_rse_rnat_addr(ulong *);
static ulong rse_read_reg(struct unw_frame_info *, int, int *);
static void rse_function_params(struct unw_frame_info *, char *);
static int ia64_vtop_4l_xen_wpt(ulong, physaddr_t *paddr, ulong *pgd, int, int);
static int ia64_vtop_xen_wpt(ulong, physaddr_t *paddr, ulong *pgd, int, int);
static int ia64_xen_kdump_p2m_create(struct xen_kdump_data *);
static int ia64_xendump_p2m_create(struct xendump_data *);
static void ia64_debug_dump_page(FILE *, char *, char *);
static char *ia64_xendump_load_page(ulong, struct xendump_data *);
static int ia64_xendump_page_index(ulong, struct xendump_data *);
static ulong ia64_xendump_panic_task(struct xendump_data *);
static void ia64_get_xendump_regs(struct xendump_data *, struct bt_info *, ulong *, ulong *);
static void ia64_init_hyper(int);
struct machine_specific ia64_machine_specific = { 0 };
void
ia64_init(int when)
{
struct syment *sp, *spn;
if (XEN_HYPER_MODE()) {
ia64_init_hyper(when);
return;
}
switch (when)
{
case SETUP_ENV:
#if defined(PR_SET_FPEMU) && defined(PR_FPEMU_NOPRINT)
prctl(PR_SET_FPEMU, PR_FPEMU_NOPRINT, 0, 0, 0);
#endif
#if defined(PR_SET_UNALIGN) && defined(PR_UNALIGN_NOPRINT)
prctl(PR_SET_UNALIGN, PR_UNALIGN_NOPRINT, 0, 0, 0);
#endif
break;
case PRE_SYMTAB:
machdep->verify_symbol = ia64_verify_symbol;
machdep->machspec = &ia64_machine_specific;
if (pc->flags & KERNEL_DEBUG_QUERY)
return;
machdep->pagesize = memory_page_size();
machdep->pageshift = ffs(machdep->pagesize) - 1;
machdep->pageoffset = machdep->pagesize - 1;
machdep->pagemask = ~(machdep->pageoffset);
switch (machdep->pagesize)
{
case 4096:
machdep->stacksize = (power(2, 3) * PAGESIZE());
break;
case 8192:
machdep->stacksize = (power(2, 2) * PAGESIZE());
break;
case 16384:
machdep->stacksize = (power(2, 1) * PAGESIZE());
break;
case 65536:
machdep->stacksize = (power(2, 0) * PAGESIZE());
break;
default:
machdep->stacksize = 32*1024;
break;
}
if ((machdep->pgd = (char *)malloc(PAGESIZE())) == NULL)
error(FATAL, "cannot malloc pgd space.");
if ((machdep->pud = (char *)malloc(PAGESIZE())) == NULL)
error(FATAL, "cannot malloc pud space.");
if ((machdep->pmd = (char *)malloc(PAGESIZE())) == NULL)
error(FATAL, "cannot malloc pmd space.");
if ((machdep->ptbl = (char *)malloc(PAGESIZE())) == NULL)
error(FATAL, "cannot malloc ptbl space.");
machdep->last_pgd_read = 0;
machdep->last_pud_read = 0;
machdep->last_pmd_read = 0;
machdep->last_ptbl_read = 0;
machdep->verify_paddr = ia64_verify_paddr;
machdep->get_kvaddr_ranges = ia64_get_kvaddr_ranges;
machdep->ptrs_per_pgd = PTRS_PER_PGD;
machdep->machspec->phys_start = UNKNOWN_PHYS_START;
if (machdep->cmdline_args[0])
parse_cmdline_args();
if (ACTIVE())
machdep->flags |= DEVMEMRD;
break;
case PRE_GDB:
if (pc->flags & KERNEL_DEBUG_QUERY)
return;
/*
* Until the kernel core dump and va_server library code
* do the right thing with respect to the configured page size,
* try to recognize a fatal inequity between the compiled-in
* page size and the page size used by the kernel.
*/
if ((sp = symbol_search("empty_zero_page")) &&
(spn = next_symbol(NULL, sp)) &&
((spn->value - sp->value) != PAGESIZE()))
error(FATAL,
"compiled-in page size: %d (apparent) kernel page size: %ld\n",
PAGESIZE(), spn->value - sp->value);
machdep->kvbase = KERNEL_VMALLOC_BASE;
machdep->identity_map_base = KERNEL_CACHED_BASE;
machdep->is_kvaddr = generic_is_kvaddr;
machdep->is_uvaddr = generic_is_uvaddr;
machdep->eframe_search = ia64_eframe_search;
machdep->back_trace = ia64_back_trace_cmd;
machdep->processor_speed = ia64_processor_speed;
machdep->uvtop = ia64_uvtop;
machdep->kvtop = ia64_kvtop;
machdep->get_task_pgd = ia64_get_task_pgd;
machdep->dump_irq = ia64_dump_irq;
machdep->get_stack_frame = ia64_get_stack_frame;
machdep->get_stackbase = ia64_get_stackbase;
machdep->get_stacktop = ia64_get_stacktop;
machdep->translate_pte = ia64_translate_pte;
machdep->memory_size = generic_memory_size;
machdep->vmalloc_start = ia64_vmalloc_start;
machdep->is_task_addr = ia64_is_task_addr;
machdep->dis_filter = ia64_dis_filter;
machdep->cmd_mach = ia64_cmd_mach;
machdep->get_smp_cpus = ia64_get_smp_cpus;
machdep->line_number_hooks = ia64_line_number_hooks;
machdep->value_to_symbol = generic_machdep_value_to_symbol;
machdep->init_kernel_pgd = NULL;
machdep->get_irq_affinity = generic_get_irq_affinity;
machdep->show_interrupts = generic_show_interrupts;
if ((sp = symbol_search("_stext"))) {
machdep->machspec->kernel_region =
VADDR_REGION(sp->value);
machdep->machspec->kernel_start = sp->value;
} else {
machdep->machspec->kernel_region = KERNEL_CACHED_REGION;
machdep->machspec->kernel_start = KERNEL_CACHED_BASE;
}
if (machdep->machspec->kernel_region == KERNEL_VMALLOC_REGION) {
machdep->machspec->vmalloc_start =
machdep->machspec->kernel_start +
GIGABYTES((ulong)(4));
if (machdep->machspec->phys_start == UNKNOWN_PHYS_START)
ia64_calc_phys_start();
} else
machdep->machspec->vmalloc_start = KERNEL_VMALLOC_BASE;
machdep->xen_kdump_p2m_create = ia64_xen_kdump_p2m_create;
machdep->xendump_p2m_create = ia64_xendump_p2m_create;
machdep->xendump_panic_task = ia64_xendump_panic_task;
machdep->get_xendump_regs = ia64_get_xendump_regs;
break;
case POST_GDB:
STRUCT_SIZE_INIT(cpuinfo_ia64, "cpuinfo_ia64");
STRUCT_SIZE_INIT(switch_stack, "switch_stack");
MEMBER_OFFSET_INIT(thread_struct_fph, "thread_struct", "fph");
MEMBER_OFFSET_INIT(switch_stack_b0, "switch_stack", "b0");
MEMBER_OFFSET_INIT(switch_stack_ar_bspstore,
"switch_stack", "ar_bspstore");
MEMBER_OFFSET_INIT(switch_stack_ar_pfs,
"switch_stack", "ar_pfs");
MEMBER_OFFSET_INIT(switch_stack_ar_rnat,
"switch_stack", "ar_rnat");
MEMBER_OFFSET_INIT(switch_stack_pr,
"switch_stack", "pr");
MEMBER_OFFSET_INIT(cpuinfo_ia64_proc_freq,
"cpuinfo_ia64", "proc_freq");
MEMBER_OFFSET_INIT(cpuinfo_ia64_unimpl_va_mask,
"cpuinfo_ia64", "unimpl_va_mask");
MEMBER_OFFSET_INIT(cpuinfo_ia64_unimpl_pa_mask,
"cpuinfo_ia64", "unimpl_pa_mask");
if (kernel_symbol_exists("nr_irqs"))
get_symbol_data("nr_irqs", sizeof(unsigned int),
&machdep->nr_irqs);
else if (symbol_exists("irq_desc"))
ARRAY_LENGTH_INIT(machdep->nr_irqs, irq_desc,
"irq_desc", NULL, 0);
else if (symbol_exists("_irq_desc"))
ARRAY_LENGTH_INIT(machdep->nr_irqs, irq_desc,
"_irq_desc", NULL, 0);
if (!machdep->hz)
machdep->hz = 1024;
machdep->section_size_bits = _SECTION_SIZE_BITS;
machdep->max_physmem_bits = _MAX_PHYSMEM_BITS;
ia64_create_memmap();
break;
case POST_INIT:
ia64_post_init();
break;
case LOG_ONLY:
machdep->machspec = &ia64_machine_specific;
machdep->machspec->kernel_start = kt->vmcoreinfo._stext_SYMBOL;
machdep->machspec->kernel_region =
VADDR_REGION(kt->vmcoreinfo._stext_SYMBOL);
if (machdep->machspec->kernel_region == KERNEL_VMALLOC_REGION) {
machdep->machspec->vmalloc_start =
machdep->machspec->kernel_start +
GIGABYTES((ulong)(4));
ia64_calc_phys_start();
}
break;
}
}
/*
* --machdep <addr> defaults to the physical start location.
*
* Otherwise, it's got to be a "item=value" string, separated
* by commas if more than one is passed in.
*/
void
parse_cmdline_args(void)
{
int index, i, c, errflag;
char *p;
char buf[BUFSIZE];
char *arglist[MAXARGS];
ulong value;
struct machine_specific *ms;
int vm_flag;
ms = &ia64_machine_specific;
vm_flag = 0;
for (index = 0; index < MAX_MACHDEP_ARGS; index++) {
if (!machdep->cmdline_args[index])
break;
if (!strstr(machdep->cmdline_args[index], "=")) {
errflag = 0;
value = htol(machdep->cmdline_args[index],
RETURN_ON_ERROR|QUIET, &errflag);
if (!errflag) {
ms->phys_start = value;
error(NOTE, "setting phys_start to: 0x%lx\n",
ms->phys_start);
} else
error(WARNING, "ignoring --machdep option: %s\n\n",
machdep->cmdline_args[index]);
continue;
}
strcpy(buf, machdep->cmdline_args[index]);
for (p = buf; *p; p++) {
if (*p == ',')
*p = ' ';
}
c = parse_line(buf, arglist);
for (i = 0; i < c; i++) {
errflag = 0;
if (STRNEQ(arglist[i], "phys_start=")) {
p = arglist[i] + strlen("phys_start=");
if (strlen(p)) {
value = htol(p, RETURN_ON_ERROR|QUIET,
&errflag);
if (!errflag) {
ms->phys_start = value;
error(NOTE,
"setting phys_start to: 0x%lx\n",
ms->phys_start);
continue;
}
}
} else if (STRNEQ(arglist[i], "init_stack_size=")) {
p = arglist[i] + strlen("init_stack_size=");
if (strlen(p)) {
value = stol(p, RETURN_ON_ERROR|QUIET,
&errflag);
if (!errflag) {
ms->ia64_init_stack_size = (int)value;
error(NOTE,
"setting init_stack_size to: 0x%x (%d)\n",
ms->ia64_init_stack_size,
ms->ia64_init_stack_size);
continue;
}
}
} else if (STRNEQ(arglist[i], "vm=")) {
vm_flag++;
p = arglist[i] + strlen("vm=");
if (strlen(p)) {
if (STREQ(p, "4l")) {
machdep->flags |= VM_4_LEVEL;
continue;
}
}
}
error(WARNING, "ignoring --machdep option: %s\n", arglist[i]);
}
if (vm_flag) {
switch (machdep->flags & (VM_4_LEVEL))
{
case VM_4_LEVEL:
error(NOTE, "using 4-level pagetable\n");
c++;
break;
default:
error(WARNING, "invalid vm= option\n");
c++;
machdep->flags &= ~(VM_4_LEVEL);
break;
}
}
if (c)
fprintf(fp, "\n");
}
}
int
ia64_in_init_stack(ulong addr)
{
ulong init_stack_addr;
if (!symbol_exists("ia64_init_stack"))
return FALSE;
/*
* ia64_init_stack could be aliased to region 5
*/
init_stack_addr = ia64_VTOP(symbol_value("ia64_init_stack"));
addr = ia64_VTOP(addr);
if ((addr < init_stack_addr) ||
(addr >= (init_stack_addr+machdep->machspec->ia64_init_stack_size)))
return FALSE;
return TRUE;
}
static ulong
ia64_in_per_cpu_mca_stack(void)
{
int plen, i;
ulong flag;
ulong vaddr, paddr, stackbase, stacktop;
ulong *__per_cpu_mca;
struct task_context *tc;
tc = CURRENT_CONTEXT();
if (STRNEQ(CURRENT_COMM(), "INIT"))
flag = INIT;
else if (STRNEQ(CURRENT_COMM(), "MCA"))
flag = MCA;
else
return 0;
if (!symbol_exists("__per_cpu_mca") ||
!(plen = get_array_length("__per_cpu_mca", NULL, 0)) ||
(plen < kt->cpus))
return 0;
vaddr = SWITCH_STACK_ADDR(CURRENT_TASK());
if (VADDR_REGION(vaddr) != KERNEL_CACHED_REGION)
return 0;
paddr = ia64_VTOP(vaddr);
__per_cpu_mca = (ulong *)GETBUF(sizeof(ulong) * kt->cpus);
if (!readmem(symbol_value("__per_cpu_mca"), KVADDR, __per_cpu_mca,
sizeof(ulong) * kt->cpus, "__per_cpu_mca", RETURN_ON_ERROR|QUIET))
return 0;
if (CRASHDEBUG(1)) {
for (i = 0; i < kt->cpus; i++) {
fprintf(fp, "__per_cpu_mca[%d]: %lx\n",
i, __per_cpu_mca[i]);
}
}
stackbase = __per_cpu_mca[tc->processor];
stacktop = stackbase + (STACKSIZE() * 2);
FREEBUF(__per_cpu_mca);
if ((paddr >= stackbase) && (paddr < stacktop))
return flag;
else
return 0;
}
void
ia64_dump_machdep_table(ulong arg)
{
int i, others, verbose;
struct machine_specific *ms;
verbose = FALSE;
ms = &ia64_machine_specific;
if (arg) {
switch (arg)
{
default:
case 1:
verbose = TRUE;
break;
case 2:
if (machdep->flags & NEW_UNWIND) {
machdep->flags &=
~(NEW_UNWIND|NEW_UNW_V1|NEW_UNW_V2|NEW_UNW_V3);
machdep->flags |= OLD_UNWIND;
ms->unwind_init = ia64_old_unwind_init;
ms->unwind = ia64_old_unwind;
ms->dump_unwind_stats = NULL;
ms->unwind_debug = NULL;
} else {
machdep->flags &= ~OLD_UNWIND;
machdep->flags |= NEW_UNWIND;
if (MEMBER_EXISTS("unw_frame_info", "pt")) {
if (MEMBER_EXISTS("pt_regs", "ar_csd")) {
machdep->flags |= NEW_UNW_V3;
ms->unwind_init = unwind_init_v3;
ms->unwind = unwind_v3;
ms->unwind_debug = unwind_debug_v3;
ms->dump_unwind_stats =
dump_unwind_stats_v3;
} else {
machdep->flags |= NEW_UNW_V2;
ms->unwind_init = unwind_init_v2;
ms->unwind = unwind_v2;
ms->unwind_debug = unwind_debug_v2;
ms->dump_unwind_stats =
dump_unwind_stats_v2;
}
} else {
machdep->flags |= NEW_UNW_V1;
ms->unwind_init = unwind_init_v1;
ms->unwind = unwind_v1;
ms->unwind_debug = unwind_debug_v1;
ms->dump_unwind_stats =
dump_unwind_stats_v1;
}
}
ms->unwind_init();
return;
case 3:
if (machdep->flags & NEW_UNWIND)
ms->unwind_debug(arg);
return;
}
}
others = 0;
fprintf(fp, " flags: %lx (", machdep->flags);
/* future flags tests here */
if (machdep->flags & NEW_UNWIND)
fprintf(fp, "%sNEW_UNWIND", others++ ? "|" : "");
if (machdep->flags & NEW_UNW_V1)
fprintf(fp, "%sNEW_UNW_V1", others++ ? "|" : "");
if (machdep->flags & NEW_UNW_V2)
fprintf(fp, "%sNEW_UNW_V2", others++ ? "|" : "");
if (machdep->flags & NEW_UNW_V3)
fprintf(fp, "%sNEW_UNW_V3", others++ ? "|" : "");
if (machdep->flags & OLD_UNWIND)
fprintf(fp, "%sOLD_UNWIND", others++ ? "|" : "");
if (machdep->flags & UNW_OUT_OF_SYNC)
fprintf(fp, "%sUNW_OUT_OF_SYNC", others++ ? "|" : "");
if (machdep->flags & UNW_READ)
fprintf(fp, "%sUNW_READ", others++ ? "|" : "");
if (machdep->flags & UNW_PTREGS)
fprintf(fp, "%sUNW_PTREGS", others++ ? "|" : "");
if (machdep->flags & UNW_R0)
fprintf(fp, "%sUNW_R0", others++ ? "|" : "");
if (machdep->flags & MEM_LIMIT)
fprintf(fp, "%sMEM_LIMIT", others++ ? "|" : "");
if (machdep->flags & DEVMEMRD)
fprintf(fp, "%sDEVMEMRD", others++ ? "|" : "");
if (machdep->flags & INIT)
fprintf(fp, "%sINIT", others++ ? "|" : "");
if (machdep->flags & MCA)
fprintf(fp, "%sMCA", others++ ? "|" : "");
if (machdep->flags & VM_4_LEVEL)
fprintf(fp, "%sVM_4_LEVEL", others++ ? "|" : "");
fprintf(fp, ")\n");
fprintf(fp, " kvbase: %lx\n", machdep->kvbase);
fprintf(fp, " identity_map_base: %lx\n", machdep->identity_map_base);
fprintf(fp, " pagesize: %d\n", machdep->pagesize);
fprintf(fp, " pageshift: %d\n", machdep->pageshift);
fprintf(fp, " pagemask: %llx\n", machdep->pagemask);
fprintf(fp, " pageoffset: %lx\n", machdep->pageoffset);
fprintf(fp, " stacksize: %ld\n", machdep->stacksize);
fprintf(fp, " hz: %d\n", machdep->hz);
fprintf(fp, " mhz: %d\n", machdep->hz);
fprintf(fp, " memsize: %ld (0x%lx)\n",
machdep->memsize, machdep->memsize);
fprintf(fp, " bits: %d\n", machdep->bits);
fprintf(fp, " nr_irqs: %d\n", machdep->nr_irqs);
fprintf(fp, " eframe_search: ia64_eframe_search()\n");
fprintf(fp, " back_trace: ia64_back_trace_cmd()\n");
fprintf(fp, "get_processor_speed: ia64_processor_speed()\n");
fprintf(fp, " uvtop: ia64_uvtop()\n");
fprintf(fp, " kvtop: ia64_kvtop()\n");
fprintf(fp, " get_task_pgd: ia64_get_task_pgd()\n");
fprintf(fp, " dump_irq: ia64_dump_irq()\n");
fprintf(fp, " get_stack_frame: ia64_get_stack_frame()\n");
fprintf(fp, " get_stackbase: ia64_get_stackbase()\n");
fprintf(fp, " get_stacktop: ia64_get_stacktop()\n");
fprintf(fp, " translate_pte: ia64_translate_pte()\n");
fprintf(fp, " memory_size: generic_memory_size()\n");
fprintf(fp, " vmalloc_start: ia64_vmalloc_start()\n");
fprintf(fp, " is_task_addr: ia64_is_task_addr()\n");
fprintf(fp, " verify_symbol: ia64_verify_symbol()\n");
fprintf(fp, " dis_filter: ia64_dis_filter()\n");
fprintf(fp, " cmd_mach: ia64_cmd_mach()\n");
fprintf(fp, " get_smp_cpus: ia64_get_smp_cpus()\n");
fprintf(fp, " get_kvaddr_ranges: ia64_get_kvaddr_ranges()\n");
fprintf(fp, " is_kvaddr: generic_is_kvaddr()\n");
fprintf(fp, " is_uvaddr: generic_is_uvaddr()\n");
fprintf(fp, " verify_paddr: %s()\n",
(machdep->verify_paddr == ia64_verify_paddr) ?
"ia64_verify_paddr" : "generic_verify_paddr");
fprintf(fp, " get_irq_affinity: generic_get_irq_affinity()\n");
fprintf(fp, " show_interrupts: generic_show_interrupts()\n");
fprintf(fp, " init_kernel_pgd: NULL\n");
fprintf(fp, "xen_kdump_p2m_create: ia64_xen_kdump_p2m_create()\n");
fprintf(fp, " xendump_p2m_create: ia64_xendump_p2m_create()\n");
fprintf(fp, " xendump_panic_task: ia64_xendump_panic_task()\n");
fprintf(fp, " get_xendump_regs: ia64_get_xendump_regs()\n");
fprintf(fp, " value_to_symbol: generic_machdep_value_to_symbol()\n");
fprintf(fp, " line_number_hooks: ia64_line_number_hooks\n");
fprintf(fp, " last_pgd_read: %lx\n", machdep->last_pgd_read);
fprintf(fp, " last_pud_read: %lx\n", machdep->last_pud_read);
fprintf(fp, " last_pmd_read: %lx\n", machdep->last_pmd_read);
fprintf(fp, " last_ptbl_read: %lx\n", machdep->last_ptbl_read);
fprintf(fp, " pgd: %lx\n", (ulong)machdep->pgd);
fprintf(fp, " pud: %lx\n", (ulong)machdep->pud);
fprintf(fp, " pmd: %lx\n", (ulong)machdep->pmd);
fprintf(fp, " ptbl: %lx\n", (ulong)machdep->ptbl);
fprintf(fp, " ptrs_per_pgd: %d\n", machdep->ptrs_per_pgd);
for (i = 0; i < MAX_MACHDEP_ARGS; i++) {
fprintf(fp, " cmdline_args[%d]: %s\n",
i, machdep->cmdline_args[i] ?
machdep->cmdline_args[i] : "(unused)");
}
fprintf(fp, " section_size_bits: %ld\n", machdep->section_size_bits);
fprintf(fp, " max_physmem_bits: %ld\n", machdep->max_physmem_bits);
fprintf(fp, " sections_per_root: %ld\n", machdep->sections_per_root);
fprintf(fp, " machspec: ia64_machine_specific\n");
fprintf(fp, " cpu_data_address: %lx\n",
machdep->machspec->cpu_data_address);
fprintf(fp, " unimpl_va_mask: %lx\n",
machdep->machspec->unimpl_va_mask);
fprintf(fp, " unimpl_pa_mask: %lx\n",
machdep->machspec->unimpl_pa_mask);
fprintf(fp, " unw: %lx\n",
(ulong)machdep->machspec->unw);
fprintf(fp, " unw_tables_offset: %ld\n",
machdep->machspec->unw_tables_offset);
fprintf(fp, " unw_kernel_table_offset: %ld %s\n",
machdep->machspec->unw_kernel_table_offset,
machdep->machspec->unw_kernel_table_offset ? "" : "(unused)");
fprintf(fp, " unw_pt_regs_offsets: %ld %s\n",
machdep->machspec->unw_pt_regs_offsets,
machdep->machspec->unw_pt_regs_offsets ? "" : "(unused)");
fprintf(fp, " script_index: %d\n",
machdep->machspec->script_index);
fprintf(fp, " script_cache: %lx%s",
(ulong)machdep->machspec->script_cache,
machdep->flags & OLD_UNWIND ? "\n" : " ");
if (machdep->flags & NEW_UNWIND)
ms->dump_unwind_stats();
if (!(machdep->flags & (NEW_UNWIND|OLD_UNWIND)))
fprintf(fp, "\n");
fprintf(fp, " mem_limit: %lx\n",
machdep->machspec->mem_limit);
fprintf(fp, " kernel_region: %ld\n",
machdep->machspec->kernel_region);
fprintf(fp, " kernel_start: %lx\n",
machdep->machspec->kernel_start);
fprintf(fp, " phys_start: %lx (%lx)\n",
machdep->machspec->phys_start,
machdep->machspec->phys_start & KERNEL_TR_PAGE_MASK);
fprintf(fp, " vmalloc_start: %lx\n",
machdep->machspec->vmalloc_start);
fprintf(fp, " ia64_memmap: %lx\n",
(ulong)machdep->machspec->ia64_memmap);
fprintf(fp, " efi_memmap_size: %ld\n",
(ulong)machdep->machspec->efi_memmap_size);
fprintf(fp, " efi_memdesc_size: %ld\n",
(ulong)machdep->machspec->efi_memdesc_size);
fprintf(fp, " unwind_init: ");
if (ms->unwind_init == unwind_init_v1)
fprintf(fp, "unwind_init_v1()\n");
else if (ms->unwind_init == unwind_init_v2)
fprintf(fp, "unwind_init_v2()\n");
else if (ms->unwind_init == unwind_init_v3)
fprintf(fp, "unwind_init_v3()\n");
else if (ms->unwind_init == ia64_old_unwind_init)
fprintf(fp, "ia64_old_unwind_init()\n");
else
fprintf(fp, "%lx\n", (ulong)ms->unwind_init);
fprintf(fp, " unwind: ");
if (ms->unwind == unwind_v1)
fprintf(fp, "unwind_v1()\n");
else if (ms->unwind == unwind_v2)
fprintf(fp, "unwind_v2()\n");
else if (ms->unwind == unwind_v3)
fprintf(fp, "unwind_v3()\n");
else if (ms->unwind == ia64_old_unwind)
fprintf(fp, "ia64_old_unwind()\n");
else
fprintf(fp, "%lx\n", (ulong)ms->unwind);
fprintf(fp, " dump_unwind_stats: ");
if (ms->dump_unwind_stats == dump_unwind_stats_v1)
fprintf(fp, "dump_unwind_stats_v1()\n");
else if (ms->dump_unwind_stats == dump_unwind_stats_v2)
fprintf(fp, "dump_unwind_stats_v2()\n");
else if (ms->dump_unwind_stats == dump_unwind_stats_v3)
fprintf(fp, "dump_unwind_stats_v3()\n");
else
fprintf(fp, "%lx\n", (ulong)ms->dump_unwind_stats);
fprintf(fp, " unwind_debug: ");
if (ms->unwind_debug == unwind_debug_v1)
fprintf(fp, "unwind_debug_v1()\n");
else if (ms->unwind_debug == unwind_debug_v2)
fprintf(fp, "unwind_debug_v2()\n");
else if (ms->unwind_debug == unwind_debug_v3)
fprintf(fp, "unwind_debug_v3()\n");
else
fprintf(fp, "%lx\n", (ulong)ms->unwind_debug);
fprintf(fp, " ia64_init_stack_size: %d\n",
ms->ia64_init_stack_size);
if (verbose)
ia64_display_memmap();
}
/*
* Keep or reject a symbol from the namelist.
*/
static int
ia64_verify_symbol(const char *name, ulong value, char type)
{
ulong region;
if (!name || !strlen(name))
return FALSE;
if (XEN_HYPER_MODE() && STREQ(name, "__per_cpu_shift"))
return TRUE;
if (CRASHDEBUG(8))
fprintf(fp, "%016lx %s\n", value, name);
// if (STREQ(name, "phys_start") && type == 'A')
// if (machdep->machspec->phys_start == UNKNOWN_PHYS_START)
// machdep->machspec->phys_start = value;
region = VADDR_REGION(value);
return (((region == KERNEL_CACHED_REGION) ||
(region == KERNEL_VMALLOC_REGION)));
}
/*
* Look for likely exception frames in a stack.
*/
static int
ia64_eframe_search(struct bt_info *bt)
{
return(error(FATAL,
"ia64_eframe_search: not available for this architecture\n"));
}
/*
* Unroll a kernel stack.
*/
#define BT_SWITCH_STACK BT_SYMBOLIC_ARGS
static void
ia64_back_trace_cmd(struct bt_info *bt)
{
struct machine_specific *ms = &ia64_machine_specific;
if (bt->flags & BT_SWITCH_STACK)
ia64_dump_switch_stack(bt->task, 0);
if (machdep->flags & UNW_OUT_OF_SYNC)
error(FATAL,
"kernel and %s unwind data structures are out of sync\n",
pc->program_name);
ms->unwind(bt);
if (bt->flags & BT_UNWIND_ERROR)
try_old_unwind(bt);
}
/*
* Dump the IRQ table.
*/
static void
ia64_dump_irq(int irq)
{
if (symbol_exists("irq_desc") || symbol_exists("_irq_desc") ||
kernel_symbol_exists("irq_desc_ptrs")) {
machdep->dump_irq = generic_dump_irq;
return(generic_dump_irq(irq));
}
error(FATAL,
"ia64_dump_irq: neither irq_desc or _irq_desc exist\n");
}
/*
* Calculate and return the speed of the processor.
*/
static ulong
ia64_processor_speed(void)
{
ulong mhz, proc_freq;
int bootstrap_processor;
if (machdep->mhz)
return(machdep->mhz);
mhz = 0;
bootstrap_processor = 0;
if (!machdep->machspec->cpu_data_address ||
!VALID_STRUCT(cpuinfo_ia64) ||
!VALID_MEMBER(cpuinfo_ia64_proc_freq))
return (machdep->mhz = mhz);
if (symbol_exists("bootstrap_processor"))
get_symbol_data("bootstrap_processor", sizeof(int),
&bootstrap_processor);
if (bootstrap_processor == -1)
bootstrap_processor = 0;
readmem(machdep->machspec->cpu_data_address +
OFFSET(cpuinfo_ia64_proc_freq),
KVADDR, &proc_freq, sizeof(ulong),
"cpuinfo_ia64 proc_freq", FAULT_ON_ERROR);
mhz = proc_freq/1000000;
return (machdep->mhz = mhz);
}
/* Generic abstraction to translate user or kernel virtual
* addresses to physical using a 4 level page table.
*/
static int
ia64_vtop_4l(ulong vaddr, physaddr_t *paddr, ulong *pgd, int verbose, int usr)
{
ulong *page_dir;
ulong *page_upper;
ulong *page_middle;
ulong *page_table;
ulong pgd_pte;
ulong pud_pte;
ulong pmd_pte;
ulong pte;
ulong region, offset;
if (usr) {
region = VADDR_REGION(vaddr);
offset = (vaddr >> PGDIR_SHIFT) & ((PTRS_PER_PGD >> 3) - 1);
offset |= (region << (PAGESHIFT() - 6));
page_dir = pgd + offset;
} else {
if (!(pgd = (ulong *)vt->kernel_pgd[0]))
error(FATAL, "cannot determine kernel pgd pointer\n");
page_dir = pgd + ((vaddr >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1));
}
if (verbose)
fprintf(fp, "PAGE DIRECTORY: %lx\n", (ulong)pgd);
FILL_PGD(PAGEBASE(pgd), KVADDR, PAGESIZE());
pgd_pte = ULONG(machdep->pgd + PAGEOFFSET(page_dir));
if (verbose)
fprintf(fp, " PGD: %lx => %lx\n", (ulong)page_dir, pgd_pte);
if (!(pgd_pte))
return FALSE;
offset = (vaddr >> PUD_SHIFT) & (PTRS_PER_PUD - 1);
page_upper = (ulong *)(PTOV(pgd_pte & _PFN_MASK)) + offset;
FILL_PUD(PAGEBASE(page_upper), KVADDR, PAGESIZE());
pud_pte = ULONG(machdep->pud + PAGEOFFSET(page_upper));
if (verbose)
fprintf(fp, " PUD: %lx => %lx\n", (ulong)page_upper, pud_pte);
if (!(pud_pte))
return FALSE;
offset = (vaddr >> PMD_SHIFT) & (PTRS_PER_PMD - 1);
page_middle = (ulong *)(PTOV(pud_pte & _PFN_MASK)) + offset;
FILL_PMD(PAGEBASE(page_middle), KVADDR, PAGESIZE());
pmd_pte = ULONG(machdep->pmd + PAGEOFFSET(page_middle));
if (verbose)
fprintf(fp, " PMD: %lx => %lx\n", (ulong)page_middle, pmd_pte);
if (!(pmd_pte))
return FALSE;
offset = (vaddr >> PAGESHIFT()) & (PTRS_PER_PTE - 1);
page_table = (ulong *)(PTOV(pmd_pte & _PFN_MASK)) + offset;
FILL_PTBL(PAGEBASE(page_table), KVADDR, PAGESIZE());
pte = ULONG(machdep->ptbl + PAGEOFFSET(page_table));
if (verbose)
fprintf(fp, " PTE: %lx => %lx\n", (ulong)page_table, pte);
if (!(pte & (_PAGE_P | _PAGE_PROTNONE))) {
if (usr)
*paddr = pte;
if (pte && verbose) {
fprintf(fp, "\n");
ia64_translate_pte(pte, 0, 0);
}
return FALSE;
}
*paddr = (pte & _PFN_MASK) + PAGEOFFSET(vaddr);
if (verbose) {
fprintf(fp, " PAGE: %lx\n\n", PAGEBASE(*paddr));
ia64_translate_pte(pte, 0, 0);
}
return TRUE;
}
/* Generic abstraction to translate user or kernel virtual
* addresses to physical using a 3 level page table.
*/
static int
ia64_vtop(ulong vaddr, physaddr_t *paddr, ulong *pgd, int verbose, int usr)
{
ulong *page_dir;
ulong *page_middle;
ulong *page_table;
ulong pgd_pte;
ulong pmd_pte;
ulong pte;
ulong region, offset;
if (usr) {
region = VADDR_REGION(vaddr);
offset = (vaddr >> PGDIR_SHIFT_3L) & ((PTRS_PER_PGD >> 3) - 1);
offset |= (region << (PAGESHIFT() - 6));
page_dir = pgd + offset;
} else {
if (!(pgd = (ulong *)vt->kernel_pgd[0]))
error(FATAL, "cannot determine kernel pgd pointer\n");
page_dir = pgd + ((vaddr >> PGDIR_SHIFT_3L) & (PTRS_PER_PGD - 1));
}
if (verbose)
fprintf(fp, "PAGE DIRECTORY: %lx\n", (ulong)pgd);
FILL_PGD(PAGEBASE(pgd), KVADDR, PAGESIZE());
pgd_pte = ULONG(machdep->pgd + PAGEOFFSET(page_dir));
if (verbose)
fprintf(fp, " PGD: %lx => %lx\n", (ulong)page_dir, pgd_pte);
if (!(pgd_pte))
return FALSE;
offset = (vaddr >> PMD_SHIFT) & (PTRS_PER_PMD - 1);
page_middle = (ulong *)(PTOV(pgd_pte & _PFN_MASK)) + offset;
FILL_PMD(PAGEBASE(page_middle), KVADDR, PAGESIZE());
pmd_pte = ULONG(machdep->pmd + PAGEOFFSET(page_middle));
if (verbose)
fprintf(fp, " PMD: %lx => %lx\n", (ulong)page_middle, pmd_pte);
if (!(pmd_pte))
return FALSE;
offset = (vaddr >> PAGESHIFT()) & (PTRS_PER_PTE - 1);
page_table = (ulong *)(PTOV(pmd_pte & _PFN_MASK)) + offset;
FILL_PTBL(PAGEBASE(page_table), KVADDR, PAGESIZE());
pte = ULONG(machdep->ptbl + PAGEOFFSET(page_table));
if (verbose)
fprintf(fp, " PTE: %lx => %lx\n", (ulong)page_table, pte);
if (!(pte & (_PAGE_P | _PAGE_PROTNONE))) {
if (usr)
*paddr = pte;
if (pte && verbose) {
fprintf(fp, "\n");
ia64_translate_pte(pte, 0, 0);
}
return FALSE;
}