Commit 99a5603e authored by Ard Biesheuvel's avatar Ard Biesheuvel Committed by Matt Fleming
Browse files

efi/arm64: Handle missing virtual mapping for UEFI System Table

If we cannot resolve the virtual address of the UEFI System Table, its
physical offset must be missing from the virtual memory map, and there
is really no point in proceeding with installing the virtual memory map
and the runtime services dispatch table. So back out gracefully.
Signed-off-by: default avatarArd Biesheuvel <>
Acked-by: default avatarMark Salter <>
Acked-by: default avatarCatalin Marinas <>
Signed-off-by: default avatarMatt Fleming <>
parent c7341d6a
......@@ -414,13 +414,24 @@ static int __init arm64_enter_virtual_mode(void)
for_each_efi_memory_desc(&memmap, md) {
if (!(md->attribute & EFI_MEMORY_RUNTIME))
if (remap_region(md, &virt_md))
if (!remap_region(md, &virt_md))
goto err_unmap;
efi.systab = (__force void *)efi_lookup_mapped_addr(efi_system_table);
if (efi.systab)
set_bit(EFI_SYSTEM_TABLES, &efi.flags);
if (!efi.systab) {
* If we have no virtual mapping for the System Table at this
* point, the memory map doesn't cover the physical offset where
* it resides. This means the System Table will be inaccessible
* to Runtime Services themselves once the virtual mapping is
* installed.
pr_err("Failed to remap EFI System Table -- buggy firmware?\n");
goto err_unmap;
set_bit(EFI_SYSTEM_TABLES, &efi.flags);
cpu_switch_mm(idmap_pg_dir, &init_mm);
......@@ -453,5 +464,14 @@ static int __init arm64_enter_virtual_mode(void)
set_bit(EFI_RUNTIME_SERVICES, &efi.flags);
return 0;
/* unmap all mappings that succeeded: there are 'count' of those */
for (virt_md = virtmap; count--; virt_md += memmap.desc_size) {
md = virt_md;
iounmap((__force void __iomem *)md->virt_addr);
return -1;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment