summaryrefslogtreecommitdiff
path: root/arch/x86/include/asm/processor.h
diff options
context:
space:
mode:
authorMateusz Guzik <mjguzik@gmail.com>2024-06-13 10:26:37 +0200
committerBorislav Petkov (AMD) <bp@alien8.de>2024-06-13 14:40:29 +0200
commit501bd734f933f4eb5c080b87936e9d43f471d723 (patch)
tree16b37e70d6317bdce9fdd6e8cc3b6e62b8c5e480 /arch/x86/include/asm/processor.h
parenteb9d3c0bb065e55af6ec88e82a94b57fa1bb6e5d (diff)
downloadlinux-501bd734f933f4eb5c080b87936e9d43f471d723.tar.gz
linux-501bd734f933f4eb5c080b87936e9d43f471d723.tar.bz2
linux-501bd734f933f4eb5c080b87936e9d43f471d723.zip
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
Diffstat (limited to 'arch/x86/include/asm/processor.h')
-rw-r--r--arch/x86/include/asm/processor.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index cb4f6c513c48..a75a07f4931f 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -692,7 +692,17 @@ static inline u32 per_cpu_l2c_id(unsigned int cpu)
#ifdef CONFIG_CPU_SUP_AMD
extern u32 amd_get_highest_perf(void);
-extern void amd_clear_divider(void);
+
+/*
+ * Issue a DIV 0/1 insn to clear any division data from previous DIV
+ * operations.
+ */
+static __always_inline void amd_clear_divider(void)
+{
+ asm volatile(ALTERNATIVE("", "div %2\n\t", X86_BUG_DIV0)
+ :: "a" (0), "d" (0), "r" (1));
+}
+
extern void amd_check_microcode(void);
#else
static inline u32 amd_get_highest_perf(void) { return 0; }