Dave Hansen | 66d3757 | 2016-02-12 13:02:32 -0800 | [diff] [blame] | 1 | #ifndef _LINUX_PKEYS_H |
| 2 | #define _LINUX_PKEYS_H |
| 3 | |
| 4 | #include <linux/mm_types.h> |
| 5 | #include <asm/mmu_context.h> |
| 6 | |
Dave Hansen | 8459429 | 2016-02-12 13:02:36 -0800 | [diff] [blame] | 7 | #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 Hansen | 66d3757 | 2016-02-12 13:02:32 -0800 | [diff] [blame] | 12 | #ifdef CONFIG_ARCH_HAS_PKEYS |
| 13 | #include <asm/pkeys.h> |
| 14 | #else /* ! CONFIG_ARCH_HAS_PKEYS */ |
| 15 | #define arch_max_pkey() (1) |
Dave Hansen | 62b5f7d | 2016-02-12 13:02:40 -0800 | [diff] [blame] | 16 | #define execute_only_pkey(mm) (0) |
| 17 | #define arch_override_mprotect_pkey(vma, prot, pkey) (0) |
| 18 | #define PKEY_DEDICATED_EXECUTE_ONLY 0 |
Dave Hansen | 66d3757 | 2016-02-12 13:02:32 -0800 | [diff] [blame] | 19 | #endif /* ! CONFIG_ARCH_HAS_PKEYS */ |
| 20 | |
| 21 | /* |
| 22 | * This is called from mprotect_pkey(). |
| 23 | * |
| 24 | * Returns true if the protection keys is valid. |
| 25 | */ |
| 26 | static inline bool validate_pkey(int pkey) |
| 27 | { |
| 28 | if (pkey < 0) |
| 29 | return false; |
| 30 | return (pkey < arch_max_pkey()); |
| 31 | } |
| 32 | |
| 33 | #endif /* _LINUX_PKEYS_H */ |