Registering Regions on AMD64

Registering the available memory is split between two functions on AMD64. The active memory regions are registered as follows:

arch/x86/kernel/e820_64.c e820_register_active_regions(int nid, unsigned long start_pfn, unsigned long end_pfn)

unsigned long ei_startpfn; unsigned long ei_endpfn; int i;

for (i =0; i < e820.nr_map; i++) if (e820_find_active_region(&[i], start_pfn, end_pfn, &ei_startpfn, &ei_endpfn)) add_active_range(nid, ei_startpfn, ei_endpfn);

Essentially the code iterates over all regions provided by the BIOS and finds the active region for each entry. This is interesting because add_active_range is potentially called multiple times in contrast to the IA-32 variant.

Filling in max_zone_pfns is handled by paging_init:

arch/x86/mm/init_64.c void _init paging_init(void)

unsigned long max_zone_pfns[MAX_NR_ZONES]; memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); max_zone_pfns[ZONE_DMA] = MAX_DMA_PFN; max_zone_pfns[ZONE_DMA32] = MAX_DMA32_PFN; max_zone_pfns[ZONE_NORMAL] = end_pfn;


The page frame boundaries for the 16- and 32-bit DMA regions are stored in pre-processor symbols that translate the 16 MiB and 4 GiB ranges into page frames:


#define MAX_DMA_PFN ((16*1024*1024) >> PAGE_SHIFT)

/* 4GB broken PCI/AGP hardware bus master zone */ #define MAX_DMA32_PFN ((4UL*1024*1024*1024) >> PAGE_SHIFT)

end_pfn is the largest page frame number detected. Since AMD64 does not require high memory, the corresponding entry in max_zone_pfns remains NULL.

Continue reading here: Address Space Setup on AMD64

Was this article helpful?

0 0