]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/i386/kernel/alternative.c
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
[linux-2.6-omap-h63xx.git] / arch / i386 / kernel / alternative.c
index f09635408049fe3f5c26dedb5fb451d46bdfac56..d8cda14fff8bc4713f41a15a0193cb935550c602 100644 (file)
@@ -5,6 +5,7 @@
 #include <asm/alternative.h>
 #include <asm/sections.h>
 
+static int noreplace_smp     = 0;
 static int smp_alt_once      = 0;
 static int debug_alternative = 0;
 
@@ -13,15 +14,33 @@ static int __init bootonly(char *str)
        smp_alt_once = 1;
        return 1;
 }
+__setup("smp-alt-boot", bootonly);
+
 static int __init debug_alt(char *str)
 {
        debug_alternative = 1;
        return 1;
 }
-
-__setup("smp-alt-boot", bootonly);
 __setup("debug-alternative", debug_alt);
 
+static int __init setup_noreplace_smp(char *str)
+{
+       noreplace_smp = 1;
+       return 1;
+}
+__setup("noreplace-smp", setup_noreplace_smp);
+
+#ifdef CONFIG_PARAVIRT
+static int noreplace_paravirt = 0;
+
+static int __init setup_noreplace_paravirt(char *str)
+{
+       noreplace_paravirt = 1;
+       return 1;
+}
+__setup("noreplace-paravirt", setup_noreplace_paravirt);
+#endif
+
 #define DPRINTK(fmt, args...) if (debug_alternative) \
        printk(KERN_DEBUG fmt, args)
 
@@ -185,6 +204,9 @@ static void alternatives_smp_unlock(u8 **start, u8 **end, u8 *text, u8 *text_end
 {
        u8 **ptr;
 
+       if (noreplace_smp)
+               return;
+
        for (ptr = start; ptr < end; ptr++) {
                if (*ptr < text)
                        continue;
@@ -219,6 +241,9 @@ void alternatives_smp_module_add(struct module *mod, char *name,
        struct smp_alt_module *smp;
        unsigned long flags;
 
+       if (noreplace_smp)
+               return;
+
        if (smp_alt_once) {
                if (boot_cpu_has(X86_FEATURE_UP))
                        alternatives_smp_unlock(locks, locks_end,
@@ -253,7 +278,7 @@ void alternatives_smp_module_del(struct module *mod)
        struct smp_alt_module *item;
        unsigned long flags;
 
-       if (smp_alt_once)
+       if (smp_alt_once || noreplace_smp)
                return;
 
        spin_lock_irqsave(&smp_alt, flags);
@@ -284,7 +309,7 @@ void alternatives_smp_switch(int smp)
        return;
 #endif
 
-       if (smp_alt_once)
+       if (noreplace_smp || smp_alt_once)
                return;
        BUG_ON(!smp && (num_online_cpus() > 1));
 
@@ -310,36 +335,31 @@ void alternatives_smp_switch(int smp)
 #endif
 
 #ifdef CONFIG_PARAVIRT
-void apply_paravirt(struct paravirt_patch *start, struct paravirt_patch *end)
+void apply_paravirt(struct paravirt_patch_site *start,
+                   struct paravirt_patch_site *end)
 {
-       struct paravirt_patch *p;
+       struct paravirt_patch_site *p;
+
+       if (noreplace_paravirt)
+               return;
 
        for (p = start; p < end; p++) {
                unsigned int used;
 
                used = paravirt_ops.patch(p->instrtype, p->clobbers, p->instr,
                                          p->len);
-#ifdef CONFIG_DEBUG_PARAVIRT
-               {
-               int i;
-               /* Deliberately clobber regs using "not %reg" to find bugs. */
-               for (i = 0; i < 3; i++) {
-                       if (p->len - used >= 2 && (p->clobbers & (1 << i))) {
-                               memcpy(p->instr + used, "\xf7\xd0", 2);
-                               p->instr[used+1] |= i;
-                               used += 2;
-                       }
-               }
-               }
-#endif
+
+               BUG_ON(used > p->len);
+
                /* Pad the rest with nops */
                nop_out(p->instr + used, p->len - used);
        }
 
-       /* Sync to be conservative, in case we patched following instructions */
+       /* Sync to be conservative, in case we patched following
+        * instructions */
        sync_core();
 }
-extern struct paravirt_patch __start_parainstructions[],
+extern struct paravirt_patch_site __start_parainstructions[],
        __stop_parainstructions[];
 #endif /* CONFIG_PARAVIRT */
 
@@ -370,8 +390,8 @@ void __init alternative_instructions(void)
                                                _text, _etext);
                }
                free_init_pages("SMP alternatives",
-                               __pa_symbol(&__smp_locks),
-                               __pa_symbol(&__smp_locks_end));
+                               (unsigned long)__smp_locks,
+                               (unsigned long)__smp_locks_end);
        } else {
                alternatives_smp_module_add(NULL, "core kernel",
                                            __smp_locks, __smp_locks_end,
@@ -379,6 +399,6 @@ void __init alternative_instructions(void)
                alternatives_smp_switch(0);
        }
 #endif
-       apply_paravirt(__start_parainstructions, __stop_parainstructions);
+       apply_paravirt(__parainstructions, __parainstructions_end);
        local_irq_restore(flags);
 }