mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sohil Mehta <sohil.mehta@intel.com>
To: Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, Andy Lutomirski <luto@kernel.org>,
	Borislav Petkov <bp@alien8.de>, "H . Peter Anvin" <hpa@zytor.com>
Cc: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Sohil Mehta <sohil.mehta@intel.com>,
	Nam Cao <namcao@linutronix.de>,
	Cedric Xing <cedric.xing@intel.com>,
	Rick Edgecombe <rick.p.edgecombe@intel.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Michael Roth <michael.roth@amd.com>,
	Brijesh Singh <brijesh.singh@amd.com>,
	Jarkko Sakkinen <jarkko@kernel.org>,
	Tony Luck <tony.luck@intel.com>,
	linux-kernel@vger.kernel.org
Subject: [RFC PATCH 1/2] x86/vsyscall: Avoid vsyscall emulation when X86_PF_INSTR is not set
Date: Fri, 13 Mar 2026 12:23:26 -0700	[thread overview]
Message-ID: <20260313192327.2089471-2-sohil.mehta@intel.com> (raw)
In-Reply-To: <20260313192327.2089471-1-sohil.mehta@intel.com>

On systems that support X86_FEATURE_NX, X86_PF_INSTR is expected to be
set in the PFEC when a #PF is triggered due to an instruction fetch on a
vsyscall page.

Commit 8ba38a7a9a69 ("x86/vsyscall: Do not require X86_PF_INSTR to
emulate vsyscall") changed the requirement for X86_PF_INSTR to be set
because X86_FEATURE_NX may not be available on some platforms. Vsyscall
emulation now relies on the fact that, in the case of a #PF due to an
instruction fetch, the RIP will always match the vsyscall fault address
reported via CR2.

The kernel still issues a warning if X86_PF_INSTR is not set when
X86_FEATURE_NX is enabled. However, this warning is almost impossible to
trigger unless something is very wrong. Instead of continuing, avoid
vsyscall emulation in this extremely unlikely situation.

Suggested-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Signed-off-by: Sohil Mehta <sohil.mehta@intel.com>
---
 arch/x86/entry/vsyscall/vsyscall_64.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/entry/vsyscall/vsyscall_64.c b/arch/x86/entry/vsyscall/vsyscall_64.c
index ea36de9fa864..b1f8f8a57b02 100644
--- a/arch/x86/entry/vsyscall/vsyscall_64.c
+++ b/arch/x86/entry/vsyscall/vsyscall_64.c
@@ -282,8 +282,9 @@ bool emulate_vsyscall_pf(unsigned long error_code, struct pt_regs *regs,
 	 * available, use it to double-check that the emulation code
 	 * is only being used for instruction fetches:
 	 */
-	if (cpu_feature_enabled(X86_FEATURE_NX))
-		WARN_ON_ONCE(!(error_code & X86_PF_INSTR));
+	if (cpu_feature_enabled(X86_FEATURE_NX) &&
+	    WARN_ON_ONCE(!(error_code & X86_PF_INSTR)))
+		return false;
 
 	return __emulate_vsyscall(regs, address);
 }
-- 
2.43.0


  reply	other threads:[~2026-03-13 19:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-13 19:23 [RFC PATCH 0/2] x86/vsyscall: Tighten vsyscall emulation checks for a #PF fixup Sohil Mehta
2026-03-13 19:23 ` Sohil Mehta [this message]
2026-03-13 19:23 ` [RFC PATCH 2/2] x86/vsyscall: Avoid vsyscall emulation for some unexpected fault types Sohil Mehta
2026-03-18 18:47 ` [RFC PATCH 0/2] x86/vsyscall: Tighten vsyscall emulation checks for a #PF fixup Edgecombe, Rick P
2026-03-18 18:47 ` Edgecombe, Rick P
2026-03-19 18:30   ` Sohil Mehta

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=20260313192327.2089471-2-sohil.mehta@intel.com \
    --to=sohil.mehta@intel.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=bp@alien8.de \
    --cc=brijesh.singh@amd.com \
    --cc=cedric.xing@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jarkko@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=michael.roth@amd.com \
    --cc=mingo@redhat.com \
    --cc=namcao@linutronix.de \
    --cc=peterz@infradead.org \
    --cc=rick.p.edgecombe@intel.com \
    --cc=tglx@kernel.org \
    --cc=tony.luck@intel.com \
    --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®