Skip to content

Commit c6f5d8f

Browse files
committed
arm64: Use the fault handler when one is provided
In align_abort() and tag_check_abort(), if we got a fault while in kernel, do not panic if a fault handler has been provided. We may get such a fault when trying to read or write userland data, it can at least happen with _umtx_op() if an unaligned pointer is provided. Instead, just let the fault handler deal with it. MFC After: 1 week Approved by: andrew Differential Revision: https://reviews.freebsd.org/D58426
1 parent 24983c4 commit c6f5d8f

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

‎sys/arm64/arm64/trap.c‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,17 @@ align_abort(struct thread *td, struct trapframe *frame, uint64_t esr,
217217
uint64_t far, int lower)
218218
{
219219
if (!lower) {
220+
/*
221+
* Accessing unaligned memory may fault when using atomics.
222+
* Make sure we don't panic if we're doing an unaligned
223+
* access to userland memory, as can happen with _umtx_op()
224+
*/
225+
if (td->td_intr_nesting_level == 0 &&
226+
td->td_pcb->pcb_onfault != 0) {
227+
frame->tf_elr = td->td_pcb->pcb_onfault;
228+
return;
229+
}
230+
220231
print_registers(frame);
221232
print_gp_register("far", far);
222233
printf(" esr: 0x%.16lx\n", esr);
@@ -262,6 +273,14 @@ tag_check_abort(struct thread *td, struct trapframe *frame, uint64_t esr,
262273
* at EL0 and a kernel panic if at EL1.
263274
*/
264275
if (!lower) {
276+
/*
277+
* If we have a fault handler, let it decide what to do.
278+
*/
279+
if (td->td_intr_nesting_level == 0 &&
280+
td->td_pcb->pcb_onfault != 0) {
281+
frame->tf_elr = td->td_pcb->pcb_onfault;
282+
return;
283+
}
265284
print_registers(frame);
266285
print_gp_register("far", far);
267286
printf(" esr: 0x%.16lx\n", esr);

0 commit comments

Comments
 (0)