From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752801AbbHaIV3 (ORCPT ); Mon, 31 Aug 2015 04:21:29 -0400 Received: from mga03.intel.com ([134.134.136.65]:29783 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751883AbbHaIV1 (ORCPT ); Mon, 31 Aug 2015 04:21:27 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,439,1437462000"; d="scan'208";a="635309054" From: Huaitong Han To: a.p.zijlstra@chello.nl, mingo@redhat.com, acme@kernel.org Cc: linux-kernel@vger.kernel.org, alexander.shishkin@linux.intel.com, Huaitong Han Subject: [PATCH] perf/x86/intel/pt: rdmsr before the CPUID test produces KVM warning Date: Mon, 31 Aug 2015 16:21:02 +0800 Message-Id: <1441009262-9792-1-git-send-email-huaitong.han@intel.com> X-Mailer: git-send-email 2.4.3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If KVM does not support INTEL_PT, guest MSR_IA32_RTIT_CTL reading will produce host warning like "kvm [2469]: vcpu0 unhandled rdmsr: 0x570". Guest can determine whether the CPU supports Intel_PT according to CPUID, so test_cpu_cap function is added before rdmsr,and it is more in line with the code style. Signed-off-by: Huaitong Han Reviewed-by: Alexander Shishkin diff --git a/arch/x86/kernel/cpu/perf_event_intel_pt.c b/arch/x86/kernel/cpu/perf_event_intel_pt.c index 183de71..4cc6492 100644 --- a/arch/x86/kernel/cpu/perf_event_intel_pt.c +++ b/arch/x86/kernel/cpu/perf_event_intel_pt.c @@ -123,9 +123,6 @@ static int __init pt_pmu_hw_init(void) long i; attrs = NULL; - ret = -ENODEV; - if (!test_cpu_cap(&boot_cpu_data, X86_FEATURE_INTEL_PT)) - goto fail; for (i = 0; i < PT_CPUID_LEAVES; i++) { cpuid_count(20, i, @@ -1061,6 +1058,10 @@ static __init int pt_init(void) int ret, cpu, prior_warn = 0; BUILD_BUG_ON(sizeof(struct topa) > PAGE_SIZE); + + if (!test_cpu_cap(&boot_cpu_data, X86_FEATURE_INTEL_PT)) + return -ENODEV; + get_online_cpus(); for_each_online_cpu(cpu) { u64 ctl; -- 2.4.3