Set si_trapno to the exception code from scause.

Reviewed by:	kib
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D25770
This commit is contained in:
John Baldwin 2020-07-27 16:28:44 +00:00
parent e21c0b0753
commit c294dddb03

View File

@ -80,7 +80,7 @@ void do_trap_supervisor(struct trapframe *);
void do_trap_user(struct trapframe *); void do_trap_user(struct trapframe *);
static __inline void static __inline void
call_trapsignal(struct thread *td, int sig, int code, void *addr) call_trapsignal(struct thread *td, int sig, int code, void *addr, int trapno)
{ {
ksiginfo_t ksi; ksiginfo_t ksi;
@ -88,6 +88,7 @@ call_trapsignal(struct thread *td, int sig, int code, void *addr)
ksi.ksi_signo = sig; ksi.ksi_signo = sig;
ksi.ksi_code = code; ksi.ksi_code = code;
ksi.ksi_addr = addr; ksi.ksi_addr = addr;
ksi.ksi_trapno = trapno;
trapsignal(td, &ksi); trapsignal(td, &ksi);
} }
@ -224,7 +225,8 @@ data_abort(struct trapframe *frame, int usermode)
error = vm_fault_trap(map, va, ftype, VM_FAULT_NORMAL, &sig, &ucode); error = vm_fault_trap(map, va, ftype, VM_FAULT_NORMAL, &sig, &ucode);
if (error != KERN_SUCCESS) { if (error != KERN_SUCCESS) {
if (usermode) { if (usermode) {
call_trapsignal(td, sig, ucode, (void *)stval); call_trapsignal(td, sig, ucode, (void *)stval,
frame->tf_scause & EXCP_MASK);
} else { } else {
if (pcb->pcb_onfault != 0) { if (pcb->pcb_onfault != 0) {
frame->tf_a[0] = error; frame->tf_a[0] = error;
@ -353,11 +355,13 @@ do_trap_user(struct trapframe *frame)
break; break;
} }
#endif #endif
call_trapsignal(td, SIGILL, ILL_ILLTRP, (void *)frame->tf_sepc); call_trapsignal(td, SIGILL, ILL_ILLTRP, (void *)frame->tf_sepc,
exception);
userret(td, frame); userret(td, frame);
break; break;
case EXCP_BREAKPOINT: case EXCP_BREAKPOINT:
call_trapsignal(td, SIGTRAP, TRAP_BRKPT, (void *)frame->tf_sepc); call_trapsignal(td, SIGTRAP, TRAP_BRKPT, (void *)frame->tf_sepc,
exception);
userret(td, frame); userret(td, frame);
break; break;
default: default: