On Sun, Dec 17, 2017 at 08:34:52PM +0100, Patrick Wildt wrote:
> Hi,
> 
> I had been looking into booting a 32-bit kernel with efiboot and the
> first thing I stumbled upon is that when we jump back into 32-bit mode
> we don't disable the Long Mode Extension.  Thus when the i386 kernel
> turns on paging, LME goes active as well and "weird things happen".
> 
> Not sure this path is worth pursuing, but this diff at least resets
> EFER correctly.
> 
> Opinions? ok?
> 
> Patrick
> 
> diff --git a/sys/arch/amd64/stand/efiboot/run_i386.S 
> b/sys/arch/amd64/stand/efiboot/run_i386.S
> index 1c70f8d4610..63d6f1f1dca 100644
> --- a/sys/arch/amd64/stand/efiboot/run_i386.S
> +++ b/sys/arch/amd64/stand/efiboot/run_i386.S
> @@ -88,6 +88,12 @@ start32a:
>       andl    $(~CR4_PAE), %eax
>       movl    %eax, %cr4
>  
> +     /* Disable LME */
> +     movl    $MSR_EFER, %ecx
> +     rdmsr
> +     xor     %eax, %eax
> +     wrmsr
> +
>       jmp     start32b
>  start32b:
>       .code32
> 

Could we ever have the case where EFI set up EFER_NXE? Does that
need to be preserved (even in i386 mode)?

-ml

Reply via email to