Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp456702ybt; Wed, 8 Jul 2020 04:09:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxK2RrfwBI+AbIcUQfCVLfAsb2uue8LKTQKjqPhYut8a7edSSDpF5OXhuxGxJsnSs/CMPtA X-Received: by 2002:a17:906:fa9b:: with SMTP id lt27mr49819652ejb.513.1594206597856; Wed, 08 Jul 2020 04:09:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594206597; cv=none; d=google.com; s=arc-20160816; b=dJkLTDeQfnAHPpD9b15my/xjv6tyx7beMyYLltqrFI/SiiWH3d/5rW4a0FM+C+42BJ 8m7EvCV71GZg0KvrmnhnjVoSev2nHAffhKBUdNy7IJcLwiSRRbjASmZMskWAP1K0LKEB IMyz8ZLSNVZH5OpHqDvlo63RWfYY3E3jQDKljORXETWt+gP1nLUEtVWL9nKJsFpEgFCD gTF7n0ynFP66e2KvX7cOuMLXbMBxvAnHHNZbIJbLY2an8rxkz2HgwZKJLmBjmd1YNzub r+7qNGsY/p+ALv/UlsboyapC1q41sTj3ZteqSqMpS6V8+Eqvydyr91SGT+7gC92K2jP7 3mnQ== 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:from:references:cc:to:subject:dkim-signature; bh=UsTH2g5Srh8ZxaMtl2dCP3xACw/aEbSOpSitaM2tt8A=; b=Dnkd2q+EKwMWK6OQqt1sZAEJVESpyrAHuZcQR+7d1Oc9rpMrKgtPNzHajhK5ODGJ+Q 0te36SVBHmSlPjcAzr8rjDbeExn7fdnylslJ89QSMVSMtyN+CNwZVEF77f0Z6iGcXMhU OVSEQ21JrRhYGw3nJ0LNsEylGmxMKfEk+HrmwKotUiWoQUihCbyVQjBP+d9aLirWE4PB KyfBx1zyDVq4HweTqafWxfN3rWN748pRT75RbgrzkUpgrRqat+grl/eerdOT2LbfTVt6 +71tlGlTWEII3jkSzVVVh6haCbDX+nILyQTmxxPvedpJ2V2f6aHQbfxXmGu/tKAiF7pZ Sv+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dfuebEZ6; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z14si21408860edl.500.2020.07.08.04.09.35; Wed, 08 Jul 2020 04:09:57 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dfuebEZ6; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728770AbgGHLIe (ORCPT + 99 others); Wed, 8 Jul 2020 07:08:34 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:49823 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728385AbgGHLId (ORCPT ); Wed, 8 Jul 2020 07:08:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594206512; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UsTH2g5Srh8ZxaMtl2dCP3xACw/aEbSOpSitaM2tt8A=; b=dfuebEZ69Nl8u7couTN5mm/RTDEhc2SqsiKHx3p574k1YF1CtlZnSUeDqz7ZzjT5oSwfJ6 7mwHhtBoO3GKNt8OPLQa2qi3VmyNww79RaEXP/qwchJt8A1sSWDLCpnOW9+9YmXUoxrKmU T/yYaSWBTtXtgdE066jkEQPAlTu16GY= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-371-SFwAx6CiOo-yu-5zFDIr1A-1; Wed, 08 Jul 2020 07:08:30 -0400 X-MC-Unique: SFwAx6CiOo-yu-5zFDIr1A-1 Received: by mail-wr1-f69.google.com with SMTP id b8so37630879wro.19 for ; Wed, 08 Jul 2020 04:08:30 -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:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=UsTH2g5Srh8ZxaMtl2dCP3xACw/aEbSOpSitaM2tt8A=; b=p9qieC2D2b5UafoKflr85kdHnBm0i3FS/duMIRrDe9E+yUcbrplFuGwd3td/TQHYss MxPaD7kEWaW/V1levOrQnriq8AgUCvrWG5AjtstQWrkYX6ZvVU0W0VadEeMqQHHPPp5+ DmzTZg+z68lTbaXUcrLzELa/Qv3FgtgW7ic3mFPy4hSe1iE5HeanydaETSJLLSmye4gj tiqMZFz9xMrOcewODOSsKZy0yitTbArHRWl/iba4+EiaFaGXrVzj8Ysdb4NUsn1HKMAE Mis7BaNmicH/b+jv8bP1JgKejek04gN6hWqDT8pc5gZ8TXgVtFqzGsy7yLEDqY2x20gS 44Qg== X-Gm-Message-State: AOAM531/Qw9kb/cY1Dh6cjeMURit0LUzFaDtvvU8rWmoTP0wYSjmMMkN wYg98fSdeRrq7A/wh+49Pd4H33Jjrp5Fzy339tx0DiFaaNfHxlxeMf2T82rP7U4P1aQSrydgLOS DFdNYUq02rZYLl/Iz0H06whSn X-Received: by 2002:a1c:9e84:: with SMTP id h126mr8405462wme.61.1594206509465; Wed, 08 Jul 2020 04:08:29 -0700 (PDT) X-Received: by 2002:a1c:9e84:: with SMTP id h126mr8405427wme.61.1594206509215; Wed, 08 Jul 2020 04:08:29 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:9541:9439:cb0f:89c? ([2001:b07:6468:f312:9541:9439:cb0f:89c]) by smtp.gmail.com with ESMTPSA id c136sm5923589wmd.10.2020.07.08.04.08.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 Jul 2020 04:08:28 -0700 (PDT) Subject: Re: [PATCH] kvm: x86: limit the maximum number of vPMU fixed counters to 3 To: Like Xu , kvm@vger.kernel.org Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , linux-kernel@vger.kernel.org References: <20200624015928.118614-1-like.xu@linux.intel.com> From: Paolo Bonzini Message-ID: Date: Wed, 8 Jul 2020 13:08:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200624015928.118614-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 24/06/20 03:59, Like Xu wrote: > Some new Intel platforms (such as TGL) already have the > fourth fixed counter TOPDOWN.SLOTS, but it has not been > fully enabled on KVM and the host. > > Therefore, we limit edx.split.num_counters_fixed to 3, > so that it does not break the kvm-unit-tests PMU test > case and bad-handled userspace. > > Signed-off-by: Like Xu > --- > arch/x86/kvm/cpuid.c | 2 +- > arch/x86/kvm/pmu.h | 2 ++ > 2 files changed, 3 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c > index 8a294f9747aa..0a2c6d2b4650 100644 > --- a/arch/x86/kvm/cpuid.c > +++ b/arch/x86/kvm/cpuid.c > @@ -604,7 +604,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) > eax.split.bit_width = cap.bit_width_gp; > eax.split.mask_length = cap.events_mask_len; > > - edx.split.num_counters_fixed = cap.num_counters_fixed; > + edx.split.num_counters_fixed = min(cap.num_counters_fixed, MAX_FIXED_COUNTERS); > edx.split.bit_width_fixed = cap.bit_width_fixed; > edx.split.reserved = 0; > > diff --git a/arch/x86/kvm/pmu.h b/arch/x86/kvm/pmu.h > index ab85eed8a6cc..067fef51760c 100644 > --- a/arch/x86/kvm/pmu.h > +++ b/arch/x86/kvm/pmu.h > @@ -15,6 +15,8 @@ > #define VMWARE_BACKDOOR_PMC_REAL_TIME 0x10001 > #define VMWARE_BACKDOOR_PMC_APPARENT_TIME 0x10002 > > +#define MAX_FIXED_COUNTERS 3 > + > struct kvm_event_hw_type_mapping { > u8 eventsel; > u8 unit_mask; > Queued, thanks. Paolo