mirror of
https://github.com/torvalds/linux.git
synced 2024-12-27 13:22:23 +00: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>
104 lines
2.6 KiB
C
104 lines
2.6 KiB
C
#ifndef _ASM_X86_REQUIRED_FEATURES_H
|
|
#define _ASM_X86_REQUIRED_FEATURES_H
|
|
|
|
/* Define minimum CPUID feature set for kernel These bits are checked
|
|
really early to actually display a visible error message before the
|
|
kernel dies. Make sure to assign features to the proper mask!
|
|
|
|
Some requirements that are not in CPUID yet are also in the
|
|
CONFIG_X86_MINIMUM_CPU_FAMILY which is checked too.
|
|
|
|
The real information is in arch/x86/Kconfig.cpu, this just converts
|
|
the CONFIGs into a bitmask */
|
|
|
|
#ifndef CONFIG_MATH_EMULATION
|
|
# define NEED_FPU (1<<(X86_FEATURE_FPU & 31))
|
|
#else
|
|
# define NEED_FPU 0
|
|
#endif
|
|
|
|
#if defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
|
|
# define NEED_PAE (1<<(X86_FEATURE_PAE & 31))
|
|
#else
|
|
# define NEED_PAE 0
|
|
#endif
|
|
|
|
#ifdef CONFIG_X86_CMPXCHG64
|
|
# define NEED_CX8 (1<<(X86_FEATURE_CX8 & 31))
|
|
#else
|
|
# define NEED_CX8 0
|
|
#endif
|
|
|
|
#if defined(CONFIG_X86_CMOV) || defined(CONFIG_X86_64)
|
|
# define NEED_CMOV (1<<(X86_FEATURE_CMOV & 31))
|
|
#else
|
|
# define NEED_CMOV 0
|
|
#endif
|
|
|
|
#ifdef CONFIG_X86_USE_3DNOW
|
|
# define NEED_3DNOW (1<<(X86_FEATURE_3DNOW & 31))
|
|
#else
|
|
# define NEED_3DNOW 0
|
|
#endif
|
|
|
|
#if defined(CONFIG_X86_P6_NOP) || defined(CONFIG_X86_64)
|
|
# define NEED_NOPL (1<<(X86_FEATURE_NOPL & 31))
|
|
#else
|
|
# define NEED_NOPL 0
|
|
#endif
|
|
|
|
#ifdef CONFIG_MATOM
|
|
# define NEED_MOVBE (1<<(X86_FEATURE_MOVBE & 31))
|
|
#else
|
|
# define NEED_MOVBE 0
|
|
#endif
|
|
|
|
#ifdef CONFIG_X86_64
|
|
#ifdef CONFIG_PARAVIRT
|
|
/* Paravirtualized systems may not have PSE or PGE available */
|
|
#define NEED_PSE 0
|
|
#define NEED_PGE 0
|
|
#else
|
|
#define NEED_PSE (1<<(X86_FEATURE_PSE) & 31)
|
|
#define NEED_PGE (1<<(X86_FEATURE_PGE) & 31)
|
|
#endif
|
|
#define NEED_MSR (1<<(X86_FEATURE_MSR & 31))
|
|
#define NEED_FXSR (1<<(X86_FEATURE_FXSR & 31))
|
|
#define NEED_XMM (1<<(X86_FEATURE_XMM & 31))
|
|
#define NEED_XMM2 (1<<(X86_FEATURE_XMM2 & 31))
|
|
#define NEED_LM (1<<(X86_FEATURE_LM & 31))
|
|
#else
|
|
#define NEED_PSE 0
|
|
#define NEED_MSR 0
|
|
#define NEED_PGE 0
|
|
#define NEED_FXSR 0
|
|
#define NEED_XMM 0
|
|
#define NEED_XMM2 0
|
|
#define NEED_LM 0
|
|
#endif
|
|
|
|
#define REQUIRED_MASK0 (NEED_FPU|NEED_PSE|NEED_MSR|NEED_PAE|\
|
|
NEED_CX8|NEED_PGE|NEED_FXSR|NEED_CMOV|\
|
|
NEED_XMM|NEED_XMM2)
|
|
#define SSE_MASK (NEED_XMM|NEED_XMM2)
|
|
|
|
#define REQUIRED_MASK1 (NEED_LM|NEED_3DNOW)
|
|
|
|
#define REQUIRED_MASK2 0
|
|
#define REQUIRED_MASK3 (NEED_NOPL)
|
|
#define REQUIRED_MASK4 (NEED_MOVBE)
|
|
#define REQUIRED_MASK5 0
|
|
#define REQUIRED_MASK6 0
|
|
#define REQUIRED_MASK7 0
|
|
#define REQUIRED_MASK8 0
|
|
#define REQUIRED_MASK9 0
|
|
#define REQUIRED_MASK10 0
|
|
#define REQUIRED_MASK11 0
|
|
#define REQUIRED_MASK12 0
|
|
#define REQUIRED_MASK13 0
|
|
#define REQUIRED_MASK14 0
|
|
#define REQUIRED_MASK15 0
|
|
#define REQUIRED_MASK16 0
|
|
|
|
#endif /* _ASM_X86_REQUIRED_FEATURES_H */
|