Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp2709166pxf; Sun, 14 Mar 2021 09:02:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3lDRg6WZZ43uXWdmmvwpyQGc16Au+fiSCwGM/q3tkOK7FfiXGTHVzWNsrtUlXUq+eENuK X-Received: by 2002:a17:906:5797:: with SMTP id k23mr19643994ejq.515.1615737760963; Sun, 14 Mar 2021 09:02:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615737760; cv=none; d=google.com; s=arc-20160816; b=OqzK+d00u0pTr3fjbRoDD0NXpaU9RPA3y8GL+LEAu9pYZNJb1g3qzcMnWaQ1zDnH9c INxSwRF7JcjETrM5C5gDY/fgm497aB9N/GomLpkIT+0Hoj0zXNWW0BIgsENPY7pbUu3/ 5C+fnfa2SMQPoRuV/ZeJZoz9GCHkrSN60VmpXPM617Zklk7cz8BlVGA2NILefOyKcU+k bPQt4U2ywoKDIYadmYn4pa01h3hg9n4THff/3OmwDvF92Tdw1toNVGMGBvGqj3JaQJ1L aDebvM8/s4le2qpyylViykbRxI2XimiZ9wKpo+XZkmuy0rgRlR3QqHgazbx3PJVu59Yj y50A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=MQ5eEXMeWz83euPpKhSUSozPp2C1MAcwGlS79prfRbI=; b=DJObaBGTU212aMBJVD/xTKo9C9n+6UoB7ux/syn1/z2LhGPmAjyfNDCI2HEUQ4+qpH uZnHoFt6hV5VqAYdHF1LAhZMubd8ck5Q57ijUrwiZF5r5N4OQJIhC5s5BzXgG8pWRH2U 3NQ64tP8xQgB0nPvfVUw1+wTuIHozkUCKmSB5R9OL6TVk4vtE7C7I6n0c1WZhDPYq4q9 isyTi2Jln48iRyN7yvtWWgTyeJ8L+1oHOLaMCIlV291F1L0R5wd2CI9zKRFvvurno5Hi xG+zuO9vYsDs8ztz4jtse/cT2KkjDQRFp9rPRojtGdakYIwDNL09Y5OBW2d/vJrJm35P mlTA== 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 kk8si9038995ejc.404.2021.03.14.09.02.19; Sun, 14 Mar 2021 09:02: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; 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 S234430AbhCNQBU (ORCPT + 99 others); Sun, 14 Mar 2021 12:01:20 -0400 Received: from mga14.intel.com ([192.55.52.115]:7144 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234055AbhCNQAe (ORCPT ); Sun, 14 Mar 2021 12:00:34 -0400 IronPort-SDR: e9OoYv1lSk68Q4SFXlo0XYEV5XkcaCgZ32zSwx2Z5MrFMlXHOBwvT4FMWFocWQovO2by5iKTe7 pG4IZmVfNUCQ== X-IronPort-AV: E=McAfee;i="6000,8403,9923"; a="188360700" X-IronPort-AV: E=Sophos;i="5.81,248,1610438400"; d="scan'208";a="188360700" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Mar 2021 09:00:34 -0700 IronPort-SDR: TzFY1PShlwmlYWWb27cNqY1xn9i//P14d4JXGr+6/iIw9So1MgzD+45QG+5PuSBWS1cUdFKQbu QpYebQC5X2kw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,248,1610438400"; d="scan'208";a="439530637" Received: from clx-ap-likexu.sh.intel.com ([10.239.48.108]) by FMSMGA003.fm.intel.com with ESMTP; 14 Mar 2021 09:00:31 -0700 From: Like Xu To: Paolo Bonzini , Sean Christopherson Cc: Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, x86@kernel.org, wei.w.wang@intel.com, linux-kernel@vger.kernel.org, Like Xu , Kan Liang , Peter Zijlstra , Borislav Petkov , Ingo Molnar , Andi Kleen Subject: [PATCH v4 03/11] perf/x86/lbr: Skip checking for the existence of LBR_TOS for Arch LBR Date: Sun, 14 Mar 2021 23:52:16 +0800 Message-Id: <20210314155225.206661-4-like.xu@linux.intel.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210314155225.206661-1-like.xu@linux.intel.com> References: <20210314155225.206661-1-like.xu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Cc: Kan Liang Cc: Peter Zijlstra Cc: Borislav Petkov Cc: Ingo Molnar 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 7bb96ac87615..0338e354826d 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -5568,7 +5568,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; for (i = 0; i < x86_pmu.lbr_nr; i++) { if (!(check_msr(x86_pmu.lbr_from + i, 0xffffUL) && -- 2.29.2