Re: [PATCH 3/5] x86/vsyscall: Add vsyscall emulation for #GP
From: Dave Hansen
Date: Tue Mar 03 2026 - 10:55:57 EST
On 2/19/26 15:35, Sohil Mehta wrote:
> With LASS, these accesses are intercepted before the paging structures
> are traversed triggering a #GP instead of a #PF. The #GP doesn't provide
> much information in terms of the error code.
It's the error code and the address from CR2, right?
> However, as clarified in the SDM, the LASS violation only triggers after
> an instruction fetch happens from the vsyscall address. So, the faulting
> RIP, which is preserved in the user registers, can be used to determine
> if the #GP was triggered due to a vsyscall access in XONLY mode.
>
> Reuse the common emulation code during a #GP and emulate the vsyscall
> access in XONLY mode without going through complex instruction decoding.
> Note, this doesn't work for EMULATE mode which maps the vsyscall page as
> readable.
>
> Add an extra check in the common emulation code to ensure that the fault
> really happened in 64-bit user mode. This is primarily a sanity check
> with the #GP handler reusing the emulation code.
This part of the changelog loses me.
I _think_ this is trying to make the point that "emulate" mode is hard
with LASS. It's hard because it needs to be able to tell the difference
between a read of the vsyscall page and an instruction fetch from the
vsyscall page.
But, the "xonly" mode is far easier because reads are simply disallowed.
Any time userspace has an RIP pointing to the vsyscall page (with LASS
enabled), it's assumed to be a vsyscall. Any normal memory reads of the
vsyscall page get normal #GP handling.
Is that right?
BTW, reading it back now, I think the subject is really unfortunate. It
would be quite easy to read it and infer that this "adds
vsyscall=emulate for #GP".
It should probably be:
x86/vsyscall: Restore vsyscall=xonly mode under LASS
Maybe this structure would help, based around explaining the three
vsyscall= modes:
The vsyscall page is in the high/kernel part of the address
space. LASS prevents access to this page from userspace. The
kernel currently forces vsyscall=none mode with LASS.
Support vsyscall=xonly mode with LASS. <include more content
here>
Keep vsyscall=emulate mutually exclusive with LASS. It is hard
to support because the #GP handler (unlike #PF) doesn't have
PFEC or CR2 to give information about the fault.