Skip to content

Commit 7fe5d2b

Browse files
Ard Biesheuvelctmarinas
authored andcommitted
arm64/efi: handle potential failure to remap memory map
When remapping the UEFI memory map using ioremap_cache(), we have to deal with potential failure. Note that, even if the common case is for ioremap_cache() to return the existing linear mapping of the memory map, we cannot rely on that to be always the case, e.g., in the presence of a mem= kernel parameter. At the same time, remove a stale comment and move the memmap code together. Signed-off-by: Ard Biesheuvel <[email protected]> Acked-by: Mark Rutland <[email protected]> Acked-by: Mark Salter <[email protected]> Signed-off-by: Catalin Marinas <[email protected]>
1 parent d67703a commit 7fe5d2b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

arch/arm64/kernel/efi.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,19 +229,21 @@ static int __init arm64_enable_runtime_services(void)
229229
return -1;
230230
}
231231

232-
mapsize = memmap.map_end - memmap.map;
233-
234232
if (efi_runtime_disabled()) {
235233
pr_info("EFI runtime services will be disabled.\n");
236234
return -1;
237235
}
238236

239237
pr_info("Remapping and enabling EFI services.\n");
240-
/* replace early memmap mapping with permanent mapping */
238+
239+
mapsize = memmap.map_end - memmap.map;
241240
memmap.map = (__force void *)ioremap_cache((phys_addr_t)memmap.phys_map,
242241
mapsize);
242+
if (!memmap.map) {
243+
pr_err("Failed to remap EFI memory map\n");
244+
return -1;
245+
}
243246
memmap.map_end = memmap.map + mapsize;
244-
245247
efi.memmap = &memmap;
246248

247249
efi.systab = (__force void *)ioremap_cache(efi_system_table,

0 commit comments

Comments
 (0)