Skip to content

Commit 6083fe7

Browse files
mrutland-armctmarinas
authored andcommitted
arm64: respect mem= for EFI
When booting with EFI, we acquire the EFI memory map after parsing the early params. This unfortuantely renders the option useless as we call memblock_enforce_memory_limit (which uses memblock_remove_range behind the scenes) before we've added any memblocks. We end up removing nothing, then adding all of memory later when efi_init calls reserve_regions. Instead, we can log the limit and apply this later when we do the rest of the memblock work in memblock_init, which should work regardless of the presence of EFI. At the same time we may as well move the early parameter into arm64's mm/init.c, close to arm64_memblock_init. Any memory which must be mapped (e.g. for use by EFI runtime services) must be mapped explicitly reather than relying on the linear mapping, which may be truncated as a result of a mem= option passed on the kernel command line. Signed-off-by: Mark Rutland <[email protected]> Acked-by: Catalin Marinas <[email protected]> Acked-by: Ard Biesheuvel <[email protected]> Tested-by: Ard Biesheuvel <[email protected]> Cc: Leif Lindholm <[email protected]> Cc: Will Deacon <[email protected]> Signed-off-by: Catalin Marinas <[email protected]>
1 parent 7fe5d2b commit 6083fe7

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

arch/arm64/kernel/setup.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -322,25 +322,6 @@ static void __init setup_machine_fdt(phys_addr_t dt_phys)
322322
dump_stack_set_arch_desc("%s (DT)", of_flat_dt_get_machine_name());
323323
}
324324

325-
/*
326-
* Limit the memory size that was specified via FDT.
327-
*/
328-
static int __init early_mem(char *p)
329-
{
330-
phys_addr_t limit;
331-
332-
if (!p)
333-
return 1;
334-
335-
limit = memparse(p, &p) & PAGE_MASK;
336-
pr_notice("Memory limited to %lldMB\n", limit >> 20);
337-
338-
memblock_enforce_memory_limit(limit);
339-
340-
return 0;
341-
}
342-
early_param("mem", early_mem);
343-
344325
static void __init request_standard_resources(void)
345326
{
346327
struct memblock_region *region;

arch/arm64/mm/init.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,29 @@ static void arm64_memory_present(void)
136136
}
137137
#endif
138138

139+
static phys_addr_t memory_limit = (phys_addr_t)ULLONG_MAX;
140+
141+
/*
142+
* Limit the memory size that was specified via FDT.
143+
*/
144+
static int __init early_mem(char *p)
145+
{
146+
if (!p)
147+
return 1;
148+
149+
memory_limit = memparse(p, &p) & PAGE_MASK;
150+
pr_notice("Memory limited to %lldMB\n", memory_limit >> 20);
151+
152+
return 0;
153+
}
154+
early_param("mem", early_mem);
155+
139156
void __init arm64_memblock_init(void)
140157
{
141158
phys_addr_t dma_phys_limit = 0;
142159

160+
memblock_enforce_memory_limit(memory_limit);
161+
143162
/*
144163
* Register the kernel text, kernel data, initrd, and initial
145164
* pagetables with memblock.

0 commit comments

Comments
 (0)