Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp244407ybi; Tue, 16 Jul 2019 19:56:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqwFpKNRKnuAAXtksvi38AWV4ODKlvnV7boF4+l6RGxQVfP+eOLxAfa/8WdvjTuVVR34NgVi X-Received: by 2002:a17:902:9004:: with SMTP id a4mr40032012plp.109.1563332204782; Tue, 16 Jul 2019 19:56:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563332204; cv=none; d=google.com; s=arc-20160816; b=UXiNqWQQDdPO2D1B6E3rOe8Qn+EdQJwHJTrIh4UCSItmKp42Y3ykrrjjeNjSbyBHNp LtcGo40TrFLy9O4otFRziJqYYkBbTLV0z19xSK+JcQ+k87sySndrrf550VbqVVouq4jW giVf5uMrgmB5t0HecFLNHtE2Ot4kxEiUjbTxPB4qrd9eSc4dZO7BUAKCtmsCfEN1MUq5 YXpb5duIknkBrFISgyZjX3yKkOcqWVl7dEYpbCU9vju3ZRtfQ1adjxsY8KbZhTkDarbr qMcNVrr/+xFyPN60UynLA9wYDfPaL1gLBCb049EikJhnY5A79m/A02Ue2GPjhCdEsMzn gN5A== 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 :message-id:date:subject:cc:to:from; bh=CyINkaBC5Xk2SZ4r/30ZB7BvX8qQh0W99vBJRJdEwCY=; b=QzaOLEUS8PnujbrY+prg1ZYii5Y67w65xxkX7dAcboWmTUu8nwze1qYkbMDwU31qHP pOlcCOqSo+xNNFnkxKVVIqX/567IQz+XJJLOZ8F3Joyu0tR9EP5iJUE95mrVNxwlmQW0 k+zhTSD1usbff85ke9FzQP78v5eXSGdiL1Ko3XolenVOql9GFmgWK0mIyboMeAwoYs3y TKuj9VXOHGL/x1w3sodGHjVtXt3G0vsuzNrfMZYE/O/Hb+pgxo1Ow1fZubJUyNnbii7i gv7imB8tAEIQRlfLYjjH5LCHI2uWyK0p9rud4s8zm6BNoZn9ir7Y2pJ+/Cl7xeOleBLs y2tA== 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 a14si20879176pjo.40.2019.07.16.19.56.28; Tue, 16 Jul 2019 19:56:44 -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 S1728290AbfGQCyY (ORCPT + 99 others); Tue, 16 Jul 2019 22:54:24 -0400 Received: from mga18.intel.com ([134.134.136.126]:5742 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725294AbfGQCyY (ORCPT ); Tue, 16 Jul 2019 22:54:24 -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 orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jul 2019 19:54:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,272,1559545200"; d="scan'208";a="175583455" Received: from likexu-e5-2699-v4.sh.intel.com ([10.239.48.159]) by FMSMGA003.fm.intel.com with ESMTP; 16 Jul 2019 19:54:22 -0700 From: Like Xu To: Paolo Bonzini Cc: like.xu@linux.intel.com, wehuang@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] KVM: x86/vPMU: reset pmc->counter to 0 for pmu fixed_counters Date: Wed, 17 Jul 2019 10:51:18 +0800 Message-Id: <20190717025118.16783-1-like.xu@linux.intel.com> X-Mailer: git-send-email 2.21.0 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 To avoid semantic inconsistency, the fixed_counters in Intel vPMU need to be reset to 0 in intel_pmu_reset() as gp_counters does. Signed-off-by: Like Xu --- arch/x86/kvm/vmx/pmu_intel.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c index 68d231d49c7a..4dea0e0e7e39 100644 --- a/arch/x86/kvm/vmx/pmu_intel.c +++ b/arch/x86/kvm/vmx/pmu_intel.c @@ -337,17 +337,22 @@ static void intel_pmu_init(struct kvm_vcpu *vcpu) static void intel_pmu_reset(struct kvm_vcpu *vcpu) { struct kvm_pmu *pmu = vcpu_to_pmu(vcpu); + struct kvm_pmc *pmc = NULL; int i; for (i = 0; i < INTEL_PMC_MAX_GENERIC; i++) { - struct kvm_pmc *pmc = &pmu->gp_counters[i]; + pmc = &pmu->gp_counters[i]; pmc_stop_counter(pmc); pmc->counter = pmc->eventsel = 0; } - for (i = 0; i < INTEL_PMC_MAX_FIXED; i++) - pmc_stop_counter(&pmu->fixed_counters[i]); + for (i = 0; i < INTEL_PMC_MAX_FIXED; i++) { + pmc = &pmu->fixed_counters[i]; + + pmc_stop_counter(pmc); + pmc->counter = 0; + } pmu->fixed_ctr_ctrl = pmu->global_ctrl = pmu->global_status = pmu->global_ovf_ctrl = 0; -- 2.21.0