[RFC v5 11/38] mm: introduce an additional vma bit for powerpc pkey

2017-07-05 Thread Ram Pai
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

[RFC v5 17/38] powerpc: sys_pkey_alloc() and sys_pkey_free() system calls

2017-07-05 Thread Ram Pai
Finally this patch provides the ability for a process to allocate and free a protection key. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/include/asm/systbl.h |2 ++ arch/powerpc/include/asm/unistd.h |4 +--- arch/powerpc/include/uapi/asm/unistd.h |2

[RFC v5 13/38] x86: disallow pkey creation with PKEY_DISABLE_EXECUTE

2017-07-05 Thread Ram Pai
x86 does not support disabling execute permissions on a pkey. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/x86/kernel/fpu/xstate.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c index c

[RFC v5 17/38] powerpc: sys_pkey_alloc() and sys_pkey_free() system calls

2017-07-05 Thread Ram Pai
Finally this patch provides the ability for a process to allocate and free a protection key. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/systbl.h |2 ++ arch/powerpc/include/asm/unistd.h |4 +--- arch/powerpc/include/uapi/asm/unistd.h |2 ++ 3 files changed, 5

[RFC v5 13/38] x86: disallow pkey creation with PKEY_DISABLE_EXECUTE

2017-07-05 Thread Ram Pai
x86 does not support disabling execute permissions on a pkey. Signed-off-by: Ram Pai --- arch/x86/kernel/fpu/xstate.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c index c24ac1e..d582631 100644 --- a/arch

[RFC v5 14/38] powerpc: initial plumbing for key management

2017-07-05 Thread Ram Pai
functions and macros, that the architecture-independent code expects to be available. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/Kconfig | 16 + arch/powerpc/include/asm/book3s/64/mmu.h |9 +++ arch/powerpc/include/asm/pkeys.h

[RFC v5 14/38] powerpc: initial plumbing for key management

2017-07-05 Thread Ram Pai
functions and macros, that the architecture-independent code expects to be available. Signed-off-by: Ram Pai --- arch/powerpc/Kconfig | 16 + arch/powerpc/include/asm/book3s/64/mmu.h |9 +++ arch/powerpc/include/asm/pkeys.h | 106

[RFC v5 18/38] powerpc: store and restore the pkey state across context switches

2017-07-05 Thread Ram Pai
Store and restore the AMR, IAMR and UMOR register state of the task before scheduling out and after scheduling in, respectively. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/include/asm/processor.h |5 + arch/powerpc/kernel/process.c| 18 +++

[RFC v5 18/38] powerpc: store and restore the pkey state across context switches

2017-07-05 Thread Ram Pai
Store and restore the AMR, IAMR and UMOR register state of the task before scheduling out and after scheduling in, respectively. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/processor.h |5 + arch/powerpc/kernel/process.c| 18 ++ 2 files changed, 23

[RFC v5 16/38] powerpc: implementation for arch_set_user_pkey_access()

2017-07-05 Thread Ram Pai
This patch provides the detailed implementation for a user to allocate a key and enable it in the hardware. It provides the plumbing, but it cannot be used yet till the system call is implemented. The next patch will do so. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/p

[RFC v5 16/38] powerpc: implementation for arch_set_user_pkey_access()

2017-07-05 Thread Ram Pai
This patch provides the detailed implementation for a user to allocate a key and enable it in the hardware. It provides the plumbing, but it cannot be used yet till the system call is implemented. The next patch will do so. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/pkeys.h

[RFC v5 22/38] powerpc: map vma key-protection bits to pte key bits.

2017-07-05 Thread Ram Pai
-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/include/asm/book3s/64/pgtable.h | 20 +++- arch/powerpc/include/asm/mman.h |8 arch/powerpc/include/asm/pkeys.h |9 + 3 files changed, 36 insertions(+), 1 deletions(-) diff

[RFC v5 22/38] powerpc: map vma key-protection bits to pte key bits.

2017-07-05 Thread Ram Pai
-by: Ram Pai --- arch/powerpc/include/asm/book3s/64/pgtable.h | 20 +++- arch/powerpc/include/asm/mman.h |8 arch/powerpc/include/asm/pkeys.h |9 + 3 files changed, 36 insertions(+), 1 deletions(-) diff --git a/arch/powerpc/include

[RFC v5 19/38] powerpc: introduce execute-only pkey

2017-07-05 Thread Ram Pai
This patch provides the implementation of execute-only pkey. The architecture-independent expects the ability to create and manage a special key which has execute-only permission. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/include/asm/book3s/64/mmu.h |1 + arch/p

[RFC v5 19/38] powerpc: introduce execute-only pkey

2017-07-05 Thread Ram Pai
This patch provides the implementation of execute-only pkey. The architecture-independent expects the ability to create and manage a special key which has execute-only permission. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/book3s/64/mmu.h |1 + arch/powerpc/include/asm/pkeys.h

[RFC v5 23/38] powerpc: sys_pkey_mprotect() system call

2017-07-05 Thread Ram Pai
Patch provides the ability for a process to associate a pkey with a address range. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/include/asm/systbl.h |1 + arch/powerpc/include/asm/unistd.h |4 +--- arch/powerpc/include/uapi/asm/unistd.h |1 + 3

[RFC v5 20/38] powerpc: ability to associate pkey to a vma

2017-07-05 Thread Ram Pai
arch-independent code expects the arch to map a pkey into the vma's protection bit setting. The patch provides that ability. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/include/asm/mman.h |8 +++- arch/powerpc/include/asm/pkeys.h | 14 -- 2

[RFC v5 23/38] powerpc: sys_pkey_mprotect() system call

2017-07-05 Thread Ram Pai
Patch provides the ability for a process to associate a pkey with a address range. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/systbl.h |1 + arch/powerpc/include/asm/unistd.h |4 +--- arch/powerpc/include/uapi/asm/unistd.h |1 + 3 files changed, 3 insertions(+), 3

[RFC v5 20/38] powerpc: ability to associate pkey to a vma

2017-07-05 Thread Ram Pai
arch-independent code expects the arch to map a pkey into the vma's protection bit setting. The patch provides that ability. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/mman.h |8 +++- arch/powerpc/include/asm/pkeys.h | 14 -- 2 files changed, 19 insertions

[RFC v5 21/38] powerpc: implementation for arch_override_mprotect_pkey()

2017-07-05 Thread Ram Pai
arch independent code calls arch_override_mprotect_pkey() to return a pkey that best matches the requested protection. This patch provides the implementation. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/include/asm/pkeys.h | 10 ++- arch/powerpc/mm/p

[RFC v5 21/38] powerpc: implementation for arch_override_mprotect_pkey()

2017-07-05 Thread Ram Pai
arch independent code calls arch_override_mprotect_pkey() to return a pkey that best matches the requested protection. This patch provides the implementation. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/pkeys.h | 10 ++- arch/powerpc/mm/pkeys.c | 47

[RFC v5 25/38] powerpc: helper to validate key-access permissions of a pte

2017-07-05 Thread Ram Pai
helper function that checks if the read/write/execute is allowed on the pte. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/include/asm/book3s/64/pgtable.h |2 + arch/powerpc/include/asm/pkeys.h |9 +++ arch/powerpc/mm/pkeys.c

[RFC v5 25/38] powerpc: helper to validate key-access permissions of a pte

2017-07-05 Thread Ram Pai
helper function that checks if the read/write/execute is allowed on the pte. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/book3s/64/pgtable.h |2 + arch/powerpc/include/asm/pkeys.h |9 +++ arch/powerpc/mm/pkeys.c | 31

[RFC v5 26/38] powerpc: check key protection for user page access

2017-07-05 Thread Ram Pai
Make sure that the kernel does not access user pages without checking their key-protection. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/include/asm/book3s/64/pgtable.h | 14 ++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/i

[RFC v5 26/38] powerpc: check key protection for user page access

2017-07-05 Thread Ram Pai
Make sure that the kernel does not access user pages without checking their key-protection. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/book3s/64/pgtable.h | 14 ++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h

[RFC v5 33/38] powerpc: Deliver SEGV signal on pkey violation

2017-07-05 Thread Ram Pai
The value of the AMR register at the time of exception is made available in gp_regs[PT_AMR] of the siginfo. The value of the pkey, whose protection got violated, is made available in si_pkey field of the siginfo structure. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/i

[RFC v5 31/38] powerpc: introduce get_pte_pkey() helper

2017-07-05 Thread Ram Pai
get_pte_pkey() helper returns the pkey associated with a address corresponding to a given mm_struct. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/include/asm/book3s/64/mmu-hash.h |5 arch/powerpc/mm/hash_utils_64.c | 28 + 2

[RFC v5 31/38] powerpc: introduce get_pte_pkey() helper

2017-07-05 Thread Ram Pai
get_pte_pkey() helper returns the pkey associated with a address corresponding to a given mm_struct. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/book3s/64/mmu-hash.h |5 arch/powerpc/mm/hash_utils_64.c | 28 + 2 files changed, 33

[RFC v5 33/38] powerpc: Deliver SEGV signal on pkey violation

2017-07-05 Thread Ram Pai
The value of the AMR register at the time of exception is made available in gp_regs[PT_AMR] of the siginfo. The value of the pkey, whose protection got violated, is made available in si_pkey field of the siginfo structure. Signed-off-by: Ram Pai --- arch/powerpc/include/uapi/asm/ptrace.h

[RFC v5 28/38] powerpc: implementation for arch_vma_access_permitted()

2017-07-05 Thread Ram Pai
This patch provides the implementation for arch_vma_access_permitted(). Returns true if the requested access is allowed by pkey associated with the vma. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/include/asm/mmu_context.h |5 arch/powerpc/mm/p

[RFC v5 28/38] powerpc: implementation for arch_vma_access_permitted()

2017-07-05 Thread Ram Pai
This patch provides the implementation for arch_vma_access_permitted(). Returns true if the requested access is allowed by pkey associated with the vma. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/mmu_context.h |5 arch/powerpc/mm/pkeys.c| 40

[RFC v5 36/38] selftest: PowerPC specific test updates to memory protection keys

2017-07-05 Thread Ram Pai
checkpatch.pl happy Signed-off-by: Ram Pai <linux...@us.ibm.com> --- tools/testing/selftests/vm/pkey-helpers.h| 230 +-- tools/testing/selftests/vm/protection_keys.c | 567 +++--- 2 files changed, 518 insertions(+), 279 deletions(-) diff --git a/tools/t

[RFC v5 36/38] selftest: PowerPC specific test updates to memory protection keys

2017-07-05 Thread Ram Pai
checkpatch.pl happy Signed-off-by: Ram Pai --- tools/testing/selftests/vm/pkey-helpers.h| 230 +-- tools/testing/selftests/vm/protection_keys.c | 567 +++--- 2 files changed, 518 insertions(+), 279 deletions(-) diff --git a/tools/testing/selftests/vm/pkey-helpers.h

[RFC v5 35/38] selftest: Move protecton key selftest to arch neutral directory

2017-07-05 Thread Ram Pai
Signed-off-by: Ram Pai <linux...@us.ibm.com> --- tools/testing/selftests/vm/Makefile |1 + tools/testing/selftests/vm/pkey-helpers.h | 219 tools/testing/selftests/vm/protection_keys.c | 1395 + tools/testing/selftests/x86/Makefile

[RFC v5 35/38] selftest: Move protecton key selftest to arch neutral directory

2017-07-05 Thread Ram Pai
Signed-off-by: Ram Pai --- tools/testing/selftests/vm/Makefile |1 + tools/testing/selftests/vm/pkey-helpers.h | 219 tools/testing/selftests/vm/protection_keys.c | 1395 + tools/testing/selftests/x86/Makefile |2 +- tools/testing

[RFC v5 34/38] procfs: display the protection-key number associated with a vma

2017-07-05 Thread Ram Pai
Display the pkey number associated with the vma in smaps of a task. The key will be seen as below: ProtectionKey: 0 Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/kernel/setup_64.c |8 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/

[RFC v5 32/38] powerpc: capture the violated protection key on fault

2017-07-05 Thread Ram Pai
Capture the protection key that got violated in paca. This value will be used by used to inform the signal handler. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/include/asm/paca.h |1 + arch/powerpc/kernel/asm-offsets.c |1 + arch/powerpc/mm/fault.c

[RFC v5 34/38] procfs: display the protection-key number associated with a vma

2017-07-05 Thread Ram Pai
Display the pkey number associated with the vma in smaps of a task. The key will be seen as below: ProtectionKey: 0 Signed-off-by: Ram Pai --- arch/powerpc/kernel/setup_64.c |8 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/kernel/setup_64.c b/arch

[RFC v5 32/38] powerpc: capture the violated protection key on fault

2017-07-05 Thread Ram Pai
Capture the protection key that got violated in paca. This value will be used by used to inform the signal handler. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/paca.h |1 + arch/powerpc/kernel/asm-offsets.c |1 + arch/powerpc/mm/fault.c |3 +++ 3 files changed, 5

[RFC v5 29/38] powerpc: Handle exceptions caused by pkey violation

2017-07-05 Thread Ram Pai
in such a case. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/include/asm/reg.h |2 +- arch/powerpc/mm/fault.c| 21 + 2 files changed, 22 insertions(+), 1 deletions(-) diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h index b

[RFC v5 38/38] Documentation: PowerPC specific updates to memory protection keys

2017-07-05 Thread Ram Pai
Add documentation updates that capture PowerPC specific changes. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- Documentation/vm/protection-keys.txt | 85 ++ 1 files changed, 65 insertions(+), 20 deletions(-) diff --git a/Documentation/vm/protection-ke

[RFC v5 29/38] powerpc: Handle exceptions caused by pkey violation

2017-07-05 Thread Ram Pai
in such a case. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/reg.h |2 +- arch/powerpc/mm/fault.c| 21 + 2 files changed, 22 insertions(+), 1 deletions(-) diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h index ba110dd..6e2a860 100644

[RFC v5 38/38] Documentation: PowerPC specific updates to memory protection keys

2017-07-05 Thread Ram Pai
Add documentation updates that capture PowerPC specific changes. Signed-off-by: Ram Pai --- Documentation/vm/protection-keys.txt | 85 ++ 1 files changed, 65 insertions(+), 20 deletions(-) diff --git a/Documentation/vm/protection-keys.txt b/Documentation/vm

[RFC v5 27/38] powerpc: Macro the mask used for checking DSI exception

2017-07-05 Thread Ram Pai
Replace the magic number used to check for DSI exception with a meaningful value. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/include/asm/reg.h |7 ++- arch/powerpc/kernel/exceptions-64s.S |2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff

[RFC v5 37/38] Documentation: Move protecton key documentation to arch neutral directory

2017-07-05 Thread Ram Pai
Since PowerPC and Intel both support memory protection keys, moving the documenation to arch-neutral directory. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- Documentation/vm/protection-keys.txt | 85 + Documentation/x86/protection-keys.txt

[RFC v5 27/38] powerpc: Macro the mask used for checking DSI exception

2017-07-05 Thread Ram Pai
Replace the magic number used to check for DSI exception with a meaningful value. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/reg.h |7 ++- arch/powerpc/kernel/exceptions-64s.S |2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include

[RFC v5 37/38] Documentation: Move protecton key documentation to arch neutral directory

2017-07-05 Thread Ram Pai
Since PowerPC and Intel both support memory protection keys, moving the documenation to arch-neutral directory. Signed-off-by: Ram Pai --- Documentation/vm/protection-keys.txt | 85 + Documentation/x86/protection-keys.txt | 85

[RFC v5 30/38] powerpc: capture AMR register content on pkey violation

2017-07-05 Thread Ram Pai
capture AMR register contents, and save it in paca whenever a pkey violation is detected. This value will be needed to deliver pkey-violation signal to the task. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/include/asm/paca.h |3 +++ arch/powerpc/kernel/asm-off

[RFC v5 30/38] powerpc: capture AMR register content on pkey violation

2017-07-05 Thread Ram Pai
capture AMR register contents, and save it in paca whenever a pkey violation is detected. This value will be needed to deliver pkey-violation signal to the task. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/paca.h |3 +++ arch/powerpc/kernel/asm-offsets.c |5 + arch

[RFC v5 12/38] mm: ability to disable execute permission on a key at creation

2017-07-05 Thread Ram Pai
this. Hence the next patch will add ability in x86 to return error if PKEY_DISABLE_EXECUTE is specified. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- include/uapi/asm-generic/mman-common.h |4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/include/uapi/asm-generi

[RFC v5 12/38] mm: ability to disable execute permission on a key at creation

2017-07-05 Thread Ram Pai
this. Hence the next patch will add ability in x86 to return error if PKEY_DISABLE_EXECUTE is specified. Signed-off-by: Ram Pai --- include/uapi/asm-generic/mman-common.h |4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/include/uapi/asm-generic/mman-common.h b/include

[RFC v5 24/38] powerpc: Program HPTE key protection bits

2017-07-05 Thread Ram Pai
Map the PTE protection key bits to the HPTE key protection bits, while creating HPTE entries. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/include/asm/book3s/64/mmu-hash.h |5 + arch/powerpc/include/asm/pkeys.h |9 + arch/powe

[RFC v5 24/38] powerpc: Program HPTE key protection bits

2017-07-05 Thread Ram Pai
Map the PTE protection key bits to the HPTE key protection bits, while creating HPTE entries. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/book3s/64/mmu-hash.h |5 + arch/powerpc/include/asm/pkeys.h |9 + arch/powerpc/mm/hash_utils_64.c

[RFC v5 04/38] powerpc: introduce pte_get_hash_gslot() helper

2017-07-05 Thread Ram Pai
Introduce pte_get_hash_gslot()() which returns the slot number of the HPTE in the global hash table. This function will come in handy as we work towards re-arranging the PTE bits in the later patches. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/include/asm/book3s/64/

[RFC v5 04/38] powerpc: introduce pte_get_hash_gslot() helper

2017-07-05 Thread Ram Pai
Introduce pte_get_hash_gslot()() which returns the slot number of the HPTE in the global hash table. This function will come in handy as we work towards re-arranging the PTE bits in the later patches. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/book3s/64/hash.h |3 +++ arch/powerpc

[RFC v5 05/38] powerpc: capture the PTE format changes in the dump pte report

2017-07-05 Thread Ram Pai
The H_PAGE_F_SECOND,H_PAGE_F_GIX are not in the 64K main-PTE. capture these changes in the dump pte report. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/mm/dump_linuxpagetables.c |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/arch/powe

[RFC v5 07/38] powerpc: use helper functions in __hash_page_huge() for 64K PTE

2017-07-05 Thread Ram Pai
replace redundant code in __hash_page_huge() with helper functions pte_get_hash_gslot() and pte_set_hash_slot() Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/mm/hugetlbpage-hash64.c | 24 1 files changed, 4 insertions(+), 20 deletions(-) diff

[RFC v5 05/38] powerpc: capture the PTE format changes in the dump pte report

2017-07-05 Thread Ram Pai
The H_PAGE_F_SECOND,H_PAGE_F_GIX are not in the 64K main-PTE. capture these changes in the dump pte report. Signed-off-by: Ram Pai --- arch/powerpc/mm/dump_linuxpagetables.c |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/arch/powerpc/mm/dump_linuxpagetables.c b/arch

[RFC v5 07/38] powerpc: use helper functions in __hash_page_huge() for 64K PTE

2017-07-05 Thread Ram Pai
replace redundant code in __hash_page_huge() with helper functions pte_get_hash_gslot() and pte_set_hash_slot() Signed-off-by: Ram Pai --- arch/powerpc/mm/hugetlbpage-hash64.c | 24 1 files changed, 4 insertions(+), 20 deletions(-) diff --git a/arch/powerpc/mm

[RFC v5 00/38] powerpc: Memory Protection Keys

2017-07-05 Thread Ram Pai
if the pte was not yet Hashed with a hpte. Reported by Aneesh. (3) Fixed ABI breakage caused in siginfo structure. Reported by Anshuman. version v1: Initial version Ram Pai (38): powerpc: Free up four 64K PTE bits in 4K backed HPTE pages powerpc: Free up fo

[RFC v5 00/38] powerpc: Memory Protection Keys

2017-07-05 Thread Ram Pai
if the pte was not yet Hashed with a hpte. Reported by Aneesh. (3) Fixed ABI breakage caused in siginfo structure. Reported by Anshuman. version v1: Initial version Ram Pai (38): powerpc: Free up four 64K PTE bits in 4K backed HPTE pages powerpc: Free up fo

Re: [RFC v4 09/17] powerpc: call the hash functions with the correct pkey value

2017-06-28 Thread Ram Pai
On Tue, Jun 27, 2017 at 08:54:07PM +0530, Aneesh Kumar K.V wrote: > > > On Tuesday 27 June 2017 03:41 PM, Ram Pai wrote: > >Pass the correct protection key value to the hash functions on > >page fault. > > > >Signed-off-by: Ram Pai <linux...@us.ibm.com&g

Re: [RFC v4 09/17] powerpc: call the hash functions with the correct pkey value

2017-06-28 Thread Ram Pai
On Tue, Jun 27, 2017 at 08:54:07PM +0530, Aneesh Kumar K.V wrote: > > > On Tuesday 27 June 2017 03:41 PM, Ram Pai wrote: > >Pass the correct protection key value to the hash functions on > >page fault. > > > >Signed-off-by: Ram Pai > >--- >

[RFC v4 01/17] mm: introduce an additional vma bit for powerpc pkey

2017-06-27 Thread Ram Pai
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 <linux...@us.ibm.com> --- fs/proc/task_mmu.c | 6 +- include/linux/mm.

[RFC v4 01/17] mm: introduce an additional vma bit for powerpc pkey

2017-06-27 Thread Ram Pai
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

[RFC v4 06/17] powerpc: Implementation for sys_mprotect_pkey() system call

2017-06-27 Thread Ram Pai
This system call, associates the pkey with vma corresponding to the given address range. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/include/asm/mman.h| 8 ++- arch/powerpc/include/asm/pkeys.h | 17 ++- arch/powerpc/include/asm/systbl.h | 1 +

[RFC v4 07/17] powerpc: make the hash functions protection-key aware

2017-06-27 Thread Ram Pai
Prepare the hash functions to be aware of protection keys. This key will later be used to program the HPTE. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/include/asm/book3s/64/hash.h | 2 +- arch/powerpc/include/asm/book3s/64/mmu-hash.h | 14 ++- arch/powe

[RFC v4 06/17] powerpc: Implementation for sys_mprotect_pkey() system call

2017-06-27 Thread Ram Pai
This system call, associates the pkey with vma corresponding to the given address range. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/mman.h| 8 ++- arch/powerpc/include/asm/pkeys.h | 17 ++- arch/powerpc/include/asm/systbl.h | 1 + arch/powerpc/include/asm

[RFC v4 07/17] powerpc: make the hash functions protection-key aware

2017-06-27 Thread Ram Pai
Prepare the hash functions to be aware of protection keys. This key will later be used to program the HPTE. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/book3s/64/hash.h | 2 +- arch/powerpc/include/asm/book3s/64/mmu-hash.h | 14 ++- arch/powerpc/mm/hash64_4k.c

[RFC v4 04/17] powerpc: Implement sys_pkey_alloc and sys_pkey_free system call

2017-06-27 Thread Ram Pai
a key can be initialize to disable execute. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/Kconfig | 15 arch/powerpc/include/asm/book3s/64/mmu.h | 10 +++ arch/powerpc/include/asm/book3s/64/pgtable.h | 62 ++ arch/powerpc/inclu

[RFC v4 04/17] powerpc: Implement sys_pkey_alloc and sys_pkey_free system call

2017-06-27 Thread Ram Pai
a key can be initialize to disable execute. Signed-off-by: Ram Pai --- arch/powerpc/Kconfig | 15 arch/powerpc/include/asm/book3s/64/mmu.h | 10 +++ arch/powerpc/include/asm/book3s/64/pgtable.h | 62 ++ arch/powerpc/include/asm/pkeys.h | 124

[RFC v4 09/17] powerpc: call the hash functions with the correct pkey value

2017-06-27 Thread Ram Pai
Pass the correct protection key value to the hash functions on page fault. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/include/asm/pkeys.h | 11 +++ arch/powerpc/mm/hash_utils_64.c | 4 arch/powerpc/mm/mem.c| 6 ++ 3 files changed, 21 inse

[RFC v4 09/17] powerpc: call the hash functions with the correct pkey value

2017-06-27 Thread Ram Pai
Pass the correct protection key value to the hash functions on page fault. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/pkeys.h | 11 +++ arch/powerpc/mm/hash_utils_64.c | 4 arch/powerpc/mm/mem.c| 6 ++ 3 files changed, 21 insertions(+) diff --git a/arch

[RFC v4 02/17] mm: ability to disable execute permission on a key at creation

2017-06-27 Thread Ram Pai
this. Hence the next patch will add ability in x86 to return error if PKEY_DISABLE_EXECUTE is specified. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- include/uapi/asm-generic/mman-common.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/uapi/asm-generi

[RFC v4 02/17] mm: ability to disable execute permission on a key at creation

2017-06-27 Thread Ram Pai
this. Hence the next patch will add ability in x86 to return error if PKEY_DISABLE_EXECUTE is specified. Signed-off-by: Ram Pai --- include/uapi/asm-generic/mman-common.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/uapi/asm-generic/mman-common.h b/include/uapi

[RFC v4 12/17] powerpc: Deliver SEGV signal on pkey violation

2017-06-27 Thread Ram Pai
The value of the AMR register at the time of exception is made available in gp_regs[PT_AMR] of the siginfo. The value of the pkey, whose protection got violated, is made available in si_pkey field of the siginfo structure. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/i

[RFC v4 08/17] powerpc: Program HPTE key protection bits

2017-06-27 Thread Ram Pai
Map the PTE protection key bits to the HPTE key protection bits, while creating HPTE entries. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- Makefile | 2 +- arch/powerpc/include/asm/book3s/64/mmu-hash.h | 5 + arch/powerpc/include/asm/p

[RFC v4 12/17] powerpc: Deliver SEGV signal on pkey violation

2017-06-27 Thread Ram Pai
The value of the AMR register at the time of exception is made available in gp_regs[PT_AMR] of the siginfo. The value of the pkey, whose protection got violated, is made available in si_pkey field of the siginfo structure. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/paca.h| 1

[RFC v4 08/17] powerpc: Program HPTE key protection bits

2017-06-27 Thread Ram Pai
Map the PTE protection key bits to the HPTE key protection bits, while creating HPTE entries. Signed-off-by: Ram Pai --- Makefile | 2 +- arch/powerpc/include/asm/book3s/64/mmu-hash.h | 5 + arch/powerpc/include/asm/pkeys.h | 9

[RFC v4 10/17] powerpc: Macro the mask used for checking DSI exception

2017-06-27 Thread Ram Pai
Replace the magic number used to check for DSI exception with a meaningful value. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/include/asm/reg.h | 7 ++- arch/powerpc/kernel/exceptions-64s.S | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git

[RFC v4 10/17] powerpc: Macro the mask used for checking DSI exception

2017-06-27 Thread Ram Pai
Replace the magic number used to check for DSI exception with a meaningful value. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/reg.h | 7 ++- arch/powerpc/kernel/exceptions-64s.S | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm

[RFC v4 05/17] powerpc: store and restore the pkey state across context switches

2017-06-27 Thread Ram Pai
Store and restore the AMR, IAMR and UMOR register state of the task before scheduling out and after scheduling in, respectively. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/include/asm/processor.h | 5 + arch/powerpc/kernel/process.c| 18 ++ 2

[RFC v4 05/17] powerpc: store and restore the pkey state across context switches

2017-06-27 Thread Ram Pai
Store and restore the AMR, IAMR and UMOR register state of the task before scheduling out and after scheduling in, respectively. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/processor.h | 5 + arch/powerpc/kernel/process.c| 18 ++ 2 files changed, 23

[RFC v4 15/17] Documentation: Move protecton key documentation to arch neutral directory

2017-06-27 Thread Ram Pai
Since PowerPC and Intel both support memory protection keys, moving the documenation to arch-neutral directory. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- Documentation/vm/protection-keys.txt | 85 +++ Documentation/x86/protection-keys.tx

[RFC v4 15/17] Documentation: Move protecton key documentation to arch neutral directory

2017-06-27 Thread Ram Pai
Since PowerPC and Intel both support memory protection keys, moving the documenation to arch-neutral directory. Signed-off-by: Ram Pai --- Documentation/vm/protection-keys.txt | 85 +++ Documentation/x86/protection-keys.txt | 85

[RFC v4 16/17] Documentation: PowerPC specific updates to memory protection keys

2017-06-27 Thread Ram Pai
Add documentation updates that capture PowerPC specific changes. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- Documentation/vm/protection-keys.txt | 89 1 file changed, 69 insertions(+), 20 deletions(-) diff --git a/Documentation/vm/protection-ke

[RFC v4 16/17] Documentation: PowerPC specific updates to memory protection keys

2017-06-27 Thread Ram Pai
Add documentation updates that capture PowerPC specific changes. Signed-off-by: Ram Pai --- Documentation/vm/protection-keys.txt | 89 1 file changed, 69 insertions(+), 20 deletions(-) diff --git a/Documentation/vm/protection-keys.txt b/Documentation/vm

[RFC v4 13/17] selftest: Move protecton key selftest to arch neutral directory

2017-06-27 Thread Ram Pai
Signed-off-by: Ram Pai <linux...@us.ibm.com> --- tools/testing/selftests/vm/Makefile |1 + tools/testing/selftests/vm/pkey-helpers.h | 219 tools/testing/selftests/vm/protection_keys.c | 1395 + tools/testing/selftests/x86/Makefile

[RFC v4 13/17] selftest: Move protecton key selftest to arch neutral directory

2017-06-27 Thread Ram Pai
Signed-off-by: Ram Pai --- tools/testing/selftests/vm/Makefile |1 + tools/testing/selftests/vm/pkey-helpers.h | 219 tools/testing/selftests/vm/protection_keys.c | 1395 + tools/testing/selftests/x86/Makefile |2 +- tools/testing

[RFC v4 14/17] selftest: PowerPC specific test updates to memory protection keys

2017-06-27 Thread Ram Pai
checkpatch.pl happy Signed-off-by: Ram Pai <linux...@us.ibm.com> --- tools/testing/selftests/vm/pkey-helpers.h| 230 +-- tools/testing/selftests/vm/protection_keys.c | 567 --- 2 files changed, 518 insertions(+), 279 deletions(-) diff --git a/tools/t

[RFC v4 14/17] selftest: PowerPC specific test updates to memory protection keys

2017-06-27 Thread Ram Pai
checkpatch.pl happy Signed-off-by: Ram Pai --- tools/testing/selftests/vm/pkey-helpers.h| 230 +-- tools/testing/selftests/vm/protection_keys.c | 567 --- 2 files changed, 518 insertions(+), 279 deletions(-) diff --git a/tools/testing/selftests/vm/pkey-helpers.h

[RFC v4 17/17] procfs: display the protection-key number associated with a vma

2017-06-27 Thread Ram Pai
Display the pkey number associated with the vma in smaps of a task. The key will be seen as below: VmFlags: rd wr mr mw me dw ac key=0 Signed-off-by: Ram Pai <linux...@us.ibm.com> --- Documentation/filesystems/proc.txt | 3 ++- fs/proc/task_mmu.c | 22 +++

[RFC v4 17/17] procfs: display the protection-key number associated with a vma

2017-06-27 Thread Ram Pai
Display the pkey number associated with the vma in smaps of a task. The key will be seen as below: VmFlags: rd wr mr mw me dw ac key=0 Signed-off-by: Ram Pai --- Documentation/filesystems/proc.txt | 3 ++- fs/proc/task_mmu.c | 22 +++--- 2 files changed, 13

[RFC v4 11/17] powerpc: Handle exceptions caused by pkey violation

2017-06-27 Thread Ram Pai
Handle Data and Instruction exceptions caused by memory protection-key. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/include/asm/mmu_context.h | 12 ++ arch/powerpc/include/asm/reg.h | 2 +- arch/powerpc/mm/fault.c| 20 + arch/powe

[RFC v4 03/17] x86: key creation with PKEY_DISABLE_EXECUTE disallowed

2017-06-27 Thread Ram Pai
x86 does not support disabling execute permissions on a pkey. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/x86/kernel/fpu/xstate.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c index c24ac1e..d582631 100644 ---

[RFC v4 11/17] powerpc: Handle exceptions caused by pkey violation

2017-06-27 Thread Ram Pai
Handle Data and Instruction exceptions caused by memory protection-key. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/mmu_context.h | 12 ++ arch/powerpc/include/asm/reg.h | 2 +- arch/powerpc/mm/fault.c| 20 + arch/powerpc/mm/pkeys.c

[RFC v4 03/17] x86: key creation with PKEY_DISABLE_EXECUTE disallowed

2017-06-27 Thread Ram Pai
x86 does not support disabling execute permissions on a pkey. Signed-off-by: Ram Pai --- arch/x86/kernel/fpu/xstate.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c index c24ac1e..d582631 100644 --- a/arch/x86/kernel/fpu

[RFC v4 00/17] powerpc: Memory Protection Keys

2017-06-27 Thread Ram Pai
correctly, and initialization of second-part-of-the-pte was not done correctly if the pte was not yet Hashed with a hpte. Reported by Aneesh. (3) Fixed ABI breakage caused in siginfo structure. Reported by Anshuman. version v1: Initial version Ram Pai

[RFC v4 00/17] powerpc: Memory Protection Keys

2017-06-27 Thread Ram Pai
correctly, and initialization of second-part-of-the-pte was not done correctly if the pte was not yet Hashed with a hpte. Reported by Aneesh. (3) Fixed ABI breakage caused in siginfo structure. Reported by Anshuman. version v1: Initial version Ram Pai

Re: [RFC v3 02/23] powerpc: introduce set_hidx_slot helper

2017-06-26 Thread Ram Pai
On Sun, Jun 25, 2017 at 11:02:58PM -0500, Benjamin Herrenschmidt wrote: > On Mon, 2017-06-26 at 09:03 +1000, Balbir Singh wrote: > > On Wed, 2017-06-21 at 18:39 -0700, Ram Pai wrote: > > > Introduce set_hidx_slot() which sets the (H_PAGE_F_SECOND|H_PAGE_F_GIX) > > >

<    3   4   5   6   7   8   9   10   11   12   >