From 07f14401ecfabfe5c8b624a07302963a37bc3776 Mon Sep 17 00:00:00 2001 From: Chaohong guo Date: Wed, 16 Jan 2019 14:18:25 +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: #2349 Signed-off-by: Chaohong guo Reviewed-by: Zheng, Gen --- hypervisor/bsp/uefi/uefi.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/hypervisor/bsp/uefi/uefi.c b/hypervisor/bsp/uefi/uefi.c index e69843243..5096cbc9f 100644 --- a/hypervisor/bsp/uefi/uefi.c +++ b/hypervisor/bsp/uefi/uefi.c @@ -11,7 +11,7 @@ #ifdef CONFIG_EFI_STUB -static struct efi_context *efi_ctx = NULL; +static struct efi_context efi_ctx; static struct lapic_regs uefi_lapic_regs; static int32_t efi_initialized; @@ -28,14 +28,9 @@ static void efi_init(void) pr_err("no multiboot drivers for uefi found"); } else { - efi_ctx = (struct efi_context *)hpa2hva((uint64_t)mbi->mi_drives_addr); - if (efi_ctx == NULL) { - pr_err("no uefi context found"); - } else { - - save_lapic(&uefi_lapic_regs); - efi_initialized = 1; - } + memcpy_s(&efi_ctx, sizeof(struct efi_context), hpa2hva((uint64_t)mbi->mi_drives_addr), sizeof(struct efi_context)); + save_lapic(&uefi_lapic_regs); + efi_initialized = 1; } } } @@ -46,17 +41,17 @@ void *get_rsdp_from_uefi(void) 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; } const struct efi_context *get_efi_ctx(void) { - return efi_ctx; + return (const struct efi_context *)&efi_ctx; } const struct lapic_regs *get_efi_lapic_regs(void)