diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2021-06-23 14:02:23 +0200 |
---|---|---|
committer | Borislav Petkov <bp@suse.de> | 2021-06-23 19:55:51 +0200 |
commit | 72a6c08c44e4460e39315ca828f60b8d5afd6b19 (patch) | |
tree | 385a8cb9ee0dc549709a9afd559e3095cd645db1 /arch/x86/include/asm/pkru.h | |
parent | 0e8c54f6b2c8b1037cef9276e451522ee90ed969 (diff) | |
download | linux-stable-72a6c08c44e4460e39315ca828f60b8d5afd6b19.tar.gz linux-stable-72a6c08c44e4460e39315ca828f60b8d5afd6b19.tar.bz2 linux-stable-72a6c08c44e4460e39315ca828f60b8d5afd6b19.zip |
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/asm/pkru.h')
-rw-r--r-- | arch/x86/include/asm/pkru.h | 17 |
1 files changed, 4 insertions, 13 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) |