Re: [PATCH v5 05/16] x86/cpu: Defer CR pinning setup until after EFI initialization

From: Sohil Mehta
Date: Tue Oct 29 2024 - 18:10:59 EST


On 10/28/2024 9:07 AM, Alexander Shishkin wrote:
> In order to map the EFI runtime services, set_virtual_address_map
> needs to be called, which resides in the lower half of the address
> space. This means that LASS needs to be temporarily disabled around
> this call. This can only be done before the CR pinning is set up.
>

...

>
> /*
> * This needs to follow the FPU initializtion, since EFI depends on it.
> + * It also needs to precede the CR pinning setup, because we need to be
> + * able to temporarily clear the CR4.LASS bit in order to execute the
> + * set_virtual_address_map call, which resides in lower addresses and
> + * would trip LASS if enabled.
> */

It would be helpful to describe why lass_stac()/clac() doesn't work here
and instead the heavy handed CR4 toggling is needed.

> if (efi_enabled(EFI_RUNTIME_SERVICES))
> efi_enter_virtual_mode();
>
> + setup_cr_pinning();
> +