Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp393351ybl; Fri, 23 Aug 2019 02:28:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqzdgzj3iAtXq0TuV6yx4Wgu6UvntnyBVOBd08jGfXIXMOtIfivzpJkbVhATaXTOreN1b26Y X-Received: by 2002:a17:902:ac87:: with SMTP id h7mr3803578plr.36.1566552499018; Fri, 23 Aug 2019 02:28:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566552499; cv=none; d=google.com; s=arc-20160816; b=yJxzIij2gJDKcwi5HnR9mR1B/KTuef63jbawSyiVV94OZbCTMN5UBy0JbKXhHImW45 qyEGesQ8wrFkvxHH4TAaO7WqAAiUAQd4o4myBkzfl4qZR8tdTGZnJv+kqMwzhTG+Bhkc kzpPzS387Tm1LmbJZ5A9lumlL1lu5B06eRVLX6JkikoOQE4kq4Pu/y77HHTwtNKY/lj8 QJ5/0W/vk5zRCQHEV9qk+8sLyQzbbO4atYZFbjg4SMlI4/yLRZTBjroImzDZ44kMWusY uxQtOka/h+mJC5ZUCJxDxw1E6wOfBvz94JA6ZdfcweCLw7LHxClrgYK+Z6OI3SF3ucqj RsRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=bY55QVSAHIc1BxeR0YsXfQLBtJn2QpY3qRdGRRHA/qI=; b=wj3TnpIqbN94Yy5+U1mOmc3CPQoZfFQFzddq7TyHpDisRnOVh/blFmkxLuY1Sf96S/ qmzz8LGSkHnte1N1D4q2kwYe2FgH7o+EDs5e4uXpMql05cJD98ukTJOe/DsdNGuKQn2Z 7JhBtl1I61h7b2cD3n53UKR9FJiQv5I1fhcY0L22oY+sPmgnug9rL3IwjTu5+lrJeuVM 592Aed4TEjWsESlbyBIUpvkEgszil7t4nWNhuWzca5SN1FaKCFP0Ix8Zn/h+uZpyHFns gt/ep9o/bwLZ/AUd0cFbHZt39dfv/XaBWtWgZ/8RfYl9Kj2Qx2c4ZgJRzanWXre89uOL oVOw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g5si1955425plp.435.2019.08.23.02.28.03; Fri, 23 Aug 2019 02:28:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387578AbfHWBIW (ORCPT + 99 others); Thu, 22 Aug 2019 21:08:22 -0400 Received: from mga01.intel.com ([192.55.52.88]:37991 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732613AbfHWBHL (ORCPT ); Thu, 22 Aug 2019 21:07:11 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Aug 2019 18:07:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,419,1559545200"; d="scan'208";a="186733486" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.41]) by FMSMGA003.fm.intel.com with ESMTP; 22 Aug 2019 18:07:10 -0700 From: Sean Christopherson To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RESEND PATCH 01/13] KVM: x86: Relocate MMIO exit stats counting Date: Thu, 22 Aug 2019 18:06:57 -0700 Message-Id: <20190823010709.24879-2-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190823010709.24879-1-sean.j.christopherson@intel.com> References: <20190823010709.24879-1-sean.j.christopherson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Sean Christopherson --- arch/x86/kvm/mmu.c | 2 -- arch/x86/kvm/vmx/vmx.c | 1 - arch/x86/kvm/x86.c | 2 ++ 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 4c45ff0cfbd0..845e39d8a970 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -5437,8 +5437,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: - ++vcpu->stat.mmio_exits; - /* fall through */ case EMULATE_FAIL: return 0; default: diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 570a233e272b..18286e5b5983 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -5200,7 +5200,6 @@ static int handle_invalid_guest_state(struct kvm_vcpu *vcpu) err = kvm_emulate_instruction(vcpu, 0); if (err == EMULATE_USER_EXIT) { - ++vcpu->stat.mmio_exits; ret = 0; goto out; } diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index b4cfd786d0b6..cd425f54096a 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -6598,6 +6598,8 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, } r = EMULATE_USER_EXIT; } else if (vcpu->mmio_needed) { + ++vcpu->stat.mmio_exits; + if (!vcpu->mmio_is_write) writeback = false; r = EMULATE_USER_EXIT; -- 2.22.0