Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1598306pxj; Wed, 19 May 2021 09:26:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkD8d6F91Wvu1y6ERT2peN/baLKhTM5hKeylHRgifpweGs0NiK2nqyBsJ1GdVPESgsVOOZ X-Received: by 2002:aa7:d786:: with SMTP id s6mr15406025edq.239.1621441564688; Wed, 19 May 2021 09:26:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621441564; cv=none; d=google.com; s=arc-20160816; b=KL+ftGkqVuzVQS5EsnhcaPsGFE0tM9z65B5GsV6r3wj7a6jNkTP8qEIQpQgMFPvhf5 DNtt4ZZJt+0dpTKzCFRHyV6jZ9hgqbu2b7YnVhoiT044jC2zMbxiBVDTzIythrVFi8Dm zlWlZowudqn8bx2cHmLKsbu/NTJI7UJwwg4lITPClvCY4MN5r9UNOBXzxbRysMqtKQqM fywKR/Kta8/JXHlXqz4fVk80yygJnLxgAhh+RMWeVCzJZuNhStZrDqOylHOKxvzkQq5P /JVKFaFrZqgisol/fEEtZm45gy44qrGEMvdjOCovPZ5tfRkF4/0GAu6LyCEasoZm4q71 q3DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=aS1+LAICVOrBDmfJPI6lvgopKP/OKpuUOdIVCI8VNA8=; b=wmx60OJUNI6sMxAkQRQJ4DXinFXQrN3qiCncxgvEbtjmS5OezRmu9hgN5OxmIEh3+z 0tDAThmX4Cw2LpClATDFGFKVDgEqODvc0+yoTolhc4PmGymAlz8F8Tn3aMDYNBgGwonI DF6zL2yGs9lkTprksz+VWcoAXbGVTFDRm7Yu6QcM2A6cTYfoo2N+7MVsuqyHO33HsrrX 9HCJzDojbrrrCSSluWy58sdc8cvvrL78IVLJO+/CdpwA0hOCi6wGVaDZPlLT0IIRIUHS DoW2N38z0k09i2RoB1SeiJOo2bFxh+dSKcvYXYmKtzyvwAtkFdHOM0BMiGeyKnPL7wkj JUVw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hb7si148525ejc.507.2021.05.19.09.25.40; Wed, 19 May 2021 09:26:04 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347339AbhERH4s (ORCPT + 99 others); Tue, 18 May 2021 03:56:48 -0400 Received: from mga11.intel.com ([192.55.52.93]:6291 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240382AbhERH4p (ORCPT ); Tue, 18 May 2021 03:56:45 -0400 IronPort-SDR: +eEq+CNmZg2mxrVjHuEGKSAPritqby+sEJxal9wB5E9RNhhKirkMXKV+JBI8KR9jHeaEN9LuUb VEaCpjp0vocw== X-IronPort-AV: E=McAfee;i="6200,9189,9987"; a="197567722" X-IronPort-AV: E=Sophos;i="5.82,309,1613462400"; d="scan'208";a="197567722" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2021 00:55:20 -0700 IronPort-SDR: /3B3uMeIMrkmVOQIwdCVW1cvukL66BLkMbptcCsQwVGKmkQKzhUzHtQNgGSy6T0w+DcFjRl1Bn KgbXL8rshUBA== X-IronPort-AV: E=Sophos;i="5.82,309,1613462400"; d="scan'208";a="472830856" Received: from likexu-mobl1.ccr.corp.intel.com (HELO [10.238.4.93]) ([10.238.4.93]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2021 00:55:15 -0700 Subject: Re: [PATCH v6 05/16] KVM: x86/pmu: Introduce the ctrl_mask value for fixed counter To: Peter Zijlstra Cc: Paolo Bonzini , Borislav Petkov , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , weijiang.yang@intel.com, Kan Liang , ak@linux.intel.com, wei.w.wang@intel.com, eranian@google.com, liuxiangdong5@huawei.com, linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org, Like Xu References: <20210511024214.280733-1-like.xu@linux.intel.com> <20210511024214.280733-6-like.xu@linux.intel.com> From: "Xu, Like" Message-ID: <1fb87ea1-d7e6-0ca3-f3ed-4007a7e5a7d7@intel.com> Date: Tue, 18 May 2021 15:55:13 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/5/17 16:18, Peter Zijlstra wrote: > On Tue, May 11, 2021 at 10:42:03AM +0800, Like Xu wrote: >> The mask value of fixed counter control register should be dynamic >> adjusted with the number of fixed counters. This patch introduces a >> variable that includes the reserved bits of fixed counter control >> registers. This is needed for later Ice Lake fixed counter changes. >> >> Co-developed-by: Luwei Kang >> Signed-off-by: Luwei Kang >> Signed-off-by: Like Xu >> --- >> arch/x86/include/asm/kvm_host.h | 1 + >> arch/x86/kvm/vmx/pmu_intel.c | 6 +++++- >> 2 files changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h >> index 55efbacfc244..49b421bd3dd8 100644 >> --- a/arch/x86/include/asm/kvm_host.h >> +++ b/arch/x86/include/asm/kvm_host.h >> @@ -457,6 +457,7 @@ struct kvm_pmu { >> unsigned nr_arch_fixed_counters; >> unsigned available_event_types; >> u64 fixed_ctr_ctrl; >> + u64 fixed_ctr_ctrl_mask; >> u64 global_ctrl; >> u64 global_status; >> u64 global_ovf_ctrl; >> diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c >> index d9dbebe03cae..ac7fe714e6c1 100644 >> --- a/arch/x86/kvm/vmx/pmu_intel.c >> +++ b/arch/x86/kvm/vmx/pmu_intel.c >> @@ -400,7 +400,7 @@ static int intel_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) >> case MSR_CORE_PERF_FIXED_CTR_CTRL: >> if (pmu->fixed_ctr_ctrl == data) >> return 0; >> - if (!(data & 0xfffffffffffff444ull)) { >> + if (!(data & pmu->fixed_ctr_ctrl_mask)) { > Don't we already have hardware with more than 3 fixed counters? Yes, so we update this mask based on the value of pmu->nr_arch_fixed_counters: +    for (i = 0; i < pmu->nr_arch_fixed_counters; i++) +        pmu->fixed_ctr_ctrl_mask &= ~(0xbull << (i * 4)); I assume this comment will not result in any code changes for this patch.