Skip to content

Commit 662a022

Browse files
Peter ZijlstraKAGA-KOKO
authored andcommitted
x86/entry: Fix AC assertion
The WARN added in commit 3c73b81 ("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: 3c73b81 ("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]
1 parent 2356bb4 commit 662a022

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

arch/x86/include/asm/entry-common.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,16 @@ static __always_inline void arch_check_user_regs(struct pt_regs *regs)
1818
* state, not the interrupt state as imagined by Xen.
1919
*/
2020
unsigned long flags = native_save_fl();
21-
WARN_ON_ONCE(flags & (X86_EFLAGS_AC | X86_EFLAGS_DF |
22-
X86_EFLAGS_NT));
21+
unsigned long mask = X86_EFLAGS_DF | X86_EFLAGS_NT;
22+
23+
/*
24+
* For !SMAP hardware we patch out CLAC on entry.
25+
*/
26+
if (boot_cpu_has(X86_FEATURE_SMAP) ||
27+
(IS_ENABLED(CONFIG_64_BIT) && boot_cpu_has(X86_FEATURE_XENPV)))
28+
mask |= X86_EFLAGS_AC;
29+
30+
WARN_ON_ONCE(flags & mask);
2331

2432
/* We think we came from user mode. Make sure pt_regs agrees. */
2533
WARN_ON_ONCE(!user_mode(regs));

0 commit comments

Comments
 (0)