public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>,
	"H. Peter Anvin" <hpa@zytor.com>, Jason Baron <jbaron@redhat.com>
Subject: [PATCH 7/7] x86/jump labels: Handle initialization of enabled nops
Date: Thu, 08 Mar 2012 17:17:37 -0500	[thread overview]
Message-ID: <20120308222203.176951592@goodmis.org> (raw)
In-Reply-To: 20120308221730.807074710@goodmis.org

[-- Attachment #1: Type: text/plain, Size: 1331 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

When jump labels are initialized at boot up, they are compared
to the default_nop before switching to the ideal nop.

But if a jump label is enabled by default on start up, the
enabled code does not test against the default nop, only the
ideal nop. But as this jump label has not been converted to the
ideal nop, it fails the check, and will crash the box.

The enabled path needs to be aware of initialization too.

Reported-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 arch/x86/kernel/jump_label.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
index 9bae2c9..c3ae7c3 100644
--- a/arch/x86/kernel/jump_label.c
+++ b/arch/x86/kernel/jump_label.c
@@ -66,7 +66,8 @@ static void __jump_label_transform(struct jump_entry *entry,
 			code.jump_short = 0xeb;
 			code.offset = entry->target - (entry->code + 2);
 			/* Check for overflow ? */
-		} else if (memcmp(ip, ideal_nop, 5) == 0) {
+		} else if ((!init && memcmp(ip, ideal_nop, 5) == 0) ||
+			   (init && memcmp(ip, default_nop, 5) == 0)) {
 			size = JUMP_LABEL_NOP_SIZE;
 			code.jump = 0xe9;
 			code.offset = entry->target - (entry->code + size);
-- 
1.7.8.3



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

      parent reply	other threads:[~2012-03-08 22:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-08 22:17 [PATCH 0/7] [GIT PULL] jump-labels: Implement 2 and 5 byte jumps Steven Rostedt
2012-03-08 22:17 ` [PATCH 1/7] x86/jump-label: Use best default nops for inital jump label calls Steven Rostedt
2012-03-08 22:17 ` [PATCH 2/7] x86/jump-label: Do not bother updating nops if they are correct Steven Rostedt
2012-03-08 22:17 ` [PATCH 3/7] x86/jump-label: Add safety checks to jump label conversions Steven Rostedt
2012-03-08 22:17 ` [PATCH 4/7] jump labels: Add infrastructure to update jump labels at compile time Steven Rostedt
2012-03-08 22:17 ` [PATCH 5/7] x86/jump labels: Use etiher 5 byte or 2 byte jumps Steven Rostedt
2012-03-12 16:17   ` Jason Baron
2012-03-12 16:29     ` Steven Rostedt
2012-03-12 17:27     ` Steven Rostedt
2012-03-12 18:03       ` Jason Baron
2012-03-08 22:17 ` [PATCH 6/7] x86/jump lables: Show where and what was wrong on errors Steven Rostedt
2012-03-08 22:17 ` Steven Rostedt [this message]

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=20120308222203.176951592@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=hpa@zytor.com \
    --cc=jbaron@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox