path: root/ipc
diff options
authorDave Hansen <>2021-06-30 18:57:03 -0700
committerLinus Torvalds <>2021-07-01 11:06:06 -0700
commitd892454b6814f07da676dae5e686cf221d34a1af (patch)
tree0544b31cae35e98b052818e26ef9335a7b880eda /ipc
parent6039ca254979694c5362dfebadd105e286c397bb (diff)
selftests/vm/pkeys: exercise x86 XSAVE init state
On x86, there is a set of instructions used to save and restore register state collectively known as the XSAVE architecture. There are about a dozen different features managed with XSAVE. The protection keys register, PKRU, is one of those features. The hardware optimizes XSAVE by tracking when the state has not changed from its initial (init) state. In this case, it can avoid the cost of writing state to memory (it would usually just be a bunch of 0's). When the pkey register is 0x0 the hardware optionally choose to track the register as being in the init state (optimize away the writes). AMD CPUs do this more aggressively compared to Intel. On x86, PKRU is rarely in its (very permissive) init state. Instead, the value defaults to something very restrictive. It is not surprising that bugs have popped up in the rare cases when PKRU reaches its init state. Add a protection key selftest which gets the protection keys register into its init state in a way that should work on Intel and AMD. Then, do a bunch of pkey register reads to watch for inadvertent changes. This adds "-mxsave" to CFLAGS for all the x86 vm selftests in order to allow use of the XSAVE instruction __builtin functions. This will make the builtins available on all of the vm selftests, but is expected to be harmless. Link: Signed-off-by: Dave Hansen <> Signed-off-by: Thomas Gleixner <> Tested-by: Aneesh Kumar K.V <> Cc: Ram Pai <> Cc: Sandipan Das <> Cc: Florian Weimer <> Cc: "Desnes A. Nunes do Rosario" <> Cc: Ingo Molnar <> Cc: Thiago Jung Bauermann <> Cc: Michael Ellerman <> Cc: Michal Hocko <> Cc: Michal Suchanek <> Cc: Shuah Khan <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
Diffstat (limited to 'ipc')
0 files changed, 0 insertions, 0 deletions