diff --git a/hypervisor/arch/x86/guest/vcpu.c b/hypervisor/arch/x86/guest/vcpu.c index db56493a5..18f998d60 100644 --- a/hypervisor/arch/x86/guest/vcpu.c +++ b/hypervisor/arch/x86/guest/vcpu.c @@ -177,9 +177,13 @@ int start_vcpu(struct vcpu *vcpu) if (ibrs_type == IBRS_RAW) msr_write(MSR_IA32_PRED_CMD, PRED_SET_IBPB); + vcpu->in_rootmode = false; + /* Launch the VM */ status = vmx_vmrun(cur_context, VM_LAUNCH, ibrs_type); + vcpu->in_rootmode = true; + /* See if VM launched successfully */ if (status == 0) { if (is_vcpu_bsp(vcpu)) { @@ -196,8 +200,11 @@ int start_vcpu(struct vcpu *vcpu) exec_vmwrite(VMX_GUEST_RIP, ((rip + instlen) & 0xFFFFFFFFFFFFFFFF)); + vcpu->in_rootmode = false; /* Resume the VM */ status = vmx_vmrun(cur_context, VM_RESUME, ibrs_type); + + vcpu->in_rootmode = true; } /* Save guest CR3 register */ diff --git a/hypervisor/arch/x86/interrupt.c b/hypervisor/arch/x86/interrupt.c index a5e454788..6f66a92ee 100644 --- a/hypervisor/arch/x86/interrupt.c +++ b/hypervisor/arch/x86/interrupt.c @@ -88,7 +88,7 @@ static bool vcpu_pending_request(struct vcpu *vcpu) */ if (ret != 0) { /* we have pending IRR */ - vcpu_make_request(vcpu, ACRN_REQUEST_EVENT); + //vcpu_make_request(vcpu, ACRN_REQUEST_EVENT); } return vcpu->arch_vcpu.pending_req != 0; diff --git a/hypervisor/common/schedule.c b/hypervisor/common/schedule.c index eabeef27c..708faadc9 100644 --- a/hypervisor/common/schedule.c +++ b/hypervisor/common/schedule.c @@ -88,11 +88,25 @@ static struct vcpu *select_next_vcpu(int pcpu_id) return vcpu; } +/* here we assume there is no reschedule request will be made after + * acrn_handle_pending_request + */ +static bool reschedule_need_notify_vcpu(struct vcpu *vcpu) +{ + if (vcpu->in_rootmode) + return false; + + if ((int)get_cpu_id() != vcpu->pcpu_id) + return true; + else + return false; +} void make_reschedule_request(struct vcpu *vcpu) { bitmap_set(NEED_RESCHEDULE, &per_cpu(sched_ctx, vcpu->pcpu_id).flags); - send_single_ipi(vcpu->pcpu_id, VECTOR_NOTIFY_VCPU); + if (reschedule_need_notify_vcpu(vcpu)) + send_single_ipi(vcpu->pcpu_id, VECTOR_NOTIFY_VCPU); } int need_reschedule(int pcpu_id) diff --git a/hypervisor/include/arch/x86/guest/vcpu.h b/hypervisor/include/arch/x86/guest/vcpu.h index 03eef395f..ee299c841 100644 --- a/hypervisor/include/arch/x86/guest/vcpu.h +++ b/hypervisor/include/arch/x86/guest/vcpu.h @@ -233,6 +233,7 @@ struct vcpu { struct list_head run_list; /* inserted to schedule runqueue */ unsigned long pending_pre_work; /* any pre work pending? */ bool launched; /* Whether the vcpu is launched on target pcpu */ + bool in_rootmode; /* Whether the vcpu is vm exit and under root mode */ unsigned int paused_cnt; /* how many times vcpu is paused */ int running; /* vcpu is picked up and run? */ int ioreq_pending; /* ioreq is ongoing or not? */