From: Sohil Mehta <sohil.mehta@intel.com>
To: Andy Lutomirski <luto@kernel.org>,
Dave Hansen <dave.hansen@intel.com>,
the arch/x86 maintainers <x86@kernel.org>,
Dave Hansen <dave.hansen@linux.intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
"Ingo Molnar" <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>
Cc: Jonathan Corbet <corbet@lwn.net>,
"H. Peter Anvin" <hpa@zytor.com>,
"Josh Poimboeuf" <jpoimboe@kernel.org>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
Ard Biesheuvel <ardb@kernel.org>,
"Kirill A . Shutemov" <kas@kernel.org>, Xin Li <xin@zytor.com>,
David Woodhouse <dwmw@amazon.co.uk>,
Sean Christopherson <seanjc@google.com>,
"Rick P Edgecombe" <rick.p.edgecombe@intel.com>,
Vegard Nossum <vegard.nossum@oracle.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
"Randy Dunlap" <rdunlap@infradead.org>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Kees Cook <kees@kernel.org>, Tony Luck <tony.luck@intel.com>,
"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
<linux-doc@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
<linux-efi@vger.kernel.org>
Subject: Re: [PATCH v11 5/9] x86/efi: Disable LASS while mapping the EFI runtime services
Date: Thu, 6 Nov 2025 23:36:23 -0800 [thread overview]
Message-ID: <1b648c3d-2fc5-41fe-8c2b-71b63be3544f@intel.com> (raw)
In-Reply-To: <27b6cafe-8cc9-4a01-af2b-3e847ff9aaa9@intel.com>
On 10/31/2025 12:04 PM, Sohil Mehta wrote:
>> Is there some way to be reasonably convinced that you haven’t missed another EFI code path?
>
> We have been running the patches on internal test platforms for a couple
> of years. But, that would only cover the common paths. I'll dig deeper
> to get you a convincing answer.
In summary, the current approach could work for BIOSes that behave well.
But, the kernel makes lots of exceptions for broken firmware and odd
implementations. We would need extra guardrails and changes to support
those, or mark them unsupported. Please see my analysis below.
For now, I am wondering if we should disable the EFI support as
well (similar to vsyscall).
if (IS_ENABLED(CONFIG_EFI))
// Do not enable LASS
I think the rest of the patches are ready. I can post a new revision
with the above change to collect additional reviews/acks. Even though,
this would significantly restrict usage, it would make it easier to
review EFI support (as well vsyscall support) in its independent,
focussed series.
My analysis
-----------
After a 1-week crash course in EFI (mainly reading lkml archives) below
is my understanding. Thanks Rick and Peter Anvin for the pointers and
insights. I would highly appreciate it if folks can validate assumptions
and help with some opens.
1) Does LASS affect EFI BootTimeServices?
Contrary to my assumption, EFI_BOOT_SERVICES_CODE/_DATA could be
accessed even after ExitBootServices() has been called. For example,
early ACPI code in efi_bgrt_init() accesses it.
efi_check_for_embedded_firmwares() accesses this memory even after
SetVirtualAddressMap() has been called right before
efi_free_boot_services().
At a minimum, we need to disable LASS around these special cases or
enable LASS only after EFI has completely finished entering virtual mode
(including freeing boot services).
Ideally, we would enable LASS much later, right before enabling userspace.
2) How does SetVirtualAddressMap() impact LASS?
SetVirtualAddressMap() is the first and only runtime service call that
is made in EFI physical mode (at the lower mapping). After the call,
firmware is expected to switch all its pointers to the high virtual
address provided by the kernel.
If LASS is enabled, it needs to be temporarily turned off during
SetVirtualAddressMap() as done in this patch. Though, the resolution in
#1 would likely make this patch moot.
3) Would LASS interfere with other runtime services?
Unfortunately, some firmware tends to cling to the old physical
addresses even after SetVirtualAddressMap() and doesn't completely
switch over to using the new virtual addresses. To workaround, the
kernel dual maps all the memory marked as EFI_RUNTIME under a separate
efi_mm. First with a 1:1 map and second with the high virtual address.
See efi_map_region().
Also, some runtime services expect to access the First 4kb of physical
memory, which is also mapped 1:1 to avoid failures.
To avoid any of these corner cases, LASS must be toggled everytime we
make a runtime EFI call. Because efi_mm doesn't have real user mappings,
disabling LASS after efi_enter_mm() should be fine.
I am unsure whether the accesses are only data accesses, or could
instruction fetch happen as well. Based on that, we would need a
STAC/CLAC pair or a CR4.LASS toggle to disable LASS.
Writing to CR4 might be the safest option, because performance is not a
concern here, right?
4) What happens if an EFI runtime call trips LASS?
If a LASS violation happens with EFI, the system would trigger a #GP and
hang. For page faults, we seem to have introduced
efi_crash_gracefully_on_page_fault() to attribute the fault to EFI. Do
we require something similar for #GP?
My inclination is to add the helpful prints after we run into an issue.
5) Is there any other aspect of EFI that should be considered?
Please let me know if I have missed something.
Another approach could be to support only limited (well behaving)
firmware implementations with LASS. But, I am not sure how practical
that would be given all the quirks we have in place.
Thanks,
Sohil
next prev parent reply other threads:[~2025-11-07 7:36 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-29 21:03 [PATCH v11 0/9] x86: Enable Linear Address Space Separation support Sohil Mehta
2025-10-29 21:03 ` [PATCH v11 1/9] x86/cpufeatures: Enumerate the LASS feature bits Sohil Mehta
2025-10-31 17:03 ` Dave Hansen
2025-10-29 21:03 ` [PATCH v11 2/9] x86/cpu: Add an LASS dependency on SMAP Sohil Mehta
2025-10-31 17:04 ` Dave Hansen
2025-10-29 21:03 ` [PATCH v11 3/9] x86/asm: Introduce inline memcpy and memset Sohil Mehta
2025-10-31 17:06 ` Dave Hansen
2025-10-29 21:03 ` [PATCH v11 4/9] x86/alternatives: Disable LASS when patching kernel code Sohil Mehta
2025-10-31 17:10 ` Dave Hansen
2025-11-10 18:15 ` Sohil Mehta
2025-11-10 19:09 ` H. Peter Anvin
2025-11-10 19:24 ` Borislav Petkov
2025-11-12 13:56 ` Ard Biesheuvel
2025-11-12 14:51 ` Dave Hansen
2025-11-12 14:57 ` H. Peter Anvin
2025-11-12 15:18 ` Ard Biesheuvel
2025-11-12 15:23 ` H. Peter Anvin
2025-11-12 15:28 ` Ard Biesheuvel
2025-11-12 15:47 ` H. Peter Anvin
2025-11-12 16:18 ` Sohil Mehta
2025-11-12 16:26 ` H. Peter Anvin
2025-11-12 16:29 ` H. Peter Anvin
2025-10-29 21:03 ` [PATCH v11 5/9] x86/efi: Disable LASS while mapping the EFI runtime services Sohil Mehta
2025-10-31 17:11 ` Dave Hansen
2025-10-31 17:38 ` Andy Lutomirski
2025-10-31 17:41 ` Dave Hansen
2025-10-31 18:03 ` Sohil Mehta
2025-10-31 18:12 ` Dave Hansen
2025-11-07 9:04 ` Peter Zijlstra
2025-11-07 9:22 ` Ard Biesheuvel
2025-11-07 9:27 ` H. Peter Anvin
2025-11-07 9:35 ` Ard Biesheuvel
2025-11-07 9:40 ` Peter Zijlstra
2025-11-07 10:09 ` Ard Biesheuvel
2025-11-07 10:27 ` Peter Zijlstra
2025-11-08 0:48 ` Andy Lutomirski
2025-11-08 16:18 ` H. Peter Anvin
2025-11-08 22:50 ` H. Peter Anvin
2025-11-07 10:10 ` Peter Zijlstra
2025-11-07 10:17 ` Ard Biesheuvel
2025-10-31 19:04 ` Sohil Mehta
2025-11-07 7:36 ` Sohil Mehta [this message]
2025-10-31 18:32 ` Sohil Mehta
2025-10-29 21:03 ` [PATCH v11 6/9] x86/kexec: Disable LASS during relocate kernel Sohil Mehta
2025-10-31 17:14 ` Dave Hansen
2025-10-29 21:03 ` [PATCH v11 7/9] x86/traps: Communicate a LASS violation in #GP message Sohil Mehta
2025-10-31 17:16 ` Dave Hansen
2025-10-31 19:59 ` Sohil Mehta
2025-10-31 20:03 ` Andy Lutomirski
2025-10-31 20:56 ` Dave Hansen
2025-10-29 21:03 ` [PATCH v11 8/9] selftests/x86: Update the negative vsyscall tests to expect a #GP Sohil Mehta
2025-10-31 17:20 ` Dave Hansen
2025-10-29 21:03 ` [PATCH v11 9/9] x86/cpu: Enable LASS by default during CPU initialization Sohil Mehta
2025-10-30 8:40 ` H. Peter Anvin
2025-10-30 15:45 ` Andy Lutomirski
2025-10-30 16:44 ` Sohil Mehta
2025-10-30 16:53 ` Andy Lutomirski
2025-10-30 17:24 ` Sohil Mehta
2025-10-30 17:31 ` Andy Lutomirski
2025-10-30 21:13 ` David Laight
2025-10-31 6:41 ` H. Peter Anvin
2025-10-31 16:55 ` Dave Hansen
2025-10-30 16:27 ` Dave Hansen
2025-11-07 8:01 ` H. Peter Anvin
2025-11-07 20:08 ` Sohil Mehta
2025-10-31 17:21 ` Dave Hansen
2025-10-31 20:04 ` 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=1b648c3d-2fc5-41fe-8c2b-71b63be3544f@intel.com \
--to=sohil.mehta@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=andrew.cooper3@citrix.com \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=corbet@lwn.net \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=dwmw@amazon.co.uk \
--cc=geert@linux-m68k.org \
--cc=hpa@zytor.com \
--cc=jpoimboe@kernel.org \
--cc=kas@kernel.org \
--cc=kees@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rdunlap@infradead.org \
--cc=rick.p.edgecombe@intel.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=vegard.nossum@oracle.com \
--cc=x86@kernel.org \
--cc=xin@zytor.com \
/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;
as well as URLs for NNTP newsgroup(s).