From: "Xin Li (Intel)" <xin@zytor.com>
To: linux-kernel@vger.kernel.org
Cc: luto@kernel.org, tglx@linutronix.de, mingo@redhat.com,
bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org,
hpa@zytor.com, brgerst@gmail.com
Subject: [PATCH v1 1/1] x86/entry/64: Skip SYSRET validation tests when FRED is enabled
Date: Tue, 2 Apr 2024 23:24:03 -0700 [thread overview]
Message-ID: <20240403062404.2956240-1-xin@zytor.com> (raw)
Don't do SYSRET validation tests when FRED is enabled, since ERETU is
the only legit instruction to return to user level.
Signed-off-by: Xin Li (Intel) <xin@zytor.com>
---
arch/x86/entry/common.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
index 6356060caaf3..1c3944eb9901 100644
--- a/arch/x86/entry/common.c
+++ b/arch/x86/entry/common.c
@@ -72,7 +72,7 @@ static __always_inline bool do_syscall_x32(struct pt_regs *regs, int nr)
return false;
}
-/* Returns true to return using SYSRET, or false to use IRET */
+/* Returns true to return using SYSRET, or false to use IRET/ERETU */
__visible noinstr bool do_syscall_64(struct pt_regs *regs, int nr)
{
add_random_kstack_offset();
@@ -88,6 +88,10 @@ __visible noinstr bool do_syscall_64(struct pt_regs *regs, int nr)
instrumentation_end();
syscall_exit_to_user_mode(regs);
+ /* No test for FRED, which returns to user level with ERETU only */
+ if (cpu_feature_enabled(X86_FEATURE_FRED))
+ return false;
+
/*
* Check that the register state is valid for using SYSRET to exit
* to userspace. Otherwise use the slower but fully capable IRET
@@ -325,7 +329,7 @@ static noinstr bool __do_fast_syscall_32(struct pt_regs *regs)
return true;
}
-/* Returns true to return using SYSEXIT/SYSRETL, or false to use IRET */
+/* Returns true to return using SYSEXIT/SYSRETL, or false to use IRET/ERETU */
__visible noinstr bool do_fast_syscall_32(struct pt_regs *regs)
{
/*
@@ -346,6 +350,10 @@ __visible noinstr bool do_fast_syscall_32(struct pt_regs *regs)
if (!__do_fast_syscall_32(regs))
return false;
+ /* No test for FRED, which returns to user level with ERETU only */
+ if (cpu_feature_enabled(X86_FEATURE_FRED))
+ return false;
+
/*
* Check that the register state is valid for using SYSRETL/SYSEXIT
* to exit to userspace. Otherwise use the slower but fully capable
base-commit: 65d1240b6728b38e4d2068d6738a17e4ee4351f5
--
2.44.0
next reply other threads:[~2024-04-03 6:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-03 6:24 Xin Li (Intel) [this message]
2024-04-09 23:35 ` H. Peter Anvin
2024-04-10 16:44 ` Xin Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240403062404.2956240-1-xin@zytor.com \
--to=xin@zytor.com \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®