diff --git a/hypervisor/arch/x86/cpu.c b/hypervisor/arch/x86/cpu.c index 1f8cc1a2a..0eca62f72 100644 --- a/hypervisor/arch/x86/cpu.c +++ b/hypervisor/arch/x86/cpu.c @@ -546,10 +546,11 @@ static void bsp_boot_post(void) console_setup_timer(); - /* Start initializing the VM for this CPU */ - if (hv_main(BOOT_CPU_ID) != 0) { - panic("failed to start VM for bsp\n"); - } + exec_vmxon_instr(BOOT_CPU_ID); + + prepare_vm0(); + + default_idle(); /* Control should not come here */ cpu_dead(BOOT_CPU_ID); @@ -621,13 +622,12 @@ static void cpu_secondary_post(void) /* Wait for boot processor to signal all secondary cores to continue */ pcpu_sync_sleep(&pcpu_sync, 0UL); - ret = hv_main(get_cpu_id()); - if (ret != 0) { - panic("hv_main ret = %d\n", ret); - } + exec_vmxon_instr(get_cpu_id()); - /* Control will only come here for secondary CPUs not configured for - * use or if an error occurs in hv_main + default_idle(); + + /* Control will only come here for secondary + * CPUs not configured for use. */ cpu_dead(get_cpu_id()); } diff --git a/hypervisor/arch/x86/idt.S b/hypervisor/arch/x86/idt.S index 30957e68b..251d2eb3a 100644 --- a/hypervisor/arch/x86/idt.S +++ b/hypervisor/arch/x86/idt.S @@ -393,7 +393,7 @@ external_interrupt_save_frame: /* * We disable softirq path from interrupt IRET, since right now all IRQ - * are for Guest, and we can execute softirq in hv_main() loop + * are for Guest. */ popq %rax diff --git a/hypervisor/common/hv_main.c b/hypervisor/common/hv_main.c index bc6d2bec3..6d9b0b61e 100644 --- a/hypervisor/common/hv_main.c +++ b/hypervisor/common/hv_main.c @@ -107,48 +107,6 @@ void vcpu_thread(struct vcpu *vcpu) } while (1); } -static bool is_vm0_bsp(uint16_t pcpu_id) -{ -#ifdef CONFIG_VM0_DESC - return pcpu_id == vm0_desc.vm_pcpu_ids[0]; -#else - return pcpu_id == BOOT_CPU_ID; -#endif -} - -int32_t hv_main(uint16_t pcpu_id) -{ - int32_t ret; - - pr_info("%s, Starting common entry point for CPU %hu", - __func__, pcpu_id); - - if (pcpu_id != get_cpu_id()) { - pr_err("%s, cpu_id %hu mismatch\n", __func__, pcpu_id); - return -EINVAL; - } - - /* Enable virtualization extensions */ - ret = exec_vmxon_instr(pcpu_id); - if (ret != 0) { - return ret; - } - - /* X2APIC mode is disabled by default. */ - x2apic_enabled = false; - - if (is_vm0_bsp(pcpu_id)) { - ret = prepare_vm0(); - if (ret != 0) { - return ret; - } - } - - default_idle(); - - return 0; -} - #ifdef HV_DEBUG void get_vmexit_profile(char *str_arg, int str_max) { diff --git a/hypervisor/common/hypercall.c b/hypervisor/common/hypercall.c index 2ffa2db9e..fd32386b0 100644 --- a/hypervisor/common/hypercall.c +++ b/hypervisor/common/hypercall.c @@ -161,9 +161,6 @@ int32_t hcall_create_vm(struct vm *vm, uint64_t param) { int32_t ret = 0; struct vm *target_vm = NULL; - /* VM are created from hv_main() directly - * Here we just return the vmid for DM - */ struct acrn_create_vm cv; struct vm_description vm_desc; diff --git a/hypervisor/include/arch/x86/cpu.h b/hypervisor/include/arch/x86/cpu.h index e4e6c3792..72da16b44 100644 --- a/hypervisor/include/arch/x86/cpu.h +++ b/hypervisor/include/arch/x86/cpu.h @@ -261,7 +261,6 @@ extern struct cpuinfo_x86 boot_cpu_data; /* Function prototypes */ void cpu_dead(uint16_t pcpu_id); void trampoline_start16(void); -int32_t hv_main(uint16_t cpu_id); bool is_vapic_supported(void); bool is_vapic_intr_delivery_supported(void); bool is_vapic_virt_reg_supported(void);