Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 501bd73

Browse files
mjguzikbp3tk0v
authored andcommitted
x86/CPU/AMD: Always inline amd_clear_divider()
The routine is used on syscall exit and on non-AMD CPUs is guaranteed to be empty. It probably does not need to be a function call even on CPUs which do need the mitigation. [ bp: Make sure it is always inlined so that noinstr marking works. ] Signed-off-by: Mateusz Guzik <mjguzik@gmail.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://lore.kernel.org/r/20240613082637.659133-1-mjguzik@gmail.com
1 parent eb9d3c0 commit 501bd73

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

arch/x86/include/asm/processor.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,17 @@ static inline u32 per_cpu_l2c_id(unsigned int cpu)
692692

693693
#ifdef CONFIG_CPU_SUP_AMD
694694
extern u32 amd_get_highest_perf(void);
695-
extern void amd_clear_divider(void);
695+
696+
/*
697+
* Issue a DIV 0/1 insn to clear any division data from previous DIV
698+
* operations.
699+
*/
700+
static __always_inline void amd_clear_divider(void)
701+
{
702+
asm volatile(ALTERNATIVE("", "div %2\n\t", X86_BUG_DIV0)
703+
:: "a" (0), "d" (0), "r" (1));
704+
}
705+
696706
extern void amd_check_microcode(void);
697707
#else
698708
static inline u32 amd_get_highest_perf(void) { return 0; }

arch/x86/kernel/cpu/amd.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,14 +1220,3 @@ void amd_check_microcode(void)
12201220

12211221
on_each_cpu(zenbleed_check_cpu, NULL, 1);
12221222
}
1223-
1224-
/*
1225-
* Issue a DIV 0/1 insn to clear any division data from previous DIV
1226-
* operations.
1227-
*/
1228-
void noinstr amd_clear_divider(void)
1229-
{
1230-
asm volatile(ALTERNATIVE("", "div %2\n\t", X86_BUG_DIV0)
1231-
:: "a" (0), "d" (0), "r" (1));
1232-
}
1233-
EXPORT_SYMBOL_GPL(amd_clear_divider);

0 commit comments

Comments
 (0)