hv: mmu: fliter e820 which is over top address space

Now the default board memory size is 16 GB. However, ACRN support more and more boards
which may have memory size large than 16 GB. This patch try to filter e820 table which
is over top address space.

Tracked-On: #4007
Signed-off-by: Li Fei1 <fei1.li@intel.com>
This commit is contained in:
Li Fei1 2019-11-06 18:13:02 +08:00 committed by wenlingz
parent 620a1c5215
commit 8189d1f01c
1 changed files with 9 additions and 0 deletions

View File

@ -112,6 +112,7 @@ uint64_t e820_alloc_low_memory(uint32_t size_arg)
void init_e820(void)
{
uint32_t i;
uint64_t top_addr_space = CONFIG_PLATFORM_RAM_SIZE + PLATFORM_LO_MMIO_SIZE;
if (boot_regs[0] == MULTIBOOT_INFO_MAGIC) {
/*
@ -137,6 +138,14 @@ void init_e820(void)
mbi->mi_mmap_length, mbi->mi_mmap_addr, hv_e820_entries_nr);
for (i = 0U; i < hv_e820_entries_nr; i++) {
if (mmap[i].baseaddr >= top_addr_space) {
mmap[i].length = 0UL;
} else {
if ((mmap[i].baseaddr + mmap[i].length) > top_addr_space) {
mmap[i].length = top_addr_space - mmap[i].baseaddr;
}
}
hv_e820[i].baseaddr = mmap[i].baseaddr;
hv_e820[i].length = mmap[i].length;
hv_e820[i].type = mmap[i].type;