linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] RDMSR before test_cpu_capacity brings about KVM warning
@ 2015-08-14 10:07 Huaitong Han
  2015-08-17 12:04 ` Alexander Shishkin
  0 siblings, 1 reply; 3+ messages in thread
From: Huaitong Han @ 2015-08-14 10:07 UTC (permalink / raw)
  To: alexander.shishkin, mingo, acme; +Cc: linux-kernel, Huaitong Han

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] RDMSR before test_cpu_capacity brings about KVM warning
  2015-08-14 10:07 [PATCH] RDMSR before test_cpu_capacity brings about KVM warning Huaitong Han
@ 2015-08-17 12:04 ` Alexander Shishkin
  2015-08-17 13:23   ` Han, Huaitong
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander Shishkin @ 2015-08-17 12:04 UTC (permalink / raw)
  To: Huaitong Han; +Cc: linux-kernel, Huaitong Han, Peter Zijlstra, mingo, acme

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] RDMSR before test_cpu_capacity brings about KVM warning
  2015-08-17 12:04 ` Alexander Shishkin
@ 2015-08-17 13:23   ` Han, Huaitong
  0 siblings, 0 replies; 3+ messages in thread
From: Han, Huaitong @ 2015-08-17 13:23 UTC (permalink / raw)
  To: alexander.shishkin; +Cc: linux-kernel, a.p.zijlstra, mingo, acme

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 1137 bytes --]

On Mon, 2015-08-17 at 15:04 +0300, Alexander Shishkin wrote:
> 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"?
KVM codes. Current KVM does not support Intel_PT. But guest kernel may
readmsr MSR_IA32_RTIT_CTL that KVM cannot understand.
Details from https://bugzilla.kernel.org/show_bug.cgi?id=102651
> 
> > 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.
I will update the commit message.
> 
> FWIW,
> 
> Reviewed-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> 
> Regards,
> --
> Alex

ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-08-17 13:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-14 10:07 [PATCH] RDMSR before test_cpu_capacity brings about KVM warning Huaitong Han
2015-08-17 12:04 ` Alexander Shishkin
2015-08-17 13:23   ` Han, Huaitong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).