Commit 1a7227fe0013b6ff6b3b9d46db3faea30cbe48e5

Authored by Ard Biesheuvel
Committed by Greg Kroah-Hartman
1 parent 058ec24e2b

arm64/efi: add missing call to early_ioremap_reset()

commit 0e63ea48b4d8035dd0e91a3fa6fb79458b47adfb upstream.

The early ioremap support introduced by patch bf4b558eba92
("arm64: add early_ioremap support") failed to add a call to
early_ioremap_reset() at an appropriate time. Without this call,
invocations of early_ioremap etc. that are done too late will go
unnoticed and may cause corruption.

This is exactly what happened when the first user of this feature
was added in patch f84d02755f5a ("arm64: add EFI runtime services").
The early mapping of the EFI memory map is unmapped during an early
initcall, at which time the early ioremap support is long gone.

Fix by adding the missing call to early_ioremap_reset() to
setup_arch(), and move the offending early_memunmap() to right after
the point where the early mapping of the EFI memory map is last used.

Fixes: f84d02755f5a ("arm64: add EFI runtime services")
Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 2 changed files with 2 additions and 1 deletions Side-by-side Diff

arch/arm64/kernel/efi.c
... ... @@ -327,6 +327,7 @@
327 327  
328 328 /* boot time idmap_pg_dir is incomplete, so fill in missing parts */
329 329 efi_setup_idmap();
  330 + early_memunmap(memmap.map, memmap.map_end - memmap.map);
330 331 }
331 332  
332 333 static int __init remap_region(efi_memory_desc_t *md, void **new)
... ... @@ -381,7 +382,6 @@
381 382 }
382 383  
383 384 mapsize = memmap.map_end - memmap.map;
384   - early_memunmap(memmap.map, mapsize);
385 385  
386 386 if (efi_runtime_disabled()) {
387 387 pr_info("EFI runtime services will be disabled.\n");
arch/arm64/kernel/setup.c
... ... @@ -394,6 +394,7 @@
394 394 request_standard_resources();
395 395  
396 396 efi_idmap_init();
  397 + early_ioremap_reset();
397 398  
398 399 unflatten_device_tree();
399 400