Files
acrn-hypervisor/hypervisor/boot/boot.c
Victor Sun 9dfac7a7a3 HV: init hv_e820 from efi mmap if boot from uefi
Hypervisor use e820_alloc_memory() api to allocate memory for trampoline code
and ept pages, whereas the usable ram in hv_e820 might include efi boot service
region if system boot from uefi environment, this would result in some uefi
service broken in SOS. These boot service region should be filtered from
hv_e820.
This patch will parse the efi memory descriptor entries info from efi memory
map pointer when system boot from uefi environment, and then initialize hv_e820
accordingly, that all efi boot service region would be kept as reserved in
hv_e820.

Please note the original efi memory map could be above 4GB address space,
so the efi memory parsing process must be done after enable_paging().

Tracked-On: #5626

Signed-off-by: Victor Sun <victor.sun@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
2021-06-11 10:06:02 +08:00

59 lines
1.2 KiB
C

/*
* Copyright (C) 2021 Intel Corporation.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <types.h>
#include <errno.h>
#include <asm/pgtable.h>
#include <boot.h>
#include <rtl.h>
#include <logmsg.h>
static struct acrn_boot_info acrn_bi = { 0U };
void init_acrn_boot_info(uint32_t *registers)
{
(void)init_multiboot_info(registers);
/* TODO: add more boot protocol support here */
}
int32_t sanitize_acrn_boot_info(struct acrn_boot_info *abi)
{
int32_t abi_status = 0;
if (abi->mods_count == 0U) {
pr_err("no boot module info found");
abi_status = -EINVAL;
}
if (abi->mmap_entries == 0U) {
pr_err("no boot mmap info found");
abi_status = -EINVAL;
}
printf("%s environment detected.\n", boot_from_uefi(abi) ? "UEFI" : "Non-UEFI");
if (boot_from_uefi(abi) && (abi->uefi_info.memmap == 0U) && (abi->uefi_info.memmap_hi == 0U)) {
pr_err("no efi memmap found!");
abi_status = -EINVAL;
}
if (abi->loader_name[0] == '\0') {
pr_err("no bootloader name found!");
abi_status = -EINVAL;
} else {
printf("%s Bootloader: %s\n", abi->protocol_name, abi->loader_name);
}
return abi_status;
}
/*
* @post retval != NULL
*/
struct acrn_boot_info *get_acrn_boot_info(void)
{
return &acrn_bi;
}