Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752161AbdFUHRP (ORCPT ); Wed, 21 Jun 2017 03:17:15 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:42021 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751108AbdFUHRO (ORCPT ); Wed, 21 Jun 2017 03:17:14 -0400 From: "Aneesh Kumar K.V" To: Ram Pai , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Cc: benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au, khandual@linux.vnet.ibm.com, bsingharora@gmail.com, dave.hansen@intel.com, hbabu@us.ibm.com, linuxram@us.ibm.com Subject: Re: [RFC v2 05/12] powerpc: Implementation for sys_mprotect_pkey() system call. In-Reply-To: <1497671564-20030-6-git-send-email-linuxram@us.ibm.com> References: <1497671564-20030-1-git-send-email-linuxram@us.ibm.com> <1497671564-20030-6-git-send-email-linuxram@us.ibm.com> Date: Wed, 21 Jun 2017 12:46:11 +0530 MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-MML: disable x-cbid: 17062107-0008-0000-0000-00000144749B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17062107-0009-0000-0000-000009741257 Message-Id: <87tw39ak04.fsf@skywalker.in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-06-21_01:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1706210120 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1444 Lines: 45 Ram Pai 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