[patch 27/41] x86/pkru: Provide pkru_write_default()
From: Thomas Gleixner
Date: Fri Jun 11 2021 - 12:45:37 EST
Provide a simple and trivial helper which just writes the PKRU default
value without trying to fiddle with the tasks xsave buffer.
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
---
V4: New patch
---
arch/x86/include/asm/pkru.h | 8 ++++++++
1 file changed, 8 insertions(+)
--- a/arch/x86/include/asm/pkru.h
+++ b/arch/x86/include/asm/pkru.h
@@ -60,4 +60,12 @@ static inline void write_pkru(u32 pkru)
fpregs_unlock();
}
+static inline void pkru_write_default(void)
+{
+ if (!cpu_feature_enabled(X86_FEATURE_OSPKE))
+ return;
+
+ wrpkru(pkru_get_init_value());
+}
+
#endif