git: 6aa36e57d0b2 - stable/15 - amd64: do not pass SYSENTER frame to FRED fast syscall handler

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 03 Nov 2026 09:02:07 UTC
The branch stable/15 has been updated by kib:

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

commit 6aa36e57d0b26f6ccacd10c577c9bb5c3cf57c12
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-10-27 10:08:14 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-11-03 09:01:14 +0000

    amd64: do not pass SYSENTER frame to FRED fast syscall handler
    
    (cherry picked from commit 8671e823b7678731cd1aaf8850ccde4a2c293527)
---
 sys/amd64/amd64/exception.S | 8 ++++----
 sys/amd64/amd64/genassym.c  | 6 ++++++
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/sys/amd64/amd64/exception.S b/sys/amd64/amd64/exception.S
index b596a0ff1b9d..e7f1c9ad5664 100644
--- a/sys/amd64/amd64/exception.S
+++ b/sys/amd64/amd64/exception.S
@@ -1650,10 +1650,10 @@ fred_events_handlers:
 	movq	%rsi,TF_RSI(%rsp)
 	movl	TF_FRED_EVINFO2(%rsp),%edi
 	movl	%edi,%eax
-	andl	$TF_FRED_EVINFO2_TYPEMASK,%edi
-	cmpl	$TF_FRED_EVINFO2_TYPE_SYSCALL,%edi
-	je	user_fred_syscall
-	jmp	user_fred_non_syscall
+	andl	$TF_FRED_EVINFO2_SYSCALLMASK,%edi
+	cmpl	$TF_FRED_EVINFO2_SYSCALLVAL,%edi
+	jne	user_fred_non_syscall
+	jmp	user_fred_syscall
 
 	. = fred_events_handlers + 256
 	subq	$TF_ERR,%rsp
diff --git a/sys/amd64/amd64/genassym.c b/sys/amd64/amd64/genassym.c
index 96663a9a2b55..affcf38576ac 100644
--- a/sys/amd64/amd64/genassym.c
+++ b/sys/amd64/amd64/genassym.c
@@ -188,9 +188,15 @@ ASSYM(TF_FRED_EVINFO2, offsetof(struct trapframe, tf_fred_evinfo2));
 ASSYM(TF_FLAGS, offsetof(struct trapframe, tf_flags));
 ASSYM(TF_SIZE, sizeof(struct trapframe));
 ASSYM(TF_HASSEGS, TF_HASSEGS);
+ASSYM(TF_FRED_EVINFO2_VECMASK, TF_FRED_EVINFO2_VECMASK);
+ASSYM(TF_FRED_EVINFO2_VEC_SYSCALL, TF_FRED_EVINFO2_VEC_SYSCALL);
+ASSYM(TF_FRED_EVINFO2_SYSCALLMASK, TF_FRED_EVINFO2_TYPEMASK |
+    TF_FRED_EVINFO2_VECMASK | TF_FRED_EVINFO2_LM);
 ASSYM(TF_FRED_EVINFO2_TYPE_EXC, TF_FRED_EVINFO2_TYPE_EXC);
 ASSYM(TF_FRED_EVINFO2_TYPE_SYSCALL, TF_FRED_EVINFO2_TYPE_SYSCALL);
 ASSYM(TF_FRED_EVINFO2_TYPEMASK, TF_FRED_EVINFO2_TYPEMASK);
+ASSYM(TF_FRED_EVINFO2_SYSCALLVAL, TF_FRED_EVINFO2_TYPE_SYSCALL |
+    TF_FRED_EVINFO2_VEC_SYSCALL | TF_FRED_EVINFO2_LM);
 ASSYM(TF_FRED_EVINFO2_INSTLENMASK, TF_FRED_EVINFO2_INSTLENMASK);
 ASSYM(TF_FRED_EVINFO2_INSTLENSHIFT, TF_FRED_EVINFO2_INSTLENSHIFT);