linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Ram Pai <linuxram@us.ibm.com>
To: Ingo Molnar <mingo@kernel.org>
Cc: mpe@ellerman.id.au, mingo@redhat.com, akpm@linux-foundation.org,
	linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org,
	x86@kernel.org, linux-arch@vger.kernel.org,
	linux-kernel@vger.kernel.org, dave.hansen@intel.com,
	benh@kernel.crashing.org, paulus@samba.org,
	khandual@linux.vnet.ibm.com, aneesh.kumar@linux.vnet.ibm.com,
	bsingharora@gmail.com, hbabu@us.ibm.com, mhocko@kernel.org,
	bauerman@linux.vnet.ibm.com, ebiederm@xmission.com,
	corbet@lwn.net, arnd@arndb.de, fweimer@redhat.com,
	msuchanek@suse.com, Ulrich.Weigand@de.ibm.com
Subject: Re: [PATCH] x86, powerpc : pkey-mprotect must allow pkey-0
Date: Fri, 9 Mar 2018 12:09:17 -0800	[thread overview]
Message-ID: <20180309200917.GT1060@ram.oc3035372033.ibm.com> (raw)
In-Reply-To: <20180309084332.hk6xt6obghoqokbc@gmail.com>

On Fri, Mar 09, 2018 at 09:43:32AM +0100, Ingo Molnar wrote:
> 
> * Ram Pai <linuxram@us.ibm.com> wrote:
> 
> > Once an address range is associated with an allocated pkey, it cannot be
> > reverted back to key-0. There is no valid reason for the above behavior.  On
> > the contrary applications need the ability to do so.
> > 
> > The patch relaxes the restriction.
> > 
> > Tested on powerpc and x86_64.
> > 
> > cc: Dave Hansen <dave.hansen@intel.com>
> > cc: Michael Ellermen <mpe@ellerman.id.au>
> > cc: Ingo Molnar <mingo@kernel.org>
> > Signed-off-by: Ram Pai <linuxram@us.ibm.com>
> > ---
> >  arch/powerpc/include/asm/pkeys.h | 19 ++++++++++++++-----
> >  arch/x86/include/asm/pkeys.h     |  5 +++--
> >  2 files changed, 17 insertions(+), 7 deletions(-)
> > 
> > diff --git a/arch/powerpc/include/asm/pkeys.h b/arch/powerpc/include/asm/pkeys.h
> > index 0409c80..3e8abe4 100644
> > --- a/arch/powerpc/include/asm/pkeys.h
> > +++ b/arch/powerpc/include/asm/pkeys.h
> > @@ -101,10 +101,18 @@ static inline u16 pte_to_pkey_bits(u64 pteflags)
> >  
> >  static inline bool mm_pkey_is_allocated(struct mm_struct *mm, int pkey)
> >  {
> > -	/* A reserved key is never considered as 'explicitly allocated' */
> > -	return ((pkey < arch_max_pkey()) &&
> > -		!__mm_pkey_is_reserved(pkey) &&
> > -		__mm_pkey_is_allocated(mm, pkey));
> > +	/* pkey 0 is allocated by default. */
> > +	if (!pkey)
> > +	       return true;
> > +
> > +	if (pkey < 0 || pkey >= arch_max_pkey())
> > +	       return false;
> > +
> > +	/* reserved keys are never allocated. */
> > +	if (__mm_pkey_is_reserved(pkey))
> > +	       return false;
> 
> Please capitalize in comments consistently, i.e.:

ok.

> 
> 	/* Reserved keys are never allocated: */
> 
> > +
> > +	return(__mm_pkey_is_allocated(mm, pkey));
> 
> 'return' is not a function.

right. will fix.

Thanks,
RP

  reply	other threads:[~2018-03-09 20:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-09  8:12 Ram Pai
2018-03-09  8:37 ` Balbir Singh
2018-03-09 19:54   ` Ram Pai
2018-03-09  8:43 ` Ingo Molnar
2018-03-09 20:09   ` Ram Pai [this message]
2018-03-09 10:19 ` Michael Ellerman
2018-03-09 20:06   ` Ram Pai
2018-03-12 15:46     ` Dave Hansen
2018-03-09 11:04 ` Florian Weimer
2018-03-09 20:00   ` Ram Pai
2018-03-14  8:00     ` Florian Weimer
2018-03-14  8:05       ` Florian Weimer
2018-03-14 14:08       ` Dave Hansen
2018-03-09 22:40 ` Dave Hansen
2018-03-10  5:55   ` Ram Pai
2018-03-10  6:50     ` Dave Hansen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180309200917.GT1060@ram.oc3035372033.ibm.com \
    --to=linuxram@us.ibm.com \
    --cc=Ulrich.Weigand@de.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=arnd@arndb.de \
    --cc=bauerman@linux.vnet.ibm.com \
    --cc=benh@kernel.crashing.org \
    --cc=bsingharora@gmail.com \
    --cc=corbet@lwn.net \
    --cc=dave.hansen@intel.com \
    --cc=ebiederm@xmission.com \
    --cc=fweimer@redhat.com \
    --cc=hbabu@us.ibm.com \
    --cc=khandual@linux.vnet.ibm.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mhocko@kernel.org \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=mpe@ellerman.id.au \
    --cc=msuchanek@suse.com \
    --cc=paulus@samba.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox