[syslinux] [PATCH] Call ExitBootServices twice
celelibi at gmail.com
celelibi at gmail.com
Tue Aug 25 20:54:03 PDT 2015
From: Sylvain Gault <sylvain.gault at gmail.com>
On some architecture, including my hardware, the function ExitBootServices may
need to be called twice in order to successfully exit the boot services. As
stated by the UEFI spec, the first call to ExitBootServices may perform a
partial shutdown of the services. It seems that during this partial shutdown,
the memory map can be modified, thus making another call to GetMemoryMap
necessary. However GetMemoryMap needs a buffer to fill, but the memory
allocation functions should not be used after the first call to
ExitBootServices despite still working on my hardware. This patch solve this
problem as follow:
- Get the memory map and allocate a buffer larger than necessary
- Call ExitBootServices
- If it succeed, we're done
- Get the new memory map in the same buffer
- Reallocate this buffer if it is too small anyway
So the call to the memory allocation functions may be called after
ExitBootServices only if the existing buffer was too small despite being
already larger than needed on the first call to GetMemoryMap.
This issue of calling ExitBootServices twice is mentioned around the web and
this patch is quite close to the one implemented in Linux.
Sylvain Gault (1):
efi: Call ExitBootServices at least twice
efi/main.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 64 insertions(+), 11 deletions(-)
--
2.5.0
More information about the Syslinux
mailing list