diff --git a/hypervisor/arch/x86/guest/vm.c b/hypervisor/arch/x86/guest/vm.c index c4125b9be..b3156ad47 100644 --- a/hypervisor/arch/x86/guest/vm.c +++ b/hypervisor/arch/x86/guest/vm.c @@ -42,6 +42,7 @@ #ifdef CONFIG_SECURITY_VM_FIXUP #include #endif +#include /* Local variables */ @@ -409,6 +410,7 @@ static void prepare_service_vm_memmap(struct acrn_vm *vm) uint32_t entries_count = vm->e820_entry_num; const struct e820_entry *p_e820 = vm->e820_entries; struct pci_mmcfg_region *pci_mmcfg; + uint64_t trampoline_memory_size = round_page_up((uint64_t)(&ld_trampoline_end - &ld_trampoline_start)); pr_dbg("Service VM e820 layout:\n"); for (i = 0U; i < entries_count; i++) { @@ -462,7 +464,7 @@ static void prepare_service_vm_memmap(struct acrn_vm *vm) /* unmap AP trampoline code for security * This buffer is guaranteed to be page aligned. */ - ept_del_mr(vm, pml4_page, get_trampoline_start16_paddr(), CONFIG_LOW_RAM_SIZE); + ept_del_mr(vm, pml4_page, get_trampoline_start16_paddr(), trampoline_memory_size); /* unmap PCIe MMCONFIG region since it's owned by hypervisor */ pci_mmcfg = get_mmcfg_region(); diff --git a/hypervisor/arch/x86/trampoline.c b/hypervisor/arch/x86/trampoline.c index 9729b2307..fc2e1382b 100644 --- a/hypervisor/arch/x86/trampoline.c +++ b/hypervisor/arch/x86/trampoline.c @@ -107,22 +107,22 @@ static void update_trampoline_code_refs(uint64_t dest_pa) uint64_t prepare_trampoline(void) { - uint64_t size, dest_pa; + uint64_t trampline_size, trampoline_pa; - size = (uint64_t)(&ld_trampoline_end - &ld_trampoline_start); - dest_pa = e820_alloc_memory(CONFIG_LOW_RAM_SIZE, MEM_1M); + trampline_size = (uint64_t)(&ld_trampoline_end - &ld_trampoline_start); + trampoline_pa = e820_alloc_memory(trampline_size, MEM_1M); - pr_dbg("trampoline code: %lx size %x", dest_pa, size); + pr_dbg("trampoline code: %lx trampline_size %x", trampoline_pa, trampline_size); /* Copy segment for AP initialization code below 1MB */ - (void)memcpy_s(hpa2hva(dest_pa), (size_t)size, &ld_trampoline_load, - (size_t)size); - update_trampoline_code_refs(dest_pa); + (void)memcpy_s(hpa2hva(trampoline_pa), (size_t)trampline_size, &ld_trampoline_load, + (size_t)trampline_size); + update_trampoline_code_refs(trampoline_pa); cpu_memory_barrier(); - flush_cache_range(hpa2hva(dest_pa), size); + flush_cache_range(hpa2hva(trampoline_pa), trampline_size); - trampoline_start16_paddr = dest_pa; + trampoline_start16_paddr = trampoline_pa; - return dest_pa; + return trampoline_pa; } diff --git a/hypervisor/bsp/ld/link_ram.ld.in b/hypervisor/bsp/ld/link_ram.ld.in index a1bb65c56..55f8f82a9 100644 --- a/hypervisor/bsp/ld/link_ram.ld.in +++ b/hypervisor/bsp/ld/link_ram.ld.in @@ -3,7 +3,7 @@ ENTRY(cpu_primary_start_32) MEMORY { /* Low 1MB of memory for secondary processor start-up */ - lowram : ORIGIN = 0, LENGTH = CONFIG_LOW_RAM_SIZE + lowram : ORIGIN = 0, LENGTH = 0x100000 /* 32 MBytes of RAM for HV */ ram : ORIGIN = CONFIG_HV_RAM_START, LENGTH = 0x80000000 - CONFIG_HV_RAM_START