Skip to content

Commit f42a40f

Browse files
amlutosuryasaimadhu
authored andcommitted
x86/fault/32: Move is_f00f_bug() to do_kern_addr_fault()
bad_area() and its relatives are called from many places in fault.c, and exactly one of them wants the F00F workaround. __bad_area_nosemaphore() no longer contains any kernel fault code, which prepares for further cleanups. Signed-off-by: Andy Lutomirski <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Link: https://lkml.kernel.org/r/e9668729a48ce6754022b0a4415631e8ebdd00e7.1612924255.git.luto@kernel.org
1 parent ec35271 commit f42a40f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

arch/x86/mm/fault.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -482,10 +482,12 @@ static int is_errata100(struct pt_regs *regs, unsigned long address)
482482
}
483483

484484
/* Pentium F0 0F C7 C8 bug workaround: */
485-
static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
485+
static int is_f00f_bug(struct pt_regs *regs, unsigned long error_code,
486+
unsigned long address)
486487
{
487488
#ifdef CONFIG_X86_F00F_BUG
488-
if (boot_cpu_has_bug(X86_BUG_F00F) && idt_is_f00f_address(address)) {
489+
if (boot_cpu_has_bug(X86_BUG_F00F) && !(error_code & X86_PF_USER) &&
490+
idt_is_f00f_address(address)) {
489491
handle_invalid_op(regs);
490492
return 1;
491493
}
@@ -853,9 +855,6 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
853855
return;
854856
}
855857

856-
if (is_f00f_bug(regs, address))
857-
return;
858-
859858
no_context(regs, error_code, address, SIGSEGV, si_code);
860859
}
861860

@@ -1195,6 +1194,9 @@ do_kern_addr_fault(struct pt_regs *regs, unsigned long hw_error_code,
11951194
}
11961195
#endif
11971196

1197+
if (is_f00f_bug(regs, hw_error_code, address))
1198+
return;
1199+
11981200
/* Was the fault spurious, caused by lazy TLB invalidation? */
11991201
if (spurious_kernel_fault(hw_error_code, address))
12001202
return;

0 commit comments

Comments
 (0)