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

@@ -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;
}