666ffc862ef737b41816fd03e9549b7f5f7721c8
[cascardo/linux.git] / arch / x86 / include / asm / pkeys.h
1 #ifndef _ASM_X86_PKEYS_H
2 #define _ASM_X86_PKEYS_H
3
4 #define PKEY_DEDICATED_EXECUTE_ONLY 15
5 /*
6  * Consider the PKEY_DEDICATED_EXECUTE_ONLY key unavailable.
7  */
8 #define arch_max_pkey() (boot_cpu_has(X86_FEATURE_OSPKE) ? \
9                 PKEY_DEDICATED_EXECUTE_ONLY : 1)
10
11 extern int arch_set_user_pkey_access(struct task_struct *tsk, int pkey,
12                 unsigned long init_val);
13
14 /*
15  * Try to dedicate one of the protection keys to be used as an
16  * execute-only protection key.
17  */
18 extern int __execute_only_pkey(struct mm_struct *mm);
19 static inline int execute_only_pkey(struct mm_struct *mm)
20 {
21         if (!boot_cpu_has(X86_FEATURE_OSPKE))
22                 return 0;
23
24         return __execute_only_pkey(mm);
25 }
26
27 extern int __arch_override_mprotect_pkey(struct vm_area_struct *vma,
28                 int prot, int pkey);
29 static inline int arch_override_mprotect_pkey(struct vm_area_struct *vma,
30                 int prot, int pkey)
31 {
32         if (!boot_cpu_has(X86_FEATURE_OSPKE))
33                 return 0;
34
35         return __arch_override_mprotect_pkey(vma, prot, pkey);
36 }
37
38 extern int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey,
39                 unsigned long init_val);
40
41 #define ARCH_VM_PKEY_FLAGS (VM_PKEY_BIT0 | VM_PKEY_BIT1 | VM_PKEY_BIT2 | VM_PKEY_BIT3)
42
43 #endif /*_ASM_X86_PKEYS_H */