[RFC v2 05/12] powerpc: Implementation for sys_mprotect_pkey() system call.

Aneesh Kumar K.V aneesh.kumar at linux.vnet.ibm.com
Wed Jun 21 17:16:11 AEST 2017


Ram Pai <linuxram at us.ibm.com> writes:

....

>
> +#ifdef CONFIG_PPC64_MEMORY_PROTECTION_KEYS
> +
>  /*
>   * This file is included by linux/mman.h, so we can't use cacl_vm_prot_bits()
>   * here.  How important is the optimization?
>   */
> -static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
> -		unsigned long pkey)
> -{
> -	return (prot & PROT_SAO) ? VM_SAO : 0;
> -}
> -#define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey)
> +#define arch_calc_vm_prot_bits(prot, key) (             \
> +		((prot) & PROT_SAO ? VM_SAO : 0) |	\
> +			pkey_to_vmflag_bits(key))
> +#define arch_vm_get_page_prot(vm_flags) __pgprot(       \
> +		((vm_flags) & VM_SAO ? _PAGE_SAO : 0) |	\
> +		vmflag_to_page_pkey_bits(vm_flags))

Can we avoid converting static inline back to macors ? They loose type checking.
> +
> +#else /* CONFIG_PPC64_MEMORY_PROTECTION_KEYS */
> +
> +#define arch_calc_vm_prot_bits(prot, key) (	\
> +		((prot) & PROT_SAO ? VM_SAO : 0))
> +#define arch_vm_get_page_prot(vm_flags) __pgprot(	\
> +		((vm_flags) & VM_SAO ? _PAGE_SAO : 0))
> +
> +#endif /* CONFIG_PPC64_MEMORY_PROTECTION_KEYS */
>
> -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
> -{
> -	return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
> -}
> -#define arch_vm_get_page_prot(vm_flags) arch_vm_get_page_prot(vm_flags)
>
>  static inline bool arch_validate_prot(unsigned long prot)
>  {

-aneesh



More information about the Linuxppc-dev mailing list