From: Mateusz Guzik <mjguzik@gmail.com>
To: bp@alien8.de
Cc: linux-kernel@vger.kernel.org, x86@kernel.org,
Mateusz Guzik <mjguzik@gmail.com>
Subject: [PATCH] x86/CPU/AMD: inline amd_clear_divider
Date: Thu, 13 Jun 2024 10:26:37 +0200 [thread overview]
Message-ID: <20240613082637.659133-1-mjguzik@gmail.com> (raw)
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 func call even on CPUs which do need
the mitigation.
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
---
This is a random tidbit I spotted at the bottom of the profile while
looking at something else, I did not bother benchmarking the change --
not sneaking in a func call to syscall exit should not require a
justification. :)
I am assuming the ALTERNATIVE mechanism does work fine for inlined
routines.
I am not going to argue for the change. If you don't want it altogether
that's it.
If there are cosmetic touch ups you want done here I would appreciate if
you just did them yourself, I merely copied a chunk elsewhere.
cheers
arch/x86/include/asm/processor.h | 12 +++++++++++-
arch/x86/kernel/cpu/amd.c | 11 -----------
2 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index cb4f6c513c48..7a1f741df8f1 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 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; }
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 44df3f11e731..be5889bded49 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -1220,14 +1220,3 @@ void amd_check_microcode(void)
on_each_cpu(zenbleed_check_cpu, NULL, 1);
}
-
-/*
- * Issue a DIV 0/1 insn to clear any division data from previous DIV
- * operations.
- */
-void noinstr amd_clear_divider(void)
-{
- asm volatile(ALTERNATIVE("", "div %2\n\t", X86_BUG_DIV0)
- :: "a" (0), "d" (0), "r" (1));
-}
-EXPORT_SYMBOL_GPL(amd_clear_divider);
--
2.43.0
next reply other threads:[~2024-06-13 8:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-13 8:26 Mateusz Guzik [this message]
2024-06-13 13:04 ` [tip: x86/cpu] x86/CPU/AMD: Always inline amd_clear_divider() tip-bot2 for Mateusz Guzik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240613082637.659133-1-mjguzik@gmail.com \
--to=mjguzik@gmail.com \
--cc=bp@alien8.de \
--cc=linux-kernel@vger.kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®