Skip to content

Commit

Permalink
Set si_trapno to the exception code from esr.
Browse files Browse the repository at this point in the history
Reviewed by:	kib
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D25771
  • Loading branch information
bsdjhb committed Jul 23, 2020
1 parent e7aaabe commit d7d14db
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions sys/arm64/arm64/trap.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,15 @@ static abort_handler *abort_handlers[] = {
};

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_init_trap(&ksi);
ksi.ksi_signo = sig;
ksi.ksi_code = code;
ksi.ksi_addr = addr;
ksi.ksi_trapno = trapno;
trapsignal(td, &ksi);
}

Expand Down Expand Up @@ -161,7 +162,8 @@ svc_handler(struct thread *td, struct trapframe *frame)
syscallenter(td);
syscallret(td);
} else {
call_trapsignal(td, SIGILL, ILL_ILLOPN, (void *)frame->tf_elr);
call_trapsignal(td, SIGILL, ILL_ILLOPN, (void *)frame->tf_elr,
ESR_ELx_EXCEPTION(frame->tf_esr));
userret(td, frame);
}
}
Expand All @@ -177,7 +179,8 @@ align_abort(struct thread *td, struct trapframe *frame, uint64_t esr,
panic("Misaligned access from kernel space!");
}

call_trapsignal(td, SIGBUS, BUS_ADRALN, (void *)frame->tf_elr);
call_trapsignal(td, SIGBUS, BUS_ADRALN, (void *)frame->tf_elr,
ESR_ELx_EXCEPTION(frame->tf_esr));
userret(td, frame);
}

Expand Down Expand Up @@ -261,7 +264,8 @@ data_abort(struct thread *td, struct trapframe *frame, uint64_t esr,
error = vm_fault_trap(map, far, ftype, VM_FAULT_NORMAL, &sig, &ucode);
if (error != KERN_SUCCESS) {
if (lower) {
call_trapsignal(td, sig, ucode, (void *)far);
call_trapsignal(td, sig, ucode, (void *)far,
ESR_ELx_EXCEPTION(esr));
} else {
if (td->td_intr_nesting_level == 0 &&
pcb->pcb_onfault != 0) {
Expand Down Expand Up @@ -483,24 +487,29 @@ do_el0_sync(struct thread *td, struct trapframe *frame)
break;
case EXCP_UNKNOWN:
if (!undef_insn(0, frame))
call_trapsignal(td, SIGILL, ILL_ILLTRP, (void *)far);
call_trapsignal(td, SIGILL, ILL_ILLTRP, (void *)far,
exception);
userret(td, frame);
break;
case EXCP_SP_ALIGN:
call_trapsignal(td, SIGBUS, BUS_ADRALN, (void *)frame->tf_sp);
call_trapsignal(td, SIGBUS, BUS_ADRALN, (void *)frame->tf_sp,
exception);
userret(td, frame);
break;
case EXCP_PC_ALIGN:
call_trapsignal(td, SIGBUS, BUS_ADRALN, (void *)frame->tf_elr);
call_trapsignal(td, SIGBUS, BUS_ADRALN, (void *)frame->tf_elr,
exception);
userret(td, frame);
break;
case EXCP_BRKPT_EL0:
case EXCP_BRK:
call_trapsignal(td, SIGTRAP, TRAP_BRKPT, (void *)frame->tf_elr);
call_trapsignal(td, SIGTRAP, TRAP_BRKPT, (void *)frame->tf_elr,
exception);
userret(td, frame);
break;
case EXCP_MSR:
call_trapsignal(td, SIGILL, ILL_PRVOPC, (void *)frame->tf_elr);
call_trapsignal(td, SIGILL, ILL_PRVOPC, (void *)frame->tf_elr,
exception);
userret(td, frame);
break;
case EXCP_SOFTSTP_EL0:
Expand All @@ -509,11 +518,12 @@ do_el0_sync(struct thread *td, struct trapframe *frame)
WRITE_SPECIALREG(mdscr_el1,
READ_SPECIALREG(mdscr_el1) & ~DBG_MDSCR_SS);
call_trapsignal(td, SIGTRAP, TRAP_TRACE,
(void *)frame->tf_elr);
(void *)frame->tf_elr, exception);
userret(td, frame);
break;
default:
call_trapsignal(td, SIGBUS, BUS_OBJERR, (void *)frame->tf_elr);
call_trapsignal(td, SIGBUS, BUS_OBJERR, (void *)frame->tf_elr,
exception);
userret(td, frame);
break;
}
Expand Down

0 comments on commit d7d14db

Please sign in to comment.