All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf/x86: fix broken LBR fixup code
@ 2012-06-11 13:44 Stephane Eranian
  2012-06-11 13:47 ` Peter Zijlstra
  2012-06-14  8:40 ` [tip:perf/urgent] perf/x86: Fix " tip-bot for Stephane Eranian
  0 siblings, 2 replies; 4+ messages in thread
From: Stephane Eranian @ 2012-06-11 13:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: peterz, asharma, mingo


I noticed that the LBR fixups were not working anymore
on programs where they used to. I tracked this down to
a recent change to copy_from_user_nmi().

commit db0dc75d6403b6663c0eab4c6ccb672eb9b2ed72
Author: Arun Sharma <asharma@fb.com>
Date:   Fri Apr 20 15:41:36 2012 -0700

    perf/x86: Check user address explicitly in copy_from_user_nmi()
    
This commit added a call to __range_not_ok() to the
copy_from_user_nmi() routine. The problem is that the logic
of the test must be reversed. __range_not_ok() returns 0 if the
range is VALID. We want to return early from copy_from_user_nmi()
if the range is NOT valid.

Signed-off-by: Stephane Eranian <eranian@google.com>
---

diff --git a/arch/x86/lib/usercopy.c b/arch/x86/lib/usercopy.c
index 677b1ed..4f74d94 100644
--- a/arch/x86/lib/usercopy.c
+++ b/arch/x86/lib/usercopy.c
@@ -22,7 +22,7 @@ copy_from_user_nmi(void *to, const void __user *from, unsigned long n)
 	void *map;
 	int ret;
 
-	if (__range_not_ok(from, n, TASK_SIZE) == 0)
+	if (__range_not_ok(from, n, TASK_SIZE))
 		return len;
 
 	do {

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

* Re: [PATCH] perf/x86: fix broken LBR fixup code
  2012-06-11 13:44 [PATCH] perf/x86: fix broken LBR fixup code Stephane Eranian
@ 2012-06-11 13:47 ` Peter Zijlstra
  2012-06-11 19:41   ` Arun Sharma
  2012-06-14  8:40 ` [tip:perf/urgent] perf/x86: Fix " tip-bot for Stephane Eranian
  1 sibling, 1 reply; 4+ messages in thread
From: Peter Zijlstra @ 2012-06-11 13:47 UTC (permalink / raw)
  To: Stephane Eranian; +Cc: linux-kernel, asharma, mingo

On Mon, 2012-06-11 at 15:44 +0200, Stephane Eranian wrote:
> I noticed that the LBR fixups were not working anymore
> on programs where they used to. I tracked this down to
> a recent change to copy_from_user_nmi().
> 
> commit db0dc75d6403b6663c0eab4c6ccb672eb9b2ed72
> Author: Arun Sharma <asharma@fb.com>
> Date:   Fri Apr 20 15:41:36 2012 -0700
> 
>     perf/x86: Check user address explicitly in copy_from_user_nmi()
>     
> This commit added a call to __range_not_ok() to the
> copy_from_user_nmi() routine. The problem is that the logic
> of the test must be reversed. __range_not_ok() returns 0 if the
> range is VALID. We want to return early from copy_from_user_nmi()
> if the range is NOT valid.

D'0h.. Thanks!

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

* Re: [PATCH] perf/x86: fix broken LBR fixup code
  2012-06-11 13:47 ` Peter Zijlstra
@ 2012-06-11 19:41   ` Arun Sharma
  0 siblings, 0 replies; 4+ messages in thread
From: Arun Sharma @ 2012-06-11 19:41 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: Stephane Eranian, linux-kernel, mingo

On 6/11/12 6:47 AM, Peter Zijlstra wrote:
> On Mon, 2012-06-11 at 15:44 +0200, Stephane Eranian wrote:
>> I noticed that the LBR fixups were not working anymore
>> on programs where they used to. I tracked this down to
>> a recent change to copy_from_user_nmi().
>>
>> commit db0dc75d6403b6663c0eab4c6ccb672eb9b2ed72
>> Author: Arun Sharma<asharma@fb.com>
>> Date:   Fri Apr 20 15:41:36 2012 -0700
>>
>>      perf/x86: Check user address explicitly in copy_from_user_nmi()
>>
>> This commit added a call to __range_not_ok() to the
>> copy_from_user_nmi() routine. The problem is that the logic
>> of the test must be reversed. __range_not_ok() returns 0 if the
>> range is VALID. We want to return early from copy_from_user_nmi()
>> if the range is NOT valid.
>
> D'0h.. Thanks!

My bad. I was fooled by all the kernel addresses that were unwound 
properly. Didn't notice the broken unwinding in user space before I sent 
the patch. The fix looks good. Thanks.

  -Arun

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

* [tip:perf/urgent] perf/x86: Fix broken LBR fixup code
  2012-06-11 13:44 [PATCH] perf/x86: fix broken LBR fixup code Stephane Eranian
  2012-06-11 13:47 ` Peter Zijlstra
@ 2012-06-14  8:40 ` tip-bot for Stephane Eranian
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Stephane Eranian @ 2012-06-14  8:40 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, eranian, hpa, mingo, a.p.zijlstra, tglx, asharma

Commit-ID:  25f42985825dd93f0593efe454e54c2aa13f7830
Gitweb:     http://git.kernel.org/tip/25f42985825dd93f0593efe454e54c2aa13f7830
Author:     Stephane Eranian <eranian@google.com>
AuthorDate: Mon, 11 Jun 2012 15:44:26 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 13 Jun 2012 15:00:28 +0200

perf/x86: Fix broken LBR fixup code

I noticed that the LBR fixups were not working anymore
on programs where they used to. I tracked this down to
a recent change to copy_from_user_nmi():

 db0dc75d640 ("perf/x86: Check user address explicitly in copy_from_user_nmi()")

This commit added a call to __range_not_ok() to the
copy_from_user_nmi() routine. The problem is that the logic
of the test must be reversed. __range_not_ok() returns 0 if the
range is VALID. We want to return early from copy_from_user_nmi()
if the range is NOT valid.

Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Arun Sharma <asharma@fb.com>
Link: http://lkml.kernel.org/r/20120611134426.GA7542@quad
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/lib/usercopy.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/lib/usercopy.c b/arch/x86/lib/usercopy.c
index 677b1ed..4f74d94 100644
--- a/arch/x86/lib/usercopy.c
+++ b/arch/x86/lib/usercopy.c
@@ -22,7 +22,7 @@ copy_from_user_nmi(void *to, const void __user *from, unsigned long n)
 	void *map;
 	int ret;
 
-	if (__range_not_ok(from, n, TASK_SIZE) == 0)
+	if (__range_not_ok(from, n, TASK_SIZE))
 		return len;
 
 	do {

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

end of thread, other threads:[~2012-06-14  8:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-11 13:44 [PATCH] perf/x86: fix broken LBR fixup code Stephane Eranian
2012-06-11 13:47 ` Peter Zijlstra
2012-06-11 19:41   ` Arun Sharma
2012-06-14  8:40 ` [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.