Re: [PATCH] perf/x86: fix RAPL rdmsrl_safe() usage

2014-04-23 Thread Andi Kleen
> > Acked-by: Borislav Petkov 
> 
> Brown-Paper-Bag-Worn-By: Venkatesh Srinivas 

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

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


Re: [PATCH] perf/x86: fix RAPL rdmsrl_safe() usage

2014-04-23 Thread Venkatesh Srinivas
On Wed, Apr 23, 2014 at 12:00 PM, Borislav Petkov  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: 
>
> 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 
>
> Acked-by: Borislav Petkov 

Brown-Paper-Bag-Worn-By: Venkatesh Srinivas 

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


Re: [PATCH] perf/x86: fix RAPL rdmsrl_safe() usage

2014-04-23 Thread Borislav Petkov
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: 

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 

Acked-by: Borislav Petkov 

-- 
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] perf/x86: fix RAPL rdmsrl_safe() usage

2014-04-23 Thread Stephane Eranian

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 

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, _rapl_power_unit_bits))
+   /* protect rdmsrl() to handle virtualization */
+   if (rdmsrl_safe(MSR_RAPL_POWER_UNIT, _rapl_power_unit_bits))
return -1;
 
pmu = kzalloc_node(sizeof(*pmu), GFP_KERNEL, cpu_to_node(cpu));
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] perf/x86: fix RAPL rdmsrl_safe() usage

2014-04-23 Thread Stephane Eranian

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 eran...@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));
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] perf/x86: fix RAPL rdmsrl_safe() usage

2014-04-23 Thread Borislav Petkov
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 eran...@google.com

Acked-by: Borislav Petkov b...@suse.de

-- 
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] perf/x86: fix RAPL rdmsrl_safe() usage

2014-04-23 Thread Venkatesh Srinivas
On Wed, Apr 23, 2014 at 12:00 PM, Borislav Petkov b...@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 eran...@google.com

 Acked-by: Borislav Petkov b...@suse.de

Brown-Paper-Bag-Worn-By: Venkatesh Srinivas venkate...@google.com

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


Re: [PATCH] perf/x86: fix RAPL rdmsrl_safe() usage

2014-04-23 Thread Andi Kleen
  Acked-by: Borislav Petkov b...@suse.de
 
 Brown-Paper-Bag-Worn-By: Venkatesh Srinivas venkate...@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

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