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>
This commit is contained in:
Tw 2019-03-04 13:51:41 +08:00 committed by wenlingz
parent 56d8b08b78
commit 9b24620e16
13 changed files with 29 additions and 19 deletions

View File

@ -232,15 +232,10 @@ C_SRCS += bsp/firmware_uefi.c
C_SRCS += bsp/cmdline.c
C_SRCS += bsp/const_dmar.c
ifeq ($(CONFIG_PLATFORM_UEFI),y)
C_SRCS += boot/uefi/uefi_boot.c
else
ifeq ($(CONFIG_PLATFORM_SBL),y)
C_SRCS += boot/sbl/multiboot.c
C_SRCS += boot/sbl/sbl_seed_parse.c
C_SRCS += boot/sbl/abl_seed_parse.c
endif
endif
# retpoline support
ifeq (true, $(shell [ $(GCC_MAJOR) -eq 7 ] && [ $(GCC_MINOR) -ge 3 ] && echo true))

View File

@ -23,6 +23,7 @@
#include <mmu.h>
#include <logmsg.h>
#include <cat.h>
#include <firmware.h>
vm_sw_loader_t vm_sw_loader;
@ -329,7 +330,7 @@ int32_t create_vm(uint16_t vm_id, struct acrn_vm_config *vm_config, struct acrn_
create_sos_vm_e820(vm);
prepare_sos_vm_memmap(vm);
status = init_vm_boot_info(vm);
status = firmware_init_vm_boot_info(vm);
if (status == 0) {
init_fallback_iommu_domain(vm->iommu, vm->vm_id, vm->arch_vm.nworld_eptp);
} else {
@ -358,7 +359,7 @@ int32_t create_vm(uint16_t vm_id, struct acrn_vm_config *vm_config, struct acrn_
#ifdef CONFIG_PARTITION_MODE
create_prelaunched_vm_e820(vm);
prepare_prelaunched_vm_memmap(vm, vm_config);
(void)init_vm_boot_info(vm);
(void)firmware_init_vm_boot_info(vm);
#endif
}

View File

@ -14,6 +14,7 @@
#include <vmx.h>
#include <vm.h>
#include <logmsg.h>
#include <firmware.h>
/* Push sp magic to top of stack for call trace */
#define SWITCH_TO(rsp, to) \

View File

@ -28,6 +28,7 @@
*/
#include <hypervisor.h>
#include <firmware.h>
#include "acpi_priv.h"
#include "acpi.h"

View File

@ -111,7 +111,7 @@ static void *get_kernel_load_addr(void *kernel_src_addr)
* @pre vm != NULL
* @pre is_sos_vm(vm) == true
*/
int32_t init_vm_boot_info(struct acrn_vm *vm)
int32_t sbl_init_vm_boot_info(struct acrn_vm *vm)
{
struct multiboot_module *mods = NULL;
struct multiboot_info *mbi = NULL;

View File

@ -7,7 +7,7 @@
#include <hypervisor.h>
#include <multiboot.h>
#include <boot_context.h>
#include <uefi.h>
#include <firmware_uefi.h>
static int32_t uefi_sw_loader(struct acrn_vm *vm)
{
@ -15,23 +15,23 @@ static int32_t uefi_sw_loader(struct acrn_vm *vm)
/* get primary vcpu */
struct acrn_vcpu *vcpu = vcpu_from_vid(vm, BOOT_CPU_ID);
struct acrn_vcpu_regs *vcpu_regs = &boot_context;
const struct efi_context *efi_ctx = get_efi_ctx();
const struct lapic_regs *uefi_lapic_regs = get_efi_lapic_regs();
const struct uefi_context *uefi_ctx = get_uefi_ctx();
const struct lapic_regs *uefi_lapic_regs = get_uefi_lapic_regs();
pr_dbg("Loading guest to run-time location");
vlapic_restore(vcpu_vlapic(vcpu), uefi_lapic_regs);
/* For UEFI platform, the bsp init regs come from two places:
* 1. saved in efi_boot: gpregs, rip
* 1. saved in uefi_boot: gpregs, rip
* 2. saved when HV started: other registers
* We copy the info saved in efi_boot to boot_context and
* We copy the info saved in uefi_boot to boot_context and
* init bsp with boot_context.
*/
memcpy_s(&(vcpu_regs->gprs), sizeof(struct acrn_gp_regs),
&(efi_ctx->vcpu_regs.gprs), sizeof(struct acrn_gp_regs));
&(uefi_ctx->vcpu_regs.gprs), sizeof(struct acrn_gp_regs));
vcpu_regs->rip = efi_ctx->vcpu_regs.rip;
vcpu_regs->rip = uefi_ctx->vcpu_regs.rip;
set_vcpu_regs(vcpu, vcpu_regs);
/* defer irq enabling till vlapic is ready */
@ -40,7 +40,7 @@ static int32_t uefi_sw_loader(struct acrn_vm *vm)
return ret;
}
int32_t init_vm_boot_info(__unused struct acrn_vm *vm)
int32_t uefi_init_vm_boot_info(__unused struct acrn_vm *vm)
{
vm_sw_loader = uefi_sw_loader;

View File

@ -36,6 +36,7 @@ static struct firmware_operations firmware_sbl_ops = {
.get_ap_trampoline = sbl_get_ap_trampoline,
.get_rsdp = sbl_get_rsdp,
.init_irq = sbl_init_irq,
.init_vm_boot_info = sbl_init_vm_boot_info,
};
struct firmware_operations* sbl_get_firmware_operations(void)

View File

@ -34,13 +34,13 @@ static void uefi_init(void)
}
}
const struct uefi_context *get_efi_ctx(void)
const struct uefi_context *get_uefi_ctx(void)
{
uefi_init();
return &uefi_ctx;
}
const struct lapic_regs *get_efi_lapic_regs(void)
const struct lapic_regs *get_uefi_lapic_regs(void)
{
uefi_init();
return &uefi_lapic_regs;
@ -80,6 +80,7 @@ static struct firmware_operations firmware_uefi_ops = {
.get_ap_trampoline = uefi_get_ap_trampoline,
.get_rsdp = uefi_get_rsdp,
.init_irq = uefi_init_irq,
.init_vm_boot_info = uefi_init_vm_boot_info,
};
struct firmware_operations* uefi_get_firmware_operations(void)

View File

@ -9,6 +9,7 @@
#include <firmware.h>
#include <firmware_sbl.h>
#include <firmware_uefi.h>
#include "platform_acpi_info.h"
static struct firmware_operations *firmware_ops;
@ -77,3 +78,9 @@ void firmware_init_irq(void)
{
return firmware_ops->init_irq();
}
/* @pre: firmware_ops->init_vm_boot_info != NULL */
int32_t firmware_init_vm_boot_info(struct acrn_vm *vm)
{
return firmware_ops->init_vm_boot_info(vm);
}

View File

@ -13,6 +13,7 @@ struct firmware_operations {
uint64_t (*get_ap_trampoline)(void);
void *(*get_rsdp)(void);
void (*init_irq)(void);
int32_t (*init_vm_boot_info)(struct acrn_vm *vm);
};
void init_firmware_operations(void);
@ -20,6 +21,7 @@ void init_firmware(void);
uint64_t firmware_get_ap_trampoline(void);
void *firmware_get_rsdp(void);
void firmware_init_irq(void);
int32_t firmware_init_vm_boot_info(struct acrn_vm *vm);
#ifndef CONFIG_CONSTANT_ACPI
void acpi_fixup(void);

View File

@ -11,5 +11,6 @@
#include <firmware.h>
struct firmware_operations* sbl_get_firmware_operations(void);
int32_t sbl_init_vm_boot_info(struct acrn_vm *vm);
#endif /* end of include guard: FIRMWARE_SBL_H */

View File

@ -19,5 +19,6 @@ const struct uefi_context *get_uefi_ctx(void);
const struct lapic_regs *get_uefi_lapic_regs(void);
struct firmware_operations* uefi_get_firmware_operations(void);
int32_t uefi_init_vm_boot_info(__unused struct acrn_vm *vm);
#endif /* end of include guard: FIRMWARE_UEFI_H */

View File

@ -17,7 +17,6 @@
#include <bits.h>
#include <spinlock.h>
#include <acrn_common.h>
#include <firmware.h>
#include <vcpu.h>
#include <vioapic.h>
#include <vpic.h>