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

From: Brian Geffon
Date: Mon Nov 08 2021 - 20:48:20 EST


> One more thing... Does the protection_keys kernel selftest hit any
> errors on this same setup? It does a lot of PKRU sanity checking and
> I'm a bit surprised it hasn't caught something yet.

Hi Dave,

This issue does reproduce with the self tests too, my simple test
program also fails consistently [1], all it does is spin executing
RDPKRU waiting for a context switch to clobber the value.

$ ./test
unexpected value on iteration 3772082 value:0x55555554 expected:0x55555550

==========================
self tests:

$ ./protection_keys_64
has pkeys: 1
startup pkey_reg: 0000000055555550
WARNING: not run as root, can not do hugetlb test
test 0 PASSED (iteration 1)
test 1 PASSED (iteration 1)
test 2 PASSED (iteration 1)
test 3 PASSED (iteration 1)
test 4 PASSED (iteration 1)
test 5 PASSED (iteration 1)
protection_keys_64: pkey-helpers.h:127: _read_pkey_reg: Assertion
`pkey_reg == shadow_pkey_reg' failed.
Aborted (core dumped)

$ uname -a
Linux localhost 5.13.0-17189-g62fb9874f5da #12 SMP PREEMPT Tue Nov 9
01:29:44 UTC 2021 x86_64 11th Gen Intel(R) Core(TM) i5-1135G7 @
2.40GHz GenuineIntel GNU/Linux

Let me know if I can provide anything else, I'm happy to help troubleshoot this.

Thanks,
Brian

1. https://gist.github.com/bgaff/e4b5457ab1cf5126fea6327666c63441