HV: init paging before init e820

With this patch, the hv_e820 will be initialized after enable paging. This
is because the hv_e820 will be initialized from efi mmap when system boot
from uefi, which the efi mmap could be above 4G space.

Tracked-On: #5626

Signed-off-by: Victor Sun <victor.sun@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
This commit is contained in:
Victor Sun 2021-06-03 20:41:42 +08:00 committed by wenlingz
parent 82c28af404
commit 4e1deab3d9
2 changed files with 9 additions and 6 deletions

View File

@ -144,8 +144,8 @@ void init_pcpu_pre(bool is_bsp)
load_pcpu_state_data();
/* Initialize the hypervisor paging */
init_e820();
init_paging();
init_e820();
/*
* Need update uart_base_address here for vaddr2paddr mapping may changed

View File

@ -231,10 +231,12 @@ void init_paging(void)
uint32_t i;
uint64_t low32_max_ram = 0UL;
uint64_t high64_max_ram = MEM_4G;
uint64_t top_addr_space = CONFIG_PLATFORM_RAM_SIZE + PLATFORM_LO_MMIO_SIZE;
const struct e820_entry *entry;
uint32_t entries_count = get_e820_entries_count();
const struct e820_entry *p_e820 = get_e820_entry();
struct acrn_boot_info *abi = get_acrn_boot_info();
const struct abi_mmap *entry;
uint32_t entries_count = abi->mmap_entries;
const struct abi_mmap *p_mmap = abi->mmap_entry;
pr_dbg("HV MMU Initialization");
@ -245,8 +247,8 @@ void init_paging(void)
/* Modify WB attribute for E820_TYPE_RAM */
for (i = 0U; i < entries_count; i++) {
entry = p_e820 + i;
if (entry->type == E820_TYPE_RAM) {
entry = p_mmap + i;
if (entry->type == MMAP_TYPE_RAM) {
uint64_t end = entry->baseaddr + entry->length;
if (end < MEM_4G) {
low32_max_ram = max(end, low32_max_ram);
@ -257,6 +259,7 @@ void init_paging(void)
}
low32_max_ram = round_pde_up(low32_max_ram);
high64_max_ram = min(high64_max_ram, top_addr_space);
high64_max_ram = round_pde_down(high64_max_ram);
/* Map [0, low32_max_ram) and [4G, high64_max_ram) RAM regions as WB attribute */