Commit f74f9414 authored by Paolo Bonzini's avatar Paolo Bonzini

KVM: SVM: introduce nested_run_pending

We want to inject vmexits immediately from svm_check_nested_events,
so that the interrupt/NMI window requests happen in inject_pending_event
right after it returns.

This however has the same issue as in vmx_check_nested_events, so
introduce a nested_run_pending flag with the exact same purpose
of delaying vmexit injection after the vmentry.
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 4aef2ec9
...@@ -414,6 +414,7 @@ int nested_svm_vmrun(struct vcpu_svm *svm) ...@@ -414,6 +414,7 @@ int nested_svm_vmrun(struct vcpu_svm *svm)
copy_vmcb_control_area(hsave, vmcb); copy_vmcb_control_area(hsave, vmcb);
svm->nested.nested_run_pending = 1;
enter_svm_guest_mode(svm, vmcb_gpa, nested_vmcb, &map); enter_svm_guest_mode(svm, vmcb_gpa, nested_vmcb, &map);
if (!nested_svm_vmrun_msrpm(svm)) { if (!nested_svm_vmrun_msrpm(svm)) {
...@@ -815,7 +816,8 @@ static int svm_check_nested_events(struct kvm_vcpu *vcpu) ...@@ -815,7 +816,8 @@ static int svm_check_nested_events(struct kvm_vcpu *vcpu)
{ {
struct vcpu_svm *svm = to_svm(vcpu); struct vcpu_svm *svm = to_svm(vcpu);
bool block_nested_events = bool block_nested_events =
kvm_event_needs_reinjection(vcpu) || svm->nested.exit_required; kvm_event_needs_reinjection(vcpu) || svm->nested.exit_required ||
svm->nested.nested_run_pending;
if (kvm_cpu_has_interrupt(vcpu) && nested_exit_on_intr(svm)) { if (kvm_cpu_has_interrupt(vcpu) && nested_exit_on_intr(svm)) {
if (block_nested_events) if (block_nested_events)
......
...@@ -3429,6 +3429,7 @@ static enum exit_fastpath_completion svm_vcpu_run(struct kvm_vcpu *vcpu) ...@@ -3429,6 +3429,7 @@ static enum exit_fastpath_completion svm_vcpu_run(struct kvm_vcpu *vcpu)
sync_cr8_to_lapic(vcpu); sync_cr8_to_lapic(vcpu);
svm->next_rip = 0; svm->next_rip = 0;
svm->nested.nested_run_pending = 0;
svm->vmcb->control.tlb_ctl = TLB_CONTROL_DO_NOTHING; svm->vmcb->control.tlb_ctl = TLB_CONTROL_DO_NOTHING;
......
...@@ -97,6 +97,10 @@ struct nested_state { ...@@ -97,6 +97,10 @@ struct nested_state {
/* A VMEXIT is required but not yet emulated */ /* A VMEXIT is required but not yet emulated */
bool exit_required; bool exit_required;
/* A VMRUN has started but has not yet been performed, so
* we cannot inject a nested vmexit yet. */
bool nested_run_pending;
/* cache for intercepts of the guest */ /* cache for intercepts of the guest */
u32 intercept_cr; u32 intercept_cr;
u32 intercept_dr; u32 intercept_dr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment