diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2021-06-23 15:02:23 +0300 |
---|---|---|
committer | Borislav Petkov <bp@suse.de> | 2021-06-23 20:55:51 +0300 |
commit | 72a6c08c44e4460e39315ca828f60b8d5afd6b19 (patch) | |
tree | 385a8cb9ee0dc549709a9afd559e3095cd645db1 /arch/x86/include | |
parent | 0e8c54f6b2c8b1037cef9276e451522ee90ed969 (diff) | |
download | linux-72a6c08c44e4460e39315ca828f60b8d5afd6b19.tar.xz |
x86/pkru: Remove xstate fiddling from write_pkru()
The PKRU value of a task is stored in task->thread.pkru when the task is
scheduled out. PKRU is restored on schedule in from there. So keeping the
XSAVE buffer up to date is a pointless exercise.
Remove the xstate fiddling and cleanup all related functions.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20210623121456.897372712@linutronix.de
Diffstat (limited to 'arch/x86/include')
-rw-r--r-- | arch/x86/include/asm/pkru.h | 17 | ||||
-rw-r--r-- | arch/x86/include/asm/special_insns.h | 14 |
2 files changed, 5 insertions, 26 deletions
diff --git a/arch/x86/include/asm/pkru.h b/arch/x86/include/asm/pkru.h index 7e4550911c51..ccc539faa5bb 100644 --- a/arch/x86/include/asm/pkru.h +++ b/arch/x86/include/asm/pkru.h @@ -41,23 +41,14 @@ static inline u32 read_pkru(void) static inline void write_pkru(u32 pkru) { - struct pkru_state *pk; - if (!cpu_feature_enabled(X86_FEATURE_OSPKE)) return; - - pk = get_xsave_addr(¤t->thread.fpu.state.xsave, XFEATURE_PKRU); - /* - * The PKRU value in xstate needs to be in sync with the value that is - * written to the CPU. The FPU restore on return to userland would - * otherwise load the previous value again. + * WRPKRU is relatively expensive compared to RDPKRU. + * Avoid WRPKRU when it would not change the value. */ - fpregs_lock(); - if (pk) - pk->pkru = pkru; - __write_pkru(pkru); - fpregs_unlock(); + if (pkru != rdpkru()) + wrpkru(pkru); } static inline void pkru_write_default(void) diff --git a/arch/x86/include/asm/special_insns.h b/arch/x86/include/asm/special_insns.h index 2acd6cb62328..f3fbb84ff8a7 100644 --- a/arch/x86/include/asm/special_insns.h +++ b/arch/x86/include/asm/special_insns.h @@ -104,25 +104,13 @@ static inline void wrpkru(u32 pkru) : : "a" (pkru), "c"(ecx), "d"(edx)); } -static inline void __write_pkru(u32 pkru) -{ - /* - * WRPKRU is relatively expensive compared to RDPKRU. - * Avoid WRPKRU when it would not change the value. - */ - if (pkru == rdpkru()) - return; - - wrpkru(pkru); -} - #else static inline u32 rdpkru(void) { return 0; } -static inline void __write_pkru(u32 pkru) +static inline void wrpkru(u32 pkru) { } #endif |