blob: fc325b367bd00180b6898580e8273f7d1c0b58ca [file] [log] [blame]
Dave Hansen66d37572016-02-12 13:02:32 -08001#ifndef _LINUX_PKEYS_H
2#define _LINUX_PKEYS_H
3
4#include <linux/mm_types.h>
5#include <asm/mmu_context.h>
6
Dave Hansen84594292016-02-12 13:02:36 -08007#define PKEY_DISABLE_ACCESS 0x1
8#define PKEY_DISABLE_WRITE 0x2
9#define PKEY_ACCESS_MASK (PKEY_DISABLE_ACCESS |\
10 PKEY_DISABLE_WRITE)
11
Dave Hansen66d37572016-02-12 13:02:32 -080012#ifdef CONFIG_ARCH_HAS_PKEYS
13#include <asm/pkeys.h>
14#else /* ! CONFIG_ARCH_HAS_PKEYS */
15#define arch_max_pkey() (1)
16#endif /* ! CONFIG_ARCH_HAS_PKEYS */
17
18/*
19 * This is called from mprotect_pkey().
20 *
21 * Returns true if the protection keys is valid.
22 */
23static inline bool validate_pkey(int pkey)
24{
25 if (pkey < 0)
26 return false;
27 return (pkey < arch_max_pkey());
28}
29
30#endif /* _LINUX_PKEYS_H */