linux kernel cash时打印寄存器值以及寄存器指向的地址前后128字节的值
kernel cash时打印寄存器值以及寄存器指向的地址前后128字节的值
arch/arm64/kernel/process.c
void __show_regs(struct pt_regs *regs) { int i, top_reg; u64 lr, sp; if (compat_user_mode(regs)) { lr = regs->compat_lr; sp = regs->compat_sp; top_reg = 12; } else { lr = regs->regs[30]; sp = regs->sp; top_reg = 29; } show_regs_print_info(KERN_DEFAULT); print_symbol("PC is at %s\n", instruction_pointer(regs)); print_symbol("LR is at %s\n", lr); printk("pc : [<%016llx>] lr : [<%016llx>] pstate: %08llx\n", regs->pc, lr, regs->pstate); printk("sp : %016llx\n", sp); for (i = top_reg; i >= 0; i--) { printk("x%-2d: %016llx ", i, regs->regs[i]); if (i % 2 == 0) printk("\n"); } if (!user_mode(regs)) show_extra_register_data(regs, 128); printk("\n"); }
static void show_extra_register_data(struct pt_regs *regs, int nbytes) { mm_segment_t fs; unsigned int i; fs = get_fs(); set_fs(KERNEL_DS); show_data(regs->pc - nbytes, nbytes * 2, "PC"); show_data(regs->regs[30] - nbytes, nbytes * 2, "LR"); show_data(regs->sp - nbytes, nbytes * 2, "SP"); for (i = 0; i < 30; i++) { char name[4]; snprintf(name, sizeof(name), "X%u", i); show_data(regs->regs[i] - nbytes, nbytes * 2, name); } set_fs(fs); }
02-20 20:16:45.284--: [ 2027.328712] Unable to handle kernel NULL pointer dereference at virtual address 00000068 02-20 20:16:45.284--[ 2027.336813] pgd = ffffff80093ae000 02-20 20:16:45.284--[ 2027.340217] [00000068] *pgd=00000001bfffe003, *pud=00000001bfffe003, *pmd=0000000000000000 02-20 20:16:45.284--[ 2027.348524] Internal error: Oops: 96000006 [#1] PREEMPT SMP 02-20 20:16:45.285--[ 2027.388147] CPU: 0 PID: 10467 Comm: kworker/0:8 Tainted: P B W O 4.9.118+ #3 02-20 20:16:45.285--[ 2027.399671] Workqueue: usb_hub_wq hub_event 02-20 20:16:45.285--[ 2027.403874] task: ffffffc0399b9000 task.stack: ffffffc0070bc000 02-20 20:16:45.285--[ 2027.409800] PC is at qh_link_periodic+0x8c/0x1f0 02-20 20:16:45.285--[ 2027.414420] LR is at ehci_urb_enqueue+0x438/0x87c 02-20 20:16:45.285--[ 2027.419125] pc : [<ffffff800870af88>] lr : [<ffffff800870e470>] pstate: 800001c5 02-20 20:16:45.285--[ 2027.426522] sp : ffffffc0070bf2e0 02-20 20:16:45.285--[ 2027.429836] x29: ffffffc0070bf2e0 x28: 00000000024000c0 02-20 20:16:45.285--[ 2027.435172] x27: 0000000000000140 x26: 0000000000000081 02-20 20:16:45.286--[ 2027.440508] x25: ffffffc066d0eb9c x24: 0000000000000000 02-20 20:16:45.286--[ 2027.445844] x23: ffffffc0070bf388 x22: ffffffc066d0eac0 02-20 20:16:45.286--[ 2027.451178] x21: ffffffc066d0e800 x20: ffffff800906c000 02-20 20:16:45.286--[ 2027.456512] x19: ffffffc066d0eac0 x18: 00000077eadbc000 02-20 20:16:45.286--[ 2027.461846] x17: 00000077eacdf0c0 x16: 00000077683dc3c0 02-20 20:16:45.286--[ 2027.467181] x15: 0000000180000000 x14: 0000000000000000 02-20 20:16:45.286--[ 2027.472515] x13: 0000000000000000 x12: 0000000000000000 02-20 20:16:45.286--[ 2027.477848] x11: 0000000000000000 x10: 0000000000000010 02-20 20:16:45.286--[ 2027.483182] x9 : ffffffc00ea90200 x8 : 0000000000000001 02-20 20:16:45.297--[ 2027.488518] x7 : 000000000000013d x6 : ffffffc025d5c800 02-20 20:16:45.298--[ 2027.493853] x5 : 0100000000000068 x4 : 0100000000000000 02-20 20:16:45.298--[ 2027.499187] x3 : 0000000000000000 x2 : 0100000000000000 02-20 20:16:45.298--[ 2027.504523] x1 : ffffffc03d517500 x0 : ffffffc002438000 02-20 20:16:45.298--[ 2027.509859] 02-20 20:16:45.298--[ 2027.509859] SP: 0xffffffc0070bf260: 02-20 20:16:45.298--[ 2027.514824] f260 66d0eac0 ffffffc0 070bf388 ffffffc0 00000000 00000000 66d0eb9c ffffffc0 02-20 20:16:45.298--[ 2027.523108] f280 00000081 00000000 00000140 00000000 024000c0 00000000 070bf2e0 ffffffc0 02-20 20:16:45.298--[ 2027.531392] f2a0 0870e470 ffffff80 070bf2e0 ffffffc0 0870af88 ffffff80 800001c5 00000000 02-20 20:16:45.298--[ 2027.539677] f2c0 66d0e800 ffffffc0 66d0eac0 ffffffc0 ffffffff ffffffff 00000000 00000000 02-20 20:16:45.299--[ 2027.547963] f2e0 070bf310 ffffffc0 0870e470 ffffff80 3d517500 ffffffc0 0870e464 ffffff80 02-20 20:16:45.299--[ 2027.556250] f300 3d517500 ffffffc0 3d517500 ffffffc0 070bf3b0 ffffffc0 086ec950 ffffff80 02-20 20:16:45.299--[ 2027.564534] f320 0ea90200 ffffffc0 00000000 00000000 0906c000 ffffff80 66d0e800 ffffffc0 02-20 20:16:45.299--[ 2027.572817] f340 024000c0 00000000 00000010 00000000 00f1a0f8 ffffff80 00000001 00000000 02-20 20:16:45.299-- 02-20 20:16:45.299--[ 2027.581099] X0: 0xffffffc002437f80: 02-20 20:16:45.299--[ 2027.584761] 7f80 00000000 00000000 00000000 00000000 00006400 00000000 00000000 00000000 02-20 20:16:45.299--[ 2027.593045] 7fa0 00000000 00000000 00000000 00000000 00006400 00000000 00000000 00000000 02-20 20:16:45.299--[ 2027.601327] 7fc0 00000000 00000000 00000000 00007200 00000001 00000000 00000000 00000000 02-20 20:16:45.300--[ 2027.609613] 7fe0 00000000 00000000 00000000 00000000 00000000 00000000 00000018 00000000 02-20 20:16:45.300--[ 2027.617897] 8000 3d517500 ffffffc0 3d517500 ffffffc0 3d517500 ffffffc0 3d517500 ffffffc0 02-20 20:16:45.300--[ 2027.626183] 8020 3d517500 ffffffc0 3d517500 ffffffc0 3d517500 ffffffc0 3d517500 ffffffc0 02-20 20:16:45.300--[ 2027.634467] 8040 3d517500 ffffffc0 3d517500 ffffffc0 3d517500 ffffffc0 3d517500 ffffffc0 02-20 20:16:45.300--[ 2027.642753] 8060 3d517500 ffffffc0 3d517500 ffffffc0 3d517500 ffffffc0 3d517500 ffffffc0 02-20 20:16:45.300-- 02-20 20:16:45.300--[ 2027.651035] X1: 0xffffffc03d517480: 02-20 20:16:45.300--[ 2027.654697] 7480 00000000 00000000 00000000 00000000 00000000 00000000 669e13c0 ffffffc0 02-20 20:16:45.300--[ 2027.662981] 74a0 00000000 00000000 00000000 00000000 00000000 00000000 ffffffff ffffffff 02-20 20:16:45.300--[ 2027.671264] 74c0 00000000 00000000 00000000 00000000 298abea0 ffffffc0 3d5174d8 ffffffc0 02-20 20:16:45.301--[ 2027.679549] 74e0 3d5174d8 ffffffc0 3d5174e8 ffffffc0 3d5174e8 ffffffc0 64d18458 ffffffc0 02-20 20:16:45.301--[ 2027.687832] 7500 0ae1f180 ffffff80 21841180 00000000 00000000 00000000 0ae210c0 ffffff80 02-20 20:16:45.301--[ 2027.696115] 7520 0ae210c0 ffffff80 00000000 00000000 00000000 00000000 0ae21200 ffffff80 02-20 20:16:45.301--[ 2027.704398] 7540 3d517540 ffffffc0 3d517540 ffffffc0 25d5c800 ffffffc0 1628e800 ffffffc0 02-20 20:16:45.301--[ 2027.712681] 7560 329168a0 ffffffc0 329168a0 ffffffc0 1c010018 00000001 03010000 00000108