[PATCH 1/1] x86/fault: cleanup: move x86-64 test into is_vsyscall_vaddr()

From: H. Peter Anvin

Date: Thu Mar 05 2026 - 18:38:35 EST


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@xxxxxxxxx>
---
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