HV:EFI-STUB:UEFI loader name supporting

In the current design, UEFI loader name is not supported,
it is hard to ditinguish UEFI boot loader (efi stub in
the code) from other multiboot compiliant boot loader (such
as SBL, ABL, GRUB etc) explicitly. From long term, it is
better that detect boot loader according to loader name and
use different boot method according to different boot loader
and VM configuration flag.

Allocate memory to store UEFI loader name statically, set
MULTIBOOT_INFO_BOOT_LOADER_NAME in flag of the multiboot header,
store host physical start address of loader name in the multiboot
header according to multiboot protocol.

V5-->V6:
	Update "Tracked-On"

Tracked-On: #2944

Signed-off-by: Xiangyang Wu <xiangyang.wu@linux.intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Xiangyang Wu 2019-04-15 22:42:56 +08:00 committed by ACRN System Integration
parent 048d72fd94
commit a13c19b450
2 changed files with 17 additions and 2 deletions

View File

@ -247,6 +247,8 @@ switch_to_guest_mode(EFI_HANDLE image, EFI_PHYSICAL_ADDRESS hv_hpa)
struct acpi_table_rsdp *rsdp = NULL;
int32_t i;
EFI_CONFIGURATION_TABLE *config_table;
char *uefi_boot_loader_name;
const char loader_name[BOOT_LOADER_NAME_SIZE] = UEFI_BOOT_LOADER_NAME;
err = allocate_pool(EfiLoaderData, EFI_BOOT_MEM_SIZE, (VOID *)&addr);
if (err != EFI_SUCCESS) {
@ -259,6 +261,9 @@ switch_to_guest_mode(EFI_HANDLE image, EFI_PHYSICAL_ADDRESS hv_hpa)
mbi = MBOOT_INFO_PTR(addr);
efi_ctx = BOOT_CTX_PTR(addr);
uefi_boot_loader_name = BOOT_LOADER_NAME_PTR(addr);
memcpy(uefi_boot_loader_name, loader_name, BOOT_LOADER_NAME_SIZE);
/* reserve secondary memory region for CPU trampoline code */
err = emalloc_reserved_mem(&addr, CONFIG_LOW_RAM_SIZE, MEM_ADDR_1MB);
if (err != EFI_SUCCESS)
@ -302,6 +307,12 @@ switch_to_guest_mode(EFI_HANDLE image, EFI_PHYSICAL_ADDRESS hv_hpa)
mbi->mi_flags |= MULTIBOOT_INFO_HAS_DRIVES;
mbi->mi_drives_addr = (UINT32)(UINTN)efi_ctx;
/* Set boot loader name in the multiboot header of UEFI, this name is used by hypervisor;
* The host physical start address of boot loader name is stored in multiboot header.
*/
mbi->mi_flags |= MULTIBOOT_INFO_HAS_LOADER_NAME;
mbi->mi_loader_name = (UINT32)uefi_boot_loader_name;
asm volatile ("pushf\n\t"
"pop %0\n\t"
: "=r"(efi_ctx->vcpu_regs.rflags)

View File

@ -57,6 +57,8 @@
#define MSR_IA32_SYSENTER_ESP 0x00000175 /* ESP for sysenter */
#define MSR_IA32_SYSENTER_EIP 0x00000176 /* EIP for sysenter */
#define UEFI_BOOT_LOADER_NAME "ACRN UEFI loader"
/* Read MSR */
#define CPU_MSR_READ(reg, msr_val_ptr) \
{ \
@ -77,15 +79,17 @@ typedef void(*hv_func)(int32_t, struct multiboot_info*);
#define MBOOT_MMAP_SIZE (sizeof(struct multiboot_mmap) * MBOOT_MMAP_NUMS)
#define MBOOT_INFO_SIZE (sizeof(struct multiboot_info))
#define BOOT_CTX_SIZE (sizeof(struct uefi_context))
#define BOOT_LOADER_NAME_SIZE 17U
#define EFI_BOOT_MEM_SIZE \
(MBOOT_MMAP_SIZE + MBOOT_INFO_SIZE + BOOT_CTX_SIZE)
(MBOOT_MMAP_SIZE + MBOOT_INFO_SIZE + BOOT_CTX_SIZE + BOOT_LOADER_NAME_SIZE)
#define MBOOT_MMAP_PTR(addr) \
((struct multiboot_mmap *)((VOID *)(addr)))
#define MBOOT_INFO_PTR(addr) \
((struct multiboot_info *)((VOID *)(addr) + MBOOT_MMAP_SIZE))
#define BOOT_CTX_PTR(addr) \
((struct uefi_context *)((VOID *)(addr) + MBOOT_MMAP_SIZE + MBOOT_INFO_SIZE))
#define BOOT_LOADER_NAME_PTR(addr) \
((char *)((VOID *)(addr) + MBOOT_MMAP_SIZE + MBOOT_INFO_SIZE + BOOT_CTX_SIZE))
struct efi_info {
UINT32 efi_loader_signature;