From 500899c2cc3e3f06140373b587a69d30650f2d9d Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Fri, 8 Apr 2016 15:50:23 -0700 Subject: efi: ARM/arm64: ignore DT memory nodes instead of removing them There are two problems with the UEFI stub DT memory node removal routine: - it deletes nodes as it traverses the tree, which happens to work but is not supported, as deletion invalidates the node iterator; - deleting memory nodes entirely may discard annotations in the form of additional properties on the nodes. Since the discovery of DT memory nodes occurs strictly before the UEFI init sequence, we can simply clear the memblock memory table before parsing the UEFI memory map. This way, it is no longer necessary to remove the nodes, so we can remove that logic from the stub as well. Reviewed-by: Matt Fleming Acked-by: Steve Capper Signed-off-by: Ard Biesheuvel Signed-off-by: David Daney Signed-off-by: Will Deacon --- drivers/firmware/efi/arm-init.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drivers/firmware/efi/arm-init.c') diff --git a/drivers/firmware/efi/arm-init.c b/drivers/firmware/efi/arm-init.c index aa1f743152a2..5d6945b761dc 100644 --- a/drivers/firmware/efi/arm-init.c +++ b/drivers/firmware/efi/arm-init.c @@ -143,6 +143,14 @@ static __init void reserve_regions(void) if (efi_enabled(EFI_DBG)) pr_info("Processing EFI memory map:\n"); + /* + * Discard memblocks discovered so far: if there are any at this + * point, they originate from memory nodes in the DT, and UEFI + * uses its own memory map instead. + */ + memblock_dump_all(); + memblock_remove(0, ULLONG_MAX); + for_each_efi_memory_desc(&memmap, md) { paddr = md->phys_addr; npages = md->num_pages; -- cgit v1.2.3 From 7464b6e3a5fb213e7826d2fde4a2daf05abb6822 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 18 Apr 2016 10:34:19 +0200 Subject: efi: ARM: avoid warning about phys_addr_t cast memblock_remove() takes a phys_addr_t, which may be narrower than 64 bits, causing a harmless warning: drivers/firmware/efi/arm-init.c: In function 'reserve_regions': include/linux/kernel.h:29:20: error: large integer implicitly truncated to unsigned type [-Werror=overflow] #define ULLONG_MAX (~0ULL) ^ drivers/firmware/efi/arm-init.c:152:21: note: in expansion of macro 'ULLONG_MAX' memblock_remove(0, ULLONG_MAX); This adds an explicit typecast to avoid the warning Fixes: 500899c2cc3e ("efi: ARM/arm64: ignore DT memory nodes instead of removing them") Acked-by Ard Biesheuvel Reviewed-by: Matt Fleming Signed-off-by: Arnd Bergmann Signed-off-by: Will Deacon --- drivers/firmware/efi/arm-init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/firmware/efi/arm-init.c') diff --git a/drivers/firmware/efi/arm-init.c b/drivers/firmware/efi/arm-init.c index 5d6945b761dc..ca708fb18c1d 100644 --- a/drivers/firmware/efi/arm-init.c +++ b/drivers/firmware/efi/arm-init.c @@ -149,7 +149,7 @@ static __init void reserve_regions(void) * uses its own memory map instead. */ memblock_dump_all(); - memblock_remove(0, ULLONG_MAX); + memblock_remove(0, (phys_addr_t)ULLONG_MAX); for_each_efi_memory_desc(&memmap, md) { paddr = md->phys_addr; -- cgit v1.2.3