Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp751750pxy; Wed, 21 Apr 2021 14:12:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdiUEuoTDDRqnL5CdUV3PWBJZvPqGio6oUeFHA652z5d4658/SQtDMMa+L1XRmIHwI2rUZ X-Received: by 2002:a17:906:c44f:: with SMTP id ck15mr15545934ejb.269.1619039577677; Wed, 21 Apr 2021 14:12:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619039577; cv=none; d=google.com; s=arc-20160816; b=X3YWNkXtfmabwk22eZKmRDPH1mRnWnDQIDZJBK6nwFxgjrD0C447sd1oSHzFc4MipP St5KR3ALZNmC55biYRsgmX6XuzmCt83YApxPEMhS5mOtLrL4QwEklSmEkgrvih68DH1x XANOWTrf4ywvpurel9WIcfq4zemE1LQ+N8heQspUj3eRIC8VtlMLd4NkM08ScXOE1UHx cmZYnXpxXDcZvKNQG7URMLNEFgZKro1h1MoLTvqhc8CgQwnlwmijBBsHo2FQK3RWnAbZ l5O5BgQ2RNWdZpke3Q/h7Ju95OCHVQoOvd2YxOKvwa/ybRIZI/aSOZEZQQFJMofrVuwf 7s8w== 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=66B2gxSRDO1UhRSlUXQqaq82UG5jc0B6v7Wq///8Fvg=; b=aP2AE6yLsO90mqEE2dUNLAtviOczjnm5c1Tk2IUjtJCQRs9xdXNNdHMET1JyUPLnYh TiE9h/7jMglD1jmRkYe04iVr0dcJAqsuuXVASj275w5sAEbP+USyHDFcAxYPVcSJnjVB zq5kYMiofXAkPf6AUd0y0hPe8+FMLIyVfZ/Bl3AeuHcGDPAUe46qsJ8BSWPh2L91K9V1 6u7nPDAbzAscye2PP0HpPy+jZM4h+4mzWf3w1wq5yw7b+Wv8WLaaowIAwvGlBSOrmey1 TlEpbsJpv9SCfUQuELhjMiikujFc2o9tAKs0g1YlQNFfVHXJtlHiMaYXaoQYf1Vj6WSA unXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=aKHS4AS8; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d26si476325edr.392.2021.04.21.14.12.34; Wed, 21 Apr 2021 14:12: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=@google.com header.s=20161025 header.b=aKHS4AS8; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240703AbhDUPay (ORCPT + 99 others); Wed, 21 Apr 2021 11:30:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238526AbhDUPay (ORCPT ); Wed, 21 Apr 2021 11:30:54 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D682C06174A for ; Wed, 21 Apr 2021 08:30:21 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id p16so17892886plf.12 for ; Wed, 21 Apr 2021 08:30:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=66B2gxSRDO1UhRSlUXQqaq82UG5jc0B6v7Wq///8Fvg=; b=aKHS4AS8T9TbS2RDVl2a39inxJIvy5TRJQWJvYPBPe3iknI6pZaZRtS2/UEBRHKuRm 4hknkmpa9H5yuBbSYa0dLPRJ7hmWXfIpHHN+QyLYNJBWtxpmtse2lKv4UpU9Rf36h0Pd X3qnS7WzG4fFtNmGnWPC91GqbCVAKzLwso5GASOHQe8O1u/CQo15Y/T7ao2nWW7nBd5h CcYrQlRFHGIsdFsXTOdrfFf8pCv67JVQSm0yxQjLPg2Kt9JSfQzeZWYk0JFK83Eij9DM 7G/R+glTe0LNWf48jSNVMsFubwPSYHYPbHQuMeUg+bPVq3dcEKtOm5QAwgc3fWIaJezc vCog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=66B2gxSRDO1UhRSlUXQqaq82UG5jc0B6v7Wq///8Fvg=; b=ebyHCMc3dMgLuaM3/TIuN+2KEp4cp7yGN/HFAQ9mIDAsAOVIfgneR8ttGpCmcdpoH7 cJvdKd0K+OTn4NkboonXoZOv2lklV9G6kQH241T3G10ar1+AWEreaREGm5G5SuCU+O+B 1hpYE6TUQmnQENAuYpjzyI2T+B4qteBOVk8P3Mh6sbllgTbHSe3tcGktvlE2COk9vTRP jKb9wb9IoEEgK13tzo8NJ08hZtMcVQcqMcGkGp2NMiPWN5zLRRhHU37OWuJIEh3+9hI6 lNtrYhror7uimc4vytcIfCvCGazb4vcpylnvwADO5ECygLqovHF3oMU1FtrXtlkaYuE2 mypA== X-Gm-Message-State: AOAM5307enZXh3gpKBy47xYCazoNCHlUek6PZBJfnWJGy+xXCrI4RGm1 81pZfScdSPFot2ZeuAe3mWpDgw== X-Received: by 2002:a17:902:7689:b029:eb:3d5f:ae58 with SMTP id m9-20020a1709027689b02900eb3d5fae58mr34072360pll.39.1619019020641; Wed, 21 Apr 2021 08:30:20 -0700 (PDT) Received: from google.com (240.111.247.35.bc.googleusercontent.com. [35.247.111.240]) by smtp.gmail.com with ESMTPSA id 195sm2091418pfy.194.2021.04.21.08.30.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Apr 2021 08:30:19 -0700 (PDT) Date: Wed, 21 Apr 2021 15:30:16 +0000 From: Sean Christopherson To: Like Xu Cc: Peter Zijlstra , Kan Liang , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Borislav Petkov , x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH RESEND 1/2] perf/x86: Skip checking MSR for MSR 0x0 Message-ID: References: <20210421021825.37872-1-like.xu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210421021825.37872-1-like.xu@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 21, 2021, Like Xu wrote: > The Architecture LBR does not have MSR_LBR_TOS (0x000001c9). > When ARCH_LBR we don't set lbr_tos, the failure from the > check_msr() against MSR 0x000 will make x86_pmu.lbr_nr = 0, > 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 > --- > arch/x86/events/intel/core.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c > index 5272f349dca2..5036496caa60 100644 > --- a/arch/x86/events/intel/core.c > +++ b/arch/x86/events/intel/core.c > @@ -4751,10 +4751,10 @@ static bool check_msr(unsigned long msr, u64 mask) > u64 val_old, val_new, val_tmp; > > /* > - * Disable the check for real HW, so we don't > + * Disable the check for real HW or non-sense msr, so we don't I think this should be "undefined MSR" or something along those lines. MSR 0x0 is a "real" MSR, on Intel CPUs it's an alias for IA32_MC0_ADDR; at least it's supposed to be, most/all Intel CPUs incorrectly alias it to IA32_MC0_CTL. Anyways, my point is that if your definition of "nonsense" is any MSR that is not a valid perf MSR, then this check is woefully incompletely. If your definition is a nonsensical value, then this comment is simply wrong. What you're really looking for is precisely the case where the MSR was zero initialized and never defined. > * mess with potentionaly enabled registers: > */ > - if (!boot_cpu_has(X86_FEATURE_HYPERVISOR)) > + if (!boot_cpu_has(X86_FEATURE_HYPERVISOR) || !msr) > return true; > > /* > -- > 2.30.2 >