diff options
Diffstat (limited to 'arch/x86/include/asm/pgtable.h')
| -rw-r--r-- | arch/x86/include/asm/pgtable.h | 34 | 
1 files changed, 30 insertions, 4 deletions
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 2779ace16d23..5e0509b41986 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -23,6 +23,8 @@  #ifndef __ASSEMBLY__  #include <asm/x86_init.h> +#include <asm/fpu/xstate.h> +#include <asm/fpu/api.h>  extern pgd_t early_top_pgt[PTRS_PER_PGD];  int __init __early_make_pgtable(unsigned long address, pmdval_t pmd); @@ -46,7 +48,7 @@ void ptdump_walk_user_pgd_level_checkwx(void);   */  extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)]  	__visible; -#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) +#define ZERO_PAGE(vaddr) ((void)(vaddr),virt_to_page(empty_zero_page))  extern spinlock_t pgd_lock;  extern struct list_head pgd_list; @@ -127,14 +129,29 @@ static inline int pte_dirty(pte_t pte)  static inline u32 read_pkru(void)  {  	if (boot_cpu_has(X86_FEATURE_OSPKE)) -		return __read_pkru(); +		return rdpkru();  	return 0;  }  static inline void write_pkru(u32 pkru)  { -	if (boot_cpu_has(X86_FEATURE_OSPKE)) -		__write_pkru(pkru); +	struct pkru_state *pk; + +	if (!boot_cpu_has(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. +	 */ +	fpregs_lock(); +	if (pk) +		pk->pkru = pkru; +	__write_pkru(pkru); +	fpregs_unlock();  }  static inline int pte_young(pte_t pte) @@ -1021,6 +1038,9 @@ static inline void __meminit init_trampoline_default(void)  	/* Default trampoline pgd value */  	trampoline_pgd_entry = init_top_pgt[pgd_index(__PAGE_OFFSET)];  } + +void __init poking_init(void); +  # ifdef CONFIG_RANDOMIZE_MEMORY  void __meminit init_trampoline(void);  # else @@ -1355,6 +1375,12 @@ static inline pmd_t pmd_swp_clear_soft_dirty(pmd_t pmd)  #define PKRU_WD_BIT 0x2  #define PKRU_BITS_PER_PKEY 2 +#ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS +extern u32 init_pkru_value; +#else +#define init_pkru_value	0 +#endif +  static inline bool __pkru_allows_read(u32 pkru, u16 pkey)  {  	int pkru_pkey_bits = pkey * PKRU_BITS_PER_PKEY;  | 
