Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1207460 > unrolled thread

[PATCH] RDMSR before test_cpu_capacity brings about KVM warning

Started byHuaitong Han <huaitong.han@intel.com>
First post2015-08-14 12:10 +0200
Last post2015-08-17 15:30 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] RDMSR before test_cpu_capacity brings about KVM warning Huaitong Han <huaitong.han@intel.com> - 2015-08-14 12:10 +0200
    Re: [PATCH] RDMSR before test_cpu_capacity brings about KVM warning Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2015-08-17 14:10 +0200
      Re: [PATCH] RDMSR before test_cpu_capacity brings about KVM warning "Han, Huaitong" <huaitong.han@intel.com> - 2015-08-17 15:30 +0200

#1207460 — [PATCH] RDMSR before test_cpu_capacity brings about KVM warning

FromHuaitong Han <huaitong.han@intel.com>
Date2015-08-14 12:10 +0200
Subject[PATCH] RDMSR before test_cpu_capacity brings about KVM warning
Message-ID<pXk5X-7mp-5@gated-at.bofh.it>
rdmsrl_safe does not lead to #GP in native kernel although CPU
does not support INTEL_PT, but if KVM does not support INTEL_PT,
the codes cannot understand MSR_IA32_RTIT_CTL, and the warning
is produced.

If KVM does not support INTEL_PT, its guest CPUID also does not.
So test_cpu_cap is added before RDMSR, and it is more in line with
the code style.

Signed-off-by: Huaitong Han <huaitong.han@intel.com>

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;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1208561

FromAlexander Shishkin <alexander.shishkin@linux.intel.com>
Date2015-08-17 14:10 +0200
Message-ID<pYroK-6RF-23@gated-at.bofh.it>
In reply to#1207460
Huaitong Han <huaitong.han@intel.com> writes:

> rdmsrl_safe does not lead to #GP in native kernel although CPU
> does not support INTEL_PT, but if KVM does not support INTEL_PT,
> the codes cannot understand MSR_IA32_RTIT_CTL, and the warning
> is produced.

"the codes"?

> If KVM does not support INTEL_PT, its guest CPUID also does not.
> So test_cpu_cap is added before RDMSR, and it is more in line with
> the code style.

It does make more sense like this, but please improve this commit
message. And don't forget to include Peter in the loop.

FWIW,

Reviewed-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>

Regards,
--
Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1208592

From"Han, Huaitong" <huaitong.han@intel.com>
Date2015-08-17 15:30 +0200
Message-ID<pYsEb-8i-27@gated-at.bofh.it>
In reply to#1208561
T24gTW9uLCAyMDE1LTA4LTE3IGF0IDE1OjA0ICswMzAwLCBBbGV4YW5kZXIgU2hpc2hraW4gd3Jv
dGU6DQo+IEh1YWl0b25nIEhhbiA8aHVhaXRvbmcuaGFuQGludGVsLmNvbT4gd3Jp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1pdCBtZXNzYWdlLg0KPiANCj4gRldJVywNCj4gDQo+IFJldmlld2Vk
LWJ5OiBBbGV4YW5kZXIgU2hpc2hraW4gPGFsZXhhbmRlci5zaGlzaGtpbkBsaW51eC5pbnRlbC5j
b20+DQo+IA0KPiBSZWdhcmRzLA0KPiAtLQ0KPiBBbGV4DQoNCg==
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web