]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
KVM: nVMX: nSVM: 'nested_run' should count guest-entry attempts that make it to guest...
authorKrish Sadhukhan <krish.sadhukhan@oracle.com>
Wed, 9 Jun 2021 18:03:38 +0000 (14:03 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 17 Jun 2021 17:09:35 +0000 (13:09 -0400)
Currently, the 'nested_run' statistic counts all guest-entry attempts,
including those that fail during vmentry checks on Intel and during
consistency checks on AMD. Convert this statistic to count only those
guest-entries that make it past these state checks and make it to guest
code. This will tell us the number of guest-entries that actually executed
or tried to execute guest code.

Signed-off-by: Krish Sadhukhan <Krish.Sadhukhan@oracle.com>
Message-Id: <20210609180340.104248-2-krish.sadhukhan@oracle.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/svm/nested.c
arch/x86/kvm/svm/svm.c
arch/x86/kvm/vmx/nested.c
arch/x86/kvm/vmx/vmx.c

index 5e8d8443154e850dc3814c1e3aeb97d9d124776a..34fc74b0d58a30fff6383e54d68be65ce77f2ad2 100644 (file)
@@ -596,8 +596,6 @@ int nested_svm_vmrun(struct kvm_vcpu *vcpu)
        struct kvm_host_map map;
        u64 vmcb12_gpa;
 
-       ++vcpu->stat.nested_run;
-
        if (is_smm(vcpu)) {
                kvm_queue_exception(vcpu, UD_VECTOR);
                return 1;
index e7bec71a3d9b0771940d545c5e99a3409b065c59..d223f5dfac5331ff27f05035e5e87f6736d44a24 100644 (file)
@@ -3844,6 +3844,12 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct kvm_vcpu *vcpu)
        svm->next_rip = 0;
        if (is_guest_mode(vcpu)) {
                nested_sync_control_from_vmcb02(svm);
+
+               /* Track VMRUNs that have made past consistency checking */
+               if (svm->nested.nested_run_pending &&
+                   svm->vmcb->control.exit_code != SVM_EXIT_ERR)
+                        ++vcpu->stat.nested_run;
+
                svm->nested.nested_run_pending = 0;
        }
 
index 98b5f5f104da70e16883948bf5a9380b63959219..e77b8ee28df876fbea5c77927ab8fdf622ad53f8 100644 (file)
@@ -3470,8 +3470,6 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch)
        u32 interrupt_shadow = vmx_get_interrupt_shadow(vcpu);
        enum nested_evmptrld_status evmptrld_status;
 
-       ++vcpu->stat.nested_run;
-
        if (!nested_vmx_check_permission(vcpu))
                return 1;
 
index 51bbde75b1fd460f16b4ef6c4ccfa5a73e994f63..5aa0e54c793b29c82bf2e76a651b77ac93273912 100644 (file)
@@ -6809,7 +6809,18 @@ static fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu)
 
        kvm_load_host_xsave_state(vcpu);
 
-       vmx->nested.nested_run_pending = 0;
+       if (is_guest_mode(vcpu)) {
+               /*
+                * Track VMLAUNCH/VMRESUME that have made past guest state
+                * checking.
+                */
+               if (vmx->nested.nested_run_pending &&
+                   !vmx->exit_reason.failed_vmentry)
+                       ++vcpu->stat.nested_run;
+
+               vmx->nested.nested_run_pending = 0;
+       }
+
        vmx->idt_vectoring_info = 0;
 
        if (unlikely(vmx->fail)) {