From: Borislav Petkov <bp@alien8.de>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
x86@kernel.org, Filipe Manana <fdmanana@suse.com>,
stable@vger.kernel.org
Subject: Re: [patch 1/3] x86/fpu: Prevent FPU state corruption
Date: Mon, 2 May 2022 15:16:16 +0200 [thread overview]
Message-ID: <Ym/ZoAIvawVUljjz@zn.tnic> (raw)
In-Reply-To: <20220501193102.588689270@linutronix.de>
On Sun, May 01, 2022 at 09:31:43PM +0200, Thomas Gleixner wrote:
> The latter is checking whether some other context already uses FPU in the
> kernel, but if that's not the case then it allows FPU to be used
> unconditionally even if the calling context interupted a fpregs_lock()
Unknown word [interupted] in commit message.
Suggestions: ['interrupted', ...
> /*
> * Can we use the FPU in kernel mode with the
> * whole "kernel_fpu_begin/end()" sequence?
While at it, drop the "we": "Can the FPU be used in kernel mode... "
> - *
> - * It's always ok in process context (ie "not interrupt")
> - * but it is sometimes ok even from an irq.
> */
> bool irq_fpu_usable(void)
> {
> - return !in_interrupt() ||
> - interrupted_user_mode() ||
> - interrupted_kernel_fpu_idle();
> + if (WARN_ON_ONCE(in_nmi()))
> + return false;
> +
> + /* In kernel FPU usage already active? */
> + if (this_cpu_read(in_kernel_fpu))
> + return false;
> +
> + /*
> + * When not in NMI or hard interrupt context, FPU can be used:
"... can be used in:"
> + *
> + * - Task context is safe except from within fpregs_lock()'ed
> + * critical regions.
> + *
> + * - Soft interrupt processing context which cannot happen
> + * while in a fpregs_lock()'ed critical region.
But those are only nitpicks. With those fixed:
Reviewed-by: Borislav Petkov <bp@suse.de>
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
next prev parent reply other threads:[~2022-05-02 13:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220501192740.203963477@linutronix.de>
2022-05-01 19:31 ` [patch 1/3] x86/fpu: Prevent FPU state corruption Thomas Gleixner
2022-05-02 13:16 ` Borislav Petkov [this message]
2022-05-05 0:42 ` [tip: x86/urgent] " tip-bot2 for Thomas Gleixner
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=Ym/ZoAIvawVUljjz@zn.tnic \
--to=bp@alien8.de \
--cc=fdmanana@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--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