From 8189d1f01ca67a329f11c6df414d41f3e29765ff Mon Sep 17 00:00:00 2001 From: Li Fei1 Date: Wed, 6 Nov 2019 18:13:02 +0800 Subject: [PATCH] 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 --- hypervisor/arch/x86/e820.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hypervisor/arch/x86/e820.c b/hypervisor/arch/x86/e820.c index 2dc287b5a..c4dc78793 100644 --- a/hypervisor/arch/x86/e820.c +++ b/hypervisor/arch/x86/e820.c @@ -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;