aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/include/asm/pgtable.h8
-rw-r--r--arch/x86/include/asm/special_insns.h22
2 files changed, 30 insertions, 0 deletions
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 0687c4748b8f..e997dcc6ee2b 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -99,6 +99,14 @@ static inline int pte_dirty(pte_t pte)
99 return pte_flags(pte) & _PAGE_DIRTY; 99 return pte_flags(pte) & _PAGE_DIRTY;
100} 100}
101 101
102
103static inline u32 read_pkru(void)
104{
105 if (boot_cpu_has(X86_FEATURE_OSPKE))
106 return __read_pkru();
107 return 0;
108}
109
102static inline int pte_young(pte_t pte) 110static inline int pte_young(pte_t pte)
103{ 111{
104 return pte_flags(pte) & _PAGE_ACCESSED; 112 return pte_flags(pte) & _PAGE_ACCESSED;
diff --git a/arch/x86/include/asm/special_insns.h b/arch/x86/include/asm/special_insns.h
index 2270e41b32fd..aee6e76e561e 100644
--- a/arch/x86/include/asm/special_insns.h
+++ b/arch/x86/include/asm/special_insns.h
@@ -98,6 +98,28 @@ static inline void native_write_cr8(unsigned long val)
98} 98}
99#endif 99#endif
100 100
101#ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS
102static inline u32 __read_pkru(void)
103{
104 u32 ecx = 0;
105 u32 edx, pkru;
106
107 /*
108 * "rdpkru" instruction. Places PKRU contents in to EAX,
109 * clears EDX and requires that ecx=0.
110 */
111 asm volatile(".byte 0x0f,0x01,0xee\n\t"
112 : "=a" (pkru), "=d" (edx)
113 : "c" (ecx));
114 return pkru;
115}
116#else
117static inline u32 __read_pkru(void)
118{
119 return 0;
120}
121#endif
122
101static inline void native_wbinvd(void) 123static inline void native_wbinvd(void)
102{ 124{
103 asm volatile("wbinvd": : :"memory"); 125 asm volatile("wbinvd": : :"memory");