summaryrefslogtreecommitdiffstats
path: root/arch/x86/include/asm/pkeys.h
blob: 33777c291a85363dc34f0c38c79b5f6590743f31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef _ASM_X86_PKEYS_H
#define _ASM_X86_PKEYS_H

#define PKEY_DEDICATED_EXECUTE_ONLY 15
/*
 * Consider the PKEY_DEDICATED_EXECUTE_ONLY key unavailable.
 */
#define arch_max_pkey() (boot_cpu_has(X86_FEATURE_OSPKE) ? \
		PKEY_DEDICATED_EXECUTE_ONLY : 1)

extern int arch_set_user_pkey_access(struct task_struct *tsk, int pkey,
		unsigned long init_val);

/*
 * Try to dedicate one of the protection keys to be used as an
 * execute-only protection key.
 */
extern int __execute_only_pkey(struct mm_struct *mm);
static inline int execute_only_pkey(struct mm_struct *mm)
{
	if (!boot_cpu_has(X86_FEATURE_OSPKE))
		return 0;

	return __execute_only_pkey(mm);
}

extern int __arch_override_mprotect_pkey(struct vm_area_struct *vma,
		int prot, int pkey);
static inline int arch_override_mprotect_pkey(struct vm_area_struct *vma,
		int prot, int pkey)
{
	if (!boot_cpu_has(X86_FEATURE_OSPKE))
		return 0;

	return __arch_override_mprotect_pkey(vma, prot, pkey);
}

extern int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey,
		unsigned long init_val);

#endif /*_ASM_X86_PKEYS_H */