arm64: ignore DT memreserve entries when booting in UEFI mode
PATCH 1/1 arm64: ignore DT memreserve entries when booting in UEFI mode
UEFI provides its own method for marking regions to reserve, via the memory map which is also used to initialise memblock. So when using the UEFI memory map, ignore any memreserve entries present in the DT.
--- arch/arm64/kernel/efi.c | 2 ++ arch/arm64/mm/init.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-)
arch/arm64/kernel/efi.c +2 -0
@@ -188,6 +188,8 @@ static __init void reserve_regions(void)if (uefi_debug)pr_cont ("\n" ); } + +set_bit (EFI_MEMMAP , &efi.flags); }
arch/arm64/mm/init.c +3 -1
@@ -32,6 +32,7 @@#include <linux/of_fdt.h> #include <linux/dma-mapping.h> #include <linux/dma-contiguous.h> +#include <linux/efi.h> #include <asm/sections.h> #include <asm/setup.h>
@@ -151,7 +152,8 @@ void __init arm64_memblock_init(void)memblock_reserve (__pa (swapper_pg_dir),SWAPPER_DIR_SIZE );memblock_reserve (__pa (idmap_pg_dir),IDMAP_DIR_SIZE ); -early_init_fdt_scan_reserved_mem (); +if (!efi_enabled (EFI_MEMMAP )) +early_init_fdt_scan_reserved_mem ();/* 4GB maximum for 32-bit only capable devices */ if (IS_ENABLED (CONFIG_ZONE_DMA ))
Signature · 1 line
1.7.10.4
Mark Rutland
reviewerPATCH 1/1 arm64: ignore DT memreserve entries when booting in UEFI mode
Quoted 3 lines · Leif Lindholm
UEFI provides its own method for marking regions to reserve, via the memory map which is also used to initialise memblock. So when using the UEFI memory map, ignore any memreserve entries present in the DT.
It's worth noting that no-one is relying on this at present, and were they it would imply that their UEFI implementation is broken (providing a dodgy memory map).
So before people start doing dodgy things, let's, close that hole. If we need a way of modifying the memory map we should come up with a more general plan.
Quoted 12 lines
Reported-by Mark Rutland <[email protected]>Signed-off-by Leif Lindholm <[email protected]>--- arch/arm64/kernel/efi.c | 2 ++ arch/arm64/mm/init.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-)arch/arm64/kernel/efi.c +0
-0
arch/arm64/kernel/efi.c static __init void reserve_regions(void) · line 192
Quoted 5 lines
arch/arm64/kernel/efi.c +2
-0@@ -188,6 +188,8 @@ static __init void reserve_regions(void)if (uefi_debug)pr_cont ("\n" ); } + +set_bit (EFI_MEMMAP , &efi.flags);
Nothing outside of arch/x86 seems to hang off this, so using it here looks fine.
Quoted 16 lines
arch/arm64/kernel/efi.c +0
-0}arch/arm64/mm/init.c +1
-0@@ -32,6 +32,7 @@#include <linux/of_fdt.h> #include <linux/dma-mapping.h> #include <linux/dma-contiguous.h> +#include <linux/efi.h> #include <asm/sections.h> #include <asm/setup.h>
arch/arm64/mm/init.c void __init arm64_memblock_init(void) · line 156
Quoted 6 lines
arch/arm64/mm/init.c +2
-1@@ -151,7 +152,8 @@ void __init arm64_memblock_init(void)memblock_reserve (__pa (swapper_pg_dir),SWAPPER_DIR_SIZE );memblock_reserve (__pa (idmap_pg_dir),IDMAP_DIR_SIZE ); -early_init_fdt_scan_reserved_mem (); +if (!efi_enabled (EFI_MEMMAP )) +early_init_fdt_scan_reserved_mem ();
And this is a false stub for !EFI, so that looks fine.
FWIW:
I wonder if we have any other flat tree uses we need to be careful of when booting via EFI.
Thanks
Mark.
Quoted 7 lines
arch/arm64/mm/init.c +0
-0/* 4GB maximum for 32-bit only capable devices */ if (IS_ENABLED (CONFIG_ZONE_DMA ))Signature · 1 line
1.7.10.4
PATCH 1/1 arm64: ignore DT memreserve entries when booting in UEFI mode
Quoted 5 lines · Mark Rutland
Quoted 3 lines · Leif Lindholm
UEFI provides its own method for marking regions to reserve, via the memory map which is also used to initialise memblock. So when using the UEFI memory map, ignore any memreserve entries present in the DT.
Quoted 7 lines
It's worth noting that no-one is relying on this at present, and were they it would imply that their UEFI implementation is broken (providing a dodgy memory map).
So before people start doing dodgy things, let's, close that hole. If we need a way of modifying the memory map we should come up with a more general plan.
Catalin - any comments?
As it is a bugfix, can it go into 3.17?
/
Leif
Quoted 52 lines
Quoted 12 lines
Reported-by Mark Rutland <[email protected]>Signed-off-by Leif Lindholm <[email protected]>--- arch/arm64/kernel/efi.c | 2 ++ arch/arm64/mm/init.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-)arch/arm64/kernel/efi.c +0
-0arch/arm64/kernel/efi.c static __init void reserve_regions(void) · line 192
Quoted 5 lines
arch/arm64/kernel/efi.c +2
-0@@ -188,6 +188,8 @@ static __init void reserve_regions(void)if (uefi_debug)pr_cont ("\n" ); } + +set_bit (EFI_MEMMAP , &efi.flags);Nothing outside of
arch/x86seems to hang off this, so using it here looks fine.Quoted 16 lines
arch/arm64/kernel/efi.c +0
-0}arch/arm64/mm/init.c +1
-0@@ -32,6 +32,7 @@#include <linux/of_fdt.h> #include <linux/dma-mapping.h> #include <linux/dma-contiguous.h> +#include <linux/efi.h> #include <asm/sections.h> #include <asm/setup.h> arch/arm64/mm/init.c void __init arm64_memblock_init(void) · line 156
Quoted 6 lines
arch/arm64/mm/init.c +2
-1@@ -151,7 +152,8 @@ void __init arm64_memblock_init(void)memblock_reserve (__pa (swapper_pg_dir),SWAPPER_DIR_SIZE );memblock_reserve (__pa (idmap_pg_dir),IDMAP_DIR_SIZE ); -early_init_fdt_scan_reserved_mem (); +if (!efi_enabled (EFI_MEMMAP )) +early_init_fdt_scan_reserved_mem ();And this is a false stub for !EFI, so that looks fine.
FWIW:
Reviewed-by Mark Rutland <[email protected]>I wonder if we have any other flat tree uses we need to be careful of when booting via EFI.
Catalin Marinas
maintainerPATCH 1/1 arm64: ignore DT memreserve entries when booting in UEFI mode
Quoted 10 lines · Leif Lindholm
Quoted 9 lines · Mark Rutland
Quoted 3 lines · Leif Lindholm
UEFI provides its own method for marking regions to reserve, via the memory map which is also used to initialise memblock. So when using the UEFI memory map, ignore any memreserve entries present in the DT.
It's worth noting that no-one is relying on this at present, and were they it would imply that their UEFI implementation is broken (providing a dodgy memory map).
Quoted 6 lines
Quoted 3 lines
So before people start doing dodgy things, let's, close that hole. If we need a way of modifying the memory map we should come up with a more general plan.
Catalin - any comments?
As it is a bugfix, can it go into 3.17?
It looks fine to me:
(cc'ing Will who handles the 3.17 merging)
Quoted 39 lines
Quoted 39 lines
Quoted 39 lines
Reported-by Mark Rutland <[email protected]>Signed-off-by Leif Lindholm <[email protected]>--- arch/arm64/kernel/efi.c | 2 ++ arch/arm64/mm/init.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-)arch/arm64/kernel/efi.c +2
-0@@ -188,6 +188,8 @@ static __init void reserve_regions(void)if (uefi_debug)pr_cont ("\n" ); } + +set_bit (EFI_MEMMAP , &efi.flags); }arch/arm64/mm/init.c +3
-1@@ -32,6 +32,7 @@#include <linux/of_fdt.h> #include <linux/dma-mapping.h> #include <linux/dma-contiguous.h> +#include <linux/efi.h> #include <asm/sections.h> #include <asm/setup.h> @@ -151,7 +152,8 @@ void __init arm64_memblock_init(void)memblock_reserve (__pa (swapper_pg_dir),SWAPPER_DIR_SIZE );memblock_reserve (__pa (idmap_pg_dir),IDMAP_DIR_SIZE ); -early_init_fdt_scan_reserved_mem (); +if (!efi_enabled (EFI_MEMMAP )) +early_init_fdt_scan_reserved_mem ();