Commit 5e1f4178 authored by Ard Biesheuvel's avatar Ard Biesheuvel Committed by Luis Henriques

arm64/efi: add missing call to early_ioremap_reset()

commit 0e63ea48 upstream.

The early ioremap support introduced by patch bf4b558e
("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 f84d0275 ("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: f84d0275 ("arm64: add EFI runtime services")
Signed-off-by: default avatarLeif Lindholm <leif.lindholm@linaro.org>
Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
[ luis: backported to 3.16: adjusted context ]
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent 52024522
...@@ -338,6 +338,7 @@ void __init efi_idmap_init(void) ...@@ -338,6 +338,7 @@ void __init efi_idmap_init(void)
/* boot time idmap_pg_dir is incomplete, so fill in missing parts */ /* boot time idmap_pg_dir is incomplete, so fill in missing parts */
efi_setup_idmap(); efi_setup_idmap();
early_memunmap(memmap.map, memmap.map_end - memmap.map);
} }
static int __init remap_region(efi_memory_desc_t *md, void **new) static int __init remap_region(efi_memory_desc_t *md, void **new)
...@@ -395,7 +396,6 @@ static int __init arm64_enter_virtual_mode(void) ...@@ -395,7 +396,6 @@ static int __init arm64_enter_virtual_mode(void)
/* replace early memmap mapping with permanent mapping */ /* replace early memmap mapping with permanent mapping */
mapsize = memmap.map_end - memmap.map; mapsize = memmap.map_end - memmap.map;
early_memunmap(memmap.map, mapsize);
memmap.map = (__force void *)ioremap_cache((phys_addr_t)memmap.phys_map, memmap.map = (__force void *)ioremap_cache((phys_addr_t)memmap.phys_map,
mapsize); mapsize);
memmap.map_end = memmap.map + mapsize; memmap.map_end = memmap.map + mapsize;
......
...@@ -390,6 +390,7 @@ void __init setup_arch(char **cmdline_p) ...@@ -390,6 +390,7 @@ void __init setup_arch(char **cmdline_p)
request_standard_resources(); request_standard_resources();
efi_idmap_init(); efi_idmap_init();
early_ioremap_reset();
unflatten_device_tree(); unflatten_device_tree();
......
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