mman.h (d85ddd1318e66c0c2665dbfcbc21a8b66c9152aa) | mman.h (12564485ed8caac3c18572793ec01330792c7191) |
---|---|
1/* SPDX-License-Identifier: GPL-2.0-or-later */ 2/* 3 */ 4#ifndef _ASM_POWERPC_MMAN_H 5#define _ASM_POWERPC_MMAN_H 6 7#include <uapi/asm/mman.h> 8 9#ifdef CONFIG_PPC64 10 11#include <asm/cputable.h> 12#include <linux/mm.h> 13#include <linux/pkeys.h> 14#include <asm/cpu_has_feature.h> 15 | 1/* SPDX-License-Identifier: GPL-2.0-or-later */ 2/* 3 */ 4#ifndef _ASM_POWERPC_MMAN_H 5#define _ASM_POWERPC_MMAN_H 6 7#include <uapi/asm/mman.h> 8 9#ifdef CONFIG_PPC64 10 11#include <asm/cputable.h> 12#include <linux/mm.h> 13#include <linux/pkeys.h> 14#include <asm/cpu_has_feature.h> 15 |
16#ifdef CONFIG_PPC_MEM_KEYS | |
17static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot, 18 unsigned long pkey) 19{ | 16static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot, 17 unsigned long pkey) 18{ |
20 return pkey_to_vmflag_bits(pkey); | 19#ifdef CONFIG_PPC_MEM_KEYS 20 return (((prot & PROT_SAO) ? VM_SAO : 0) | pkey_to_vmflag_bits(pkey)); 21#else 22 return ((prot & PROT_SAO) ? VM_SAO : 0); 23#endif |
21} 22#define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey) 23 24static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags) 25{ | 24} 25#define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey) 26 27static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags) 28{ |
26 return __pgprot(vmflag_to_pte_pkey_bits(vm_flags)); | 29#ifdef CONFIG_PPC_MEM_KEYS 30 return (vm_flags & VM_SAO) ? 31 __pgprot(_PAGE_SAO | vmflag_to_pte_pkey_bits(vm_flags)) : 32 __pgprot(0 | vmflag_to_pte_pkey_bits(vm_flags)); 33#else 34 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0); 35#endif |
27} 28#define arch_vm_get_page_prot(vm_flags) arch_vm_get_page_prot(vm_flags) | 36} 37#define arch_vm_get_page_prot(vm_flags) arch_vm_get_page_prot(vm_flags) |
29#endif | |
30 | 38 |
39static inline bool arch_validate_prot(unsigned long prot, unsigned long addr) 40{ 41 if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC | PROT_SEM | PROT_SAO)) 42 return false; 43 if ((prot & PROT_SAO) && !cpu_has_feature(CPU_FTR_SAO)) 44 return false; 45 return true; 46} 47#define arch_validate_prot arch_validate_prot 48 |
|
31#endif /* CONFIG_PPC64 */ 32#endif /* _ASM_POWERPC_MMAN_H */ | 49#endif /* CONFIG_PPC64 */ 50#endif /* _ASM_POWERPC_MMAN_H */ |