Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp564382pxb; Wed, 13 Jan 2021 10:12:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJy69hKJpDpvzluXY9Pv61HomJqmhHJmh2Kh6jvG/1yIGlm9OOkJAtVeYo2pPhmkMEtat3cU X-Received: by 2002:a50:d60f:: with SMTP id x15mr2771917edi.224.1610561545133; Wed, 13 Jan 2021 10:12:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610561545; cv=none; d=google.com; s=arc-20160816; b=ky60UrqfXtlEAk+XRdiIfwlxfY7ONnSiYk90p9drBoyyRgZOfZ/uYh7IQ2FLrQPihA lgL9CK2/YCI3zlIN1cS2bSsIKOrFpKCBjtbZjCE5qkssEcQsUKZZUaxnldRgu0IYlamT 10pR46mh+knmQGodeSAZfpE7wigg0DHPIAZX9pxNdhMX5vTvZNtMVKkQCJWRX4d5NMVY 3twpfdXkVFHTPA3+thMd7uQjxujcB+RaPR9XicaLNEpLR+O1ZbakP5/D7B7k/wiKse79 PdZXqahx4spYIJclhd0lpESPdyCQMgo+vVnJDE0YWMCLE4Kvk91Gn+fzrJ5x5ds3s0iC squw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=jNibCvTx7q4DNq2LFCvJgnHxHkRHf0XgjGUF5aOVsQg=; b=OzxacqnyiL6PQ5BuTerJ2sKwsPQw35DrhUO9d6kzcW5dLVxTAIfSrT3upN7UTp5hmb WEFdlgZ0IHqgKbiPi+vhlF2lObAlZbr2MCiCqsjnF8b6GDMEvnJ6PEtWSb2/apzeS/A1 YkJukR7QgNQha4yvFKP2LFwWynpGcf3Kfqvizav8jI3e8fGnZGjGdpdQTisVmVP9DF+J DTQM4ceqVfYEyClrnh6sIo7Ci2ygz+qmBvVz2xLWHPqTBn3MwNyQVl5vtZaFthTM0Pcd hHB49ghAuFxpxlr71uNkBq5kKebriuTJQK7EV96sxhQiN0mtWo/Qn7206s99l6EWQ47w t/3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=nPh9SFDH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v13si1318422edr.464.2021.01.13.10.11.58; Wed, 13 Jan 2021 10:12:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=nPh9SFDH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728117AbhAMSJk (ORCPT + 99 others); Wed, 13 Jan 2021 13:09:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728057AbhAMSJj (ORCPT ); Wed, 13 Jan 2021 13:09:39 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 824D8C061795; Wed, 13 Jan 2021 10:08:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=jNibCvTx7q4DNq2LFCvJgnHxHkRHf0XgjGUF5aOVsQg=; b=nPh9SFDH0qvl6QN7IJFB0c5GI1 JqsCAQ2HZQVdv9513XN7ehbo/8oXe+FRG/YL9EY1MiYteYeztRRffMpXvXEfsqwDVpbF/a91kqN/G qjbEzNcB7aagKoT530bItc0fY6LOGR3e43Q6QrNpJwLy59H//jebViet5n52pXhF5gjWctcVkORx/ i8GG7MJdR3Hg1RkQiOJieeEMcrc4CMfdoCeK3emAb4mg7GUYwkTXrNtkS9wlvNHleGxWTQZm6ZJhs B3GZcJ6IGPIM/Alek4XlO4caXFXROifkRE2qDK2Ti0G8Hf8hjD1nUHL1izYjk/aJGhInqxPnuiwtY 5jtvzItQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1kzkXI-006Y9v-Th; Wed, 13 Jan 2021 18:06:51 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 6AF1C3010C8; Wed, 13 Jan 2021 19:06:20 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id ACB4620CC02C7; Wed, 13 Jan 2021 19:06:20 +0100 (CET) Date: Wed, 13 Jan 2021 19:06:20 +0100 From: Peter Zijlstra To: Like Xu Cc: Paolo Bonzini , eranian@google.com, kvm@vger.kernel.org, Ingo Molnar , Sean Christopherson , Thomas Gleixner , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Andi Kleen , Kan Liang , wei.w.wang@intel.com, luwei.kang@intel.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 03/17] KVM: x86/pmu: Introduce the ctrl_mask value for fixed counter Message-ID: References: <20210104131542.495413-1-like.xu@linux.intel.com> <20210104131542.495413-4-like.xu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210104131542.495413-4-like.xu@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 04, 2021 at 09:15:28PM +0800, Like Xu wrote: > @@ -327,6 +328,7 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu) > pmu->counter_bitmask[KVM_PMC_FIXED] = 0; > pmu->version = 0; > pmu->reserved_bits = 0xffffffff00200000ull; > + pmu->fixed_ctr_ctrl_mask = ~0ull; All 1s > > entry = kvm_find_cpuid_entry(vcpu, 0xa, 0); > if (!entry) > @@ -358,6 +360,9 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu) > ((u64)1 << edx.split.bit_width_fixed) - 1; > } > > + for (i = 0; i < pmu->nr_arch_fixed_counters; i++) > + pmu->fixed_ctr_ctrl_mask |= (0xbull << (i * 4)); With some extra 1s on top > + pmu->fixed_ctr_ctrl_mask = ~pmu->fixed_ctr_ctrl_mask; Inverted is all 0s, always. > pmu->global_ctrl = ((1ull << pmu->nr_arch_gp_counters) - 1) | > (((1ull << pmu->nr_arch_fixed_counters) - 1) << INTEL_PMC_IDX_FIXED); > pmu->global_ctrl_mask = ~pmu->global_ctrl; > -- > 2.29.2 >