* [PATCH] perf/x86: fix RAPL rdmsrl_safe() usage
@ 2014-04-23 17:04 Stephane Eranian
2014-04-23 19:00 ` Borislav Petkov
2014-04-24 8:03 ` [tip:perf/urgent] perf/x86: Fix " tip-bot for Stephane Eranian
0 siblings, 2 replies; 5+ messages in thread
From: Stephane Eranian @ 2014-04-23 17:04 UTC (permalink / raw)
To: linux-kernel; +Cc: peterz, mingo, venkateshs, bp, ak, zheng.z.yan
This patch fixes a bug introduced by commit 24223657.
The rdmsrl_safe() function returns 0 on success.
The current code was failing to detect the RAPL PMU
on real hardware (missing /sys/devices/power) because
the return value of rdmsrl_safe() was misinterpreted.
Signed-off-by: Stephane Eranian <eranian@google.com>
diff --git a/arch/x86/kernel/cpu/perf_event_intel_rapl.c b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
index 7c87424..619f769 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_rapl.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
@@ -543,7 +543,8 @@ static int rapl_cpu_prepare(int cpu)
if (phys_id < 0)
return -1;
- if (!rdmsrl_safe(MSR_RAPL_POWER_UNIT, &msr_rapl_power_unit_bits))
+ /* protect rdmsrl() to handle virtualization */
+ if (rdmsrl_safe(MSR_RAPL_POWER_UNIT, &msr_rapl_power_unit_bits))
return -1;
pmu = kzalloc_node(sizeof(*pmu), GFP_KERNEL, cpu_to_node(cpu));
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] perf/x86: fix RAPL rdmsrl_safe() usage
2014-04-23 17:04 [PATCH] perf/x86: fix RAPL rdmsrl_safe() usage Stephane Eranian
@ 2014-04-23 19:00 ` Borislav Petkov
2014-04-23 19:27 ` Venkatesh Srinivas
2014-04-24 8:03 ` [tip:perf/urgent] perf/x86: Fix " tip-bot for Stephane Eranian
1 sibling, 1 reply; 5+ messages in thread
From: Borislav Petkov @ 2014-04-23 19:00 UTC (permalink / raw)
To: Stephane Eranian; +Cc: linux-kernel, peterz, mingo, venkateshs, ak, zheng.z.yan
On Wed, Apr 23, 2014 at 07:04:19PM +0200, Stephane Eranian wrote:
>
> This patch fixes a bug introduced by commit 24223657.
Maybe add
Fixes: <commit-id>
tag?
> The rdmsrl_safe() function returns 0 on success.
> The current code was failing to detect the RAPL PMU
> on real hardware (missing /sys/devices/power) because
> the return value of rdmsrl_safe() was misinterpreted.
>
> Signed-off-by: Stephane Eranian <eranian@google.com>
Acked-by: Borislav Petkov <bp@suse.de>
--
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] perf/x86: fix RAPL rdmsrl_safe() usage
2014-04-23 19:00 ` Borislav Petkov
@ 2014-04-23 19:27 ` Venkatesh Srinivas
2014-04-23 20:00 ` Andi Kleen
0 siblings, 1 reply; 5+ messages in thread
From: Venkatesh Srinivas @ 2014-04-23 19:27 UTC (permalink / raw)
To: Borislav Petkov
Cc: Stephane Eranian, Linux Kernel Developers List, Peter Zijlstra,
mingo, Andi Kleen, zheng.z.yan
On Wed, Apr 23, 2014 at 12:00 PM, Borislav Petkov <bp@alien8.de> wrote:
> On Wed, Apr 23, 2014 at 07:04:19PM +0200, Stephane Eranian wrote:
>>
>> This patch fixes a bug introduced by commit 24223657.
>
> Maybe add
>
> Fixes: <commit-id>
>
> tag?
>
>> The rdmsrl_safe() function returns 0 on success.
>> The current code was failing to detect the RAPL PMU
>> on real hardware (missing /sys/devices/power) because
>> the return value of rdmsrl_safe() was misinterpreted.
>>
>> Signed-off-by: Stephane Eranian <eranian@google.com>
>
> Acked-by: Borislav Petkov <bp@suse.de>
Brown-Paper-Bag-Worn-By: Venkatesh Srinivas <venkateshs@google.com>
-- vs;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] perf/x86: fix RAPL rdmsrl_safe() usage
2014-04-23 19:27 ` Venkatesh Srinivas
@ 2014-04-23 20:00 ` Andi Kleen
0 siblings, 0 replies; 5+ messages in thread
From: Andi Kleen @ 2014-04-23 20:00 UTC (permalink / raw)
To: Venkatesh Srinivas
Cc: Borislav Petkov, Stephane Eranian, Linux Kernel Developers List,
Peter Zijlstra, mingo, zheng.z.yan
> > Acked-by: Borislav Petkov <bp@suse.de>
>
> Brown-Paper-Bag-Worn-By: Venkatesh Srinivas <venkateshs@google.com>
Again the bug is really in KVM. We wouldn't need all this crap
if KVM didn't throw the bogus #GPs. I'm sure you missed plenty
of MSR accesses elsewhere, and it's a ticking time bomb.
If the VM lies to the kernel with the family-model you need to at
least limit the consequences. KVM is spectacularly failing
to do that by throwing bogus #GPs.
The brown paper bad needs to be employed on the KVM code
(or better the bug be fixed there, by defaulting to not #GP
on unknown MSRs)
-Andi
--
ak@linux.intel.com -- Speaking for myself only
^ permalink raw reply [flat|nested] 5+ messages in thread
* [tip:perf/urgent] perf/x86: Fix RAPL rdmsrl_safe() usage
2014-04-23 17:04 [PATCH] perf/x86: fix RAPL rdmsrl_safe() usage Stephane Eranian
2014-04-23 19:00 ` Borislav Petkov
@ 2014-04-24 8:03 ` tip-bot for Stephane Eranian
1 sibling, 0 replies; 5+ messages in thread
From: tip-bot for Stephane Eranian @ 2014-04-24 8:03 UTC (permalink / raw)
To: linux-tip-commits; +Cc: linux-kernel, eranian, hpa, mingo, tglx, bp, venkateshs
Commit-ID: 9f7ff8931e3c5ddc8535476971ec9501e9555c05
Gitweb: http://git.kernel.org/tip/9f7ff8931e3c5ddc8535476971ec9501e9555c05
Author: Stephane Eranian <eranian@google.com>
AuthorDate: Wed, 23 Apr 2014 19:04:19 +0200
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 24 Apr 2014 08:12:41 +0200
perf/x86: Fix RAPL rdmsrl_safe() usage
This patch fixes a bug introduced by:
24223657806a ("perf/x86/intel: Use rdmsrl_safe() when initializing RAPL PMU")
The rdmsrl_safe() function returns 0 on success.
The current code was failing to detect the RAPL PMU
on real hardware (missing /sys/devices/power) because
the return value of rdmsrl_safe() was misinterpreted.
Signed-off-by: Stephane Eranian <eranian@google.com>
Acked-by: Borislav Petkov <bp@suse.de>
Acked-by: Venkatesh Srinivas <venkateshs@google.com>
Cc: peterz@infradead.org
Cc: zheng.z.yan@intel.com
Link: http://lkml.kernel.org/r/20140423170418.GA12767@quad
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/kernel/cpu/perf_event_intel_rapl.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/cpu/perf_event_intel_rapl.c b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
index 7c87424..619f769 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_rapl.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
@@ -543,7 +543,8 @@ static int rapl_cpu_prepare(int cpu)
if (phys_id < 0)
return -1;
- if (!rdmsrl_safe(MSR_RAPL_POWER_UNIT, &msr_rapl_power_unit_bits))
+ /* protect rdmsrl() to handle virtualization */
+ if (rdmsrl_safe(MSR_RAPL_POWER_UNIT, &msr_rapl_power_unit_bits))
return -1;
pmu = kzalloc_node(sizeof(*pmu), GFP_KERNEL, cpu_to_node(cpu));
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-04-24 8:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-23 17:04 [PATCH] perf/x86: fix RAPL rdmsrl_safe() usage Stephane Eranian
2014-04-23 19:00 ` Borislav Petkov
2014-04-23 19:27 ` Venkatesh Srinivas
2014-04-23 20:00 ` Andi Kleen
2014-04-24 8:03 ` [tip:perf/urgent] perf/x86: Fix " tip-bot for Stephane Eranian
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.