]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - arch/x86/kernel/alternative.c
Merge branches 'perf-fixes-for-linus' and 'x86-fixes-for-linus' of git://git.kernel...
[net-next-2.6.git] / arch / x86 / kernel / alternative.c
index f65ab8b014c4f42421d77200243c39c7fd252165..5079f24c955a2d3b9b66532cd2c8cd45e5116d14 100644 (file)
@@ -195,7 +195,7 @@ static void __init_or_module add_nops(void *insns, unsigned int len)
 
 extern struct alt_instr __alt_instructions[], __alt_instructions_end[];
 extern s32 __smp_locks[], __smp_locks_end[];
-static void *text_poke_early(void *addr, const void *opcode, size_t len);
+void *text_poke_early(void *addr, const void *opcode, size_t len);
 
 /* Replace instructions with better alternatives for this CPU type.
    This runs before SMP is initialized to avoid SMP problems with
@@ -522,7 +522,7 @@ void __init alternative_instructions(void)
  * instructions. And on the local CPU you need to be protected again NMI or MCE
  * handlers seeing an inconsistent instruction while you patch.
  */
-static void *__init_or_module text_poke_early(void *addr, const void *opcode,
+void *__init_or_module text_poke_early(void *addr, const void *opcode,
                                              size_t len)
 {
        unsigned long flags;
@@ -637,7 +637,33 @@ void *__kprobes text_poke_smp(void *addr, const void *opcode, size_t len)
        tpp.len = len;
        atomic_set(&stop_machine_first, 1);
        wrote_text = 0;
-       stop_machine(stop_machine_text_poke, (void *)&tpp, NULL);
+       /* Use __stop_machine() because the caller already got online_cpus. */
+       __stop_machine(stop_machine_text_poke, (void *)&tpp, cpu_online_mask);
        return addr;
 }
 
+#if defined(CONFIG_DYNAMIC_FTRACE) || defined(HAVE_JUMP_LABEL)
+
+#ifdef CONFIG_X86_64
+unsigned char ideal_nop5[5] = { 0x66, 0x66, 0x66, 0x66, 0x90 };
+#else
+unsigned char ideal_nop5[5] = { 0x3e, 0x8d, 0x74, 0x26, 0x00 };
+#endif
+
+void __init arch_init_ideal_nop5(void)
+{
+       /*
+        * There is no good nop for all x86 archs.  This selection
+        * algorithm should be unified with the one in find_nop_table(),
+        * but this should be good enough for now.
+        *
+        * For cases other than the ones below, use the safe (as in
+        * always functional) defaults above.
+        */
+#ifdef CONFIG_X86_64
+       /* Don't use these on 32 bits due to broken virtualizers */
+       if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
+               memcpy(ideal_nop5, p6_nops[5], 5);
+#endif
+}
+#endif