mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, Andy Lutomirski <luto@kernel.org>,
	Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Sohil Mehta <sohil.mehta@intel.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 1/1] x86/fault: cleanup: move x86-64 test into is_vsyscall_vaddr()
Date: Thu,  5 Mar 2026 15:21:35 -0800	[thread overview]
Message-ID: <20260305232136.224922-2-hpa@zytor.com> (raw)
In-Reply-To: <20260305232136.224922-1-hpa@zytor.com>

In one location, there is an IS_ENABLED(CONFIG_X86_64) before calling
is_vsyscall_vaddr(), in another the whole thing is under #ifdef.

Moving IS_ENABLED(CONFIG_X86_64) into is_vsyscall_vaddr(), which is an
inline function anyway, eliminates the need for both.

This exposes a dummy call to emulate_vsyscall() to the compiler on
x86-32, but that is perfectly OK since the stub inline for
!CONFIG_X86_VSYSCALL_EMULATION is available even when compiling for
x86-32.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
---
 arch/x86/include/asm/vsyscall.h | 3 ++-
 arch/x86/mm/fault.c             | 4 +---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/vsyscall.h b/arch/x86/include/asm/vsyscall.h
index 538053b1656a..57ab3da53002 100644
--- a/arch/x86/include/asm/vsyscall.h
+++ b/arch/x86/include/asm/vsyscall.h
@@ -36,7 +36,8 @@ static inline bool emulate_vsyscall_gp(struct pt_regs *regs)
  */
 static inline bool is_vsyscall_vaddr(unsigned long vaddr)
 {
-	return unlikely((vaddr & PAGE_MASK) == VSYSCALL_ADDR);
+	return IS_ENABLED(CONFIG_X86_64) &&
+		unlikely((vaddr & PAGE_MASK) == VSYSCALL_ADDR);
 }
 
 #endif /* _ASM_X86_VSYSCALL_H */
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index f0e77e084482..fcd6b58dc0ac 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -1119,7 +1119,7 @@ bool fault_in_kernel_space(unsigned long address)
 	 * TASK_SIZE_MAX, but is not considered part of the kernel
 	 * address space.
 	 */
-	if (IS_ENABLED(CONFIG_X86_64) && is_vsyscall_vaddr(address))
+	if (is_vsyscall_vaddr(address))
 		return false;
 
 	return address >= TASK_SIZE_MAX;
@@ -1301,7 +1301,6 @@ void do_user_addr_fault(struct pt_regs *regs,
 	if (user_mode(regs))
 		flags |= FAULT_FLAG_USER;
 
-#ifdef CONFIG_X86_64
 	/*
 	 * Faults in the vsyscall page might need emulation.  The
 	 * vsyscall page is at a high address (>PAGE_OFFSET), but is
@@ -1317,7 +1316,6 @@ void do_user_addr_fault(struct pt_regs *regs,
 		if (emulate_vsyscall_pf(error_code, regs, address))
 			return;
 	}
-#endif
 
 	if (!(flags & FAULT_FLAG_USER))
 		goto lock_mmap;
-- 
2.53.0


  reply	other threads:[~2026-03-05 23:38 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-05 21:40 [PATCH v2 0/5] x86: Enable LASS support with vsyscall=xonly mode Sohil Mehta
2026-03-05 21:40 ` [PATCH v2 1/5] x86/vsyscall: Reorganize the page fault emulation code Sohil Mehta
2026-03-05 22:36   ` H. Peter Anvin
2026-03-06  0:49     ` Sohil Mehta
2026-03-19 21:59   ` [tip: x86/cpu] " tip-bot2 for Sohil Mehta
2026-03-05 21:40 ` [PATCH v2 2/5] x86/traps: Consolidate user fixups in the #GP handler Sohil Mehta
2026-03-05 22:22   ` H. Peter Anvin
2026-03-05 22:41   ` H. Peter Anvin
2026-03-19 21:59   ` [tip: x86/cpu] " tip-bot2 for Sohil Mehta
2026-03-05 21:40 ` [PATCH v2 3/5] x86/vsyscall: Restore vsyscall=xonly mode under LASS Sohil Mehta
2026-03-05 22:45   ` H. Peter Anvin
2026-03-19 21:59   ` [tip: x86/cpu] " tip-bot2 for Sohil Mehta
2026-03-05 21:40 ` [PATCH v2 4/5] x86/vsyscall: Disable LASS if vsyscall mode is set to EMULATE Sohil Mehta
2026-03-05 22:45   ` H. Peter Anvin
2026-03-19 21:59   ` [tip: x86/cpu] " tip-bot2 for Sohil Mehta
2026-03-05 21:40 ` [PATCH v2 5/5] x86/cpu: Remove LASS restriction on vsyscall emulation Sohil Mehta
2026-03-05 22:46   ` H. Peter Anvin
2026-03-19 21:59   ` [tip: x86/cpu] " tip-bot2 for Sohil Mehta
2026-03-05 23:21 ` [PATCH 0/1] x86/fault: cleanup: move x86-64 test into is_vsyscall_vaddr() H. Peter Anvin
2026-03-05 23:21   ` H. Peter Anvin [this message]
2026-03-08 10:38 ` [PATCH v2 0/5] x86: Enable LASS support with vsyscall=xonly mode Maciej Wieczor-Retman

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=20260305232136.224922-2-hpa@zytor.com \
    --to=hpa@zytor.com \
    --cc=bp@alien8.de \
    --cc=corbet@lwn.net \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=skhan@linuxfoundation.org \
    --cc=sohil.mehta@intel.com \
    --cc=tglx@kernel.org \
    --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