On Tue, 27 Jun 2023 at 10:37, Matthew Garrett <mjg59@xxxxxxxxxxxxx> wrote: > > On Tue, Jun 27, 2023 at 10:32:36AM +0200, Ard Biesheuvel wrote: > > On Tue, 27 Jun 2023 at 10:17, Matthew Garrett <mjg59@xxxxxxxxxxxxx> wrote: > > > > > > On Tue, Jun 27, 2023 at 10:14:16AM +0200, Ard Biesheuvel wrote: > > > > > > > Not quite. It should only fail the first time if the memory map > > > > changed since the last call to GetMemoryMap(), and normally, this will > > > > only happen if some kind of asynchronous event was triggered after > > > > GetMemoryMap() but before ExitBootServices(). (This is why calling > > > > ExitBootServices() at most twice should always suffice: the first call > > > > disables the timer interrupt, so the second time around, no events > > > > will fire in the mean time) > > > > > > Can't driver shutdown code also end up altering it? > > > > Yes, but doing so violates the UEFI spec: > > EVT_SIGNAL_EXIT_BOOT_SERVICES is documented as not permitting the use > > of memory allocation services, either directly or indirectly (via the > > use of other external code that might use them) > > Maybe people have become better at observing that restriction! Anyway, > feel free to ignore my nit in that case. I haven't dealt with actual production x86 hardware built to boot Windows via EFI (or CSM) as much as you have, so my world view tends to be a bit naive when it comes to actual EFI compliance :-)