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 <chaohong.guo@intel.com>
Reviewed-by: Zheng, Gen <gen.zheng@intel.com>
This commit is contained in:
Chaohong guo 2019-01-16 14:18:25 +08:00 committed by Eddie Dong
parent a445a4eae0
commit 07f14401ec

View File

@ -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)