Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp3403695ybk; Tue, 19 May 2020 03:55:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8eNltWIcDmQmKas98CLJyHYqUGDZIhWPXvN3B2xggoed8CjlRT97SMxanBUiSwhmZEECk X-Received: by 2002:a50:9f85:: with SMTP id c5mr17668646edf.72.1589885752938; Tue, 19 May 2020 03:55:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589885752; cv=none; d=google.com; s=arc-20160816; b=Kv4/N+p1hH8F4haWzl/+q7TDMHLv1vf9Q8HzLJVe1wsu8Jy7RBE8qTDuEfdNdR9m7E oclbOEJzB91POfi8HZN/6gKYaPDTjrwR8i72JgXasL8dgNU5Nz+PTRIeIpYTymHR96bR tIsDbTDOkla3SQm2fY4CWearVJLTuIjCLJx50D0C81cxIS/B8XB+ulBX5gCKJNpC3WCb 5U+3A3RFltkuJNZxyY790+gA5tDbVHhoQcc7BIokDrFVuYhILRZ7AZw5T4W+Qhw2Mvt2 9jWUF57PxLDsKXfReL9/4lXbMbU7nrfcHwmgDlv2svWSs9LXf1y68NV/jgoSxoDAlF1O wKsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=L/mR8vOE2/C4uXbuHUIpvj8AhD8h9hJmK8FIwWqfLoo=; b=OJoftL7ZhGggQcxk8GnoNk3PP9L0pUO+qmWiJzlgw9sc8sWse8+S5hGEPr7YoHrYjK L4nOi2/U4Rwtw+ngP7jaV71Dw73AEai91zpuk+CU26oGXjq78vje0qS9NVZfgnfkzsue rfHR1sDq+0N+EAopGkiha5gr8fyokc8tI0lCPtM3YzheBYrIHHHpIKvnOoU0sXH5jQ+x oyobGBVRl2UWGkE/hfJo5EYI9g6ivhCrDfS+x/fNWVrthDMMLSGOe/SpWYoOWtveWOZF RYvb15W6e6z5X7tghbusP24qPBkY/ywimxyViVU3HU9upRuKcxuRoiqls0RZi//rTvP7 VSfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=DowyvbiF; 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 r1si4709786ejs.406.2020.05.19.03.55.30; Tue, 19 May 2020 03:55:52 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=DowyvbiF; 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 S1728654AbgESKxq (ORCPT + 99 others); Tue, 19 May 2020 06:53:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726121AbgESKxp (ORCPT ); Tue, 19 May 2020 06:53:45 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9732C061A0C; Tue, 19 May 2020 03:53:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=L/mR8vOE2/C4uXbuHUIpvj8AhD8h9hJmK8FIwWqfLoo=; b=DowyvbiFDd1nuuW79qrugnsmKj W7/5XeFIyXvVjQZXn4ztxJda1TDBWKbEm/MuLiK5Q/M+OtTneDrrrxbOaU5oDENJB0nA9vm4zBahz bRlSRqPvctUD0X7j/wrDZMGzO1JMxGMqU/OESm19sx+/0VLGPAYhuwO8gIjoNeBXqXtu1vE83QPqn m2V9GZXCw1h8jitvI/t9nP7UAbIThrCbIVV8OX8FkQbXZupX4rTn3XCV7vuaLkWbpaCNnXDJvZ+0x XG0npnDpq9BbCeEaqXK/S9fvTUoGeVOIIUxeVdH50hy6nVuokgVM+YAIzqjpRlz8G3abK10N8Pilt JngH84IA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jazsQ-0001f1-6p; Tue, 19 May 2020 10:53:38 +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 F3C463008A8; Tue, 19 May 2020 12:53:35 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id DF7202868A9D5; Tue, 19 May 2020 12:53:35 +0200 (CEST) Date: Tue, 19 May 2020 12:53:35 +0200 From: Peter Zijlstra To: Like Xu Cc: Paolo Bonzini , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , ak@linux.intel.com, wei.w.wang@intel.com Subject: Re: [PATCH v11 07/11] KVM: x86: Expose MSR_IA32_PERF_CAPABILITIES for LBR record format Message-ID: <20200519105335.GF279861@hirez.programming.kicks-ass.net> References: <20200514083054.62538-1-like.xu@linux.intel.com> <20200514083054.62538-8-like.xu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200514083054.62538-8-like.xu@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 14, 2020 at 04:30:50PM +0800, Like Xu wrote: > @@ -203,6 +206,12 @@ static int intel_pmu_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) > case MSR_CORE_PERF_GLOBAL_OVF_CTRL: > msr_info->data = pmu->global_ovf_ctrl; > return 0; > + case MSR_IA32_PERF_CAPABILITIES: > + if (!msr_info->host_initiated && > + !guest_cpuid_has(vcpu, X86_FEATURE_PDCM)) > + return 1; I know this is KVM code, so maybe they feel differently, but I find the above indentation massively confusing. Consider using: "set cino=:0(0" if you're a vim user. > + msr_info->data = vcpu->arch.perf_capabilities; > + return 0; > default: > if ((pmc = get_gp_pmc(pmu, msr, MSR_IA32_PERFCTR0))) { > u64 val = pmc_read_counter(pmc); > @@ -261,6 +270,16 @@ static int intel_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) > return 0; > } > break; > + case MSR_IA32_PERF_CAPABILITIES: > + if (!msr_info->host_initiated || > + !guest_cpuid_has(vcpu, X86_FEATURE_PDCM)) > + return 1; Idem. > + if (!(data & ~vmx_get_perf_capabilities())) > + return 1; > + if ((data ^ vmx_get_perf_capabilities()) & PERF_CAP_LBR_FMT) > + return 1; > + vcpu->arch.perf_capabilities = data; > + return 0; > default: > if ((pmc = get_gp_pmc(pmu, msr, MSR_IA32_PERFCTR0))) { > if (!msr_info->host_initiated)