diff --git a/hypervisor/Makefile b/hypervisor/Makefile index 0ebfc21d9..318355fff 100644 --- a/hypervisor/Makefile +++ b/hypervisor/Makefile @@ -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 diff --git a/hypervisor/arch/x86/cpu.c b/hypervisor/arch/x86/cpu.c index fc9efef32..199f5ebb0 100644 --- a/hypervisor/arch/x86/cpu.c +++ b/hypervisor/arch/x86/cpu.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -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. */ diff --git a/hypervisor/arch/x86/guest/vm.c b/hypervisor/arch/x86/guest/vm.c index 617257148..fc2aaf181 100644 --- a/hypervisor/arch/x86/guest/vm.c +++ b/hypervisor/arch/x86/guest/vm.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -33,11 +32,10 @@ #include #include #include +#include #include #include -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(); diff --git a/hypervisor/arch/x86/irq.c b/hypervisor/arch/x86/irq.c index 0777d4280..d001d2175 100644 --- a/hypervisor/arch/x86/irq.c +++ b/hypervisor/arch/x86/irq.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -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(); } diff --git a/hypervisor/arch/x86/trampoline.c b/hypervisor/arch/x86/trampoline.c index 755b149b0..bc7721d8b 100644 --- a/hypervisor/arch/x86/trampoline.c +++ b/hypervisor/arch/x86/trampoline.c @@ -9,7 +9,6 @@ #include #include #include -#include #include 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); diff --git a/hypervisor/boot/acpi_base.c b/hypervisor/boot/acpi_base.c index 6c33b416a..4f7854fa3 100644 --- a/hypervisor/boot/acpi_base.c +++ b/hypervisor/boot/acpi_base.c @@ -28,7 +28,6 @@ */ #include #include -#include #include "acpi.h" #include #include @@ -36,6 +35,7 @@ #include #include #include +#include static struct acpi_table_rsdp *acpi_rsdp; diff --git a/hypervisor/boot/guest/vboot_info.c b/hypervisor/boot/guest/vboot_info.c index 7e7568ba0..5d90f401d 100644 --- a/hypervisor/boot/guest/vboot_info.c +++ b/hypervisor/boot/guest/vboot_info.c @@ -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; -} diff --git a/hypervisor/boot/include/boot.h b/hypervisor/boot/include/boot.h index 8eab388cc..ee129cf32 100644 --- a/hypervisor/boot/include/boot.h +++ b/hypervisor/boot/include/boot.h @@ -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_ */ diff --git a/hypervisor/boot/multiboot.c b/hypervisor/boot/multiboot.c index b7b01ca40..83bf4cd01 100644 --- a/hypervisor/boot/multiboot.c +++ b/hypervisor/boot/multiboot.c @@ -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; +} diff --git a/hypervisor/common/vm_load.c b/hypervisor/common/vm_load.c index 73d596f3e..75cecd9e3 100644 --- a/hypervisor/common/vm_load.c +++ b/hypervisor/common/vm_load.c @@ -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); diff --git a/hypervisor/include/arch/x86/guest/vm.h b/hypervisor/include/arch/x86/guest/vm.h index 48f4ac898..70264746a 100644 --- a/hypervisor/include/arch/x86/guest/vm.h +++ b/hypervisor/include/arch/x86/guest/vm.h @@ -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);