Skip to content

Commit e011c66

Browse files
Gleb Natapovbonzini
authored andcommitted
KVM: nVMX: Check all exceptions for intercept during delivery to L2
All exceptions should be checked for intercept during delivery to L2, but we check only #PF currently. Drop nested_run_pending while we are at it since exception cannot be injected during vmentry anyway. Signed-off-by: Gleb Natapov <gleb@redhat.com> [Renamed the nested_vmx_check_exception function. - Paolo] Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 851eb66 commit e011c66

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

arch/x86/kvm/vmx.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,16 +1898,12 @@ static void skip_emulated_instruction(struct kvm_vcpu *vcpu)
18981898
/*
18991899
* KVM wants to inject page-faults which it got to the guest. This function
19001900
* checks whether in a nested guest, we need to inject them to L1 or L2.
1901-
* This function assumes it is called with the exit reason in vmcs02 being
1902-
* a #PF exception (this is the only case in which KVM injects a #PF when L2
1903-
* is running).
19041901
*/
1905-
static int nested_pf_handled(struct kvm_vcpu *vcpu)
1902+
static int nested_vmx_check_exception(struct kvm_vcpu *vcpu, unsigned nr)
19061903
{
19071904
struct vmcs12 *vmcs12 = get_vmcs12(vcpu);
19081905

1909-
/* TODO: also check PFEC_MATCH/MASK, not just EB.PF. */
1910-
if (!(vmcs12->exception_bitmap & (1u << PF_VECTOR)))
1906+
if (!(vmcs12->exception_bitmap & (1u << nr)))
19111907
return 0;
19121908

19131909
nested_vmx_vmexit(vcpu);
@@ -1921,8 +1917,8 @@ static void vmx_queue_exception(struct kvm_vcpu *vcpu, unsigned nr,
19211917
struct vcpu_vmx *vmx = to_vmx(vcpu);
19221918
u32 intr_info = nr | INTR_INFO_VALID_MASK;
19231919

1924-
if (!reinject && nr == PF_VECTOR && is_guest_mode(vcpu) &&
1925-
!vmx->nested.nested_run_pending && nested_pf_handled(vcpu))
1920+
if (!reinject && is_guest_mode(vcpu) &&
1921+
nested_vmx_check_exception(vcpu, nr))
19261922
return;
19271923

19281924
if (has_error_code) {

0 commit comments

Comments
 (0)