From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: x86@kernel.org, Filipe Manana <fdmanana@suse.com>
Subject: [patch 2/3] x86/fpu: Rename irq_fpu_usable()
Date: Sun, 1 May 2022 21:31:45 +0200 (CEST) [thread overview]
Message-ID: <20220501193102.647328777@linutronix.de> (raw)
In-Reply-To: 20220501192740.203963477@linutronix.de
This can be invoked from almost any context, except NMI. The only
requirement is that the context is not migrateable.
Rename it to kernel_fpu_usable().
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
arch/um/include/asm/fpu/api.h | 2 +-
arch/x86/include/asm/fpu/api.h | 4 ++--
arch/x86/include/asm/simd.h | 2 +-
arch/x86/kernel/fpu/core.c | 13 +++++++------
net/netfilter/nft_set_pipapo_avx2.c | 2 +-
5 files changed, 12 insertions(+), 11 deletions(-)
--- a/arch/um/include/asm/fpu/api.h
+++ b/arch/um/include/asm/fpu/api.h
@@ -11,7 +11,7 @@
#define kernel_fpu_begin() (void)0
#define kernel_fpu_end() (void)0
-static inline bool irq_fpu_usable(void)
+static inline bool kernel_fpu_usable(void)
{
return true;
}
--- a/arch/x86/include/asm/fpu/api.h
+++ b/arch/x86/include/asm/fpu/api.h
@@ -19,7 +19,7 @@
* disables preemption so be careful if you intend to use it for long periods
* of time.
* If you intend to use the FPU in irq/softirq you need to check first with
- * irq_fpu_usable() if it is possible.
+ * kernel_fpu_usable() if it is possible.
*/
/* Kernel FPU states to initialize in kernel_fpu_begin_mask() */
@@ -28,7 +28,7 @@
extern void kernel_fpu_begin_mask(unsigned int kfpu_mask);
extern void kernel_fpu_end(void);
-extern bool irq_fpu_usable(void);
+extern bool kernel_fpu_usable(void);
extern void fpregs_mark_activate(void);
/* Code that is unaware of kernel_fpu_begin_mask() can use this */
--- a/arch/x86/include/asm/simd.h
+++ b/arch/x86/include/asm/simd.h
@@ -8,5 +8,5 @@
*/
static __must_check inline bool may_use_simd(void)
{
- return irq_fpu_usable();
+ return kernel_fpu_usable();
}
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -49,11 +49,12 @@ static DEFINE_PER_CPU(bool, in_kernel_fp
*/
DEFINE_PER_CPU(struct fpu *, fpu_fpregs_owner_ctx);
-/*
- * Can we use the FPU in kernel mode with the
- * whole "kernel_fpu_begin/end()" sequence?
+/**
+ * kernel_fpu_usable - Check whether kernel FPU usage is possible
+ *
+ * Has to be invoked before calling kernel_fpu_begin().
*/
-bool irq_fpu_usable(void)
+bool kernel_fpu_usable(void)
{
if (WARN_ON_ONCE(in_nmi()))
return false;
@@ -81,7 +82,7 @@ bool irq_fpu_usable(void)
*/
return !softirq_count();
}
-EXPORT_SYMBOL(irq_fpu_usable);
+EXPORT_SYMBOL(kernel_fpu_usable);
/*
* Track AVX512 state use because it is known to slow the max clock
@@ -409,7 +410,7 @@ void kernel_fpu_begin_mask(unsigned int
{
preempt_disable();
- WARN_ON_FPU(!irq_fpu_usable());
+ WARN_ON_FPU(!kernel_fpu_usable());
WARN_ON_FPU(this_cpu_read(in_kernel_fpu));
this_cpu_write(in_kernel_fpu, true);
--- a/net/netfilter/nft_set_pipapo_avx2.c
+++ b/net/netfilter/nft_set_pipapo_avx2.c
@@ -1128,7 +1128,7 @@ bool nft_pipapo_avx2_lookup(const struct
bool map_index;
int i, ret = 0;
- if (unlikely(!irq_fpu_usable()))
+ if (unlikely(!kernel_fpu_usable()))
return nft_pipapo_lookup(net, set, key, ext);
m = rcu_dereference(priv->match);
next prev parent reply other threads:[~2022-05-01 19:31 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-01 19:31 [patch 0/3] x86/fpu: Prevent FPU state corruption Thomas Gleixner
2022-05-01 19:31 ` [patch 1/3] " Thomas Gleixner
2022-05-02 13:16 ` Borislav Petkov
2022-05-05 0:42 ` [tip: x86/urgent] " tip-bot2 for Thomas Gleixner
2022-05-01 19:31 ` Thomas Gleixner [this message]
2022-05-02 13:57 ` [patch 2/3] x86/fpu: Rename irq_fpu_usable() Borislav Petkov
2022-05-01 19:31 ` [patch 3/3] x86/fpu: Make FPU protection more robust Thomas Gleixner
2022-05-02 14:35 ` Borislav Petkov
2022-05-02 15:58 ` Thomas Gleixner
2022-05-03 9:06 ` Peter Zijlstra
2022-05-04 15:36 ` Thomas Gleixner
2022-05-04 15:55 ` Jason A. Donenfeld
2022-05-04 16:45 ` Thomas Gleixner
2022-05-04 19:05 ` Jason A. Donenfeld
2022-05-04 21:04 ` Thomas Gleixner
2022-05-04 23:52 ` Jason A. Donenfeld
2022-05-05 0:55 ` Thomas Gleixner
2022-05-05 1:11 ` Jason A. Donenfeld
2022-05-05 1:21 ` Thomas Gleixner
2022-05-05 11:02 ` Jason A. Donenfeld
2022-05-05 11:34 ` David Laight
2022-05-05 11:35 ` Jason A. Donenfeld
2022-05-05 11:53 ` David Laight
2022-05-06 22:34 ` Jason A. Donenfeld
2022-05-07 13:50 ` David Laight
2022-05-05 13:48 ` Jason A. Donenfeld
2022-05-06 22:15 ` Jason A. Donenfeld
2022-05-03 9:03 ` Peter Zijlstra
2022-05-02 10:02 ` [patch 0/3] x86/fpu: Prevent FPU state corruption Filipe Manana
2022-05-02 12:22 ` Borislav Petkov
2022-05-04 15:40 ` Jason A. Donenfeld
2022-05-04 18:05 ` Thomas Gleixner
2022-05-18 1:02 ` Jason A. Donenfeld
2022-05-18 11:14 ` Jason A. Donenfeld
2022-05-18 11:18 ` Jason A. Donenfeld
2022-05-18 13:09 ` Thomas Gleixner
2022-05-18 14:08 ` Jason A. Donenfeld
2022-05-25 20:36 ` Jason A. Donenfeld
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=20220501193102.647328777@linutronix.de \
--to=tglx@linutronix.de \
--cc=fdmanana@suse.com \
--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