git: 473cd1bba9b4 - main - amd64: fixes for register handling of syscall entry for FRED
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 27 Oct 2026 12:01:20 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=473cd1bba9b4e80b741769ff6185ba3846b1f050
commit 473cd1bba9b4e80b741769ff6185ba3846b1f050
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-10-27 09:21:55 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-10-27 11:58:48 +0000
amd64: fixes for register handling of syscall entry for FRED
- Save %r10 into tf_rcx. This is the location for the 4th arg.
libsys stubs do 'movq %rcx, %r10' so the fast syscall path works
as is. But Go binaries directly put arg 4 into %r10.
Also save %r11 into tf_r11 for the duration of syscall handler.
- Somewhat improve binary compatibility with IDT SYSCALL fast return,
by copying userspace return %rip into %rcx, and %rflags into %r11,
emulating SYSCALL IDT delivery.
Fixes: 6e93f5e4d693 ("amd64: FRED support")
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
---
sys/amd64/amd64/exception.S | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/sys/amd64/amd64/exception.S b/sys/amd64/amd64/exception.S
index 458a7c405793..206b56abc545 100644
--- a/sys/amd64/amd64/exception.S
+++ b/sys/amd64/amd64/exception.S
@@ -1428,7 +1428,7 @@ gsbase_load_fault:
ALIGN_TEXT
user_fred_syscall:
movq %rdx,TF_RDX(%rsp)
- movq %rcx,TF_RCX(%rsp)
+ movq %r11,TF_R11(%rsp)
SAVE_SEGS
movq PCPU(CURPCB),%r11
andl $~PCB_FULL_IRET,PCB_FLAGS(%r11)
@@ -1439,6 +1439,7 @@ user_fred_syscall:
movq %r9,TF_R9(%rsp)
movq %rbx,TF_RBX(%rsp)
movq %rbp,TF_RBP(%rsp)
+ movq %r10,TF_RCX(%rsp)
movq %r12,TF_R12(%rsp)
movq %r13,TF_R13(%rsp)
movq %r14,TF_R14(%rsp)
@@ -1462,10 +1463,11 @@ user_fred_syscall:
movq TF_RSI(%rsp),%rsi
movq TF_RDX(%rsp),%rdx
movq TF_RAX(%rsp),%rax
+ movq TF_RIP(%rsp),%rcx
+ movq TF_RFLAGS(%rsp),%r11
xorl %r8d,%r8d
xorl %r9d,%r9d
xorl %r10d,%r10d
- xorl %r11d,%r11d
addq $TF_ERR,%rsp
.globl fred_syscall_eretu
fred_syscall_eretu: