[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250724013422.307954-2-sohil.mehta@intel.com>
Date: Wed, 23 Jul 2025 18:34:22 -0700
From: Sohil Mehta <sohil.mehta@...el.com>
To: Dave Hansen <dave.hansen@...ux.intel.com>,
x86@...nel.org
Cc: Borislav Petkov <bp@...en8.de>,
"H . Peter Anvin" <hpa@...or.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
Dave Hansen <dave.hansen@...el.com>,
Sohil Mehta <sohil.mehta@...el.com>,
Sean Christopherson <seanjc@...gle.com>,
Peter Zijlstra <peterz@...radead.org>,
Vignesh Balasubramanian <vigbalas@....com>,
Rick Edgecombe <rick.p.edgecombe@...el.com>,
Oleg Nesterov <oleg@...hat.com>,
"Chang S . Bae" <chang.seok.bae@...el.com>,
Brian Gerst <brgerst@...il.com>,
Eric Biggers <ebiggers@...gle.com>,
Kees Cook <kees@...nel.org>,
Chao Gao <chao.gao@...el.com>,
Fushuai Wang <wangfushuai@...du.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH v3 2/2] x86/fpu: Update the debug flow for x86_task_fpu()
Kernel threads aren't expected to directly access struct fpu using
x86_task_fpu(). They typically access the FPU state using pairs of
kernel_fpu_begin()/kernel_fpu_end().
When CONFIG_X86_DEBUG_FPU is set, any usage of x86_task_fpu() by kernel
threads is flagged with a WARN_ON_ONCE(). However, along with the
warning, x86_task_fpu() returns a NULL pointer, which deviates from the
flow without the debug config.
Changing the return value could make failures harder to debug by masking
problems or introducing its own set of issues. Keep the behavior of
x86_task_fpu() consistent across debug and non-debug configurations,
except for the warning.
Also, update the warning to include PF_USER_WORKER, as these tasks are
treated as equivalent to kernel threads during FPU state management as
well as context switch.
Signed-off-by: Sohil Mehta <sohil.mehta@...el.com>
---
v3: Improve commit message
v2: New patch
This patch is less urgent than Patch 1, which fixes the real issue.
---
arch/x86/kernel/fpu/core.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index ea138583dd92..ba16dda697b1 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -58,8 +58,7 @@ DEFINE_PER_CPU(struct fpu *, fpu_fpregs_owner_ctx);
#ifdef CONFIG_X86_DEBUG_FPU
struct fpu *x86_task_fpu(struct task_struct *task)
{
- if (WARN_ON_ONCE(task->flags & PF_KTHREAD))
- return NULL;
+ WARN_ON_ONCE(task->flags & (PF_KTHREAD | PF_USER_WORKER));
return (void *)task + sizeof(*task);
}
--
2.43.0
Powered by blists - more mailing lists