Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp692275ybi; Wed, 17 Jul 2019 03:24:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqwMtH2Kpb6QShq6iLTneLYXOJc9zlo77ZyqNFHnvF/CyfN55xcFA/HFsaYvy5lAZ+yfHxic X-Received: by 2002:a17:902:be15:: with SMTP id r21mr41260810pls.293.1563359060469; Wed, 17 Jul 2019 03:24:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563359060; cv=none; d=google.com; s=arc-20160816; b=vtVJHXEZYcJ3ohHJgS0FcHeCV5oXhQer1sWAC3lE76iItzWq2AHuqIgT5jZlLjMLxr AJoR5dBjwed5G6KOYW+cY1DgielBkbYEG+UB/2vbJcW4NNLUH665IzOKb/nN9vYbJDO/ RyP886oKtbK0fL47oitJT0xurdqbpkXPA1U4uRC7Xow0pfV2Ljnc8GqdOHvq6gb6O9ns Am2GMpJ0FahvOsGUbChgFE2NoCja77p/azo+lPe6eoKVpGr4+/WwvJYWuRPvt/bk2dV4 ID9JkacWPQlVwp+F0nyfum3I8Ou0BSw3CV3ysPKluWnGs8fQe9PzwdLJ9475N+/o3jpO qrSQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:openpgp:from:references:cc:to:subject; bh=OgDJWdqKExQDn29jdefxbq2X4b+zlsDENGAuQ8C2S/0=; b=gL/1/GrghAqPW0o5fYkE+Dk8+TiHZ/5pbEM554oYJw4VZc+E05VYhg4cB21O1KMh0R a7CF5c063GTDUGWHZXkdfuFgC+LQDUiCMGAe+ZZZqQQjJj0tnC1RL2UNtvoJTSfqSs9m FR2EiMysKVCbT/Cq2JTlFJXeNA9Mo9YApmmv6wqZrwF+22Sj+9W86zHKmdMB7s3tYcWY GInk9qzmbA6Zivmog8esYIxy83wS9JnZ3k51WclhB9FfsWRAPUskWEzbmkqtz//Hd94L iQsPHTzTMCVVLkAzdU4mdCIx181+ViUsA1oSRlRnTyCcFHPWA6xo/CjBxZ5qdYXI/Ble uErw== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 67si22900452pfb.242.2019.07.17.03.24.04; Wed, 17 Jul 2019 03:24:20 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726666AbfGQKXb (ORCPT + 99 others); Wed, 17 Jul 2019 06:23:31 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:43909 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725893AbfGQKXb (ORCPT ); Wed, 17 Jul 2019 06:23:31 -0400 Received: by mail-wr1-f65.google.com with SMTP id p13so24153883wru.10 for ; Wed, 17 Jul 2019 03:23:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=OgDJWdqKExQDn29jdefxbq2X4b+zlsDENGAuQ8C2S/0=; b=YmWlUbrCibszo4fUeAuBOgHQSi5mc/fx7KKR1j/jndMJJUOuzDaAFNIVUTRgDqPb3o XZup5p/S1+g4KKOjLWRdsgi7fGOB4ubckaU73qIV6rKBdaDoRHe9IreB3yFSiWzJ3bqs NPY8fGiQ6VWUF0suDdR4FfkAftA47KO5WDagZFYEv9Ubn98LO0R2ifK8Mn7da3LARXgb HixTNdSwxG9UYg9j6lTXdSNS0y4RbKEQmgR7kfXQHkABuQWikD0a3pHUm5/jPlYXMjBs yIHjPbuyi47w7sGRDqbV8NoUQbQf8OxE7N4HASnzrS2nsbOPdYR2STzZqxiFjdU+ksjB 8hzA== X-Gm-Message-State: APjAAAV6oSnSF4HMH4cDV4fl2io+kx+ui6JNRHjne0D8AzY1BlkXyN5s 9C30MIngUdKGIsT3qvR8jMn8LminD50EDw== X-Received: by 2002:a05:6000:187:: with SMTP id p7mr39272926wrx.189.1563359008856; Wed, 17 Jul 2019 03:23:28 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:e427:3beb:1110:dda2? ([2001:b07:6468:f312:e427:3beb:1110:dda2]) by smtp.gmail.com with ESMTPSA id t24sm21805289wmj.14.2019.07.17.03.23.28 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jul 2019 03:23:28 -0700 (PDT) Subject: Re: [PATCH] KVM: x86/vPMU: reset pmc->counter to 0 for pmu fixed_counters To: Like Xu Cc: wehuang@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20190717025118.16783-1-like.xu@linux.intel.com> From: Paolo Bonzini Openpgp: preference=signencrypt Message-ID: <20682ae6-5699-3963-318e-55a177ccd57f@redhat.com> Date: Wed, 17 Jul 2019 12:23:27 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20190717025118.16783-1-like.xu@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17/07/19 04:51, Like Xu wrote: > 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; > Queued, thanks. Paolo