RE: [PATCH] x86/efi: Restore Firmware IDT in before ExitBootServices()

From: David Laight
Date: Fri Aug 20 2021 - 04:43:53 EST


From: Joerg Roedel
> Sent: 20 August 2021 08:34
>
> From: Joerg Roedel <jroedel@xxxxxxx>
>
> Commit 79419e13e808 ("x86/boot/compressed/64: Setup IDT in startup_32
> boot path") introduced an IDT into the 32 bit boot path of the
> decompressor stub. But the IDT is set up before ExitBootServices() is
> called and some UEFI firmwares rely on their own IDT.
>
> Save the firmware IDT on boot and restore it before calling into EFI
> functions to fix boot failures introduced by above commit.

Hmmm...
If Linux needs its own IDT then temporarily substituting the old IDT
prior to a UEFI call will cause 'grief' if a 'Linux' interrupt
happens during the UEFI call.

So I suspect you just can't make EFI calls after installing the
Linux IDT.

Looks like UEFI is no better than the traditional BIOS.
Great fun trying to reliably switch from 32bit paged to
16bit segmented and back (especially on VIA C3) and discovering
that that bios code enables interrupts - so all hell happens
in the ISR entry path.

It may be that the only safe way to make UEFI calls (after the
very initial entry code) is using an emulator.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)