From: Michael Ellerman <mpe@ellerman.id.au> Date: 2018-05-08 14:59:57
This is a rework of Ram's series, which broke the build on both arches at
various points due to the differing header dependencies.
The actual pkey changes are basically the same, this just has some rework to
get the headers cleaned up a bit beforehand.
If no one objects I'll ask Stephen to put these in a topic branch in
linux-next, and I or someone else can merge them for 4.18.
cheers
Ram's original:
http://patchwork.ozlabs.org/patch/909066/http://patchwork.ozlabs.org/patch/909067/http://patchwork.ozlabs.org/patch/909068/
Michael Ellerman (5):
mm/pkeys: Remove include of asm/mmu_context.h from pkeys.h
mm/pkeys, powerpc, x86: Provide an empty vma_pkey() in linux/pkeys.h
x86/pkeys: Move vma_pkey() into asm/pkeys.h
x86/pkeys: Add arch_pkeys_enabled()
mm/pkeys: Add an empty arch_pkeys_enabled()
Ram Pai (3):
mm, powerpc, x86: define VM_PKEY_BITx bits if CONFIG_ARCH_HAS_PKEYS is
enabled
mm, powerpc, x86: introduce an additional vma bit for powerpc pkey
mm/pkeys, x86, powerpc: Display pkey in smaps if arch supports pkeys
arch/powerpc/include/asm/mmu_context.h | 5 -----
arch/powerpc/include/asm/pkeys.h | 2 ++
arch/x86/include/asm/mmu_context.h | 15 ---------------
arch/x86/include/asm/pkeys.h | 13 +++++++++++++
arch/x86/kernel/setup.c | 8 --------
fs/proc/task_mmu.c | 13 +++++++------
include/linux/mm.h | 12 +++++++-----
include/linux/pkeys.h | 13 +++++++++++--
8 files changed, 40 insertions(+), 41 deletions(-)
--
2.14.1
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2018-05-08 15:00:00
From: Ram Pai <redacted>
Currently only 4bits are allocated in the vma flags to hold 16
keys. This is sufficient for x86. PowerPC supports 32 keys,
which needs 5bits. This patch allocates an additional bit.
Reviewed-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Balbir Singh <bsingharora@gmail.com>
Signed-off-by: Ram Pai <redacted>
[mpe: Fold in #if VM_PKEY_BIT4 as noticed by Dave Hansen]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
fs/proc/task_mmu.c | 3 +++
include/linux/mm.h | 3 ++-
2 files changed, 5 insertions(+), 1 deletion(-)
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2018-05-08 15:00:04
Consolidate the pkey handling by providing a common empty definition
of vma_pkey() in pkeys.h when CONFIG_ARCH_HAS_PKEYS=n.
This also removes another entanglement of pkeys.h and
asm/mmu_context.h.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/include/asm/mmu_context.h | 5 -----
arch/x86/include/asm/mmu_context.h | 5 -----
include/linux/pkeys.h | 5 +++++
3 files changed, 5 insertions(+), 10 deletions(-)
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2018-05-08 15:00:05
This will be used in future patches to check for arch support for
pkeys in generic code.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/x86/include/asm/pkeys.h | 5 +++++
1 file changed, 5 insertions(+)
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2018-05-08 15:00:28
From: Ram Pai <redacted>
Currently the architecture specific code is expected to display the
protection keys in smap for a given vma. This can lead to redundant
code and possibly to divergent formats in which the key gets
displayed.
This patch changes the implementation. It displays the pkey only if
the architecture support pkeys, i.e arch_pkeys_enabled() returns true.
x86 arch_show_smap() function is not needed anymore, delete it.
Signed-off-by: Thiago Jung Bauermann <redacted>
Signed-off-by: Ram Pai <redacted>
[mpe: Split out from larger patch, rebased on header changes]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/x86/kernel/setup.c | 8 --------
fs/proc/task_mmu.c | 8 +++-----
2 files changed, 3 insertions(+), 13 deletions(-)
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2018-05-08 15:00:51
Add an empty arch_pkeys_enabled() in linux/pkeys.h for the
CONFIG_ARCH_HAS_PKEYS=n case.
Split out of a patch by Ram Pai [off-list ref].
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
include/linux/pkeys.h | 5 +++++
1 file changed, 5 insertions(+)
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2018-05-08 15:01:14
While trying to unify the pkey handling in show_smap() between x86 and
powerpc we stumbled across various build failures due to the order of
includes between the two arches.
Part of the problem is that linux/pkeys.h includes asm/mmu_context.h,
and the relationship between asm/mmu_context.h and asm/pkeys.h is not
consistent between the two arches.
It would be cleaner if linux/pkeys.h only included asm/pkeys.h,
creating a single integration point for the arch pkey definitions.
So this patch removes the include of asm/mmu_context.h from
linux/pkeys.h.
We can't prove that this is safe in the general case, but it passes
all the build tests I've thrown at it. Also asm/mmu_context.h is
included widely while linux/pkeys.h is not, so most likely any code
that is including linux/pkeys.h is already getting asm/mmu_context.h
from elsewhere.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
include/linux/pkeys.h | 1 -
1 file changed, 1 deletion(-)
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2018-05-08 15:01:36
From: Ram Pai <redacted>
VM_PKEY_BITx are defined only if CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS
is enabled. Powerpc also needs these bits. Hence lets define the
VM_PKEY_BITx bits for any architecture that enables
CONFIG_ARCH_HAS_PKEYS.
Reviewed-by: Dave Hansen <redacted>
Signed-off-by: Ram Pai <redacted>
Reviewed-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Aneesh Kumar K.V <redacted>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/include/asm/pkeys.h | 2 ++
fs/proc/task_mmu.c | 4 ++--
include/linux/mm.h | 9 +++++----
3 files changed, 9 insertions(+), 6 deletions(-)
On Wed, May 09, 2018 at 12:59:42AM +1000, Michael Ellerman wrote:
quoted hunk
From: Ram Pai <redacted>
Currently only 4bits are allocated in the vma flags to hold 16
keys. This is sufficient for x86. PowerPC supports 32 keys,
which needs 5bits. This patch allocates an additional bit.
Reviewed-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Balbir Singh <bsingharora@gmail.com>
Signed-off-by: Ram Pai <redacted>
[mpe: Fold in #if VM_PKEY_BIT4 as noticed by Dave Hansen]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
fs/proc/task_mmu.c | 3 +++
include/linux/mm.h | 3 ++-
2 files changed, 5 insertions(+), 1 deletion(-)
On Wed, May 09, 2018 at 12:59:44AM +1000, Michael Ellerman wrote:
Consolidate the pkey handling by providing a common empty definition
of vma_pkey() in pkeys.h when CONFIG_ARCH_HAS_PKEYS=n.
This also removes another entanglement of pkeys.h and
asm/mmu_context.h.
From: Dave Hansen <hidden> Date: 2018-05-08 16:45:05
On 05/08/2018 07:59 AM, Michael Ellerman wrote:
Consolidate the pkey handling by providing a common empty definition
of vma_pkey() in pkeys.h when CONFIG_ARCH_HAS_PKEYS=n.
This also removes another entanglement of pkeys.h and
asm/mmu_context.h.
Looks fine to me. Thanks for consolidating these.
Reviewed-by: Dave Hansen <redacted>
From: Dave Hansen <hidden> Date: 2018-05-08 16:47:28
On 05/08/2018 07:59 AM, Michael Ellerman wrote:
Currently the architecture specific code is expected to display the
protection keys in smap for a given vma. This can lead to redundant
code and possibly to divergent formats in which the key gets
displayed.
This patch changes the implementation. It displays the pkey only if
the architecture support pkeys, i.e arch_pkeys_enabled() returns true.
For this, along with 6/8 and 7/8:
Reviewed-by: Dave Hansen <redacted>
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2018-05-09 01:57:10
Dave Hansen [off-list ref] writes:
On 05/08/2018 07:59 AM, Michael Ellerman wrote:
quoted
Currently the architecture specific code is expected to display the
protection keys in smap for a given vma. This can lead to redundant
code and possibly to divergent formats in which the key gets
displayed.
This patch changes the implementation. It displays the pkey only if
the architecture support pkeys, i.e arch_pkeys_enabled() returns true.
For this, along with 6/8 and 7/8:
Reviewed-by: Dave Hansen <redacted>
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2018-05-10 13:54:31
Now that we've updated the generic headers to support 5 PKEY bits for
powerpc we don't need our own #defines in arch code.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/include/asm/pkeys.h | 15 ---------------
1 file changed, 15 deletions(-)
One additional patch to finish cleaning things up.
I've added this to my branch.
cheers
Agree. Was going to send that the moment the other patches
landed upstream. Glad I dont have to do it :-)
Reviewed-by: Ram Pai <redacted>
On Thu, May 10, 2018 at 11:54:22PM +1000, Michael Ellerman wrote:
quoted hunk
Now that we've updated the generic headers to support 5 PKEY bits for
powerpc we don't need our own #defines in arch code.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/include/asm/pkeys.h | 15 ---------------
1 file changed, 15 deletions(-)
One additional patch to finish cleaning things up.
I've added this to my branch.
cheers