[PATCH 1/9] x86, pkeys: do not special case protection key 0

2018-04-27 Thread Dave Hansen
From: Dave Hansen mm_pkey_is_allocated() treats pkey 0 as unallocated. That is inconsistent with the manpages, and also inconsistent with mm->context.pkey_allocation_map. Stop special casing it and only disallow values that are actually bad (< 0). The end-user visible effect of this is that y

Re: [PATCH 1/9] x86, pkeys: do not special case protection key 0

2018-03-26 Thread Dave Hansen
On 03/26/2018 07:27 PM, Ram Pai wrote: >> This is a bit nicer than what Ram proposed because it is simpler >> and removes special-casing for pkey 0. On the other hand, it does >> allow applciations to pkey_free() pkey-0, but that's just a silly >> thing to do, so we are not going to protect agains

Re: [PATCH 1/9] x86, pkeys: do not special case protection key 0

2018-03-26 Thread Ram Pai
On Fri, Mar 23, 2018 at 11:09:05AM -0700, Dave Hansen wrote: > > From: Dave Hansen > > mm_pkey_is_allocated() treats pkey 0 as unallocated. That is > inconsistent with the manpages, and also inconsistent with > mm->context.pkey_allocation_map. Stop special casing it and only > disallow values

Re: [PATCH 1/9] x86, pkeys: do not special case protection key 0

2018-03-26 Thread Shuah Khan
On 03/26/2018 11:53 AM, Dave Hansen wrote: > On 03/26/2018 10:47 AM, Shuah Khan wrote: >> >> Also what happens "pkey_free() pkey-0" - can you elaborate more on that >> "silliness consequences" > > It's just what happens if you free any other pkey that is in use: it > might get reallocated later.

Re: [PATCH 1/9] x86, pkeys: do not special case protection key 0

2018-03-26 Thread Dave Hansen
On 03/26/2018 10:47 AM, Shuah Khan wrote: > > Also what happens "pkey_free() pkey-0" - can you elaborate more on that > "silliness consequences" It's just what happens if you free any other pkey that is in use: it might get reallocated later. The most likely scenario is that you will get pkey-0

Re: [PATCH 1/9] x86, pkeys: do not special case protection key 0

2018-03-26 Thread Shuah Khan
On 03/26/2018 11:27 AM, Dave Hansen wrote: > From: Dave Hansen > > mm_pkey_is_allocated() treats pkey 0 as unallocated. That is > inconsistent with the manpages, and also inconsistent with > mm->context.pkey_allocation_map. Stop special casing it and only > disallow values that are actually bad

Re: [PATCH 1/9] x86, pkeys: do not special case protection key 0

2018-03-26 Thread Dave Hansen
On 03/26/2018 10:35 AM, Ram Pai wrote: >> #ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS >> if (cpu_feature_enabled(X86_FEATURE_OSPKE)) { >> -/* pkey 0 is the default and always allocated */ >> +/* pkey 0 is the default and allocated implicitly */ >> mm->c

Re: [PATCH 1/9] x86, pkeys: do not special case protection key 0

2018-03-26 Thread Ram Pai
On Fri, Mar 23, 2018 at 11:09:05AM -0700, Dave Hansen wrote: > > From: Dave Hansen > > mm_pkey_is_allocated() treats pkey 0 as unallocated. That is > inconsistent with the manpages, and also inconsistent with > mm->context.pkey_allocation_map. Stop special casing it and only > disallow values

[PATCH 1/9] x86, pkeys: do not special case protection key 0

2018-03-26 Thread Dave Hansen
From: Dave Hansen mm_pkey_is_allocated() treats pkey 0 as unallocated. That is inconsistent with the manpages, and also inconsistent with mm->context.pkey_allocation_map. Stop special casing it and only disallow values that are actually bad (< 0). The end-user visible effect of this is that y

[PATCH 1/9] x86, pkeys: do not special case protection key 0

2018-03-23 Thread Dave Hansen
From: Dave Hansen mm_pkey_is_allocated() treats pkey 0 as unallocated. That is inconsistent with the manpages, and also inconsistent with mm->context.pkey_allocation_map. Stop special casing it and only disallow values that are actually bad (< 0). The end-user visible effect of this is that y