mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-20 12:30:11 +07:00
dfb4a70f20
There are two CPUID bits for protection keys. One is for whether the CPU contains the feature, and the other will appear set once the OS enables protection keys. Specifically: Bit 04: OSPKE. If 1, OS has set CR4.PKE to enable Protection keys (and the RDPKRU/WRPKRU instructions) This is because userspace can not see CR4 contents, but it can see CPUID contents. X86_FEATURE_PKU is referred to as "PKU" in the hardware documentation: CPUID.(EAX=07H,ECX=0H):ECX.PKU [bit 3] X86_FEATURE_OSPKE is "OSPKU": CPUID.(EAX=07H,ECX=0H):ECX.OSPKE [bit 4] These are the first CPU features which need to look at the ECX word in CPUID leaf 0x7, so this patch also includes fetching that word in to the cpuinfo->x86_capability[] array. Add it to the disabled-features mask when its config option is off. Even though we are not using it here, we also extend the REQUIRED_MASK_BIT_SET() macro to keep it mirroring the DISABLED_MASK_BIT_SET() version. This means that in almost all code, you should use: cpu_has(c, X86_FEATURE_PKU) and *not* the CONFIG option. Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Dave Hansen <dave@sr71.net> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Rik van Riel <riel@redhat.com> Cc: linux-mm@kvack.org Link: http://lkml.kernel.org/r/20160212210201.7714C250@viggo.jf.intel.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
61 lines
1.7 KiB
C
61 lines
1.7 KiB
C
#ifndef _ASM_X86_DISABLED_FEATURES_H
|
|
#define _ASM_X86_DISABLED_FEATURES_H
|
|
|
|
/* These features, although they might be available in a CPU
|
|
* will not be used because the compile options to support
|
|
* them are not present.
|
|
*
|
|
* This code allows them to be checked and disabled at
|
|
* compile time without an explicit #ifdef. Use
|
|
* cpu_feature_enabled().
|
|
*/
|
|
|
|
#ifdef CONFIG_X86_INTEL_MPX
|
|
# define DISABLE_MPX 0
|
|
#else
|
|
# define DISABLE_MPX (1<<(X86_FEATURE_MPX & 31))
|
|
#endif
|
|
|
|
#ifdef CONFIG_X86_64
|
|
# define DISABLE_VME (1<<(X86_FEATURE_VME & 31))
|
|
# define DISABLE_K6_MTRR (1<<(X86_FEATURE_K6_MTRR & 31))
|
|
# define DISABLE_CYRIX_ARR (1<<(X86_FEATURE_CYRIX_ARR & 31))
|
|
# define DISABLE_CENTAUR_MCR (1<<(X86_FEATURE_CENTAUR_MCR & 31))
|
|
#else
|
|
# define DISABLE_VME 0
|
|
# define DISABLE_K6_MTRR 0
|
|
# define DISABLE_CYRIX_ARR 0
|
|
# define DISABLE_CENTAUR_MCR 0
|
|
#endif /* CONFIG_X86_64 */
|
|
|
|
#ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS
|
|
# define DISABLE_PKU (1<<(X86_FEATURE_PKU))
|
|
# define DISABLE_OSPKE (1<<(X86_FEATURE_OSPKE))
|
|
#else
|
|
# define DISABLE_PKU 0
|
|
# define DISABLE_OSPKE 0
|
|
#endif /* CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS */
|
|
|
|
/*
|
|
* Make sure to add features to the correct mask
|
|
*/
|
|
#define DISABLED_MASK0 (DISABLE_VME)
|
|
#define DISABLED_MASK1 0
|
|
#define DISABLED_MASK2 0
|
|
#define DISABLED_MASK3 (DISABLE_CYRIX_ARR|DISABLE_CENTAUR_MCR|DISABLE_K6_MTRR)
|
|
#define DISABLED_MASK4 0
|
|
#define DISABLED_MASK5 0
|
|
#define DISABLED_MASK6 0
|
|
#define DISABLED_MASK7 0
|
|
#define DISABLED_MASK8 0
|
|
#define DISABLED_MASK9 (DISABLE_MPX)
|
|
#define DISABLED_MASK10 0
|
|
#define DISABLED_MASK11 0
|
|
#define DISABLED_MASK12 0
|
|
#define DISABLED_MASK13 0
|
|
#define DISABLED_MASK14 0
|
|
#define DISABLED_MASK15 0
|
|
#define DISABLED_MASK16 (DISABLE_PKU|DISABLE_OSPKE)
|
|
|
|
#endif /* _ASM_X86_DISABLED_FEATURES_H */
|