Re: [patch 0/8] x86/fpu: Mop up XSAVES and related damage

From: Thomas Gleixner
Date: Fri Jun 04 2021 - 10:05:23 EST

On Wed, Jun 02 2021 at 14:28, Yu-cheng Yu wrote:
> On 6/2/2021 2:55 AM, Thomas Gleixner wrote:
> With the series applied, glibc pkey test fails sometimes. I will try to
> find out the cause.

That fails not sometimes. It fails always due to patch 7/8. The reason
is that before that patch fpu__clear_all() reinitialized the hardware
which includes writing the initial PKRU value.

But fpu__initialize() does not store the initial PKRU value in the
task's xstate which breaks PKRU. As that patch is not urgent we can
postpone it for not.

But looking at the above, it's not clear to me why that PKRU stuff works
at all (upstream), but I'll figure it out eventually. I'm quite sure
that it does work by pure chance not by design.