x86: Make jump_label use int3-based patching
authorJiri Kosina <jkosina@suse.cz>
Fri, 12 Jul 2013 09:22:09 +0000 (11:22 +0200)
committerH. Peter Anvin <hpa@linux.intel.com>
Wed, 17 Jul 2013 00:55:37 +0000 (17:55 -0700)
Make jump labels use text_poke_bp() for text patching instead of
text_poke_smp(), avoiding the need for stop_machine().

Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Link: http://lkml.kernel.org/r/alpine.LNX.2.00.1307121120250.29788@pobox.suse.cz
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
arch/x86/kernel/jump_label.c

index 2889b3d438823ea58d6796355e08fb081c1896f7..460f5d9ceebb65c5337a6d3b57edbad7925b8c1a 100644 (file)
@@ -37,7 +37,19 @@ static void __jump_label_transform(struct jump_entry *entry,
        } else
                memcpy(&code, ideal_nops[NOP_ATOMIC5], JUMP_LABEL_NOP_SIZE);
 
-       (*poker)((void *)entry->code, &code, JUMP_LABEL_NOP_SIZE);
+       /*
+        * Make text_poke_bp() a default fallback poker.
+        *
+        * At the time the change is being done, just ignore whether we
+        * are doing nop -> jump or jump -> nop transition, and assume
+        * always nop being the 'currently valid' instruction
+        *
+        */
+       if (poker)
+               (*poker)((void *)entry->code, &code, JUMP_LABEL_NOP_SIZE);
+       else
+               text_poke_bp((void *)entry->code, &code, JUMP_LABEL_NOP_SIZE,
+                            (void *)entry->code + JUMP_LABEL_NOP_SIZE);
 }
 
 void arch_jump_label_transform(struct jump_entry *entry,
@@ -45,7 +57,7 @@ void arch_jump_label_transform(struct jump_entry *entry,
 {
        get_online_cpus();
        mutex_lock(&text_mutex);
-       __jump_label_transform(entry, type, text_poke_smp);
+       __jump_label_transform(entry, type, NULL);
        mutex_unlock(&text_mutex);
        put_online_cpus();
 }