x86/mm/pkeys: Create an x86 arch_calc_vm_prot_bits() for VMA flags
[linux-block.git] / arch / x86 / include / uapi / asm / mman.h
CommitLineData
1965aae3
PA
1#ifndef _ASM_X86_MMAN_H
2#define _ASM_X86_MMAN_H
5c8eec50 3
5c8eec50
TG
4#define MAP_32BIT 0x40 /* only give out 32bit addresses */
5
42d7395f
AK
6#define MAP_HUGE_2MB (21 << MAP_HUGE_SHIFT)
7#define MAP_HUGE_1GB (30 << MAP_HUGE_SHIFT)
8
8f62c883
DH
9#ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS
10/*
11 * Take the 4 protection key bits out of the vma->vm_flags
12 * value and turn them in to the bits that we can put in
13 * to a pte.
14 *
15 * Only override these if Protection Keys are available
16 * (which is only on 64-bit).
17 */
18#define arch_vm_get_page_prot(vm_flags) __pgprot( \
19 ((vm_flags) & VM_PKEY_BIT0 ? _PAGE_PKEY_BIT0 : 0) | \
20 ((vm_flags) & VM_PKEY_BIT1 ? _PAGE_PKEY_BIT1 : 0) | \
21 ((vm_flags) & VM_PKEY_BIT2 ? _PAGE_PKEY_BIT2 : 0) | \
22 ((vm_flags) & VM_PKEY_BIT3 ? _PAGE_PKEY_BIT3 : 0))
878ba039
DH
23
24#define arch_calc_vm_prot_bits(prot, key) ( \
25 ((key) & 0x1 ? VM_PKEY_BIT0 : 0) | \
26 ((key) & 0x2 ? VM_PKEY_BIT1 : 0) | \
27 ((key) & 0x4 ? VM_PKEY_BIT2 : 0) | \
28 ((key) & 0x8 ? VM_PKEY_BIT3 : 0))
8f62c883
DH
29#endif
30
73a2d096 31#include <asm-generic/mman.h>
5c8eec50 32
1965aae3 33#endif /* _ASM_X86_MMAN_H */