git: d866f1d4f968 - stable/14 - aarch64: Save correct value of x18 on trapframe for nested faults
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 18 Dec 2025 18:40:58 UTC
The branch stable/14 has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=d866f1d4f968f8ead4765944d82f4af640815678
commit d866f1d4f968f8ead4765944d82f4af640815678
Author: Konrad Witaszczyk <def@FreeBSD.org>
AuthorDate: 2025-09-16 11:21:57 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-12-18 18:25:14 +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
(cherry picked from commit 99213b3c352cdf568ea7cf5b4dddb1879f16a601)
---
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 0457efe77ba8..07223fcb069d 100644
--- a/sys/arm64/arm64/exception.S
+++ b/sys/arm64/arm64/exception.S
@@ -38,7 +38,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)]!
@@ -57,7 +56,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