From 85bec0d0d11654a6f8699f05a3a50c5c73f07487 Mon Sep 17 00:00:00 2001 From: Yin Fengwei Date: Tue, 23 Oct 2018 15:53:23 +0800 Subject: [PATCH] hv: Move the guest_sw_loader() call from vcpu to vm guest software loading is per VM instead of vcpu. So we move it from prepare_vcpu to prepare_vm. And make sure it's called for all VMs for partition mode. Tracked-On: #1565 Signed-off-by: Yin Fengwei Acked-by: Anthony Xu --- hypervisor/arch/x86/guest/vcpu.c | 8 -------- hypervisor/arch/x86/guest/vm.c | 16 +++++++++++++++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/hypervisor/arch/x86/guest/vcpu.c b/hypervisor/arch/x86/guest/vcpu.c index aba299927..e64e5b92b 100644 --- a/hypervisor/arch/x86/guest/vcpu.c +++ b/hypervisor/arch/x86/guest/vcpu.c @@ -598,14 +598,6 @@ int prepare_vcpu(struct vm *vm, uint16_t pcpu_id) return ret; } - if (!vm_sw_loader) { - vm_sw_loader = general_sw_loader; - } - - if (is_vm0(vm)) { - vm_sw_loader(vm); - } - /* init_vmcs is delayed to vcpu vmcs launch first time */ /* initialize the vcpu tsc aux */ vcpu->msr_tsc_aux_guest = vcpu->vcpu_id; diff --git a/hypervisor/arch/x86/guest/vm.c b/hypervisor/arch/x86/guest/vm.c index 4d04f7e17..abe928461 100644 --- a/hypervisor/arch/x86/guest/vm.c +++ b/hypervisor/arch/x86/guest/vm.c @@ -272,7 +272,7 @@ int reset_vm(struct vm *vm) } if (is_vm0(vm)) { - vm_sw_loader(vm); + (void )vm_sw_loader(vm); } vioapic_reset(vm_ioapic(vm)); @@ -372,6 +372,12 @@ int prepare_vm(uint16_t pcpu_id) for (i = 1U; i < vm_desc->vm_hw_num_cores; i++) prepare_vcpu(vm, vm_desc->vm_pcpu_ids[i]); + if (!vm_sw_loader) { + vm_sw_loader = general_sw_loader; + } + + (void )vm_sw_loader(vm); + /* start vm BSP automatically */ start_vm(vm); @@ -407,6 +413,14 @@ int prepare_vm0(void) } } + if (!vm_sw_loader) { + vm_sw_loader = general_sw_loader; + } + + if (is_vm0(vm)) { + (void )vm_sw_loader(vm); + } + /* start vm0 BSP automatically */ err = start_vm(vm);