Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp10294pxy; Thu, 29 Apr 2021 22:27:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIvL13QLUQCHMjnO2SkhgUswlpHbeBLoRu3HLMQaPOnHaBFrXvV6BP6BOWrlKFytmaS2og X-Received: by 2002:a63:2542:: with SMTP id l63mr3312048pgl.128.1619760425815; Thu, 29 Apr 2021 22:27:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619760425; cv=none; d=google.com; s=arc-20160816; b=quw3HIxfiGHwloP+1AA+foQjTcDwlUGzn4PgIrXLLBMPAViZrHEc0uAurNEyHeC1+U UtztFTnp5kOESwFye7hwhrNrpv51XJAiRRo5tQTePdQurbD1RIYGgmfyxJiID4eCcS1J QYZnMBxBuc3O9jpAj34c5wWqrP7u5qpAa8cNgew2NRZqzRmJTZHvLyU4MJfKHC7T/I2S hJGMXaa51wA4K8rov5tU5NnRUh1uXV2180pqLWH1ixKHpZRyFcYo+ge6k5AgHKJYgaig ScerXUT6ts80igJmCQeYksg4qbO12vU6AB5znmk8yq23q6vyg9oP3MmnESeM4RdS3+7y Az/A== 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 :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=ZHCbB22mbFuOp2VrdLvUkyjwVMmI/hO74lekr//mZ00=; b=kY2+3wDGh5oneS5wKIHGW/9IMEVcj43XppEfJiRbnPV3ZYsBsvSQGHPNzvlJ8nnN1/ qM1GUlmohiRQdZL74PMd8/3bBek7LtlDtfc0b8SSD9RX1jGjRaN4Ma4jTDdsNpGH1nR/ iQNudI+uKJjM4Jfidm/D1m9fPnV5PqJwZSvT5uvOxFbOfQylkosRbHhDAhJRnZzCZLBu hRI0R+C4UeXM8cDKV4Hi5NuqdwryKahJWpvwKW06RCZWXUR7U5MrjoVCnI/KxUwBwc/M LquqAirFsX2IrJEvG2y4nLuH0D/8+J8fQPH4q7obMl22LE8AjikKEgkJmpe2aw1LXJ7j NoZg== 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 e23si1724921pgl.20.2021.04.29.22.26.38; Thu, 29 Apr 2021 22:27:05 -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 S230092AbhD3FYL (ORCPT + 99 others); Fri, 30 Apr 2021 01:24:11 -0400 Received: from mga05.intel.com ([192.55.52.43]:54053 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230085AbhD3FYJ (ORCPT ); Fri, 30 Apr 2021 01:24:09 -0400 IronPort-SDR: YoYAlgmiRhSYUwZXsiO/g7VnOoirSKSzSd5ka8lav05m7ZXUncZz82QxjVj8Yk16+S/edrCoBP 4armm7Z31YAg== X-IronPort-AV: E=McAfee;i="6200,9189,9969"; a="282543268" X-IronPort-AV: E=Sophos;i="5.82,260,1613462400"; d="scan'208";a="282543268" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2021 22:23:18 -0700 IronPort-SDR: APR3BpjXAr3DUNOrnyYgzaB1XLIscEEqLdhTqxozXLMjODMjMn0P0Kb1punqxqjPCExtHaQka/ rEbSOh72z+hg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,260,1613462400"; d="scan'208";a="527506049" Received: from clx-ap-likexu.sh.intel.com ([10.239.48.108]) by fmsmga001.fm.intel.com with ESMTP; 29 Apr 2021 22:23:15 -0700 From: Like Xu To: Peter Zijlstra Cc: Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org, Kan Liang , Borislav Petkov , seanjc@google.com, x86@kernel.org, Like Xu Subject: [PATCH v2 1/2] perf/x86: Skip checking if 0x0 MSR exists for guest Arch LBR Date: Fri, 30 Apr 2021 13:22:46 +0800 Message-Id: <20210430052247.3079672-1-like.xu@linux.intel.com> X-Mailer: git-send-email 2.30.2 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). In a guest that should support Architecture LBR, check_msr() will be a non-related check for the architecture MSR 0x0 (IA32_P5_MC_ADDR) that is also not supported by KVM. The failure will cause x86_pmu.lbr_nr = 0, thereby preventing the initialization of the guest Arch LBR. Fix it by avoiding this extraneous check in intel_pmu_init() for Arch LBR. Fixes: 47125db27e47 ("perf/x86/intel/lbr: Support Architectural LBR") Signed-off-by: Like Xu --- v1->v2 Changelog: - Avoid checking unrelated Architecture MSR 0x0 in a simple way 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 5272f349dca2..456aa6ffd9a1 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -6250,7 +6250,8 @@ __init int intel_pmu_init(void) * Check all LBT 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 && !static_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.30.2