lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250829150535.GA17416@redhat.com>
Date: Fri, 29 Aug 2025 17:05:35 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: Ingo Molnar <mingo@...hat.com>
Cc: Borislav Petkov <bp@...en8.de>, Chao Gao <chao.gao@...el.com>,
	Dave Hansen <dave.hansen@...ux.intel.com>,
	"Edgecombe, Rick P" <rick.p.edgecombe@...el.com>,
	Eric Biggers <ebiggers@...gle.com>,
	"H. Peter Anvin" <hpa@...or.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Thomas Gleixner <tglx@...utronix.de>, linux-kernel@...r.kernel.org,
	x86@...nel.org
Subject: [PATCH] x86/fpu: kill the PF_KTHREAD|PF_USER_WORKER check in
 switch_fpu() and kernel_fpu_begin_mask()

PF_KTHREAD | PF_USER_WORKER kernel threads do not use their FPU context,
this means that TIF_NEED_FPU_LOAD must be always set, we can remove the
unnecessary "PF_KTHREAD | PF_USER_WORKER" check.

Signed-off-by: Oleg Nesterov <oleg@...hat.com>
---
 arch/x86/include/asm/fpu/sched.h | 3 +--
 arch/x86/kernel/fpu/core.c       | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/fpu/sched.h b/arch/x86/include/asm/fpu/sched.h
index c060549c6c94..20091b4cda6a 100644
--- a/arch/x86/include/asm/fpu/sched.h
+++ b/arch/x86/include/asm/fpu/sched.h
@@ -32,8 +32,7 @@ extern void fpu_flush_thread(void);
 static inline void switch_fpu(struct task_struct *old, int cpu)
 {
 	if (!test_tsk_thread_flag(old, TIF_NEED_FPU_LOAD) &&
-	    cpu_feature_enabled(X86_FEATURE_FPU) &&
-	    !(old->flags & (PF_KTHREAD | PF_USER_WORKER))) {
+	    cpu_feature_enabled(X86_FEATURE_FPU)) {
 		struct fpu *old_fpu = x86_task_fpu(old);
 
 		set_tsk_thread_flag(old, TIF_NEED_FPU_LOAD);
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index aefd412a23dc..ef54da3c1f1a 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -453,8 +453,7 @@ void kernel_fpu_begin_mask(unsigned int kfpu_mask)
 	WARN_ON_FPU(!this_cpu_read(kernel_fpu_allowed));
 	this_cpu_write(kernel_fpu_allowed, false);
 
-	if (!(current->flags & (PF_KTHREAD | PF_USER_WORKER)) &&
-	    !test_thread_flag(TIF_NEED_FPU_LOAD)) {
+	if (!test_thread_flag(TIF_NEED_FPU_LOAD)) {
 		set_thread_flag(TIF_NEED_FPU_LOAD);
 		save_fpregs_to_fpstate(x86_task_fpu(current));
 	}
-- 
2.25.1.362.g51ebf55



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ