Skip to content

Commit 9b24620

Browse files
tw4452852wenlingz
authored andcommitted
hv: merge SBL and UEFI related stuff under boot
This patch mainly unifies init_vm_boot_info's implementation between SBL and UEFI. Tracked-On: #2708 Signed-off-by: Tw <wei.tan@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 56d8b08 commit 9b24620

File tree

13 files changed

+29
-19
lines changed

13 files changed

+29
-19
lines changed

hypervisor/Makefile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,10 @@ C_SRCS += bsp/firmware_uefi.c
232232
C_SRCS += bsp/cmdline.c
233233
C_SRCS += bsp/const_dmar.c
234234

235-
ifeq ($(CONFIG_PLATFORM_UEFI),y)
236235
C_SRCS += boot/uefi/uefi_boot.c
237-
else
238-
ifeq ($(CONFIG_PLATFORM_SBL),y)
239236
C_SRCS += boot/sbl/multiboot.c
240237
C_SRCS += boot/sbl/sbl_seed_parse.c
241238
C_SRCS += boot/sbl/abl_seed_parse.c
242-
endif
243-
endif
244239

245240
# retpoline support
246241
ifeq (true, $(shell [ $(GCC_MAJOR) -eq 7 ] && [ $(GCC_MINOR) -ge 3 ] && echo true))

hypervisor/arch/x86/guest/vm.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <mmu.h>
2424
#include <logmsg.h>
2525
#include <cat.h>
26+
#include <firmware.h>
2627

2728
vm_sw_loader_t vm_sw_loader;
2829

@@ -329,7 +330,7 @@ int32_t create_vm(uint16_t vm_id, struct acrn_vm_config *vm_config, struct acrn_
329330
create_sos_vm_e820(vm);
330331
prepare_sos_vm_memmap(vm);
331332

332-
status = init_vm_boot_info(vm);
333+
status = firmware_init_vm_boot_info(vm);
333334
if (status == 0) {
334335
init_fallback_iommu_domain(vm->iommu, vm->vm_id, vm->arch_vm.nworld_eptp);
335336
} else {
@@ -358,7 +359,7 @@ int32_t create_vm(uint16_t vm_id, struct acrn_vm_config *vm_config, struct acrn_
358359
#ifdef CONFIG_PARTITION_MODE
359360
create_prelaunched_vm_e820(vm);
360361
prepare_prelaunched_vm_memmap(vm, vm_config);
361-
(void)init_vm_boot_info(vm);
362+
(void)firmware_init_vm_boot_info(vm);
362363
#endif
363364
}
364365

hypervisor/arch/x86/init.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <vmx.h>
1515
#include <vm.h>
1616
#include <logmsg.h>
17+
#include <firmware.h>
1718

1819
/* Push sp magic to top of stack for call trace */
1920
#define SWITCH_TO(rsp, to) \

hypervisor/boot/acpi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
*/
2929

3030
#include <hypervisor.h>
31+
#include <firmware.h>
3132
#include "acpi_priv.h"
3233
#include "acpi.h"
3334

hypervisor/boot/sbl/multiboot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static void *get_kernel_load_addr(void *kernel_src_addr)
111111
* @pre vm != NULL
112112
* @pre is_sos_vm(vm) == true
113113
*/
114-
int32_t init_vm_boot_info(struct acrn_vm *vm)
114+
int32_t sbl_init_vm_boot_info(struct acrn_vm *vm)
115115
{
116116
struct multiboot_module *mods = NULL;
117117
struct multiboot_info *mbi = NULL;

hypervisor/boot/uefi/uefi_boot.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,31 @@
77
#include <hypervisor.h>
88
#include <multiboot.h>
99
#include <boot_context.h>
10-
#include <uefi.h>
10+
#include <firmware_uefi.h>
1111

1212
static int32_t uefi_sw_loader(struct acrn_vm *vm)
1313
{
1414
int32_t ret = 0;
1515
/* get primary vcpu */
1616
struct acrn_vcpu *vcpu = vcpu_from_vid(vm, BOOT_CPU_ID);
1717
struct acrn_vcpu_regs *vcpu_regs = &boot_context;
18-
const struct efi_context *efi_ctx = get_efi_ctx();
19-
const struct lapic_regs *uefi_lapic_regs = get_efi_lapic_regs();
18+
const struct uefi_context *uefi_ctx = get_uefi_ctx();
19+
const struct lapic_regs *uefi_lapic_regs = get_uefi_lapic_regs();
2020

2121
pr_dbg("Loading guest to run-time location");
2222

2323
vlapic_restore(vcpu_vlapic(vcpu), uefi_lapic_regs);
2424

2525
/* For UEFI platform, the bsp init regs come from two places:
26-
* 1. saved in efi_boot: gpregs, rip
26+
* 1. saved in uefi_boot: gpregs, rip
2727
* 2. saved when HV started: other registers
28-
* We copy the info saved in efi_boot to boot_context and
28+
* We copy the info saved in uefi_boot to boot_context and
2929
* init bsp with boot_context.
3030
*/
3131
memcpy_s(&(vcpu_regs->gprs), sizeof(struct acrn_gp_regs),
32-
&(efi_ctx->vcpu_regs.gprs), sizeof(struct acrn_gp_regs));
32+
&(uefi_ctx->vcpu_regs.gprs), sizeof(struct acrn_gp_regs));
3333

34-
vcpu_regs->rip = efi_ctx->vcpu_regs.rip;
34+
vcpu_regs->rip = uefi_ctx->vcpu_regs.rip;
3535
set_vcpu_regs(vcpu, vcpu_regs);
3636

3737
/* defer irq enabling till vlapic is ready */
@@ -40,7 +40,7 @@ static int32_t uefi_sw_loader(struct acrn_vm *vm)
4040
return ret;
4141
}
4242

43-
int32_t init_vm_boot_info(__unused struct acrn_vm *vm)
43+
int32_t uefi_init_vm_boot_info(__unused struct acrn_vm *vm)
4444
{
4545
vm_sw_loader = uefi_sw_loader;
4646

hypervisor/bsp/firmware_sbl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ static struct firmware_operations firmware_sbl_ops = {
3636
.get_ap_trampoline = sbl_get_ap_trampoline,
3737
.get_rsdp = sbl_get_rsdp,
3838
.init_irq = sbl_init_irq,
39+
.init_vm_boot_info = sbl_init_vm_boot_info,
3940
};
4041

4142
struct firmware_operations* sbl_get_firmware_operations(void)

hypervisor/bsp/firmware_uefi.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ static void uefi_init(void)
3434
}
3535
}
3636

37-
const struct uefi_context *get_efi_ctx(void)
37+
const struct uefi_context *get_uefi_ctx(void)
3838
{
3939
uefi_init();
4040
return &uefi_ctx;
4141
}
4242

43-
const struct lapic_regs *get_efi_lapic_regs(void)
43+
const struct lapic_regs *get_uefi_lapic_regs(void)
4444
{
4545
uefi_init();
4646
return &uefi_lapic_regs;
@@ -80,6 +80,7 @@ static struct firmware_operations firmware_uefi_ops = {
8080
.get_ap_trampoline = uefi_get_ap_trampoline,
8181
.get_rsdp = uefi_get_rsdp,
8282
.init_irq = uefi_init_irq,
83+
.init_vm_boot_info = uefi_init_vm_boot_info,
8384
};
8485

8586
struct firmware_operations* uefi_get_firmware_operations(void)

hypervisor/bsp/firmware_wrapper.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <firmware.h>
1010
#include <firmware_sbl.h>
1111
#include <firmware_uefi.h>
12+
#include "platform_acpi_info.h"
1213

1314
static struct firmware_operations *firmware_ops;
1415

@@ -77,3 +78,9 @@ void firmware_init_irq(void)
7778
{
7879
return firmware_ops->init_irq();
7980
}
81+
82+
/* @pre: firmware_ops->init_vm_boot_info != NULL */
83+
int32_t firmware_init_vm_boot_info(struct acrn_vm *vm)
84+
{
85+
return firmware_ops->init_vm_boot_info(vm);
86+
}

hypervisor/bsp/include/firmware.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ struct firmware_operations {
1313
uint64_t (*get_ap_trampoline)(void);
1414
void *(*get_rsdp)(void);
1515
void (*init_irq)(void);
16+
int32_t (*init_vm_boot_info)(struct acrn_vm *vm);
1617
};
1718

1819
void init_firmware_operations(void);
1920
void init_firmware(void);
2021
uint64_t firmware_get_ap_trampoline(void);
2122
void *firmware_get_rsdp(void);
2223
void firmware_init_irq(void);
24+
int32_t firmware_init_vm_boot_info(struct acrn_vm *vm);
2325

2426
#ifndef CONFIG_CONSTANT_ACPI
2527
void acpi_fixup(void);

0 commit comments

Comments
 (0)