From: Mel Gorman <mgorman@techsingularity.net>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: "Chang S. Bae" <chang.seok.bae@intel.com>,
Borislav Petkov <bp@suse.de>, Mike Galbraith <efault@gmx.de>,
LKML <linux-kernel@vger.kernel.org>,
Linux-RT <linux-rt-users@vger.kernel.org>
Subject: Re: [RFC PATCH] x86: Drop fpregs lock before inheriting FPU permissions during clone
Date: Thu, 10 Nov 2022 12:18:31 +0000 [thread overview]
Message-ID: <20221110121831.ehke4sxsmlpl454e@techsingularity.net> (raw)
In-Reply-To: <87o7tg8584.ffs@tglx>
On Wed, Nov 09, 2022 at 05:25:47PM +0100, Thomas Gleixner wrote:
> On Wed, Nov 09 2022 at 11:30, Mel Gorman wrote:
> > BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:46
> ...
> > The splat comes from fpu_inherit_perms() being called under fpregs_lock(),
> > and us reaching the spin_lock_irq() therein due to fpu_state_size_dynamic()
> > returning true despite static key __fpu_state_size_dynamic having never
> > been enabled.
> >
> > Mike's assessment looks correct. fpregs_lock on PREEMPT_RT disables
> > preemption only so the spin_lock_irq() in fpu_inherit_perms is unsafe
> > and converting siglock to raw spinlock would be an unwelcome change.
> > This problem exists since commit 9e798e9aa14c ("x86/fpu: Prepare fpu_clone()
> > for dynamically enabled features"). While the bug triggering is probably a
> > mistake for the affected machine and due to a bug that is not in mainline,
> > spin_lock_irq within a preempt_disable section on PREEMPT_RT is problematic.
> >
> > In this specific context, it may not be necessary to hold fpregs_lock at
> > all. The lock is necessary when editing the FPU registers or a tasks fpstate
> > but in this case, the only write of any FP state in fpu_inherit_perms is
> > for the new child which is not running yet so it cannot context switch or
> > be borrowed by a kernel thread yet. Hence, fpregs_lock is not protecting
> > anything in the new child until clone() completes. The siglock still needs
> > to be acquired by fpu_inherit_perms as the read of the parents permissions
> > has to be serialised.
>
> That's correct and siglock is the real protection for the permissions.
>
> > This is not tested as I did not access to a machine with Intel's
> > eXtended Feature Disable (XFD) feature that enables the relevant path
> > in fpu_inherit_perms and the bug is against a non-mainline kernel.
>
> It's still entirely correct on mainline as there is no requirement to
> hold fpregs_lock in this case
>
> > Reported-by: Mike Galbraith <efault@gmx.de>
> > Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
>
> Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Perfect, I'll rephase the changelog slightly and resend without RFC and
all the x86 maintainers cc'd. Thanks Thomas!
--
Mel Gorman
SUSE Labs
prev parent reply other threads:[~2022-11-10 12:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-09 11:30 [RFC PATCH] x86: Drop fpregs lock before inheriting FPU permissions during clone Mel Gorman
2022-11-09 16:25 ` Thomas Gleixner
2022-11-10 12:18 ` Mel Gorman [this message]
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=20221110121831.ehke4sxsmlpl454e@techsingularity.net \
--to=mgorman@techsingularity.net \
--cc=bp@suse.de \
--cc=chang.seok.bae@intel.com \
--cc=efault@gmx.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=tglx@linutronix.de \
/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