mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [GIT PULL] x86: Put back -pg to tsc.o and add no GCOV to vread_tsc_64.o
@ 2011-05-28  3:53 Steven Rostedt
  2011-05-28  4:14 ` Andrew Lutomirski
  0 siblings, 1 reply; 2+ messages in thread
From: Steven Rostedt @ 2011-05-28  3:53 UTC (permalink / raw)
  To: LKML
  Cc: Ingo Molnar, Frederic Weisbecker, Thomas Gleixner,
	Andy Lutomirski, Andrew Morton


Ingo,

While running ktest randconfig tests on latest Linus's tree, I hit a
case where the function graph tracer caused a nasty crash, or even a
reboot. Using the ktest git bisect utility, I quickly found that the
crash was due to the commit:

  44259b1a x86-64: Move vread_tsc into a new file with sensible options

I found that it removed the -pg from tsc.o causing accesses to tsc to be
traced. The function graph tracer uses the tsc outside its recursive
protection and this caused the crash.

But this was not the only bug. As I had 3 different configs that crashed
in my randconfig tests, I tested all three. The first two ran fine with
the update of the tsc.o with the -pg option, but the third config failed
with the init process taking a segfault in the vread_tsc function.

That same patch added the vread_tsc_64.o but did not disable GCOV from
it. Thomas noticed that GCOV was set in that config and after disabling
GCOV, the strange accesses to kernel space in that function went away.

This patch adds back the -pg and protects vread_tsc_64.o from GCOV.

Note, this is based on latest Linus and not tip's perf/urgent branch
because the bug does not exist in the tip branch.


Please pull the latest tip/perf/urgent-2 tree, which can be found at:

  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
tip/perf/urgent-2


Steven Rostedt (1):
      x86: Put back -pg to tsc.o and add no GCOV to vread_tsc_64.o

----
 arch/x86/kernel/Makefile |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
---------------------------
commit 89e1be50c68eb5e58b873dce87bbac627ee18d1f
Author: Steven Rostedt <srostedt@redhat.com>
Date:   Fri May 27 23:11:24 2011 -0400

    x86: Put back -pg to tsc.o and add no GCOV to vread_tsc_64.o
    
    The commit 44259b1abfaa8bb819d25d41d71e8e33e25dd36a
        Author: Andy Lutomirski <luto@MIT.EDU>
        x86-64: Move vread_tsc into a new file with sensible options
    
    Removed the -pg from tsc.o which caused the function graph tracer
    to go into an infinite function call recursion as it uses the tsc
    internally outside its recursion protection, thus tracing the tsc
    breaks the function graph tracer.
    
    This commit also added the file vread_tsc_64.c that gets used
    by vdso but failed to prevent GCOV from monkeying with it,
    causing userspace to try to access kernel data when GCOV was
    enabled.
    
    Thanks to Thomas Gleixner for pointing out GCOV as the likely
    culprit that added strange kernel accesses into the vread_tsc()
    call.
    
    Cc: Author: Andy Lutomirski <luto@MIT.EDU>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index f5abe3a..90b06d4 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -8,6 +8,7 @@ CPPFLAGS_vmlinux.lds += -U$(UTS_MACHINE)
 
 ifdef CONFIG_FUNCTION_TRACER
 # Do not profile debug and lowlevel utilities
+CFLAGS_REMOVE_tsc.o = -pg
 CFLAGS_REMOVE_rtc.o = -pg
 CFLAGS_REMOVE_paravirt-spinlocks.o = -pg
 CFLAGS_REMOVE_pvclock.o = -pg
@@ -28,6 +29,7 @@ CFLAGS_paravirt.o	:= $(nostackp)
 GCOV_PROFILE_vsyscall_64.o	:= n
 GCOV_PROFILE_hpet.o		:= n
 GCOV_PROFILE_tsc.o		:= n
+GCOV_PROFILE_vread_tsc_64.o	:= n
 GCOV_PROFILE_paravirt.o		:= n
 
 # vread_tsc_64 is hot and should be fully optimized:



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

* Re: [GIT PULL] x86: Put back -pg to tsc.o and add no GCOV to vread_tsc_64.o
  2011-05-28  3:53 [GIT PULL] x86: Put back -pg to tsc.o and add no GCOV to vread_tsc_64.o Steven Rostedt
@ 2011-05-28  4:14 ` Andrew Lutomirski
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Lutomirski @ 2011-05-28  4:14 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Ingo Molnar, Frederic Weisbecker, Thomas Gleixner, Andrew Morton

On Fri, May 27, 2011 at 11:53 PM, Steven Rostedt <rostedt@goodmis.org> wrote:
>
> Ingo,
>
> While running ktest randconfig tests on latest Linus's tree, I hit a
> case where the function graph tracer caused a nasty crash, or even a
> reboot. Using the ktest git bisect utility, I quickly found that the
> crash was due to the commit:
>
>  44259b1a x86-64: Move vread_tsc into a new file with sensible options
>
> I found that it removed the -pg from tsc.o causing accesses to tsc to be
> traced. The function graph tracer uses the tsc outside its recursive
> protection and this caused the crash.

Oops, I didn't think of that.

>
> But this was not the only bug. As I had 3 different configs that crashed
> in my randconfig tests, I tested all three. The first two ran fine with
> the update of the tsc.o with the -pg option, but the third config failed
> with the init process taking a segfault in the vread_tsc function.
>
> That same patch added the vread_tsc_64.o but did not disable GCOV from
> it. Thomas noticed that GCOV was set in that config and after disabling
> GCOV, the strange accesses to kernel space in that function went away.

And that was just an oversight on my part.  Sorry.

> Steven Rostedt (1):
>      x86: Put back -pg to tsc.o and add no GCOV to vread_tsc_64.o

Looks fine to me.

--Andy

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

end of thread, other threads:[~2011-05-28  4:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-28  3:53 [GIT PULL] x86: Put back -pg to tsc.o and add no GCOV to vread_tsc_64.o Steven Rostedt
2011-05-28  4:14 ` Andrew Lutomirski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®