kaiser: add "nokaiser" boot option, using ALTERNATIVE
[pandora-kernel.git] / arch / x86 / kernel / entry_64.S
index 3a4356a..eb6c31b 100644 (file)
@@ -56,6 +56,8 @@
 #include <asm/ftrace.h>
 #include <asm/percpu.h>
 #include <asm/pgtable_types.h>
+#include <asm/alternative-asm.h>
+#include <asm/cpufeature.h>
 #include <asm/kaiser.h>
 
 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this.  */
@@ -404,7 +406,7 @@ ENTRY(save_paranoid)
         * unconditionally, but we need to find out whether the reverse
         * should be done on return (conveyed to paranoid_exit in %ebx).
         */
-       movq    %cr3, %rax
+       ALTERNATIVE "jmp 2f", "movq %cr3, %rax", X86_FEATURE_KAISER
        testl   $KAISER_SHADOW_PGD_OFFSET, %eax
        jz      2f
        orl     $2, %ebx
@@ -1428,6 +1430,7 @@ paranoid_kernel:
        movq    %r12, %rbx              /* restore after paranoid_userspace */
        TRACE_IRQS_IRETQ 0
 #ifdef CONFIG_KAISER
+       /* No ALTERNATIVE for X86_FEATURE_KAISER: save_paranoid sets %ebx */
        testl   $2, %ebx                /* SWITCH_USER_CR3 needed? */
        jz      paranoid_exit_no_switch
        SWITCH_USER_CR3
@@ -1597,6 +1600,7 @@ ENTRY(nmi)
 nmi_kernel:
        movq    %r12, %rbx              /* restore after nmi_userspace */
 #ifdef CONFIG_KAISER
+       /* No ALTERNATIVE for X86_FEATURE_KAISER: save_paranoid sets %ebx */
        testl   $2, %ebx                /* SWITCH_USER_CR3 needed? */
        jz      nmi_exit_no_switch
        SWITCH_USER_CR3