From b3b34fe2ade95f82ccef1fe2c0177cdc977709c2 Mon Sep 17 00:00:00 2001 From: Chaohong guo Date: Tue, 22 Jan 2019 11:00:19 +0800 Subject: [PATCH] HV: save efi_ctx into HV to use after init_paging() efi_ctx is passed by EFI stub to hypervisor. The memory was allocated right after HV binary and marked as Efireserved. But HV is doing a 2MB alignment in init_paging() and might overwrite the efi_ctx struct or change the page table attribute. Now, EFI STUB uses Efiloaderdata type memory and the memory can be re-use by hypervisor/sos after boot time done. HV should save itself a copy if the content is still needed after init_paging(). Tracked-On: #2035 Signed-off-by: Chaohong guo --- hypervisor/bsp/uefi/uefi.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/hypervisor/bsp/uefi/uefi.c b/hypervisor/bsp/uefi/uefi.c index 2c3217e83..7d945cdbf 100644 --- a/hypervisor/bsp/uefi/uefi.c +++ b/hypervisor/bsp/uefi/uefi.c @@ -12,7 +12,7 @@ #ifdef CONFIG_EFI_STUB static void efi_init(void); -struct efi_context* efi_ctx = NULL; +struct efi_context efi_ctx; struct lapic_regs uefi_lapic_regs; static int32_t efi_initialized; @@ -52,9 +52,9 @@ int32_t uefi_sw_loader(struct acrn_vm *vm) * init bsp with boot_context. */ memcpy_s(&(vcpu_regs->gprs), sizeof(struct acrn_gp_regs), - &(efi_ctx->vcpu_regs.gprs), sizeof(struct acrn_gp_regs)); + &(efi_ctx.vcpu_regs.gprs), sizeof(struct acrn_gp_regs)); - vcpu_regs->rip = efi_ctx->vcpu_regs.rip; + vcpu_regs->rip = efi_ctx.vcpu_regs.rip; set_vcpu_regs(vcpu, vcpu_regs); /* defer irq enabling till vlapic is ready */ @@ -68,12 +68,12 @@ void *get_rsdp_from_uefi(void) if (!efi_initialized) efi_init(); - return hpa2hva((uint64_t)efi_ctx->rsdp); + return hpa2hva((uint64_t)efi_ctx.rsdp); } void *get_ap_trampoline_buf(void) { - return efi_ctx->ap_trampoline_buf; + return efi_ctx.ap_trampoline_buf; } static void efi_init(void) @@ -89,8 +89,7 @@ static void efi_init(void) if (!(mbi->mi_flags & MULTIBOOT_INFO_HAS_DRIVES)) ASSERT(0, "no multiboot drivers for uefi found"); - efi_ctx = (struct efi_context *)hpa2hva((uint64_t)mbi->mi_drives_addr); - ASSERT(efi_ctx != NULL, "no uefi context found"); + memcpy_s(&efi_ctx, sizeof(struct efi_context), hpa2hva((uint64_t)mbi->mi_drives_addr), sizeof(struct efi_context)); vm_sw_loader = uefi_sw_loader;