From 99164e4253a4b4d954dc33c041b1e01ef872f2a9 Mon Sep 17 00:00:00 2001 From: jsg Date: Sat, 1 May 2021 03:03:15 +0000 Subject: [PATCH] use sival_ptr instead of sival_int for breakpoint and illegal inst For breakpoints stval will have a vaddr. For illegal instructions stval may be as large as a register or the widest instruction. Also avoid using an uninitialised variable for stval. ok mlarkin@ drahn@ --- sys/arch/riscv64/riscv64/trap_machdep.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/arch/riscv64/riscv64/trap_machdep.c b/sys/arch/riscv64/riscv64/trap_machdep.c index 0b35a1fefff..b8a64bebffb 100644 --- a/sys/arch/riscv64/riscv64/trap_machdep.c +++ b/sys/arch/riscv64/riscv64/trap_machdep.c @@ -110,7 +110,6 @@ do_trap_user(struct trapframe *frame) union sigval sv; struct proc *p; struct pcb *pcb; - uint64_t stval; p = curcpu()->ci_curproc; p->p_addr->u_pcb.pcb_tf = frame; @@ -172,7 +171,7 @@ do_trap_user(struct trapframe *frame) } } printf("ILL at %lx scause %lx stval %lx\n", frame->tf_sepc, frame->tf_scause, frame->tf_stval); - sv.sival_int = stval; + sv.sival_ptr = (void *)frame->tf_stval; KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_ILLTRP, sv); KERNEL_UNLOCK(); @@ -180,7 +179,7 @@ do_trap_user(struct trapframe *frame) break; case EXCP_BREAKPOINT: printf("BREAKPOINT\n"); - sv.sival_int = stval; + sv.sival_ptr = (void *)frame->tf_stval; KERNEL_LOCK(); trapsignal(p, SIGTRAP, 0, TRAP_BRKPT, sv); KERNEL_UNLOCK(); @@ -267,7 +266,7 @@ data_abort(struct trapframe *frame, int usermode) sig = SIGSEGV; code = SEGV_MAPERR; } - sv.sival_int = stval; + sv.sival_ptr = (void *)stval; KERNEL_LOCK(); //printf("signalling %d at pc 0%lx ra 0x%lx %llx\n", code, frame->tf_sepc, frame->tf_ra, stval); trapsignal(p, sig, 0, code, sv); @@ -289,6 +288,7 @@ done: fatal: dump_regs(frame); - panic("Fatal page fault at %#lx: %#08x", frame->tf_sepc, sv.sival_int); + panic("Fatal page fault at %#lx: %#08lx", frame->tf_sepc, + (vaddr_t)sv.sival_ptr); } -- 2.20.1