From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752689AbdGLWXt (ORCPT ); Wed, 12 Jul 2017 18:23:49 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:53614 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752434AbdGLWXr (ORCPT ); Wed, 12 Jul 2017 18:23:47 -0400 Date: Wed, 12 Jul 2017 15:23:31 -0700 From: Ram Pai To: Dave Hansen Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au, khandual@linux.vnet.ibm.com, aneesh.kumar@linux.vnet.ibm.com, bsingharora@gmail.com, hbabu@us.ibm.com, arnd@arndb.de, akpm@linux-foundation.org, corbet@lwn.net, mingo@redhat.com Subject: Re: [RFC v5 11/38] mm: introduce an additional vma bit for powerpc pkey Reply-To: Ram Pai References: <1499289735-14220-1-git-send-email-linuxram@us.ibm.com> <1499289735-14220-12-git-send-email-linuxram@us.ibm.com> <290636b0-aafd-9bcd-d309-4cff41ce923c@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <290636b0-aafd-9bcd-d309-4cff41ce923c@intel.com> User-Agent: Mutt/1.5.20 (2009-12-10) X-TM-AS-GCONF: 00 x-cbid: 17071222-0008-0000-0000-0000025DA6C9 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007357; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000214; SDB=6.00886687; UDB=6.00442631; IPR=6.00666836; BA=6.00005469; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016202; XFM=3.00000015; UTC=2017-07-12 22:23:40 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071222-0009-0000-0000-00003602A2A3 Message-Id: <20170712222331.GD5525@ram.oc3035372033.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-07-12_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707120357 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 11, 2017 at 11:10:46AM -0700, Dave Hansen wrote: > On 07/05/2017 02:21 PM, Ram Pai wrote: > > Currently there are only 4bits in the vma flags to support 16 keys > > on x86. powerpc supports 32 keys, which needs 5bits. This patch > > introduces an addition bit in the vma flags. > > > > Signed-off-by: Ram Pai > > --- > > fs/proc/task_mmu.c | 6 +++++- > > include/linux/mm.h | 18 +++++++++++++----- > > 2 files changed, 18 insertions(+), 6 deletions(-) > > > > diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c > > index f0c8b33..2ddc298 100644 > > --- a/fs/proc/task_mmu.c > > +++ b/fs/proc/task_mmu.c > > @@ -666,12 +666,16 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma) > > [ilog2(VM_MERGEABLE)] = "mg", > > [ilog2(VM_UFFD_MISSING)]= "um", > > [ilog2(VM_UFFD_WP)] = "uw", > > -#ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS > > +#ifdef CONFIG_ARCH_HAS_PKEYS > > /* These come out via ProtectionKey: */ > > [ilog2(VM_PKEY_BIT0)] = "", > > [ilog2(VM_PKEY_BIT1)] = "", > > [ilog2(VM_PKEY_BIT2)] = "", > > [ilog2(VM_PKEY_BIT3)] = "", > > +#endif /* CONFIG_ARCH_HAS_PKEYS */ > > +#ifdef CONFIG_PPC64_MEMORY_PROTECTION_KEYS > > + /* Additional bit in ProtectionKey: */ > > + [ilog2(VM_PKEY_BIT4)] = "", > > #endif > > I'd probably just leave the #ifdef out and eat the byte or whatever of > storage that this costs us on x86. fine with me. > > > }; > > size_t i; > > diff --git a/include/linux/mm.h b/include/linux/mm.h > > index 7cb17c6..3d35bcc 100644 > > --- a/include/linux/mm.h > > +++ b/include/linux/mm.h > > @@ -208,21 +208,29 @@ extern int overcommit_kbytes_handler(struct ctl_table *, int, void __user *, > > #define VM_HIGH_ARCH_BIT_1 33 /* bit only usable on 64-bit architectures */ > > #define VM_HIGH_ARCH_BIT_2 34 /* bit only usable on 64-bit architectures */ > > #define VM_HIGH_ARCH_BIT_3 35 /* bit only usable on 64-bit architectures */ > > +#define VM_HIGH_ARCH_BIT_4 36 /* bit only usable on 64-bit arch */ > > Please just copy the above lines. Just copying over makes checkpatch.pl unhappy. It exceeds 80 columns. > > > #define VM_HIGH_ARCH_0 BIT(VM_HIGH_ARCH_BIT_0) > > #define VM_HIGH_ARCH_1 BIT(VM_HIGH_ARCH_BIT_1) > > #define VM_HIGH_ARCH_2 BIT(VM_HIGH_ARCH_BIT_2) > > #define VM_HIGH_ARCH_3 BIT(VM_HIGH_ARCH_BIT_3) > > +#define VM_HIGH_ARCH_4 BIT(VM_HIGH_ARCH_BIT_4) > > #endif /* CONFIG_ARCH_USES_HIGH_VMA_FLAGS */ > > > > -#if defined(CONFIG_X86) > > -# define VM_PAT VM_ARCH_1 /* PAT reserves whole VMA at once (x86) */ > > -#if defined (CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS) > > +#ifdef CONFIG_ARCH_HAS_PKEYS > > # define VM_PKEY_SHIFT VM_HIGH_ARCH_BIT_0 > > -# define VM_PKEY_BIT0 VM_HIGH_ARCH_0 /* A protection key is a 4-bit value */ > > +# define VM_PKEY_BIT0 VM_HIGH_ARCH_0 > > # define VM_PKEY_BIT1 VM_HIGH_ARCH_1 > > # define VM_PKEY_BIT2 VM_HIGH_ARCH_2 > > # define VM_PKEY_BIT3 VM_HIGH_ARCH_3 > > -#endif > > +#endif /* CONFIG_ARCH_HAS_PKEYS */ > > We have the space here, so can we just say that it's 4-bits on x86 and 5 > on ppc? sure. > > > +#if defined(CONFIG_PPC64_MEMORY_PROTECTION_KEYS) > > +# define VM_PKEY_BIT4 VM_HIGH_ARCH_4 /* additional key bit used on ppc64 */ > > +#endif /* CONFIG_PPC64_MEMORY_PROTECTION_KEYS */ > > Why bother #ifdef'ing a #define? ok. RP