Skip to content

Commit a13c19b

Browse files
Xiangyang Wuacrnsi
authored andcommitted
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>
1 parent 048d72f commit a13c19b

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

efi-stub/boot.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ switch_to_guest_mode(EFI_HANDLE image, EFI_PHYSICAL_ADDRESS hv_hpa)
247247
struct acpi_table_rsdp *rsdp = NULL;
248248
int32_t i;
249249
EFI_CONFIGURATION_TABLE *config_table;
250+
char *uefi_boot_loader_name;
251+
const char loader_name[BOOT_LOADER_NAME_SIZE] = UEFI_BOOT_LOADER_NAME;
250252

251253
err = allocate_pool(EfiLoaderData, EFI_BOOT_MEM_SIZE, (VOID *)&addr);
252254
if (err != EFI_SUCCESS) {
@@ -259,6 +261,9 @@ switch_to_guest_mode(EFI_HANDLE image, EFI_PHYSICAL_ADDRESS hv_hpa)
259261
mbi = MBOOT_INFO_PTR(addr);
260262
efi_ctx = BOOT_CTX_PTR(addr);
261263

264+
uefi_boot_loader_name = BOOT_LOADER_NAME_PTR(addr);
265+
memcpy(uefi_boot_loader_name, loader_name, BOOT_LOADER_NAME_SIZE);
266+
262267
/* reserve secondary memory region for CPU trampoline code */
263268
err = emalloc_reserved_mem(&addr, CONFIG_LOW_RAM_SIZE, MEM_ADDR_1MB);
264269
if (err != EFI_SUCCESS)
@@ -302,6 +307,12 @@ switch_to_guest_mode(EFI_HANDLE image, EFI_PHYSICAL_ADDRESS hv_hpa)
302307
mbi->mi_flags |= MULTIBOOT_INFO_HAS_DRIVES;
303308
mbi->mi_drives_addr = (UINT32)(UINTN)efi_ctx;
304309

310+
/* Set boot loader name in the multiboot header of UEFI, this name is used by hypervisor;
311+
* The host physical start address of boot loader name is stored in multiboot header.
312+
*/
313+
mbi->mi_flags |= MULTIBOOT_INFO_HAS_LOADER_NAME;
314+
mbi->mi_loader_name = (UINT32)uefi_boot_loader_name;
315+
305316
asm volatile ("pushf\n\t"
306317
"pop %0\n\t"
307318
: "=r"(efi_ctx->vcpu_regs.rflags)

efi-stub/boot.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
#define MSR_IA32_SYSENTER_ESP 0x00000175 /* ESP for sysenter */
5858
#define MSR_IA32_SYSENTER_EIP 0x00000176 /* EIP for sysenter */
5959

60+
#define UEFI_BOOT_LOADER_NAME "ACRN UEFI loader"
61+
6062
/* Read MSR */
6163
#define CPU_MSR_READ(reg, msr_val_ptr) \
6264
{ \
@@ -77,15 +79,17 @@ typedef void(*hv_func)(int32_t, struct multiboot_info*);
7779
#define MBOOT_MMAP_SIZE (sizeof(struct multiboot_mmap) * MBOOT_MMAP_NUMS)
7880
#define MBOOT_INFO_SIZE (sizeof(struct multiboot_info))
7981
#define BOOT_CTX_SIZE (sizeof(struct uefi_context))
82+
#define BOOT_LOADER_NAME_SIZE 17U
8083
#define EFI_BOOT_MEM_SIZE \
81-
(MBOOT_MMAP_SIZE + MBOOT_INFO_SIZE + BOOT_CTX_SIZE)
84+
(MBOOT_MMAP_SIZE + MBOOT_INFO_SIZE + BOOT_CTX_SIZE + BOOT_LOADER_NAME_SIZE)
8285
#define MBOOT_MMAP_PTR(addr) \
8386
((struct multiboot_mmap *)((VOID *)(addr)))
8487
#define MBOOT_INFO_PTR(addr) \
8588
((struct multiboot_info *)((VOID *)(addr) + MBOOT_MMAP_SIZE))
8689
#define BOOT_CTX_PTR(addr) \
8790
((struct uefi_context *)((VOID *)(addr) + MBOOT_MMAP_SIZE + MBOOT_INFO_SIZE))
88-
91+
#define BOOT_LOADER_NAME_PTR(addr) \
92+
((char *)((VOID *)(addr) + MBOOT_MMAP_SIZE + MBOOT_INFO_SIZE + BOOT_CTX_SIZE))
8993

9094
struct efi_info {
9195
UINT32 efi_loader_signature;

0 commit comments

Comments
 (0)