From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
David Miller <davem@davemloft.net>,
Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>,
Roland McGrath <roland@redhat.com>,
Ulrich Drepper <drepper@redhat.com>,
Rusty Russell <rusty@rustcorp.com.au>,
Gregory Haskins <ghaskins@novell.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
"Luis Claudio R. Goncalves" <lclaudio@uudg.org>,
Clark Williams <williams@redhat.com>,
srostedt@redhat.com
Subject: Re: [PATCH] ftrace: use only 5 byte nops for x86
Date: Thu, 14 Aug 2008 16:49:37 -0700 [thread overview]
Message-ID: <48A4C491.4050301@goop.org> (raw)
In-Reply-To: <alpine.DEB.1.10.0808141755030.2911@gandalf.stny.rr.com>
Steven Rostedt wrote:
> Mathieu Desnoyers revealed a bug in the original code. The nop that is
> used to relpace the mcount caller can be a two part nop. This runs the
> risk where a process can be preempted after executing the first nop, but
> before the second part of the nop.
>
> The ftrace code calls kstop_machine to keep multiple CPUs from executing
> code that is being modified, but it does not protect against a task preempting
> in the middle of a two part nop.
>
> If the above preemption happens and the tracer is enabled, after the
> kstop_machine runs, all those nops will be calls to the trace function.
> If the preempted process that was preempted between the two nops is executed
> again, it will execute half of the call to the trace function, and this
> might crash the system.
>
> This patch instead uses what both the latest Intel and AMD spec suggests.
> That is the P6_NOP5 sequence of "0x0f 0x1f 0x44 0x00 0x00".
> Note, some older CPUs and QEMU might fault on this nop, so this nop
> is executed with fault handling first. If it detects a fault, it will then
> use the code "0x66 0x66 0x66 0x66 0x90". If that faults,
Seems very unlikely, but go mad ;)
> it will then
> default to a simple "jmp 1f; .byte 0x00 0x00 0x00; 1:". The jmp is
> not optimal but will do if the first two can not be executed.
>
> TODO: Examine the cpuid to determine the nop to use.
>
Don't think that will help in general. qemu claims its a Pentium II.
J
next prev parent reply other threads:[~2008-08-14 23:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-14 22:05 [PATCH] ftrace: use only 5 byte nops for x86 Steven Rostedt
2008-08-14 23:49 ` Jeremy Fitzhardinge [this message]
2008-08-15 9:22 ` Ingo Molnar
2008-08-15 22:30 ` H. Peter Anvin
2008-08-15 22:44 ` Linus Torvalds
2008-08-15 22:50 ` Jeremy Fitzhardinge
2008-08-15 22:52 ` H. Peter Anvin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48A4C491.4050301@goop.org \
--to=jeremy@goop.org \
--cc=acme@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=drepper@redhat.com \
--cc=ghaskins@novell.com \
--cc=lclaudio@uudg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@polymtl.ca \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=roland@redhat.com \
--cc=rostedt@goodmis.org \
--cc=rusty@rustcorp.com.au \
--cc=srostedt@redhat.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=williams@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.