diff options
-rw-r--r-- | arch/x86/include/asm/pgtable.h | 6 | ||||
-rw-r--r-- | arch/x86/include/asm/special_insns.h | 16 |
2 files changed, 22 insertions, 0 deletions
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 1ff49ec29ece..97f3242e133c 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h | |||
@@ -107,6 +107,12 @@ static inline u32 read_pkru(void) | |||
107 | return 0; | 107 | return 0; |
108 | } | 108 | } |
109 | 109 | ||
110 | static inline void write_pkru(u32 pkru) | ||
111 | { | ||
112 | if (boot_cpu_has(X86_FEATURE_OSPKE)) | ||
113 | __write_pkru(pkru); | ||
114 | } | ||
115 | |||
110 | static inline int pte_young(pte_t pte) | 116 | static inline int pte_young(pte_t pte) |
111 | { | 117 | { |
112 | return pte_flags(pte) & _PAGE_ACCESSED; | 118 | 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 aee6e76e561e..d96d04377765 100644 --- a/arch/x86/include/asm/special_insns.h +++ b/arch/x86/include/asm/special_insns.h | |||
@@ -113,11 +113,27 @@ static inline u32 __read_pkru(void) | |||
113 | : "c" (ecx)); | 113 | : "c" (ecx)); |
114 | return pkru; | 114 | return pkru; |
115 | } | 115 | } |
116 | |||
117 | static inline void __write_pkru(u32 pkru) | ||
118 | { | ||
119 | u32 ecx = 0, edx = 0; | ||
120 | |||
121 | /* | ||
122 | * "wrpkru" instruction. Loads contents in EAX to PKRU, | ||
123 | * requires that ecx = edx = 0. | ||
124 | */ | ||
125 | asm volatile(".byte 0x0f,0x01,0xef\n\t" | ||
126 | : : "a" (pkru), "c"(ecx), "d"(edx)); | ||
127 | } | ||
116 | #else | 128 | #else |
117 | static inline u32 __read_pkru(void) | 129 | static inline u32 __read_pkru(void) |
118 | { | 130 | { |
119 | return 0; | 131 | return 0; |
120 | } | 132 | } |
133 | |||
134 | static inline void __write_pkru(u32 pkru) | ||
135 | { | ||
136 | } | ||
121 | #endif | 137 | #endif |
122 | 138 | ||
123 | static inline void native_wbinvd(void) | 139 | static inline void native_wbinvd(void) |