git: a69450102ff1 - main - arm64: Raise a SIGBUS on a user external abort

From: Andrew Turner <andrew_at_FreeBSD.org>
Date: Mon, 16 Oct 2023 10:47:28 UTC
The branch main has been updated by andrew:

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

commit a69450102ff1fe1466077a021a16bb265274d3a2
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2023-09-29 13:55:48 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2023-10-16 10:38:14 +0000

    arm64: Raise a SIGBUS on a user external abort
    
    When userspace triggers an external abort allow it to handle the abort
    by raising a SIGBUS.
    
    Reviewed by:    markj, kib
    Sponsored by:   Arm Ltd
    Differential Revision:  https://reviews.freebsd.org/D42018
---
 sys/arm64/arm64/trap.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/sys/arm64/arm64/trap.c b/sys/arm64/arm64/trap.c
index 2dda8cfc4c20..6534fd2283a1 100644
--- a/sys/arm64/arm64/trap.c
+++ b/sys/arm64/arm64/trap.c
@@ -225,19 +225,25 @@ static void
 external_abort(struct thread *td, struct trapframe *frame, uint64_t esr,
     uint64_t far, int lower)
 {
+	if (lower) {
+		call_trapsignal(td, SIGBUS, BUS_OBJERR, (void *)far,
+		    ESR_ELx_EXCEPTION(frame->tf_esr));
+		userret(td, frame);
+		return;
+	}
 
 	/*
 	 * Try to handle synchronous external aborts caused by
 	 * bus_space_peek() and/or bus_space_poke() functions.
 	 */
-	if (!lower && test_bs_fault((void *)frame->tf_elr)) {
+	if (test_bs_fault((void *)frame->tf_elr)) {
 		frame->tf_elr = (uint64_t)generic_bs_fault;
 		return;
 	}
 
 	print_registers(frame);
 	print_gp_register("far", far);
-	panic("Unhandled EL%d external data abort", lower ? 0: 1);
+	panic("Unhandled external data abort");
 }
 
 /*