From: Dave Hansen <dave.hansen@intel.com>
To: Brian Geffon <bgeffon@google.com>, Thomas Gleixner <tglx@linutronix.de>
Cc: Guenter Roeck <groeck@google.com>, Borislav Petkov <bp@suse.de>,
Andy Lutomirski <luto@kernel.org>,
stable@vger.kernel.org, the arch/x86 maintainers <x86@kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: XSAVE / RDPKRU on Intel 11th Gen Core CPUs
Date: Mon, 8 Nov 2021 11:37:31 -0800 [thread overview]
Message-ID: <cb682c8a-255e-28e5-d4e0-0981c2ab6ffd@intel.com> (raw)
In-Reply-To: <CADyq12yY25-LS8cV5LY-C=6_0HLPVZbSJCKtCDJm+wyHQSeVTg@mail.gmail.com>
... adding LKML and x86@
On 11/8/21 9:37 AM, Brian Geffon wrote:
> We (ChromeOS) have run into an issue which we believe is related to
> the following errata on 11th Gen Intel Core CPUs:
>
> "TGL034 A SYSENTER FOLLOWING AN XSAVE OR A VZEROALL MAY LEAD TO
> UNEXPECTED SYSTEM BEHAVIOR" [1]
I'm struggling to figure out what that has to do with PKRU, though. I
don't think that erratum is related at all to the issue you're seeing.
> Essentially we notice that the value returned by a RDPKRU instruction
> will flip after some amount of time when running on kernels earlier
> than 5.14. I have a simple repro that can be used [2].
What does it flip to, btw? Can you dump the whole register state?
> After a little digging it appears a lot of work was done to refactor
> that code and I bisected to the following commit which fixes the
> issue:
>
> commit 954436989cc550dd91aab98363240c9c0a4b7e23
> Author: Thomas Gleixner <tglx@linutronix.de>
> Date: Wed Jun 23 14:02:21 2021 +0200
>
> x86/fpu: Remove PKRU handling from switch_fpu_finish()
>
> I backported this patch to 5.4 and it does appear to fix the issue
> because it avoids XSAVE. However, I have no idea if it's actually
> fixing anything or if the behavior is working as intended. So we're
> curious, does it make sense to pull back that patch, would that patch
> be enough? Any guidance here would be appreciated because this does
> seem broken (because of how it was previously implemented) for those
> CPUs prior to 5.14, which is why I'm CCing stable@.
I suspect what you're seeing is that the:
- __write_pkru(pkru_val);
in that commit was somehow writing a bad value which was read out of the
XSAVE buffer. That commit stops reading PKRU out of the XSAVE buffer,
which probably has bad state. Just backporting this patch won't do you
any good. You'll need to also backport the stuff that stops using the
XSAVE buffer for PKRU in the first place.
The code doesn't bite you until the task context switches. It probably
has to switch to some pkey-using task and then back to your test app.
I'd randomly guess that your test app is getting a "leaked" PKRU from
another app. It's _probably_ not a stale PKRU value (like from reading
a PKRU!=0 value from the XSAVE buffer when XSTATE_BV[PKRU]=0) because
your test app should have PKRU=0 set at all times.
Is KVM active on your test system?
next parent reply other threads:[~2021-11-08 19:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CADyq12yY25-LS8cV5LY-C=6_0HLPVZbSJCKtCDJm+wyHQSeVTg@mail.gmail.com>
2021-11-08 19:37 ` Dave Hansen [this message]
2021-11-08 22:00 ` Dave Hansen
2021-11-08 23:20 ` Brian Geffon
2021-11-09 1:47 ` Brian Geffon
2021-11-09 6:49 ` Dave Hansen
2021-11-09 13:43 ` Brian Geffon
2021-11-09 14:14 ` Brian Geffon
2021-11-09 14:57 ` Andy Lutomirski
2021-11-09 18:58 ` Brian Geffon
2021-11-09 19:25 ` Brian Geffon
2021-11-09 19:29 ` Dave Hansen
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=cb682c8a-255e-28e5-d4e0-0981c2ab6ffd@intel.com \
--to=dave.hansen@intel.com \
--cc=bgeffon@google.com \
--cc=bp@suse.de \
--cc=groeck@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@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
all inboxes | Powered by JetHome®