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) > I've certainly had > extremely deterministic requirements to call it twice, which doesn't > line up terribly well with it just being down to async events. Yeah, I guess you can still get the Windows sticker if you violate this requirement :-)