The branch main has been updated by cognet:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=c6f5d8fb269fd67a8206420b4e7d67a93bc80733

commit c6f5d8fb269fd67a8206420b4e7d67a93bc80733
Author:     Olivier Houchard <[email protected]>
AuthorDate: 2026-07-23 23:47:21 +0000
Commit:     Olivier Houchard <[email protected]>
CommitDate: 2026-07-28 10:08:56 +0000

    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
---
 sys/arm64/arm64/trap.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/sys/arm64/arm64/trap.c b/sys/arm64/arm64/trap.c
index 3afeb34abd5f..e688b9cb76a3 100644
--- a/sys/arm64/arm64/trap.c
+++ b/sys/arm64/arm64/trap.c
@@ -217,6 +217,17 @@ align_abort(struct thread *td, struct trapframe *frame, 
uint64_t esr,
     uint64_t far, int lower)
 {
        if (!lower) {
+               /*
+                * Accessing unaligned memory may fault when using atomics.
+                * Make sure we don't panic if we're doing an unaligned
+                * access to userland memory, as can happen with _umtx_op()
+                */
+               if (td->td_intr_nesting_level == 0 &&
+                   td->td_pcb->pcb_onfault != 0) {
+                       frame->tf_elr = td->td_pcb->pcb_onfault;
+                       return;
+               }
+
                print_registers(frame);
                print_gp_register("far", far);
                printf(" esr: 0x%.16lx\n", esr);
@@ -262,6 +273,14 @@ tag_check_abort(struct thread *td, struct trapframe 
*frame, uint64_t esr,
         * at EL0 and a kernel panic if at EL1.
         */
        if (!lower) {
+               /*
+                * If we have a fault handler, let it decide what to do.
+                */
+               if (td->td_intr_nesting_level == 0 &&
+                   td->td_pcb->pcb_onfault != 0) {
+                       frame->tf_elr = td->td_pcb->pcb_onfault;
+                       return;
+               }
                print_registers(frame);
                print_gp_register("far", far);
                printf(" esr: 0x%.16lx\n", esr);

Reply via email to