You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now, SetVirtualAddressMap in the UEFI compatibility layer just adjusts the virtual_start for the MemoryDescriptors returned by the allocator. However, this isn't what we should be doing (if I'm reading the spec correctly).
SetVirtualAddressMap should only be called exactly once during runtime (i.e. after calling ExitBootServices)
As Boot Services cannot be active when this is called, we don't need to modify the allocator at all (it won't be used again).
We do need to fixup any RuntimeServices code/data so that it can be called w/ non-identity paging.
The basic idea here would be to have separate ELF sections for EfiRuntimeServicesCode and EfiRuntimeServicesData. This would allow the remaining firmware to be unmapped by the OS. The EfiRuntimeServicesCode would need to be built with "relocation-model": "pic".
On a call to SetVirtualAddressMap, the code would then need to also fixup any pointers in static memory to use the new memory mapping. This can be automated by having the linker emit the necessary relocation entries.
Right now,
SetVirtualAddressMap
in the UEFI compatibility layer just adjusts thevirtual_start
for theMemoryDescriptor
s returned by the allocator. However, this isn't what we should be doing (if I'm reading the spec correctly).From the UEFI Specification 2.8 (Errata A), Section 8.4:
SetVirtualAddressMap
should only be called exactly once during runtime (i.e. after calling ExitBootServices)The basic idea here would be to have separate ELF sections for
EfiRuntimeServicesCode
andEfiRuntimeServicesData
. This would allow the remaining firmware to be unmapped by the OS. TheEfiRuntimeServicesCode
would need to be built with"relocation-model": "pic"
.On a call to
SetVirtualAddressMap
, the code would then need to also fixup any pointers in static memory to use the new memory mapping. This can be automated by having the linker emit the necessary relocation entries.EDK2's Implementation: https://github.com/tianocore/edk2/blob/3806e1fd139775610d8f2e7541a916c3a91ad989/MdeModulePkg/Core/RuntimeDxe/Runtime.c#L232
The text was updated successfully, but these errors were encountered: