mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-05-08 00:17:01 +00:00
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>
76 lines
1.4 KiB
C
76 lines
1.4 KiB
C
/*
|
|
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#include <hypervisor.h>
|
|
#include <multiboot.h>
|
|
#include <boot_context.h>
|
|
#include <vm0_boot.h>
|
|
|
|
#ifdef CONFIG_EFI_STUB
|
|
|
|
static struct efi_context efi_ctx;
|
|
static struct lapic_regs uefi_lapic_regs;
|
|
static int32_t efi_initialized;
|
|
|
|
static void efi_init(void)
|
|
{
|
|
struct multiboot_info *mbi = NULL;
|
|
|
|
if (boot_regs[0] != MULTIBOOT_INFO_MAGIC) {
|
|
pr_err("no multiboot info found");
|
|
} else {
|
|
|
|
mbi = (struct multiboot_info *) hpa2hva(((uint64_t)(uint32_t)boot_regs[1]));
|
|
if ((mbi->mi_flags & MULTIBOOT_INFO_HAS_DRIVES) == 0U) {
|
|
pr_err("no multiboot drivers for uefi found");
|
|
} else {
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
|
|
void *get_rsdp_from_uefi(void)
|
|
{
|
|
if (!efi_initialized) {
|
|
efi_init();
|
|
}
|
|
|
|
return hpa2hva((uint64_t)efi_ctx.rsdp);
|
|
}
|
|
|
|
void *get_ap_trampoline_buf(void)
|
|
{
|
|
return efi_ctx.ap_trampoline_buf;
|
|
}
|
|
|
|
const struct efi_context *get_efi_ctx(void)
|
|
{
|
|
return (const struct efi_context *)&efi_ctx;
|
|
}
|
|
|
|
const struct lapic_regs *get_efi_lapic_regs(void)
|
|
{
|
|
return &uefi_lapic_regs;
|
|
}
|
|
|
|
#endif
|
|
|
|
void init_bsp(void)
|
|
{
|
|
#ifndef CONFIG_CONSTANT_ACPI
|
|
acpi_fixup();
|
|
#endif
|
|
parse_hv_cmdline();
|
|
|
|
#ifdef CONFIG_EFI_STUB
|
|
if (!efi_initialized)
|
|
efi_init();
|
|
#endif
|
|
}
|