[PATCH 7/7] x86/jump labels: Handle initialization of enabled nops

From: Steven Rostedt
Date: Thu Mar 08 2012 - 17:23:28 EST


From: Steven Rostedt <srostedt@xxxxxxxxxx>

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@xxxxxxx>
Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
---
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: signature.asc
Description: This is a digitally signed message part