]> Git Repo - linux.git/commitdiff
x86/entry: Fix AC assertion
authorPeter Zijlstra <[email protected]>
Wed, 2 Sep 2020 13:25:50 +0000 (15:25 +0200)
committerThomas Gleixner <[email protected]>
Fri, 4 Sep 2020 13:09:29 +0000 (15:09 +0200)
The WARN added in commit 3c73b81a9164 ("x86/entry, selftests: Further
improve user entry sanity checks") unconditionally triggers on a IVB
machine because it does not support SMAP.

For !SMAP hardware the CLAC/STAC instructions are patched out and thus if
userspace sets AC, it is still have set after entry.

Fixes: 3c73b81a9164 ("x86/entry, selftests: Further improve user entry sanity checks")
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Tested-by: Daniel Thompson <[email protected]>
Acked-by: Andy Lutomirski <[email protected]>
Cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
arch/x86/include/asm/entry-common.h

index a8f9315b9eaeff990bf3781b3f085b16619acf8b..6fe54b2813c13960786595db35b7b1f2b0c0dba1 100644 (file)
@@ -18,8 +18,16 @@ static __always_inline void arch_check_user_regs(struct pt_regs *regs)
                 * state, not the interrupt state as imagined by Xen.
                 */
                unsigned long flags = native_save_fl();
-               WARN_ON_ONCE(flags & (X86_EFLAGS_AC | X86_EFLAGS_DF |
-                                     X86_EFLAGS_NT));
+               unsigned long mask = X86_EFLAGS_DF | X86_EFLAGS_NT;
+
+               /*
+                * For !SMAP hardware we patch out CLAC on entry.
+                */
+               if (boot_cpu_has(X86_FEATURE_SMAP) ||
+                   (IS_ENABLED(CONFIG_64_BIT) && boot_cpu_has(X86_FEATURE_XENPV)))
+                       mask |= X86_EFLAGS_AC;
+
+               WARN_ON_ONCE(flags & mask);
 
                /* We think we came from user mode. Make sure pt_regs agrees. */
                WARN_ON_ONCE(!user_mode(regs));
This page took 0.05768 seconds and 4 git commands to generate.