18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
28c2ecf20Sopenharmony_ci#ifndef _ASM_X86_MMAN_H
38c2ecf20Sopenharmony_ci#define _ASM_X86_MMAN_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#define MAP_32BIT	0x40		/* only give out 32bit addresses */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS
88c2ecf20Sopenharmony_ci/*
98c2ecf20Sopenharmony_ci * Take the 4 protection key bits out of the vma->vm_flags
108c2ecf20Sopenharmony_ci * value and turn them in to the bits that we can put in
118c2ecf20Sopenharmony_ci * to a pte.
128c2ecf20Sopenharmony_ci *
138c2ecf20Sopenharmony_ci * Only override these if Protection Keys are available
148c2ecf20Sopenharmony_ci * (which is only on 64-bit).
158c2ecf20Sopenharmony_ci */
168c2ecf20Sopenharmony_ci#define arch_vm_get_page_prot(vm_flags)	__pgprot(	\
178c2ecf20Sopenharmony_ci		((vm_flags) & VM_PKEY_BIT0 ? _PAGE_PKEY_BIT0 : 0) |	\
188c2ecf20Sopenharmony_ci		((vm_flags) & VM_PKEY_BIT1 ? _PAGE_PKEY_BIT1 : 0) |	\
198c2ecf20Sopenharmony_ci		((vm_flags) & VM_PKEY_BIT2 ? _PAGE_PKEY_BIT2 : 0) |	\
208c2ecf20Sopenharmony_ci		((vm_flags) & VM_PKEY_BIT3 ? _PAGE_PKEY_BIT3 : 0))
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#define arch_calc_vm_prot_bits(prot, key) (		\
238c2ecf20Sopenharmony_ci		((key) & 0x1 ? VM_PKEY_BIT0 : 0) |      \
248c2ecf20Sopenharmony_ci		((key) & 0x2 ? VM_PKEY_BIT1 : 0) |      \
258c2ecf20Sopenharmony_ci		((key) & 0x4 ? VM_PKEY_BIT2 : 0) |      \
268c2ecf20Sopenharmony_ci		((key) & 0x8 ? VM_PKEY_BIT3 : 0))
278c2ecf20Sopenharmony_ci#endif
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci#include <asm-generic/mman.h>
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci#endif /* _ASM_X86_MMAN_H */
32