From: Sohil Mehta <sohil.mehta@intel.com>
To: Rick Edgecombe <rick.p.edgecombe@intel.com>, <tglx@linutronix.de>,
<mingo@redhat.com>, <bp@alien8.de>, <x86@kernel.org>,
<hpa@zytor.com>, <dave.hansen@linux.intel.com>, <luto@kernel.org>,
<peterz@infradead.org>
Cc: <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86: Use __fpu_invalidate_fpregs_state() in exec
Date: Tue, 22 Aug 2023 13:10:57 -0700 [thread overview]
Message-ID: <2398119e-a03e-4bf9-12e7-722fb23f8c72@intel.com> (raw)
In-Reply-To: <20230818170305.502891-1-rick.p.edgecombe@intel.com>
Hi Rick,
The comment below doesn't change anything meaningfully, but mainly helps
clarifies the original comment.
Maybe something like this:
> * If the FPU register state is valid, the kernel can skip restoring the
> * FPU state from memory.
> *
> - * Any code that clobbers the FPU registers or updates the in-memory
> - * FPU state for a task MUST let the rest of the kernel know that the
> - * FPU registers are no longer valid for this task.
> + * Any code that clobbers the FPU registers or updates the in-memory FPU state
> + * for a task MUST let the rest of the kernel know that whether the FPU
> + * registers are no longer valid anywhere for this task or if the FPU state on
> + * a particular CPU is invalid.
> *
> - * Either one of these invalidation functions is enough. Invalidate
> - * a resource you control: CPU if using the CPU for something else
> - * (with preemption disabled), FPU for the current task, or a task that
> - * is prevented from running by the current task.
> + * Invalidate a resource that you truly control:
> + * - Use __cpu_invalidate_fpregs_state() or equivalent when using the CPU for
> + * something else (only with preemption disabled)
> + * - Use __fpu_invalidate_fpregs_state() or equivalent when modifying the FPU
> + * for the current task, or a task that is prevented from running by the
> + * current task.
> */
Please disregard my suggestion if you think the existing one is
sufficient for now.
On 8/18/2023 10:03 AM, Rick Edgecombe wrote:
> diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
> index e03b6b107b20..a86d37052a64 100644
> --- a/arch/x86/kernel/fpu/core.c
> +++ b/arch/x86/kernel/fpu/core.c
> @@ -713,7 +713,7 @@ static void fpu_reset_fpregs(void)
> struct fpu *fpu = ¤t->thread.fpu;
>
> fpregs_lock();
> - fpu__drop(fpu);
> + __fpu_invalidate_fpregs_state(fpu);
> /*
> * This does not change the actual hardware registers. It just
> * resets the memory image and sets TIF_NEED_FPU_LOAD so a
The code fix looks fine to me.
Even if you don't update the comment, please feel free to add:
Reviewed-by: Sohil Mehta <sohil.mehta@intel.com>
next prev parent reply other threads:[~2023-08-22 20:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-18 17:03 [PATCH] x86: Use __fpu_invalidate_fpregs_state() in exec Rick Edgecombe
2023-08-18 19:35 ` Lijun Pan
2023-08-18 21:56 ` Sohil Mehta
2023-08-24 0:04 ` Lijun Pan
2023-08-18 23:35 ` Sohil Mehta
2023-08-22 20:10 ` Sohil Mehta [this message]
2023-08-24 9:11 ` [tip: x86/urgent] x86/fpu: Invalidate FPU state correctly on exec() tip-bot2 for Rick Edgecombe
2023-08-24 15:22 ` Edgecombe, Rick P
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=2398119e-a03e-4bf9-12e7-722fb23f8c72@intel.com \
--to=sohil.mehta@intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rick.p.edgecombe@intel.com \
--cc=tglx@linutronix.de \
--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