Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4594694pxf; Tue, 23 Mar 2021 14:53:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3/nDffTnTJRvbdIle5+0K7Upuv0Bq5czT7zssJe5rjz8AuYesP5oQV7/nM06+3KzT9whJ X-Received: by 2002:a05:6402:27d4:: with SMTP id c20mr6735663ede.271.1616536420061; Tue, 23 Mar 2021 14:53:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616536420; cv=none; d=google.com; s=arc-20160816; b=yKOXlKJ9f7Geo37dFZKi7mzvIRT1ksdv6MU4z3ngZGW8IPXZfUdNR8QijSLAXrqMnS YKSX+UcN+j8CfPwRCalhQgUZEGuZogBFJY6nmsVj0EhFVlzHbJN6yh7wnh9jMwq0jwRr OhiNWTK+3GNZmVvRkQFnY6NHvVHnyz7frrCq/7mpOZqj1M7Q64Al5rHa1Q/pY5hkVvdi p67nPFk3wLHf+tWEl1tCoCR1MI7YntjFb+5OJGiDy2Ox+vWqmxtPPnP80Jq7+6KMp9yy mRNNAZ2x9gZ3qg8cpztQTlPlcbmkT9dWpPabnvjEO5cOtJzha9Qe/5SvQ87DMtjbQEbf B0GQ== 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=mYwu2RtzgZKNU9NGCGzqzPwajfLHA9RJT8xFKj9ft30=; b=bjc3/Sz6rU4mgHte6c8MJDy66yUXCFqBtcb2byqMhshZvNAUJ4NEKra3Qm9uX+f8Un MaHfKbW4oE8IV9Ibs3npOQOuzlv8GYBM5kJdc6xgk1nz6CI7VCASmU4sGscgRABd0q7p RdZ6VaPwiItoglcnbSz+6yupreHBGp9o62SG9Btb2yQ63euw17VB/emLphgVOOaDt+it AJ44+WnsBJf7KvPgmA+F3cBovZ+kD2H22z8rICHS3W7yOMA4DJyJpN1C86iQFrP9Ae26 PA60GV4yrhuqM/LTxmtDCzBwmCGSIg0LhxWNU0BCksoNX/cv613W/fiddSMUX6Tffxoq FIsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=hGs40wJk; 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 g7si180342edb.286.2021.03.23.14.52.52; Tue, 23 Mar 2021 14:53:40 -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=@infradead.org header.s=casper.20170209 header.b=hGs40wJk; 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 S233663AbhCWVui (ORCPT + 99 others); Tue, 23 Mar 2021 17:50:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233615AbhCWVuA (ORCPT ); Tue, 23 Mar 2021 17:50:00 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 959CFC061574 for ; Tue, 23 Mar 2021 14:50:00 -0700 (PDT) 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=mYwu2RtzgZKNU9NGCGzqzPwajfLHA9RJT8xFKj9ft30=; b=hGs40wJkP4sjmJs6jHLMVtmpaP 467+h70F6SkcwaImgB6TNqmKJrQu42ZfHLzwKwG47x0mluF/NH0Up/DZclQCgIBg4z/icSmi22Rdi 3q3e1rqRGTDwAg7U0WWgJZNw8xrBNu3JNrC0XMtQYYeU7qEenc8i6zt16N8JrC1CaXlbrQJNxe0xS kZnzOqqedPxFSHLArCWfkCMA4G+0HcfpBy7VDe/n/s6ggzn/OTPjn3KYYh1HXqee0tzjpZiNhtJXL 8XtmSDkWHqmdgr8eqkO/LJK+/MpogGGYjT7J50b+cUFxliIOpoPk5SjAvpMmApW1+fXmr7oIhzf6J EjDkCldA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lOou8-00AZjj-3I; Tue, 23 Mar 2021 21:49:39 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 376279864F6; Tue, 23 Mar 2021 22:49:35 +0100 (CET) Date: Tue, 23 Mar 2021 22:49:35 +0100 From: Peter Zijlstra To: Like Xu Cc: Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Borislav Petkov , Kan Liang , x86@kernel.org, linux-kernel@vger.kernel.org, Andi Kleen Subject: Re: [PATCH v4 RESEND 4/5] perf/x86/lbr: Skip checking for the existence of LBR_TOS for Arch LBR Message-ID: <20210323214935.GF4746@worktop.programming.kicks-ass.net> References: <20210322060635.821531-1-like.xu@linux.intel.com> <20210322060635.821531-5-like.xu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210322060635.821531-5-like.xu@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 22, 2021 at 02:06:34PM +0800, Like Xu wrote: > The Architecture LBR does not have MSR_LBR_TOS (0x000001c9). KVM will > generate #GP for this MSR access, thereby preventing the initialization > of the guest LBR. > > Fixes: 47125db27e47 ("perf/x86/intel/lbr: Support Architectural LBR") > Signed-off-by: Like Xu > Reviewed-by: Kan Liang > Reviewed-by: Andi Kleen > --- > arch/x86/events/intel/core.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c > index 382dd3994463..7f6d748421f2 100644 > --- a/arch/x86/events/intel/core.c > +++ b/arch/x86/events/intel/core.c > @@ -5740,7 +5740,8 @@ __init int intel_pmu_init(void) > * Check all LBR MSR here. > * Disable LBR access if any LBR MSRs can not be accessed. > */ > - if (x86_pmu.lbr_nr && !check_msr(x86_pmu.lbr_tos, 0x3UL)) > + if (x86_pmu.lbr_nr && !boot_cpu_has(X86_FEATURE_ARCH_LBR) && > + !check_msr(x86_pmu.lbr_tos, 0x3UL)) > x86_pmu.lbr_nr = 0; But when ARCH_LBR we don't set lbr_tos, so we check MSR 0x000, not 0x1c9. Do we want check_msr() to ignore msr==0 ? Additionally, do we want a check for lbr_info ? > for (i = 0; i < x86_pmu.lbr_nr; i++) { > if (!(check_msr(x86_pmu.lbr_from + i, 0xffffUL) && > -- > 2.29.2 >