in kernel/setup.c [242:287]
static void __init setup_memory(void)
{
unsigned long ram_start_pfn;
unsigned long free_ram_start_pfn;
phys_addr_t memory_start, memory_end;
memory_end = memory_start = 0;
/* Find main memory where is the kernel */
memory_start = memblock_start_of_DRAM();
memory_end = memblock_end_of_DRAM();
if (!memory_end) {
panic("No memory!");
}
ram_start_pfn = PFN_UP(memblock_start_of_DRAM());
/* free_ram_start_pfn is first page after kernel */
free_ram_start_pfn = PFN_UP(__pa(&_end));
max_pfn = PFN_DOWN(memblock_end_of_DRAM());
/* it could update max_pfn */
if (max_pfn - ram_start_pfn <= MAXMEM_PFN)
max_low_pfn = max_pfn;
else {
max_low_pfn = MAXMEM_PFN + ram_start_pfn;
if (!IS_ENABLED(CONFIG_HIGHMEM))
max_pfn = MAXMEM_PFN + ram_start_pfn;
}
/* high_memory is related with VMALLOC */
high_memory = (void *)__va(max_low_pfn * PAGE_SIZE);
min_low_pfn = free_ram_start_pfn;
/*
* initialize the boot-time allocator (with low memory only).
*
* This makes the memory from the end of the kernel to the end of
* RAM usable.
*/
memblock_set_bottom_up(true);
memblock_reserve(PFN_PHYS(ram_start_pfn), PFN_PHYS(free_ram_start_pfn - ram_start_pfn));
early_init_fdt_reserve_self();
early_init_fdt_scan_reserved_mem();
memblock_dump_all();
}