2 * Kernel Debugger Architecture Independent Support Functions
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
8 * Copyright (c) 1999-2006 Silicon Graphics, Inc. All Rights Reserved.
9 * Copyright (C) David Mosberger-Tang <davidm@hpl.hp.com>
12 #include <linux/string.h>
13 #include <linux/stddef.h>
14 #include <linux/kernel.h>
15 #include <linux/ptrace.h>
16 #include <linux/interrupt.h>
18 #include <linux/sched.h>
19 #include <linux/kdb.h>
20 #include <linux/kdbprivate.h>
21 #include <linux/module.h>
22 #ifdef CONFIG_KDB_KDUMP
23 #include <linux/kexec.h>
26 #include <asm/processor.h>
27 #include <asm/uaccess.h>
29 #include <asm/delay.h>
31 #include <asm/hw_irq.h>
35 struct kdb_running_process *kdb_running_process_save; /* [NR_CPUS] */
36 static int kdba_show_handlers = 0;
39 kdba_itm (int argc, const char **argv)
44 diag = kdbgetularg(argv[1], &val);
47 kdb_printf("new itm=" kdb_machreg_fmt "\n", val);
54 kdba_show_intregs(void)
56 u64 lid, tpr, lrr0, lrr1, itv, pmv, cmcv;
58 asm ("mov %0=cr.lid" : "=r"(lid));
59 asm ("mov %0=cr.tpr" : "=r"(tpr));
60 asm ("mov %0=cr.lrr0" : "=r"(lrr0));
61 asm ("mov %0=cr.lrr1" : "=r"(lrr1));
62 kdb_printf("lid=" kdb_machreg_fmt ", tpr=" kdb_machreg_fmt ", lrr0=" kdb_machreg_fmt ", llr1=" kdb_machreg_fmt "\n", lid, tpr, lrr0, lrr1);
64 asm ("mov %0=cr.itv" : "=r"(itv));
65 asm ("mov %0=cr.pmv" : "=r"(pmv));
66 asm ("mov %0=cr.cmcv" : "=r"(cmcv));
67 kdb_printf("itv=" kdb_machreg_fmt ", pmv=" kdb_machreg_fmt ", cmcv=" kdb_machreg_fmt "\n", itv, pmv, cmcv);
69 kdb_printf("irr=0x%016lx,0x%016lx,0x%016lx,0x%016lx\n",
70 ia64_getreg(_IA64_REG_CR_IRR0), ia64_getreg(_IA64_REG_CR_IRR1), ia64_getreg(_IA64_REG_CR_IRR2), ia64_getreg(_IA64_REG_CR_IRR3));
72 kdb_printf("itc=0x%016lx, itm=0x%016lx\n", ia64_get_itc(), ia64_get_itm());
76 kdba_sir (int argc, const char **argv)
86 * Format a struct pt_regs
90 * argv argument vector
94 * zero for success, a kdb diagnostic if error
98 * If no address is supplied, it uses the current irq pt_regs.
102 kdba_pt_regs(int argc, const char **argv)
111 addr = (kdb_machreg_t) get_irq_regs();
112 } else if (argc == 1) {
114 diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
121 p = (struct pt_regs *) addr;
122 kdb_printf("struct pt_regs %p-%p\n", p, (unsigned char *)p + sizeof(*p) - 1);
123 kdb_print_nameval("b6", p->b6);
124 kdb_print_nameval("b7", p->b7);
125 kdb_printf(" ar_csd 0x%lx\n", p->ar_csd);
126 kdb_printf(" ar_ssd 0x%lx\n", p->ar_ssd);
127 kdb_print_nameval("r8", p->r8);
128 kdb_print_nameval("r9", p->r9);
129 kdb_print_nameval("r10", p->r10);
130 kdb_print_nameval("r11", p->r11);
131 kdb_printf(" cr_ipsr 0x%lx\n", p->cr_ipsr);
132 kdb_print_nameval("cr_iip", p->cr_iip);
133 kdb_printf(" cr_ifs 0x%lx\n", p->cr_ifs);
134 kdb_printf(" ar_unat 0x%lx\n", p->ar_unat);
135 kdb_printf(" ar_pfs 0x%lx\n", p->ar_pfs);
136 kdb_printf(" ar_rsc 0x%lx\n", p->ar_rsc);
137 kdb_printf(" ar_rnat 0x%lx\n", p->ar_rnat);
138 kdb_printf(" ar_bspstore 0x%lx\n", p->ar_bspstore);
139 kdb_printf(" pr 0x%lx\n", p->pr);
140 kdb_print_nameval("b0", p->b0);
141 kdb_printf(" loadrs 0x%lx\n", p->loadrs);
142 kdb_print_nameval("r1", p->r1);
143 kdb_print_nameval("r12", p->r12);
144 kdb_print_nameval("r13", p->r13);
145 kdb_printf(" ar_fpsr 0x%lx\n", p->ar_fpsr);
146 kdb_print_nameval("r15", p->r15);
147 kdb_print_nameval("r14", p->r14);
148 kdb_print_nameval("r2", p->r2);
149 kdb_print_nameval("r3", p->r3);
150 kdb_print_nameval("r16", p->r16);
151 kdb_print_nameval("r17", p->r17);
152 kdb_print_nameval("r18", p->r18);
153 kdb_print_nameval("r19", p->r19);
154 kdb_print_nameval("r20", p->r20);
155 kdb_print_nameval("r21", p->r21);
156 kdb_print_nameval("r22", p->r22);
157 kdb_print_nameval("r23", p->r23);
158 kdb_print_nameval("r24", p->r24);
159 kdb_print_nameval("r25", p->r25);
160 kdb_print_nameval("r26", p->r26);
161 kdb_print_nameval("r27", p->r27);
162 kdb_print_nameval("r28", p->r28);
163 kdb_print_nameval("r29", p->r29);
164 kdb_print_nameval("r30", p->r30);
165 kdb_print_nameval("r31", p->r31);
166 kdb_printf(" ar_ccv 0x%lx\n", p->ar_ccv);
167 kdb_printf(" f6 0x%lx 0x%lx\n", p->f6.u.bits[0], p->f6.u.bits[1]);
168 kdb_printf(" f7 0x%lx 0x%lx\n", p->f7.u.bits[0], p->f7.u.bits[1]);
169 kdb_printf(" f8 0x%lx 0x%lx\n", p->f8.u.bits[0], p->f8.u.bits[1]);
170 kdb_printf(" f9 0x%lx 0x%lx\n", p->f9.u.bits[0], p->f9.u.bits[1]);
171 kdb_printf(" f10 0x%lx 0x%lx\n", p->f10.u.bits[0], p->f10.u.bits[1]);
172 kdb_printf(" f11 0x%lx 0x%lx\n", p->f11.u.bits[0], p->f11.u.bits[1]);
180 * Print processes that are using more than a specific percentage of their
184 * argc argument count
185 * argv argument vector
189 * zero for success, a kdb diagnostic if error
193 * If no percentage is supplied, it uses 60.
197 kdba_stackdepth(int argc, const char **argv)
199 int diag, threshold, used;
200 unsigned long percentage;
204 struct task_struct *p, *g;
205 struct switch_stack *sw;
209 } else if (argc == 1) {
211 diag = kdbgetaddrarg(argc, argv, &nextarg, &percentage, &offset, NULL);
217 percentage = max_t(int, percentage, 1);
218 percentage = min_t(int, percentage, 100);
219 threshold = ((2 * THREAD_SIZE * percentage) / 100 + 1) >> 1;
220 kdb_printf("stackdepth: processes using more than %ld%% (%d bytes) of stack\n",
221 percentage, threshold);
222 kdb_do_each_thread(g, p) {
223 if (kdb_task_has_cpu(p)) {
224 struct kdb_running_process *krp = kdb_running_process + kdb_process_cpu(p);
230 sw = (struct switch_stack *) (p->thread.ksp + 16);
233 esp = (unsigned long) sw;
234 used = THREAD_SIZE - (esp - sw->ar_bspstore);
235 if (used >= threshold) {
237 kdb_printf(" esp %lx bsp %lx used %d\n", esp, sw->ar_bspstore, used);
239 } kdb_while_each_thread(g, p);
247 * Format a struct switch_stack
250 * argc argument count
251 * argv argument vector
255 * zero for success, a kdb diagnostic if error
259 * If no address is supplied, it uses kdb_running_process[smp_processor_id()].arch.sw.
263 kdba_switch_stack(int argc, const char **argv)
269 struct switch_stack *p;
272 addr = (kdb_machreg_t) kdb_running_process[smp_processor_id()].arch.sw;
273 } else if (argc == 1) {
275 diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
282 p = (struct switch_stack *) addr;
283 kdb_printf("struct switch_stack %p-%p\n", p, (unsigned char *)p + sizeof(*p) - 1);
284 kdb_printf(" caller_unat 0x%lx\n", p->caller_unat);
285 kdb_printf(" ar_fpsr 0x%lx\n", p->ar_fpsr);
286 kdb_printf(" f2 0x%lx 0x%lx\n", p->f2.u.bits[0], p->f2.u.bits[1]);
287 kdb_printf(" f3 0x%lx 0x%lx\n", p->f3.u.bits[0], p->f3.u.bits[1]);
288 kdb_printf(" f4 0x%lx 0x%lx\n", p->f4.u.bits[0], p->f4.u.bits[1]);
289 kdb_printf(" f5 0x%lx 0x%lx\n", p->f5.u.bits[0], p->f5.u.bits[1]);
290 kdb_printf(" f12 0x%lx 0x%lx\n", p->f12.u.bits[0], p->f12.u.bits[1]);
291 kdb_printf(" f13 0x%lx 0x%lx\n", p->f13.u.bits[0], p->f13.u.bits[1]);
292 kdb_printf(" f14 0x%lx 0x%lx\n", p->f14.u.bits[0], p->f14.u.bits[1]);
293 kdb_printf(" f15 0x%lx 0x%lx\n", p->f15.u.bits[0], p->f15.u.bits[1]);
294 kdb_printf(" f16 0x%lx 0x%lx\n", p->f16.u.bits[0], p->f16.u.bits[1]);
295 kdb_printf(" f17 0x%lx 0x%lx\n", p->f17.u.bits[0], p->f17.u.bits[1]);
296 kdb_printf(" f18 0x%lx 0x%lx\n", p->f18.u.bits[0], p->f18.u.bits[1]);
297 kdb_printf(" f19 0x%lx 0x%lx\n", p->f19.u.bits[0], p->f19.u.bits[1]);
298 kdb_printf(" f20 0x%lx 0x%lx\n", p->f20.u.bits[0], p->f20.u.bits[1]);
299 kdb_printf(" f21 0x%lx 0x%lx\n", p->f21.u.bits[0], p->f21.u.bits[1]);
300 kdb_printf(" f22 0x%lx 0x%lx\n", p->f22.u.bits[0], p->f22.u.bits[1]);
301 kdb_printf(" f23 0x%lx 0x%lx\n", p->f23.u.bits[0], p->f23.u.bits[1]);
302 kdb_printf(" f24 0x%lx 0x%lx\n", p->f24.u.bits[0], p->f24.u.bits[1]);
303 kdb_printf(" f25 0x%lx 0x%lx\n", p->f25.u.bits[0], p->f25.u.bits[1]);
304 kdb_printf(" f26 0x%lx 0x%lx\n", p->f26.u.bits[0], p->f26.u.bits[1]);
305 kdb_printf(" f27 0x%lx 0x%lx\n", p->f27.u.bits[0], p->f27.u.bits[1]);
306 kdb_printf(" f28 0x%lx 0x%lx\n", p->f28.u.bits[0], p->f28.u.bits[1]);
307 kdb_printf(" f29 0x%lx 0x%lx\n", p->f29.u.bits[0], p->f29.u.bits[1]);
308 kdb_printf(" f30 0x%lx 0x%lx\n", p->f30.u.bits[0], p->f30.u.bits[1]);
309 kdb_printf(" f31 0x%lx 0x%lx\n", p->f31.u.bits[0], p->f31.u.bits[1]);
310 kdb_print_nameval("r4", p->r4);
311 kdb_print_nameval("r5", p->r5);
312 kdb_print_nameval("r6", p->r6);
313 kdb_print_nameval("r7", p->r7);
314 kdb_print_nameval("b0", p->b0);
315 kdb_print_nameval("b1", p->b1);
316 kdb_print_nameval("b2", p->b2);
317 kdb_print_nameval("b3", p->b3);
318 kdb_print_nameval("b4", p->b4);
319 kdb_print_nameval("b5", p->b5);
320 kdb_printf(" ar_pfs 0x%lx\n", p->ar_pfs);
321 kdb_printf(" ar_lc 0x%lx\n", p->ar_lc);
322 kdb_printf(" ar_unat 0x%lx\n", p->ar_unat);
323 kdb_printf(" ar_rnat 0x%lx\n", p->ar_rnat);
324 kdb_printf(" ar_bspstore 0x%lx\n", p->ar_bspstore);
325 kdb_printf(" pr 0x%lx\n", p->pr);
333 * Format the PAL minstate area.
336 * argc argument count
337 * argv argument vector
341 * zero for success, a kdb diagnostic if error
349 kdba_minstate(int argc, const char **argv)
355 pal_min_state_area_t *p;
359 diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
366 p = (pal_min_state_area_t *) addr;
367 kdb_printf("PAL minstate %p-%p\n", p, (unsigned char *)p + sizeof(*p) - 1);
368 kdb_printf(" pmsa_nat_bits 0x%lx\n", p->pmsa_nat_bits);
369 kdb_print_nameval("r1", p->pmsa_gr[1-1]);
370 kdb_print_nameval("r2", p->pmsa_gr[2-1]);
371 kdb_print_nameval("r3", p->pmsa_gr[3-1]);
372 kdb_print_nameval("r4", p->pmsa_gr[4-1]);
373 kdb_print_nameval("r5", p->pmsa_gr[5-1]);
374 kdb_print_nameval("r6", p->pmsa_gr[6-1]);
375 kdb_print_nameval("r7", p->pmsa_gr[7-1]);
376 kdb_print_nameval("r8", p->pmsa_gr[8-1]);
377 kdb_print_nameval("r9", p->pmsa_gr[9-1]);
378 kdb_print_nameval("r10", p->pmsa_gr[10-1]);
379 kdb_print_nameval("r11", p->pmsa_gr[11-1]);
380 kdb_print_nameval("r12", p->pmsa_gr[12-1]);
381 kdb_print_nameval("r13", p->pmsa_gr[13-1]);
382 kdb_print_nameval("r14", p->pmsa_gr[14-1]);
383 kdb_print_nameval("r15", p->pmsa_gr[15-1]);
384 kdb_printf(" Bank 0\n");
385 kdb_print_nameval("r16", p->pmsa_bank0_gr[16-16]);
386 kdb_print_nameval("r17", p->pmsa_bank0_gr[17-16]);
387 kdb_print_nameval("r18", p->pmsa_bank0_gr[18-16]);
388 kdb_print_nameval("r19", p->pmsa_bank0_gr[19-16]);
389 kdb_print_nameval("r20", p->pmsa_bank0_gr[20-16]);
390 kdb_print_nameval("r21", p->pmsa_bank0_gr[21-16]);
391 kdb_print_nameval("r22", p->pmsa_bank0_gr[22-16]);
392 kdb_print_nameval("r23", p->pmsa_bank0_gr[23-16]);
393 kdb_print_nameval("r24", p->pmsa_bank0_gr[24-16]);
394 kdb_print_nameval("r25", p->pmsa_bank0_gr[25-16]);
395 kdb_print_nameval("r26", p->pmsa_bank0_gr[26-16]);
396 kdb_print_nameval("r27", p->pmsa_bank0_gr[27-16]);
397 kdb_print_nameval("r28", p->pmsa_bank0_gr[28-16]);
398 kdb_print_nameval("r29", p->pmsa_bank0_gr[29-16]);
399 kdb_print_nameval("r30", p->pmsa_bank0_gr[30-16]);
400 kdb_print_nameval("r31", p->pmsa_bank0_gr[31-16]);
401 kdb_printf(" Bank 1\n");
402 kdb_print_nameval("r16", p->pmsa_bank1_gr[16-16]);
403 kdb_print_nameval("r17", p->pmsa_bank1_gr[17-16]);
404 kdb_print_nameval("r18", p->pmsa_bank1_gr[18-16]);
405 kdb_print_nameval("r19", p->pmsa_bank1_gr[19-16]);
406 kdb_print_nameval("r20", p->pmsa_bank1_gr[20-16]);
407 kdb_print_nameval("r21", p->pmsa_bank1_gr[21-16]);
408 kdb_print_nameval("r22", p->pmsa_bank1_gr[22-16]);
409 kdb_print_nameval("r23", p->pmsa_bank1_gr[23-16]);
410 kdb_print_nameval("r24", p->pmsa_bank1_gr[24-16]);
411 kdb_print_nameval("r25", p->pmsa_bank1_gr[25-16]);
412 kdb_print_nameval("r26", p->pmsa_bank1_gr[26-16]);
413 kdb_print_nameval("r27", p->pmsa_bank1_gr[27-16]);
414 kdb_print_nameval("r28", p->pmsa_bank1_gr[28-16]);
415 kdb_print_nameval("r29", p->pmsa_bank1_gr[29-16]);
416 kdb_print_nameval("r30", p->pmsa_bank1_gr[30-16]);
417 kdb_print_nameval("r31", p->pmsa_bank1_gr[31-16]);
418 kdb_printf(" pr 0x%lx\n", p->pmsa_pr);
419 kdb_print_nameval("b0", p->pmsa_br0);
420 kdb_printf(" ar.rsc 0x%lx\n", p->pmsa_rsc);
421 kdb_print_nameval("cr.iip", p->pmsa_iip);
422 kdb_printf(" cr.ipsr 0x%lx\n", p->pmsa_ipsr);
423 kdb_printf(" cr.ifs 0x%lx\n", p->pmsa_ifs);
424 kdb_print_nameval("cr.xip", p->pmsa_xip);
425 kdb_printf(" cr.xpsr 0x%lx\n", p->pmsa_xpsr);
426 kdb_printf(" cr.xfs 0x%lx\n", p->pmsa_xfs);
427 kdb_print_nameval("b1", p->pmsa_br1);
435 * Format struct cpuinfo_ia64.
438 * argc argument count
439 * argv argument vector
443 * zero for success, a kdb diagnostic if error
447 * If no cpu is supplied, it prints cpuinfo for all online cpus.
451 kdba_cpuinfo(int argc, const char **argv)
454 unsigned long cpunum = -1;
457 struct cpuinfo_ia64 *cpuinfo;
461 diag = kdbgetaddrarg(argc, argv, &nextarg, &cpunum, &offset, NULL);
464 if (cpunum >= NR_CPUS || !cpu_online(cpunum))
465 return KDB_BADCPUNUM;
466 } else if (argc > 1) {
470 for (c = (cpunum == -1 ? 0 : cpunum);
471 c < (cpunum == -1 ? NR_CPUS : cpunum+1);
475 cpuinfo = cpu_data(c);
476 kdb_printf("struct cpuinfo_ia64 for cpu %d is at 0x%p\n", c, cpuinfo);
477 kdb_printf(" softirq_pending 0x%x\n", cpuinfo->softirq_pending);
478 kdb_printf(" itm_delta %ld\n", cpuinfo->itm_delta);
479 kdb_printf(" itm_next %ld\n", cpuinfo->itm_next);
480 kdb_printf(" nsec_per_cyc %ld\n", cpuinfo->nsec_per_cyc);
481 kdb_printf(" unimpl_va_mask 0x%lx\n", cpuinfo->unimpl_va_mask);
482 kdb_printf(" unimpl_pa_mask 0x%lx\n", cpuinfo->unimpl_pa_mask);
483 kdb_printf(" itc_freq %ld\n", cpuinfo->itc_freq);
484 kdb_printf(" proc_freq %ld\n", cpuinfo->proc_freq);
485 kdb_printf(" cyc_per_usec %ld\n", cpuinfo->cyc_per_usec);
486 kdb_printf(" cyc_per_usec %ld\n", cpuinfo->cyc_per_usec);
487 #if 0 /* RJA per-cpu MCA */
488 kdb_printf(" percpu_paddr 0x%lx\n", cpuinfo->percpu_paddr);
490 kdb_printf(" ptce_base 0x%lx\n", cpuinfo->ptce_base);
491 kdb_printf(" ptce_count %d %d\n", cpuinfo->ptce_count[0], cpuinfo->ptce_count[1]);
492 kdb_printf(" ptce_stride %d %d\n", cpuinfo->ptce_stride[0], cpuinfo->ptce_stride[1]);
493 #if 0 /* RJA per-cpu MCA */
494 kdb_printf(" pal_paddr 0x%lx\n", cpuinfo->pal_paddr);
495 kdb_printf(" pal_base 0x%lx\n", cpuinfo->pal_base);
497 kdb_printf(" ksoftirqd 0x%p\n", cpuinfo->ksoftirqd);
499 kdb_printf(" loops_per_jiffy %ld\n", cpuinfo->loops_per_jiffy);
500 kdb_printf(" cpu %d\n", cpuinfo->cpu);
501 kdb_printf(" socket_id %d\n", cpuinfo->socket_id);
502 kdb_printf(" core_id %d\n", cpuinfo->core_id);
503 kdb_printf(" thread_id %d\n", cpuinfo->thread_id);
504 kdb_printf(" num_log %d\n", cpuinfo->num_log);
505 kdb_printf(" cores_per_socket %d\n", cpuinfo->cores_per_socket);
506 kdb_printf(" threads_per_core %d\n", cpuinfo->threads_per_core);
508 kdb_printf(" ppn 0x%lx\n", cpuinfo->ppn);
509 kdb_printf(" features 0x%lx\n", cpuinfo->features);
510 kdb_printf(" number %d\n", cpuinfo->number);
511 kdb_printf(" revision %d\n", cpuinfo->revision);
512 kdb_printf(" model %d\n", cpuinfo->model);
513 kdb_printf(" family %d\n", cpuinfo->family);
514 kdb_printf(" archrev %d\n", cpuinfo->archrev);
515 kdb_printf(" vendor ");
516 for (i = 0; i < sizeof(cpuinfo->vendor); ++i)
517 kdb_printf(" 0x%02x", cpuinfo->vendor[i]);
520 kdb_printf(" node_data 0x%p\n", cpuinfo->node_data);
522 #if 0 /* RJA per-cpu MCA */
523 kdb_printf(" ia64_pa_mca_data 0x%p\n", cpuinfo->ia64_pa_mca_data);
529 #ifdef CONFIG_KDB_HARDWARE_BREAKPOINTS
531 kdba_installdbreg(kdb_bp_t *bp)
534 unsigned int regbase;
535 static unsigned long masks[] = {
536 0x00FFFFFFFFFFFFFFUL, // 1 byte long
537 0x00FFFFFFFFFFFFFEUL, // 2 bytes long
538 0x0000000000000000UL, // invalid
539 0x00FFFFFFFFFFFFFCUL // 4 bytes long
541 static unsigned char modes[] = {
542 0x81, // instruction => x, plm=priv level 0 only
543 0x41, // write => w, plm=priv level 0 only
545 0x81 // read => r, plm=priv level 0 only
548 /* Note that bp->bp_hard[NR_CPU] is for x86.
549 * The ia64 uses bp->bp_hard[0] only.
552 kdb_printf("kdba_installdbreg:\n");
553 mask = masks[bp->bp_hard[0]->bph_length] |
554 (((unsigned long)(modes[bp->bp_hard[0]->bph_mode])) << 56);
555 regbase = 2*bp->bp_hard[0]->bph_reg;
557 switch (bp->bp_hard[0]->bph_mode)
562 kdb_printf("kdba_installdbreg: dbr[%u]=%016lx\n",
563 regbase, bp->bp_addr);
564 kdb_printf("kdba_installdbreg: dbr[%u]=%016lx\n",
568 ia64_set_dbr(regbase, bp->bp_addr);
569 ia64_set_dbr(regbase+1, mask);
573 case 0: /* instruction */
575 ia64_set_ibr(regbase, bp->bp_addr);
576 ia64_set_ibr(regbase+1, mask);
579 kdb_printf("\"instr\" mode not implemented\n");
584 kdb_printf("\"io\" mode not implemented\n");
590 kdba_removedbreg(kdb_bp_t *bp)
592 unsigned int regbase = 2*bp->bp_hard[0]->bph_reg;
594 /* Note that bp->bp_hard[NR_CPU] is for x86.
595 * The ia64 uses bp->bp_hard[0] only.
597 switch (bp->bp_hard[0]->bph_mode)
601 ia64_set_dbr(regbase, 0);
602 ia64_set_dbr(regbase+1, 0);
606 case 0: /* instruction */
608 ia64_set_ibr(regbase, 0);
609 ia64_set_ibr(regbase+1, 0);
612 kdb_printf("\"instr\" mode not implemented\n");
617 kdb_printf("\"io\" mode not implemented\n");
621 #endif /* CONFIG_KDB_HARDWARE_BREAKPOINTS */
625 kdba_getdr(int regnum)
627 kdb_machreg_t contents = 0;
628 unsigned long reg = (unsigned long)regnum;
630 __asm__ ("mov %0=ibr[%1]"::"r"(contents),"r"(reg));
631 // __asm__ ("mov ibr[%0]=%1"::"r"(dbreg_cond),"r"(value));
638 get_fault_regs(fault_regs_t *fr)
643 __asm__ ("rsm psr.ic;;") ;
645 __asm__ ("mov %0=cr.ifa" : "=r"(fr->ifa));
646 __asm__ ("mov %0=cr.isr" : "=r"(fr->isr));
647 __asm__ ("ssm psr.ic;;") ;
652 show_kernel_regs (void)
657 asm ("mov %0=ar.k0" : "=r"(kr[0])); asm ("mov %0=ar.k1" : "=r"(kr[1]));
658 asm ("mov %0=ar.k2" : "=r"(kr[2])); asm ("mov %0=ar.k3" : "=r"(kr[3]));
659 asm ("mov %0=ar.k4" : "=r"(kr[4])); asm ("mov %0=ar.k5" : "=r"(kr[5]));
660 asm ("mov %0=ar.k6" : "=r"(kr[6])); asm ("mov %0=ar.k7" : "=r"(kr[7]));
662 for (i = 0; i < 4; ++i)
663 kdb_printf(" kr%d: %016lx kr%d: %016lx\n", 2*i, kr[2*i], 2*i+1, kr[2*i+1]);
668 change_cur_stack_frame(int regno, unsigned long *contents)
670 unsigned long sof, i, cfm, sp, *bsp, __user *ubsp;
671 struct unw_frame_info info;
673 int cpu = kdb_process_cpu(kdb_current_task);
674 struct kdb_running_process *krp = kdb_running_process + cpu;
676 if (kdb_current_task != krp->p) {
677 kdb_printf("Stacked registers are not available for tasks that are not running.\n");
678 kdb_printf("Use bt with a large BTARGS value instead\n");
681 unw_init_frame_info(&info, krp->p, krp->arch.sw);
683 if (unw_unwind(&info) < 0) {
684 kdb_printf("Failed to unwind\n");
687 unw_get_sp(&info, &sp);
688 } while (sp <= (unsigned long) kdb_current_regs);
689 unw_get_bsp(&info, (unsigned long *) &bsp);
690 unw_get_cfm(&info, &cfm);
693 kdb_printf("Unable to get Current Stack Frame\n");
699 if(((unsigned long)regno - 32) >= (sof - 2)) return 1;
701 old_fs = set_fs(KERNEL_DS);
702 for (i = 0; i < (regno - 32); ++i)
703 bsp = ia64_rse_skip_regs(bsp, 1);
704 ubsp = (unsigned long __user *) bsp;
705 put_user(*contents, ubsp);
712 show_cur_stack_frame(int regno, unsigned long *contents)
714 unsigned long sof, i, cfm, val, sp, *bsp, __user *ubsp;
715 struct unw_frame_info info;
717 int cpu = kdb_process_cpu(kdb_current_task);
718 struct kdb_running_process *krp = kdb_running_process + cpu;
720 if (kdb_current_task != krp->p) {
721 kdb_printf("Stacked registers are not available for tasks that are not running.\n");
722 kdb_printf("Use bt with a large BTARGS value instead\n");
725 unw_init_frame_info(&info, krp->p, krp->arch.sw);
727 if (unw_unwind(&info) < 0) {
728 kdb_printf("Failed to unwind\n");
731 unw_get_sp(&info, &sp);
732 } while (sp <= (unsigned long) kdb_current_regs);
733 unw_get_bsp(&info, (unsigned long *) &bsp);
734 unw_get_cfm(&info, &cfm);
737 kdb_printf("Unable to display Current Stack Frame\n");
744 if ((unsigned) regno - 32 >= sof)
746 bsp = ia64_rse_skip_regs(bsp, regno - 32);
747 old_fs = set_fs(KERNEL_DS);
748 ubsp = (unsigned long __user *) bsp;
755 old_fs = set_fs(KERNEL_DS);
756 for (i = 0; i < sof; ++i) {
757 ubsp = (unsigned long __user *) bsp;
759 kdb_printf(" r%lu: %016lx ", 32 + i, val);
762 bsp = ia64_rse_skip_regs(bsp, 1);
771 * kdba_getregcontents
773 * Return the contents of the register specified by the
774 * input string argument. Return an error if the string
775 * does not match a machine register.
777 * The following pseudo register names are supported:
778 * ®s - Prints address of exception frame
779 * kesp - Prints kernel stack pointer at time of fault
780 * sstk - Prints switch stack for ia64
781 * %<regname> - Uses the value of the registers at the
782 * last time the user process entered kernel
783 * mode, instead of the registers at the time
787 * regname Pointer to string naming register
788 * regs Pointer to structure containing registers.
790 * *contents Pointer to unsigned long to recieve register contents
793 * KDB_BADREG Invalid register name
798 * Note that this function is really machine independent. The kdb
799 * register list is not, however.
802 static struct kdbregs {
806 { "psr", offsetof(struct pt_regs, cr_ipsr) },
807 { "ifs", offsetof(struct pt_regs, cr_ifs) },
808 { "ip", offsetof(struct pt_regs, cr_iip) },
810 { "unat", offsetof(struct pt_regs, ar_unat) },
811 { "pfs", offsetof(struct pt_regs, ar_pfs) },
812 { "rsc", offsetof(struct pt_regs, ar_rsc) },
814 { "rnat", offsetof(struct pt_regs, ar_rnat) },
815 { "bsps", offsetof(struct pt_regs, ar_bspstore) },
816 { "pr", offsetof(struct pt_regs, pr) },
818 { "ldrs", offsetof(struct pt_regs, loadrs) },
819 { "ccv", offsetof(struct pt_regs, ar_ccv) },
820 { "fpsr", offsetof(struct pt_regs, ar_fpsr) },
822 { "b0", offsetof(struct pt_regs, b0) },
823 { "b6", offsetof(struct pt_regs, b6) },
824 { "b7", offsetof(struct pt_regs, b7) },
826 { "r1",offsetof(struct pt_regs, r1) },
827 { "r2",offsetof(struct pt_regs, r2) },
828 { "r3",offsetof(struct pt_regs, r3) },
830 { "r8",offsetof(struct pt_regs, r8) },
831 { "r9",offsetof(struct pt_regs, r9) },
832 { "r10",offsetof(struct pt_regs, r10) },
834 { "r11",offsetof(struct pt_regs, r11) },
835 { "r12",offsetof(struct pt_regs, r12) },
836 { "r13",offsetof(struct pt_regs, r13) },
838 { "r14",offsetof(struct pt_regs, r14) },
839 { "r15",offsetof(struct pt_regs, r15) },
840 { "r16",offsetof(struct pt_regs, r16) },
842 { "r17",offsetof(struct pt_regs, r17) },
843 { "r18",offsetof(struct pt_regs, r18) },
844 { "r19",offsetof(struct pt_regs, r19) },
846 { "r20",offsetof(struct pt_regs, r20) },
847 { "r21",offsetof(struct pt_regs, r21) },
848 { "r22",offsetof(struct pt_regs, r22) },
850 { "r23",offsetof(struct pt_regs, r23) },
851 { "r24",offsetof(struct pt_regs, r24) },
852 { "r25",offsetof(struct pt_regs, r25) },
854 { "r26",offsetof(struct pt_regs, r26) },
855 { "r27",offsetof(struct pt_regs, r27) },
856 { "r28",offsetof(struct pt_regs, r28) },
858 { "r29",offsetof(struct pt_regs, r29) },
859 { "r30",offsetof(struct pt_regs, r30) },
860 { "r31",offsetof(struct pt_regs, r31) },
864 static const int nkdbreglist = sizeof(kdbreglist) / sizeof(struct kdbregs);
867 kdba_getregcontents(const char *regname, struct pt_regs *regs, unsigned long *contents)
871 if (strcmp(regname, "isr") == 0) {
873 get_fault_regs(&fr) ;
879 kdb_printf("%s: pt_regs not available, use bt* or pid to select a different task\n", __FUNCTION__);
883 if (strcmp(regname, "®s") == 0) {
884 *contents = (unsigned long)regs;
888 if (strcmp(regname, "sstk") == 0) {
889 *contents = (unsigned long)getprsregs(regs) ;
893 if (strcmp(regname, "ksp") == 0) {
894 *contents = (unsigned long) (regs + 1);
898 for (i=0; i<nkdbreglist; i++) {
899 if (strstr(kdbreglist[i].reg_name, regname))
903 if (i == nkdbreglist) {
904 /* Lets check the rse maybe */
905 if (regname[0] == 'r')
906 if (show_cur_stack_frame(simple_strtoul(regname+1, NULL, 0), contents))
911 *contents = *(unsigned long *)((unsigned long)regs +
912 kdbreglist[i].reg_offset);
918 * kdba_setregcontents
920 * Set the contents of the register specified by the
921 * input string argument. Return an error if the string
922 * does not match a machine register.
924 * Supports modification of user-mode registers via
928 * regname Pointer to string naming register
929 * regs Pointer to structure containing registers.
930 * contents Unsigned long containing new register contents
934 * KDB_BADREG Invalid register name
941 kdba_setregcontents(const char *regname,
942 struct pt_regs *regs,
943 unsigned long contents)
945 int i, ret = 0, fixed = 0;
949 if (regname[0] == '%') {
951 regs = (struct pt_regs *)
952 (kdb_current_task->thread.ksp - sizeof(struct pt_regs));
956 kdb_printf("%s: pt_regs not available, use bt* or pid to select a different task\n", __FUNCTION__);
960 /* fixed registers */
961 for (i=0; i<nkdbreglist; i++) {
962 if (strnicmp(kdbreglist[i].reg_name,
964 strlen(regname)) == 0) {
970 /* stacked registers */
972 regno = (simple_strtoul(®name[1], &endp, 10));
973 if ((regname[0] == 'r') && regno > (unsigned long)31) {
974 ret = change_cur_stack_frame(regno, &contents);
979 if ((i == nkdbreglist)
980 || (strlen(kdbreglist[i].reg_name) != strlen(regname))
985 /* just in case of "standard" register */
986 *(unsigned long *)((unsigned long)regs + kdbreglist[i].reg_offset) =
995 * Dump the specified register set to the display.
998 * regs Pointer to structure containing registers.
999 * type Character string identifying register set to dump
1000 * extra string further identifying register (optional)
1007 * This function will dump the general register set if the type
1008 * argument is NULL (struct pt_regs). The alternate register
1009 * set types supported by this function:
1012 * c Control registers
1013 * u User registers at most recent entry to kernel
1014 * i Interrupt registers -- same as "irr" command
1015 * Following not yet implemented:
1016 * m Model Specific Registers (extra defines register #)
1017 * r Memory Type Range Registers (extra defines register)
1019 * For now, all registers are covered as follows:
1021 * rd - dumps all regs
1022 * rd %isr - current interrupt status reg, read freshly
1023 * rd s - valid stacked regs
1024 * rd %sstk - gets switch stack addr. dump memory and search
1025 * rd d - debug regs, may not be too useful
1026 * rd k - dump kernel regs
1029 * OTHERS TB Decided ??
1032 * These will be implemented later - Srinivasa
1036 * g dump all General static registers
1037 * s dump all general Stacked registers
1038 * f dump all Floating Point registers
1039 * p dump all Predicate registers
1040 * b dump all Branch registers
1041 * a dump all Application registers
1042 * c dump all Control registers
1047 kdba_dumpregs(struct pt_regs *regs,
1056 && (type[0] == 'u')) {
1058 regs = (struct pt_regs *)
1059 (kdb_current_task->thread.ksp - sizeof(struct pt_regs));
1064 kdb_printf("%s: pt_regs not available, use bt* or pid to select a different task\n", __FUNCTION__);
1067 for (i=0; i<nkdbreglist; i++) {
1068 kdb_printf("%4s: 0x%16.16lx ",
1069 kdbreglist[i].reg_name,
1070 *(unsigned long *)((unsigned long)regs +
1071 kdbreglist[i].reg_offset));
1073 if ((++count % 3) == 0)
1077 kdb_printf("®s = %p\n", (void *)regs);
1085 for(i=0; i<8; i+=2) {
1086 kdb_printf("idr%d: 0x%16.16lx idr%d: 0x%16.16lx\n", i,
1087 kdba_getdr(i), i+1, kdba_getdr(i+1));
1093 kdba_show_intregs();
1106 kdb_printf("%s: pt_regs not available, use bt* or pid to select a different task\n", __FUNCTION__);
1109 show_cur_stack_frame(0, NULL) ;
1116 unsigned long contents ;
1118 if (!kdba_getregcontents(type+1, regs, &contents))
1119 kdb_printf("%s = 0x%16.16lx\n", type+1, contents) ;
1121 kdb_printf("diag: Invalid register %s\n", type+1) ;
1133 EXPORT_SYMBOL(kdba_dumpregs);
1136 kdba_getpc(struct pt_regs *regs)
1138 return regs ? regs->cr_iip + ia64_psr(regs)->ri : 0;
1142 kdba_setpc(struct pt_regs *regs, kdb_machreg_t newpc)
1144 if (KDB_NULL_REGS(regs))
1146 regs->cr_iip = newpc & ~0xf;
1147 ia64_psr(regs)->ri = newpc & 0x3;
1148 KDB_STATE_SET(IP_ADJUSTED);
1152 struct kdba_main_loop_data {
1153 kdb_reason_t reason;
1154 kdb_reason_t reason2;
1156 kdb_dbtrap_t db_result;
1157 struct pt_regs *regs;
1164 * Invoked from kdba_main_loop via unw_init_running() after that routine
1165 * has pushed a struct switch_stack.
1168 * info Unwind information.
1169 * data kdb data passed as void * to unw_init_running.
1171 * none (unw_init_running requires void). vdata->ret is set to
1172 * 0 KDB was invoked for an event which it wasn't responsible
1173 * 1 KDB handled the event for which it was invoked.
1179 * unw_init_running() creates struct switch_stack then struct
1180 * unw_frame_info. We get the address of the info so step over
1181 * that to get switch_stack. Just hope that unw_init_running
1182 * does not change its stack usage. unw_init_running adds padding
1183 * to put switch_stack on a 16 byte boundary.
1187 do_kdba_main_loop(struct unw_frame_info *info, void *vdata)
1189 struct kdba_main_loop_data *data = vdata;
1190 struct switch_stack *sw, *prev_sw;
1191 struct pt_regs *prev_regs;
1192 struct kdb_running_process *krp =
1193 kdb_running_process + smp_processor_id();
1194 KDB_DEBUG_STATE(__FUNCTION__, data->reason);
1195 prev_sw = krp->arch.sw;
1196 sw = (struct switch_stack *)(info+1);
1197 /* padding from unw_init_running */
1198 sw = (struct switch_stack *)(((unsigned long)sw + 15) & ~15);
1200 prev_regs = krp->regs;
1201 data->ret = kdb_save_running(data->regs, data->reason, data->reason2,
1202 data->error, data->db_result);
1203 kdb_unsave_running(data->regs);
1204 krp->regs = prev_regs;
1205 krp->arch.sw = prev_sw;
1211 * Do any architecture specific set up before entering the main kdb loop.
1212 * The primary function of this routine is to make all processes look the
1213 * same to kdb, kdb must be able to list a process without worrying if the
1214 * process is running or blocked, so make all processes look as though they
1218 * reason The reason KDB was invoked
1219 * error The hardware-defined error code
1220 * error2 kdb's current reason code. Initially error but can change
1221 * acording to kdb state.
1222 * db_result Result from break or debug point.
1223 * regs The exception frame at time of fault/breakpoint. If reason
1224 * is SILENT or CPU_UP then regs is NULL, otherwise it should
1227 * 0 KDB was invoked for an event which it wasn't responsible
1228 * 1 KDB handled the event for which it was invoked.
1230 * Builds a switch_stack structure before calling the main loop.
1238 kdba_main_loop(kdb_reason_t reason, kdb_reason_t reason2, int error,
1239 kdb_dbtrap_t db_result, struct pt_regs *regs)
1241 struct kdba_main_loop_data data;
1242 KDB_DEBUG_STATE("kdba_main_loop", reason);
1243 data.reason = reason;
1244 data.reason2 = reason2;
1246 data.db_result = db_result;
1248 unw_init_running(do_kdba_main_loop, &data);
1253 kdba_disableint(kdb_intstate_t *state)
1255 unsigned long *fp = (unsigned long *)state;
1256 unsigned long flags;
1258 local_irq_save(flags);
1263 kdba_restoreint(kdb_intstate_t *state)
1265 unsigned long flags = *(unsigned long *)state;
1266 local_irq_restore(flags);
1270 kdba_setsinglestep(struct pt_regs *regs)
1272 if (KDB_NULL_REGS(regs))
1274 ia64_psr(regs)->ss = 1;
1278 kdba_clearsinglestep(struct pt_regs *regs)
1280 if (KDB_NULL_REGS(regs))
1282 ia64_psr(regs)->ss = 0;
1288 * Virtual to Physical address translation command.
1293 * argc Count of arguments in argv
1294 * argv Space delimited command line arguments
1298 * Zero for success, a kdb diagnostic if failure.
1303 #define __xtpa(x) ({ia64_va _v; asm("tpa %0=%1" : "=r"(_v.l) : "r"(x)); _v.l;})
1305 kdba_tpa(int argc, const char **argv)
1315 return KDB_ARGCOUNT;
1316 diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
1319 if (kdb_getarea(c, addr))
1321 kdb_printf("vaddr: 0x%lx , paddr: 0x%lx\n", addr, __xtpa(addr));
1324 #if defined(CONFIG_NUMA)
1326 kdba_tpav(int argc, const char **argv)
1328 kdb_machreg_t addr, end, paddr;
1331 int nextarg, nid, nid_old;
1336 return KDB_ARGCOUNT;
1337 diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
1340 diag = kdbgetaddrarg(argc, argv, &nextarg, &end, &offset, NULL);
1343 if (kdb_getarea(c, addr))
1345 if (kdb_getarea(c, end))
1348 nid = paddr_to_nid(paddr);
1349 kdb_printf("begin: 0x%lx , paddr: 0x%lx , nid: %d\n", addr, __xtpa(addr), nid);
1350 for(;addr<end; addr += PAGE_SIZE) {
1352 paddr =__xtpa(addr);
1353 nid = paddr_to_nid(paddr);
1355 kdb_printf("NOT on same NODE: addr: 0x%lx , paddr: 0x%lx , nid: %d\n", addr, paddr, nid);
1358 nid=paddr_to_nid(end);
1359 kdb_printf("end: 0x%lx , paddr: 0x%lx , nid: %d\n", end, paddr, nid);
1364 #if defined(CONFIG_SMP)
1368 * This function implements the 'init' command.
1373 * argc argument count
1374 * argv argument vector
1378 * zero for success, a kdb diagnostic if error
1385 kdba_sendinit(int argc, const char **argv)
1387 unsigned long cpunum;
1391 return KDB_ARGCOUNT;
1393 diag = kdbgetularg(argv[1], &cpunum);
1397 if (cpunum >= NR_CPUS || !cpu_online(cpunum))
1398 return KDB_BADCPUNUM;
1400 platform_send_ipi(cpunum, 0, IA64_IPI_DM_INIT, 0);
1404 /* Invoked once from kdb_wait_for_cpus when waiting for cpus. For those cpus
1405 * that have not responded to the normal KDB interrupt yet, hit them with an
1409 kdba_wait_for_cpus(void)
1412 if (KDB_FLAG(CATASTROPHIC))
1414 kdb_printf(" Sending INIT to cpus that have not responded yet\n");
1415 for_each_online_cpu(c)
1416 if (kdb_running_process[c].seqno < kdb_seqno - 1)
1417 platform_send_ipi(c, 0, IA64_IPI_DM_INIT, 0);
1420 #endif /* CONFIG_SMP */
1422 /* This code is sensitive to the layout of the MCA/INIT stack (see mca_asm.h)
1423 * and to the stack layout that ia64_mca_modify_original_stack() creates when
1424 * it makes the original task look blocked.
1427 kdba_handlers_modify(struct task_struct *task, int cpu)
1429 struct kdb_running_process *work, *save;
1430 work = kdb_running_process + cpu;
1431 save = kdb_running_process_save + cpu;
1433 if (!kdba_show_handlers && REGION_NUMBER(task) >= RGN_GATE &&
1434 (task_thread_info(task)->flags & _TIF_MCA_INIT)) {
1435 struct ia64_sal_os_state *sos = (struct ia64_sal_os_state *)
1436 ((unsigned long)save->p + MCA_SOS_OFFSET);
1438 if (!sos->prev_task)
1440 work->p = sos->prev_task;
1441 p = (char *)sos->prev_task->thread.ksp;
1443 work->arch.sw = (struct switch_stack *)p;
1444 p += sizeof(struct switch_stack);
1445 work->regs = (struct pt_regs *)p;
1446 work->irq_depth = 2; /* any value >1 will do */
1450 /* Turn the display of the MCA/INIT handlers on or off, or display the status
1451 * of the MCA/INIT handlers.
1454 kdba_handlers(int argc, const char **argv)
1457 struct kdb_running_process *krp;
1459 return KDB_ARGCOUNT;
1460 if (strcmp(argv[1], "show") == 0)
1461 kdba_show_handlers = 1;
1462 else if (strcmp(argv[1], "hide") == 0)
1463 kdba_show_handlers = 0;
1464 else if (strcmp(argv[1], "status") != 0) {
1465 kdb_printf("handlers <show|hide|status>\n");
1468 for (cpu = 0, krp = kdb_running_process_save; cpu < NR_CPUS; ++cpu, ++krp) {
1470 kdba_handlers_modify(krp->p, cpu);
1472 if (strcmp(argv[1], "status") != 0)
1474 kdb_printf("handlers status is %s\n", kdba_show_handlers ? "'show'" : "'hide'");
1475 kdb_printf(" cpu handler task command original task command\n");
1476 for (cpu = 0, krp = kdb_running_process_save; cpu < NR_CPUS; ++cpu, ++krp) {
1477 struct task_struct *p = krp->p;
1480 kdb_printf("%4d", cpu);
1481 if (task_thread_info(p)->flags & _TIF_MCA_INIT) {
1482 struct ia64_sal_os_state *sos;
1483 kdb_printf(" " kdb_machreg_fmt0 " %-*s ",
1484 (unsigned long)p, (int)sizeof(p->comm), p->comm);
1485 sos = (struct ia64_sal_os_state *)((unsigned long)p + MCA_SOS_OFFSET);
1488 kdb_printf("%*s", (int)(1+2+16+1+sizeof(p->comm)+2), " ");
1490 kdb_printf(" " kdb_machreg_fmt0 " %-*s",
1491 (unsigned long)p, (int)sizeof(p->comm), p->comm);
1497 /* Executed once on each cpu at startup. */
1506 * Architecture specific initialization.
1521 kdb_running_process_save = kzalloc(
1522 sizeof(*kdb_running_process_save) * NR_CPUS, GFP_KERNEL);
1523 BUG_ON(!kdb_running_process_save);
1524 kdb_register("irr", kdba_sir, "", "Show interrupt registers", 0);
1525 kdb_register("itm", kdba_itm, "", "Set new ITM value", 0);
1526 #if defined(CONFIG_SMP)
1527 kdb_register("init", kdba_sendinit, "", "Send INIT to cpu", 0);
1529 kdb_register("pt_regs", kdba_pt_regs, "address", "Format struct pt_regs", 0);
1530 kdb_register("switch_stack", kdba_switch_stack, "address", "Format struct switch_stack", 0);
1531 kdb_register("minstate", kdba_minstate, "address", "Format PAL minstate", 0);
1532 kdb_register("tpa", kdba_tpa, "<vaddr>", "Translate virtual to physical address", 0);
1533 #if defined(CONFIG_NUMA)
1534 kdb_register("tpav", kdba_tpav, "<begin addr> <end addr>", "Verify that physical addresses corresponding to virtual addresses from <begin addr> to <end addr> are in same node", 0);
1536 kdb_register("stackdepth", kdba_stackdepth, "[percentage]", "Print processes using >= stack percentage", 0);
1537 kdb_register("cpuinfo", kdba_cpuinfo, "[cpu]", "Print struct cpuinfo_ia64", 0);
1538 kdb_register("handlers", kdba_handlers, "<show|hide|status>", "Control the display of MCA/INIT handlers", 0);
1540 #ifdef CONFIG_SERIAL_8250_CONSOLE
1541 kdba_serial_console = KDBA_SC_STANDARD;
1543 #ifdef CONFIG_SERIAL_SGI_L1_CONSOLE
1544 if (ia64_platform_is("sn2"))
1545 kdba_serial_console = KDBA_SC_SGI_L1;
1553 * Architecture specific adjustment of instruction pointer before leaving
1557 * reason The reason KDB was invoked
1558 * error The hardware-defined error code
1559 * regs The exception frame at time of fault/breakpoint. If reason
1560 * is SILENT or CPU_UP then regs is NULL, otherwise it should
1567 * On IA64, KDB_ENTER() and KDB_ENTER_SLAVE() use break which is a fault,
1568 * not a trap. The instruction pointer must be stepped before leaving
1569 * kdb, otherwise we get a loop.
1573 kdba_adjust_ip(kdb_reason_t reason, int error, struct pt_regs *regs)
1575 if ((reason == KDB_REASON_ENTER || reason == KDB_REASON_ENTER_SLAVE) &&
1576 !KDB_STATE(IP_ADJUSTED)) {
1577 if (KDB_NULL_REGS(regs))
1579 if (ia64_psr(regs)->ri < 2)
1580 kdba_setpc(regs, regs->cr_iip + ia64_psr(regs)->ri + 1);
1582 kdba_setpc(regs, regs->cr_iip + 16);
1587 kdba_save_running(struct kdba_running_process *k, struct pt_regs *regs)
1589 struct kdb_running_process *work, *save;
1590 int cpu = smp_processor_id();
1591 work = kdb_running_process + cpu;
1592 save = kdb_running_process_save + cpu;
1596 kdba_handlers_modify((struct task_struct *)regs->r13, cpu);
1600 kdba_unsave_running(struct kdba_running_process *k, struct pt_regs *regs)
1602 memset(kdb_running_process_save + smp_processor_id(), 0,
1603 sizeof(*kdb_running_process_save));
1607 kdba_set_current_task(const struct task_struct *p)
1609 int cpu = kdb_process_cpu(p);
1610 struct kdb_running_process *work, *save;
1611 work = kdb_running_process + cpu;
1612 save = kdb_running_process_save + cpu;
1613 kdb_current_task = p;
1614 if (kdb_task_has_cpu(p)) {
1615 kdb_current_regs = work->regs;
1618 kdb_current_regs = NULL;
1619 /* For most blocked tasks we cannot get the pt_regs without doing an
1620 * unwind, which is not worth doing. For tasks interrupted by
1621 * MCA/INIT, when the user is not working on the handlers, we must use
1622 * the registers at the time of interrupt.
1624 if (work->p == save->p || work->p != p)
1626 kdb_current_regs = (struct pt_regs *)(work->p->thread.ksp + 16 +
1627 sizeof(struct switch_stack));
1631 * asm-ia64 uaccess.h supplies __copy_to_user which relies on MMU to
1632 * trap invalid addresses in the _xxx fields. Verify the other address
1633 * of the pair is valid by accessing the first and last byte ourselves,
1634 * then any access violations should only be caused by the _xxx
1639 kdba_putarea_size(unsigned long to_xxx, void *from, size_t size)
1641 mm_segment_t oldfs = get_fs();
1644 c = *((volatile char *)from);
1645 c = *((volatile char *)from + size - 1);
1647 if (to_xxx >> 61 <= 4) {
1648 return kdb_putuserarea_size(to_xxx, from, size);
1652 r = __copy_to_user_inatomic((void __user *)to_xxx, from, size);
1658 kdba_getarea_size(void *to, unsigned long from_xxx, size_t size)
1660 mm_segment_t oldfs = get_fs();
1662 *((volatile char *)to) = '\0';
1663 *((volatile char *)to + size - 1) = '\0';
1665 if (from_xxx >> 61 <= 4)
1666 return kdb_getuserarea_size(to, from_xxx, size);
1671 r = __copy_to_user_inatomic((void __user *)to, (void *)from_xxx, 1);
1674 r = __copy_to_user_inatomic((void __user *)to, (void *)from_xxx, 2);
1677 r = __copy_to_user_inatomic((void __user *)to, (void *)from_xxx, 4);
1680 r = __copy_to_user_inatomic((void __user *)to, (void *)from_xxx, 8);
1683 r = __copy_to_user_inatomic((void __user *)to, (void *)from_xxx, size);
1691 kdba_verify_rw(unsigned long addr, size_t size)
1693 unsigned char data[(__force size_t) size];
1694 return(kdba_getarea_size(data, addr, size) || kdba_putarea_size(addr, data, size));
1697 #ifdef CONFIG_KDB_KDUMP
1699 kdba_kdump_prepare(struct pt_regs *fixed_regs)
1703 /* Set on KEXEC bit on all onlinr cpus */
1704 for (i = 1; i < NR_CPUS; ++i) {
1708 KDB_STATE_SET_CPU(KEXEC, i);
1711 machine_crash_shutdown(fixed_regs);
1714 void kdba_kdump_shutdown_slave(struct pt_regs *regs)
1716 if (kdb_kdump_state != KDB_KDUMP_RESET) {
1717 unw_init_running(kdump_cpu_freeze, NULL);