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;