Re: [PATCH 2/2] x86/pkeys: Set XINUSE[PKRU] to 1 so that PKRU is XRSTOR'd correctly
From: Dave Hansen
Date: Wed Nov 13 2024 - 14:10:21 EST
On 11/13/24 10:14, Aruna Ramakrishna wrote:
> PKRU value is not XRSTOR'd from the XSAVE area if the corresponding
> XINUSE[i] bit is 0. When PKRU value is set to 0, it sets XINUSE[PKRU]
> to 0 on AMD systems, which means the value updated on the sigframe
> later (after a wrpkru(0)) is ignored.
I think this is confusing XINUSE and XSTATE_BV.
XINUSE is really internal to the CPU and is partially exposed in
xgetbv(1). But XINUSE is monolithic; it includes user and supervisor state.
XSTATE_BV is the actual memory location in the XSAVE buffer.
So I think it's incorrect to say that XRSTOR behavior depends on XINUSE.
XRSTOR behavior depends on XSTATE_BV.