hv: remove de-privilege boot mode support and remove vboot wrappers

Now ACRN supports direct boot mode, which could be SBL/ABL, or GRUB boot.
Thus the vboot wrapper layer can be removed and the direct boot functions
don't need to be wrapped in direct_boot.c:

- remove call to init_vboot(), and call e820_alloc_memory() directly at the
  time when the trampoline buffer is actually needed.
- Similarly, call CPU_IRQ_ENABLE() instead of the wrapper init_vboot_irq().
- remove get_ap_trampoline_buf(), since the existing function
  get_trampoline_start16_paddr() returns the exact same value.
- merge init_general_vm_boot_info() into init_vm_boot_info().
- remove vm_sw_loader pointer, and call direct_boot_sw_loader() directly.
- move get_rsdp_ptr() from vboot_wrapper.c to multiboot.c, and remove the
  wrapper over two boot modes.

Tracked-On: #5197
Signed-off-by: Zide Chen <zide.chen@intel.com>
This commit is contained in:
Zide Chen 2020-08-24 00:32:15 -07:00 committed by wenlingz
parent 61699263f3
commit bebffb29fc
11 changed files with 29 additions and 92 deletions

View File

@ -261,9 +261,6 @@ ifeq ($(CONFIG_ACPI_PARSE_ENABLED),y)
HW_C_SRCS += acpi_parser/dmar_parse.c
HW_C_SRCS += acpi_parser/acpi_ext.c
endif
HW_C_SRCS += boot/guest/vboot_wrapper.c
HW_C_SRCS += boot/guest/deprivilege_boot.c
HW_C_SRCS += boot/guest/direct_boot.c
# VM Configuration
VM_CFG_C_SRCS += $(BOARD_INFO_DIR)/board.c

View File

@ -24,7 +24,6 @@
#include <ptdev.h>
#include <logmsg.h>
#include <rdt.h>
#include <vboot.h>
#include <sgx.h>
#include <uart16550.h>
#include <ivshmem.h>
@ -150,7 +149,6 @@ void init_pcpu_pre(bool is_bsp)
early_init_lapic();
init_vboot();
#ifdef CONFIG_ACPI_PARSE_ENABLED
ret = acpi_fixup();
if (ret != 0) {
@ -171,7 +169,7 @@ void init_pcpu_pre(bool is_bsp)
init_rdt_info();
#endif
/* NOTE: this must call after MMCONFIG is parsed in init_vboot and before APs are INIT.
/* NOTE: this must call after MMCONFIG is parsed in acpi_fixup() and before APs are INIT.
* We only support platform with MMIO based CFG space access.
* IO port access only support in debug version.
*/

View File

@ -25,7 +25,6 @@
#include <mmu.h>
#include <logmsg.h>
#include <vboot_info.h>
#include <vboot.h>
#include <board.h>
#include <sgx.h>
#include <sbuf.h>
@ -33,11 +32,10 @@
#include <vacpi.h>
#include <platform_caps.h>
#include <mmio_dev.h>
#include <trampoline.h>
#include <assign.h>
#include <vgpio.h>
vm_sw_loader_t vm_sw_loader;
/* Local variables */
static struct acrn_vm vm_array[CONFIG_MAX_VM_NUM] __aligned(PAGE_SIZE);
@ -349,12 +347,9 @@ static void prepare_sos_vm_memmap(struct acrn_vm *vm)
}
/* unmap AP trampoline code for security
* 'allocate_pages()' in depri boot mode or
* 'e820_alloc_memory()' in direct boot
* mode will ensure the base address of tramploline
* code be page-aligned.
* This buffer is guaranteed to be page aligned.
*/
ept_del_mr(vm, pml4_page, get_ap_trampoline_buf(), CONFIG_LOW_RAM_SIZE);
ept_del_mr(vm, pml4_page, get_trampoline_start16_paddr(), CONFIG_LOW_RAM_SIZE);
/* unmap PCIe MMCONFIG region since it's owned by hypervisor */
pci_mmcfg = get_mmcfg_region();

View File

@ -15,7 +15,6 @@
#include <ioapic.h>
#include <lapic.h>
#include <softirq.h>
#include <vboot.h>
#include <dump.h>
#include <logmsg.h>
#include <vmx.h>
@ -502,5 +501,5 @@ void init_interrupt(uint16_t pcpu_id)
init_lapic(pcpu_id);
init_default_irqs(pcpu_id);
init_vboot_irq();
CPU_IRQ_ENABLE();
}

View File

@ -9,7 +9,6 @@
#include <per_cpu.h>
#include <trampoline.h>
#include <reloc.h>
#include <vboot.h>
#include <ld_sym.h>
static uint64_t trampoline_start16_paddr;
@ -110,7 +109,7 @@ uint64_t prepare_trampoline(void)
uint64_t size, dest_pa, i;
size = (uint64_t)(&ld_trampoline_end - &ld_trampoline_start);
dest_pa = get_ap_trampoline_buf();
dest_pa = e820_alloc_memory(CONFIG_LOW_RAM_SIZE, MEM_1M);
pr_dbg("trampoline code: %lx size %x", dest_pa, size);

View File

@ -28,7 +28,6 @@
*/
#include <types.h>
#include <rtl.h>
#include <vboot.h>
#include "acpi.h"
#include <pgtable.h>
#include <ioapic.h>
@ -36,6 +35,7 @@
#include <acrn_common.h>
#include <util.h>
#include <e820.h>
#include <boot.h>
static struct acpi_table_rsdp *acpi_rsdp;

View File

@ -250,9 +250,14 @@ static int32_t init_vm_sw_load(struct acrn_vm *vm, const struct acrn_multiboot_i
}
/**
* @param[inout] vm pointer to a vm descriptor
*
* @retval 0 on success
* @retval -EINVAL on invalid parameters
*
* @pre vm != NULL
*/
static int32_t init_general_vm_boot_info(struct acrn_vm *vm)
int32_t init_vm_boot_info(struct acrn_vm *vm)
{
struct acrn_multiboot_info *mbi = get_multiboot_info();
int32_t ret = -EINVAL;
@ -267,70 +272,3 @@ static int32_t init_general_vm_boot_info(struct acrn_vm *vm)
return ret;
}
static void depri_boot_spurious_handler(uint32_t vector)
{
if (get_pcpu_id() == BSP_CPU_ID) {
struct acrn_vcpu *vcpu = vcpu_from_vid(get_sos_vm(), BSP_CPU_ID);
if (vcpu != NULL) {
vlapic_set_intr(vcpu, vector, LAPIC_TRIG_EDGE);
} else {
pr_err("%s vcpu or vlapic is not ready, interrupt lost\n", __func__);
}
}
}
static int32_t depri_boot_sw_loader(struct acrn_vm *vm)
{
int32_t ret = 0;
/* get primary vcpu */
struct acrn_vcpu *vcpu = vcpu_from_vid(vm, BSP_CPU_ID);
struct acrn_vcpu_regs *vcpu_regs = &boot_context;
const struct depri_boot_context *depri_boot_ctx = get_depri_boot_ctx();
const struct lapic_regs *depri_boot_lapic_regs = get_depri_boot_lapic_regs();
pr_dbg("Loading guest to run-time location");
vlapic_restore(vcpu_vlapic(vcpu), depri_boot_lapic_regs);
/* For UEFI platform, the bsp init regs come from two places:
* 1. saved in depri_boot: gpregs, rip
* 2. saved when HV started: other registers
* We copy the info saved in depri_boot to boot_context and
* init bsp with boot_context.
*/
(void)memcpy_s((void *)&(vcpu_regs->gprs), sizeof(struct acrn_gp_regs),
&(depri_boot_ctx->vcpu_regs.gprs), sizeof(struct acrn_gp_regs));
vcpu_regs->rip = depri_boot_ctx->vcpu_regs.rip;
set_vcpu_regs(vcpu, vcpu_regs);
/* defer irq enabling till vlapic is ready */
spurious_handler = depri_boot_spurious_handler;
CPU_IRQ_ENABLE();
return ret;
}
/**
* @param[inout] vm pointer to a vm descriptor
*
* @retval 0 on success
* @retval -EINVAL on invalid parameters
*
* @pre vm != NULL
*/
int32_t init_vm_boot_info(struct acrn_vm *vm)
{
int32_t ret = 0;
if (is_sos_vm(vm) && (get_sos_boot_mode() == DEPRI_BOOT_MODE)) {
vm_sw_loader = depri_boot_sw_loader;
} else {
vm_sw_loader = direct_boot_sw_loader;
ret = init_general_vm_boot_info(vm);
}
return ret;
}

View File

@ -87,5 +87,6 @@ struct acrn_multiboot_info *get_multiboot_info(void);
void init_acrn_multiboot_info(void);
int32_t sanitize_multiboot_info(void);
void parse_hv_cmdline(void);
const void* get_rsdp_ptr(void);
#endif /* BOOT_H_ */

View File

@ -123,3 +123,16 @@ struct acrn_multiboot_info *get_multiboot_info(void)
{
return &acrn_mbi;
}
const void* get_rsdp_ptr(void)
{
const void *rsdp_ptr;
if (boot_from_multiboot2()) {
rsdp_ptr = acrn_mbi.mi_acpi_rsdp_va;
} else {
rsdp_ptr = NULL;
}
return rsdp_ptr;
}

View File

@ -181,7 +181,7 @@ static void prepare_loading_rawimage(struct acrn_vm *vm)
/**
* @pre vm != NULL
*/
int32_t direct_boot_sw_loader(struct acrn_vm *vm)
int32_t vm_sw_loader(struct acrn_vm *vm)
{
int32_t ret = 0;
struct sw_kernel_info *sw_kernel = &(vm->sw.kernel_info);

View File

@ -234,10 +234,7 @@ struct acrn_vm *get_sos_vm(void);
void create_sos_vm_e820(struct acrn_vm *vm);
void create_prelaunched_vm_e820(struct acrn_vm *vm);
int32_t direct_boot_sw_loader(struct acrn_vm *vm);
typedef int32_t (*vm_sw_loader_t)(struct acrn_vm *vm);
extern vm_sw_loader_t vm_sw_loader;
int32_t vm_sw_loader(struct acrn_vm *vm);
void vrtc_init(struct acrn_vm *vm);