blob: 7b84565c916c7b0329ac92c79c789748ff9eeb28 [file] [log] [blame]
Dave Hansen66d37572016-02-12 13:02:32 -08001#ifndef _ASM_X86_PKEYS_H
2#define _ASM_X86_PKEYS_H
3
4#define arch_max_pkey() (boot_cpu_has(X86_FEATURE_OSPKE) ? 16 : 1)
5
Dave Hansen84594292016-02-12 13:02:36 -08006extern int arch_set_user_pkey_access(struct task_struct *tsk, int pkey,
7 unsigned long init_val);
8
Dave Hansen62b5f7d2016-02-12 13:02:40 -08009/*
10 * Try to dedicate one of the protection keys to be used as an
11 * execute-only protection key.
12 */
13#define PKEY_DEDICATED_EXECUTE_ONLY 15
14extern int __execute_only_pkey(struct mm_struct *mm);
15static inline int execute_only_pkey(struct mm_struct *mm)
16{
17 if (!boot_cpu_has(X86_FEATURE_OSPKE))
18 return 0;
19
20 return __execute_only_pkey(mm);
21}
22
23extern int __arch_override_mprotect_pkey(struct vm_area_struct *vma,
24 int prot, int pkey);
25static inline int arch_override_mprotect_pkey(struct vm_area_struct *vma,
26 int prot, int pkey)
27{
28 if (!boot_cpu_has(X86_FEATURE_OSPKE))
29 return 0;
30
31 return __arch_override_mprotect_pkey(vma, prot, pkey);
32}
33
Dave Hansen66d37572016-02-12 13:02:32 -080034#endif /*_ASM_X86_PKEYS_H */