Re: [PATCH v3] powerpc, pkey: make protection key 0 less special

2018-05-09 Thread Michal Suchánek
On Wed, 9 May 2018 08:46:08 -0700 Dave Hansen wrote: > On 05/09/2018 08:43 AM, Michal Suchánek wrote: > > It seems it is somehow assumed this is key 0 but I did not find it > > documented anywhere nor did I notice an interface for determining > > the default key. > >

Re: [PATCH v3] powerpc, pkey: make protection key 0 less special

2018-05-09 Thread Dave Hansen
On 05/09/2018 08:43 AM, Michal Suchánek wrote: > It seems it is somehow assumed this is key 0 but I did not find it > documented anywhere nor did I notice an interface for determining the > default key. Does the manpage not count as documentation? :) "pkey 0 is used as the default key"

Re: [PATCH v3] powerpc, pkey: make protection key 0 less special

2018-05-09 Thread Michal Suchánek
On Fri, 4 May 2018 12:22:58 -0700 Ram Pai wrote: > Applications need the ability to associate an address-range with some > key and latter revert to its initial default key. Pkey-0 comes close > to providing this function but falls short, because the current > implementation

Re: [PATCH v3] powerpc, pkey: make protection key 0 less special

2018-05-08 Thread Ram Pai
On Tue, May 08, 2018 at 07:03:36PM +0200, Michal Suchánek wrote: > > How is the application denied setting the permissions on key 0 if it > can program the register directly? There is a UAMOR register. The userspace can change the permissions of a given key; by modifying the bits in AMOR

Re: [PATCH v3] powerpc, pkey: make protection key 0 less special

2018-05-08 Thread Michal Suchánek
On Tue, 8 May 2018 09:38:01 -0700 Ram Pai wrote: > On Mon, May 07, 2018 at 01:21:49PM +0200, Michal Suchánek wrote: > > On Sun, 6 May 2018 13:10:43 -0700 > > Ram Pai wrote: > > > > > On Sat, May 05, 2018 at 02:39:56PM +0200, Michal Suchánek wrote:

Re: [PATCH v3] powerpc, pkey: make protection key 0 less special

2018-05-08 Thread Ram Pai
On Mon, May 07, 2018 at 01:21:49PM +0200, Michal Suchánek wrote: > On Sun, 6 May 2018 13:10:43 -0700 > Ram Pai wrote: > > > On Sat, May 05, 2018 at 02:39:56PM +0200, Michal Suchánek wrote: > > > On Fri, 4 May 2018 14:45:07 -0700 > > > Ram Pai wrote: > >

Re: [PATCH v3] powerpc, pkey: make protection key 0 less special

2018-05-07 Thread Michal Suchánek
On Sun, 6 May 2018 13:10:43 -0700 Ram Pai wrote: > On Sat, May 05, 2018 at 02:39:56PM +0200, Michal Suchánek wrote: > > On Fri, 4 May 2018 14:45:07 -0700 > > Ram Pai wrote: > > > > > On Fri, May 04, 2018 at 02:31:10PM -0700, Dave Hansen wrote: > >

Re: [PATCH v3] powerpc, pkey: make protection key 0 less special

2018-05-06 Thread Ram Pai
On Sat, May 05, 2018 at 02:39:56PM +0200, Michal Suchánek wrote: > On Fri, 4 May 2018 14:45:07 -0700 > Ram Pai wrote: > > > On Fri, May 04, 2018 at 02:31:10PM -0700, Dave Hansen wrote: > > > On 05/04/2018 02:26 PM, Michal Suchánek wrote: > > > > If it is not ok to change

Re: [PATCH v3] powerpc, pkey: make protection key 0 less special

2018-05-05 Thread Michal Suchánek
On Fri, 4 May 2018 14:45:07 -0700 Ram Pai wrote: > On Fri, May 04, 2018 at 02:31:10PM -0700, Dave Hansen wrote: > > On 05/04/2018 02:26 PM, Michal Suchánek wrote: > > > If it is not ok to change permissions of pkey 0 is it ok to free > > > it? > > > > It's pretty much

Re: [PATCH v3] powerpc, pkey: make protection key 0 less special

2018-05-04 Thread Ram Pai
On Fri, May 04, 2018 at 02:31:10PM -0700, Dave Hansen wrote: > On 05/04/2018 02:26 PM, Michal Suchánek wrote: > > If it is not ok to change permissions of pkey 0 is it ok to free it? > > It's pretty much never OK to free it on x86 or ppc. But, we're not > going to put code in to keep userspace

Re: [PATCH v3] powerpc, pkey: make protection key 0 less special

2018-05-04 Thread Dave Hansen
On 05/04/2018 02:26 PM, Michal Suchánek wrote: > If it is not ok to change permissions of pkey 0 is it ok to free it? It's pretty much never OK to free it on x86 or ppc. But, we're not going to put code in to keep userspace from shooting itself in the foot, at least on x86.

Re: [PATCH v3] powerpc, pkey: make protection key 0 less special

2018-05-04 Thread Michal Suchánek
On Fri, 4 May 2018 12:22:58 -0700 "Ram Pai" wrote: > Applications need the ability to associate an address-range with some > key and latter revert to its initial default key. Pkey-0 comes close > to providing this function but falls short, because the current >

Re: [PATCH v3] powerpc, pkey: make protection key 0 less special

2018-05-04 Thread Ram Pai
On Fri, May 04, 2018 at 12:59:27PM -0700, Dave Hansen wrote: > On 05/04/2018 12:22 PM, Ram Pai wrote: > > @@ -407,9 +414,6 @@ static bool pkey_access_permitted(int pkey, bool write, > > bool execute) > > int pkey_shift; > > u64 amr; > > > > - if (!pkey) > > - return true; >

Re: [PATCH v3] powerpc, pkey: make protection key 0 less special

2018-05-04 Thread Dave Hansen
On 05/04/2018 12:22 PM, Ram Pai wrote: > @@ -407,9 +414,6 @@ static bool pkey_access_permitted(int pkey, bool write, > bool execute) > int pkey_shift; > u64 amr; > > - if (!pkey) > - return true; > - > if (!is_pkey_enabled(pkey)) > return true;

[PATCH v3] powerpc, pkey: make protection key 0 less special

2018-05-04 Thread Ram Pai
Applications need the ability to associate an address-range with some key and latter revert to its initial default key. Pkey-0 comes close to providing this function but falls short, because the current implementation disallows applications to explicitly associate pkey-0 to the address range.