Skip to content

Commit

Permalink
x86/fault/32: Move is_f00f_bug() to do_kern_addr_fault()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
amluto authored and suryasaimadhu committed Feb 10, 2021
1 parent ec35271 commit f42a40f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions arch/x86/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,10 +482,12 @@ static int is_errata100(struct pt_regs *regs, unsigned long address)
}

/* Pentium F0 0F C7 C8 bug workaround: */
static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
static int is_f00f_bug(struct pt_regs *regs, unsigned long error_code,
unsigned long address)
{
#ifdef CONFIG_X86_F00F_BUG
if (boot_cpu_has_bug(X86_BUG_F00F) && idt_is_f00f_address(address)) {
if (boot_cpu_has_bug(X86_BUG_F00F) && !(error_code & X86_PF_USER) &&
idt_is_f00f_address(address)) {
handle_invalid_op(regs);
return 1;
}
Expand Down Expand Up @@ -853,9 +855,6 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
return;
}

if (is_f00f_bug(regs, address))
return;

no_context(regs, error_code, address, SIGSEGV, si_code);
}

Expand Down Expand Up @@ -1195,6 +1194,9 @@ do_kern_addr_fault(struct pt_regs *regs, unsigned long hw_error_code,
}
#endif

if (is_f00f_bug(regs, hw_error_code, address))
return;

/* Was the fault spurious, caused by lazy TLB invalidation? */
if (spurious_kernel_fault(hw_error_code, address))
return;
Expand Down

0 comments on commit f42a40f

Please sign in to comment.