Re: XSAVE / RDPKRU on Intel 11th Gen Core CPUs

From: Brian Geffon
Date: Tue Nov 09 2021 - 09:14:57 EST


On Tue, Nov 9, 2021 at 8:43 AM Brian Geffon <bgeffon@xxxxxxxxxx> wrote:

> What's interesting is that writing to init_pkru fails with -EINVAL for me,
> and I've traced it down to get_xsave_addr() returning NULL on the following
> check:
>
> /*
> * This assumes the last 'xsave*' instruction to
> * have requested that 'xfeature_nr' be saved.
> * If it did not, we might be seeing and old value
> * of the field in the buffer.
> *
> * This can happen because the last 'xsave' did not
> * request that this feature be saved (unlikely)
> * or because the "init optimization" caused it
> * to not be saved.
> */
> if (!(xsave->header.xfeatures & BIT_ULL(xfeature_nr)))
> return NULL;
>

Sorry, I should have probably also shared the value of xfeatures at
this point is 0x3: which appears to be: (X86_FEATURE_FPU |
X86_FEATURE_XMM)

Brian