git: 99213b3c352c - main - aarch64: Save correct value of x18 on trapframe for nested faults
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 16 Sep 2025 11:24:50 UTC
The branch main has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=99213b3c352cdf568ea7cf5b4dddb1879f16a601
commit 99213b3c352cdf568ea7cf5b4dddb1879f16a601
Author: Konrad Witaszczyk <def@FreeBSD.org>
AuthorDate: 2025-09-16 11:21:57 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-09-16 11:23:58 +0000
aarch64: Save correct value of x18 on trapframe for nested faults
x18 is overwritten with a temporary copy of the kernel stack pointer
when it is saved in the trapframe. This does not matter in terms of
function since nested exception return does not restore x18 from the
trapframe, but it does mean that examining x18 in a debugger in stack
frames above a nested fault outputs the wrong register value.
To fix, compute the value of the original stack pointer to save in x18
later after the trapframe has been constructed.
Reviewed by: jhb, andrew
Sponsored by: AFRL, DARPA
Differential Revision: https://reviews.freebsd.org/D52472
---
sys/arm64/arm64/exception.S | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/sys/arm64/arm64/exception.S b/sys/arm64/arm64/exception.S
index 6e673fbe5a43..5a4181348a54 100644
--- a/sys/arm64/arm64/exception.S
+++ b/sys/arm64/arm64/exception.S
@@ -42,7 +42,6 @@
*/
.macro save_registers_head el
.if \el == 1
- mov x18, sp
stp x0, x1, [sp, #-(TF_SIZE - TF_X + 128)]!
.else
stp x0, x1, [sp, #-(TF_SIZE - TF_X)]!
@@ -61,7 +60,9 @@
stp x24, x25, [sp, #(24 * 8)]
stp x26, x27, [sp, #(26 * 8)]
stp x28, x29, [sp, #(28 * 8)]
-.if \el == 0
+.if \el == 1
+ add x18, sp, #(TF_SIZE - TF_X + 128)
+.else
mrs x18, sp_el0
.endif
mrs x10, elr_el1