]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
KVM: x86: Relocate MMIO exit stats counting
authorSean Christopherson <sean.j.christopherson@intel.com>
Tue, 27 Aug 2019 21:40:27 +0000 (14:40 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 24 Sep 2019 11:37:35 +0000 (13:37 +0200)
Move the stat.mmio_exits update into x86_emulate_instruction().  This is
both a bug fix, e.g. the current update flows will incorrectly increment
mmio_exits on emulation failure, and a preparatory change to set the
stage for eliminating EMULATE_DONE and company.

Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu.c
arch/x86/kvm/vmx/vmx.c
arch/x86/kvm/x86.c

index a10af9c87f8ac1a2b42bf5a6f182840bd2fce276..138dcdef8a06907e445f2c84555320c9796cfc71 100644 (file)
@@ -5456,8 +5456,6 @@ int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t cr2, u64 error_code,
        case EMULATE_DONE:
                return 1;
        case EMULATE_USER_EXIT:
        case EMULATE_DONE:
                return 1;
        case EMULATE_USER_EXIT:
-               ++vcpu->stat.mmio_exits;
-               /* fall through */
        case EMULATE_FAIL:
                return 0;
        default:
        case EMULATE_FAIL:
                return 0;
        default:
index 8bab3e53d1e1a54d919d097223df4943840a0ae8..8f61250fc1c0a7d4e97730f084fe8a1572c709c0 100644 (file)
@@ -5201,7 +5201,6 @@ static int handle_invalid_guest_state(struct kvm_vcpu *vcpu)
                err = kvm_emulate_instruction(vcpu, 0);
 
                if (err == EMULATE_USER_EXIT) {
                err = kvm_emulate_instruction(vcpu, 0);
 
                if (err == EMULATE_USER_EXIT) {
-                       ++vcpu->stat.mmio_exits;
                        ret = 0;
                        goto out;
                }
                        ret = 0;
                        goto out;
                }
index 7e51924c4a1cd0d1e86f53a68e62910727015e4a..2b92c2ca1d79a22f38e6edb8418d1b11749d673e 100644 (file)
@@ -6703,6 +6703,8 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu,
                }
                r = EMULATE_USER_EXIT;
        } else if (vcpu->mmio_needed) {
                }
                r = EMULATE_USER_EXIT;
        } else if (vcpu->mmio_needed) {
+               ++vcpu->stat.mmio_exits;
+
                if (!vcpu->mmio_is_write)
                        writeback = false;
                r = EMULATE_USER_EXIT;
                if (!vcpu->mmio_is_write)
                        writeback = false;
                r = EMULATE_USER_EXIT;