Skip to content

Commit 9e9888a

Browse files
committed
efi: stub: omit SetVirtualAddressMap() if marked unsupported in RT_PROP table
The EFI_RT_PROPERTIES_TABLE contains a mask of runtime services that are available after ExitBootServices(). This mostly does not concern the EFI stub at all, given that it runs before that. However, there is one call that is made at runtime, which is the call to SetVirtualAddressMap() (which is not even callable at boot time to begin with) So add the missing handling of the RT_PROP table to ensure that we only call SetVirtualAddressMap() if it is not being advertised as unsupported by the firmware. Cc: <[email protected]> # v5.10+ Tested-by: Shawn Guo <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]>
1 parent a38fd87 commit 9e9888a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

drivers/firmware/efi/libstub/efi-stub.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,18 @@ static void install_memreserve_table(void)
9696
efi_err("Failed to install memreserve config table!\n");
9797
}
9898

99+
static u32 get_supported_rt_services(void)
100+
{
101+
const efi_rt_properties_table_t *rt_prop_table;
102+
u32 supported = EFI_RT_SUPPORTED_ALL;
103+
104+
rt_prop_table = get_efi_config_table(EFI_RT_PROPERTIES_TABLE_GUID);
105+
if (rt_prop_table)
106+
supported &= rt_prop_table->runtime_services_supported;
107+
108+
return supported;
109+
}
110+
99111
/*
100112
* EFI entry point for the arm/arm64 EFI stubs. This is the entrypoint
101113
* that is described in the PE/COFF header. Most of the code is the same
@@ -250,6 +262,10 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
250262
(prop_tbl->memory_protection_attribute &
251263
EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA);
252264

265+
/* force efi_novamap if SetVirtualAddressMap() is unsupported */
266+
efi_novamap |= !(get_supported_rt_services() &
267+
EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP);
268+
253269
/* hibernation expects the runtime regions to stay in the same place */
254270
if (!IS_ENABLED(CONFIG_HIBERNATION) && !efi_nokaslr && !flat_va_mapping) {
255271
/*

0 commit comments

Comments
 (0)