UPSTREAM: arm64/efi: mark UEFI reserved regions as MEMBLOCK_NOMAP
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Mon, 30 Nov 2015 12:28:17 +0000 (13:28 +0100)
committerSami Tolvanen <samitolvanen@google.com>
Thu, 29 Sep 2016 17:52:56 +0000 (10:52 -0700)
Change the EFI memory reservation logic to use memblock_mark_nomap()
rather than memblock_reserve() to mark UEFI reserved regions as
occupied. In addition to reserving them against allocations done by
memblock, this will also prevent them from being covered by the linear
mapping.

Reviewed-by: Matt Fleming <matt@codeblueprint.co.uk>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Change-Id: Ia3ce78f40f8d41a9afdd42238fe9cbfd81bbff08
(cherry picked from commit 4dffbfc48d65e5d8157a634fd670065d237a9377)
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
arch/arm64/kernel/efi.c

index 4eeb17198cfaf598fd403b1e4040c77f5ee3068a..04531d35f1df11366c70b32294e6bf7e20096bcc 100644 (file)
@@ -187,7 +187,7 @@ static __init void reserve_regions(void)
                        early_init_dt_add_memory_arch(paddr, size);
 
                if (is_reserve_region(md)) {
-                       memblock_reserve(paddr, size);
+                       memblock_mark_nomap(paddr, size);
                        if (efi_enabled(EFI_DBG))
                                pr_cont("*");
                }
@@ -209,8 +209,6 @@ void __init efi_init(void)
 
        efi_system_table = params.system_table;
 
-       memblock_reserve(params.mmap & PAGE_MASK,
-                        PAGE_ALIGN(params.mmap_size + (params.mmap & ~PAGE_MASK)));
        memmap.phys_map = params.mmap;
        memmap.map = early_memremap(params.mmap, params.mmap_size);
        if (memmap.map == NULL) {
@@ -230,6 +228,9 @@ void __init efi_init(void)
 
        reserve_regions();
        early_memunmap(memmap.map, params.mmap_size);
+       memblock_mark_nomap(params.mmap & PAGE_MASK,
+                           PAGE_ALIGN(params.mmap_size +
+                                      (params.mmap & ~PAGE_MASK)));
 }
 
 static bool __init efi_virtmap_init(void)