[PATCH v10 07/24] selftests/vm: fixed bugs in pkey_disable_clear()

2018-01-22 Thread Ram Pai
instead of clearing the bits, pkey_disable_clear() was setting the bits. Fixed it. Also fixed a wrong assertion in that function. When bits are cleared, the resulting bit value will be less than the original. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c |4

[PATCH v10 08/24] selftests/vm: clear the bits in shadow reg when a pkey is freed.

2018-01-22 Thread Ram Pai
When a key is freed, the key is no more effective. Clear the bits corresponding to the pkey in the shadow register. Otherwise it will carry some spurious bits which can trigger false-positive asserts. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c |3 +++ 1

[PATCH v10 05/24] selftests/vm: generic function to handle shadow key register

2018-01-22 Thread Ram Pai
helper functions to handler shadow pkey register Signed-off-by: Ram Pai --- tools/testing/selftests/vm/pkey-helpers.h| 27 tools/testing/selftests/vm/protection_keys.c | 34 - 2 files changed, 49 insertions(+), 12 deletions(-) diff --git a

[PATCH v10 09/24] selftests/vm: fix alloc_random_pkey() to make it really random

2018-01-22 Thread Ram Pai
alloc_random_pkey() was allocating the same pkey every time. Not all pkeys were geting tested. fixed it. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c | 10 +++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/vm

[PATCH v10 11/24] selftests/vm: pkey register should match shadow pkey

2018-01-22 Thread Ram Pai
throughout Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/vm/protection_keys.c b/tools/testing/selftests/vm/protection_keys.c index 254b66d..6054093 100644 --- a/tools

[PATCH v10 10/24] selftests/vm: introduce two arch independent abstraction

2018-01-22 Thread Ram Pai
open_hugepage_file() <- opens the huge page file get_start_key() <-- provides the first non-reserved key. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/pkey-helpers.h| 11 +++ tools/testing/selftests/vm/protection_keys.c |6 +++--- 2 files changed, 14 insertions

[PATCH v10 13/24] selftests/vm: powerpc implementation for generic abstraction

2018-01-22 Thread Ram Pai
Introduce powerpc implementation for the different abstactions. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/pkey-helpers.h| 109 ++ tools/testing/selftests/vm/protection_keys.c | 40 ++ 2 files changed, 118 insertions(+), 31 deletions(-) diff

[PATCH v10 16/24] selftests/vm: fix an assertion in test_pkey_alloc_exhaust()

2018-01-22 Thread Ram Pai
The maximum number of keys that can be allocated has to take into consideration, that some keys are reserved by the architecture for specific purpose. Hence cannot be allocated. Fix the assertion in test_pkey_alloc_exhaust() Signed-off-by: Ram Pai --- tools/testing/selftests/vm/pkey

[PATCH v10 14/24] selftests/vm: clear the bits in shadow reg when a pkey is freed.

2018-01-22 Thread Ram Pai
When a key is freed, the key is no more effective. Clear the bits corresponding to the pkey in the shadow register. Otherwise it will carry some spurious bits which can trigger false-positive asserts. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c |3 ++- 1

[PATCH v10 18/24] selftests/vm: associate key on a mapped page and detect write violation

2018-01-22 Thread Ram Pai
detect write-violation on a page to which write-disabled key is associated much after the page is mapped. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c | 12 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/tools/testing/selftests/vm

[PATCH v10 19/24] selftests/vm: detect write violation on a mapped access-denied-key page

2018-01-22 Thread Ram Pai
detect write-violation on a page to which access-disabled key is associated much after the page is mapped. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c | 13 + 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/tools/testing/selftests/vm

[PATCH v10 21/24] selftests/vm: sub-page allocator

2018-01-22 Thread Ram Pai
introduce a new allocator that allocates 4k hardware-pages to back 64k linux-page. This allocator is only applicable on powerpc. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c | 30 ++ 1 files changed, 30 insertions(+), 0 deletions(-) diff

[PATCH v10 22/24] selftests/vm: Fix deadlock in protection_keys.c

2018-01-22 Thread Ram Pai
60 in run_tests_once () at protection_keys.c:1414 #14 0x100561a4 in main () at protection_keys.c:1459 The fix is to refrain from calling fflush() when inside a signal handler. The output may not be as pretty but at least the testcase will be able to move on. Signed-off-by: Ram Pai Signe

[PATCH v10 23/24] selftests/powerpc: Add ptrace tests for Protection Key register

2018-01-22 Thread Ram Pai
From: Thiago Jung Bauermann This test exercises read and write access to the AMR. Signed-off-by: Thiago Jung Bauermann --- tools/testing/selftests/powerpc/include/reg.h |1 + tools/testing/selftests/powerpc/ptrace/Makefile|5 +- .../testing/selftests/powerpc/ptrace/ptrace-pkey

[PATCH v10 24/24] selftests/powerpc: Add core file test for Protection Key register

2018-01-22 Thread Ram Pai
From: Thiago Jung Bauermann This test verifies that the AMR is being written to a process' core file. Signed-off-by: Thiago Jung Bauermann --- tools/testing/selftests/powerpc/ptrace/Makefile|2 +- tools/testing/selftests/powerpc/ptrace/core-pkey.c | 438 2 files c

[PATCH v10 20/24] selftests/vm: testcases must restore pkey-permissions

2018-01-22 Thread Ram Pai
of the pkey register is not restored to its original state. The test case is responsible for restoring the key register state to its original value. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git

[PATCH v10 15/24] selftests/vm: powerpc implementation to check support for pkey

2018-01-22 Thread Ram Pai
pkey subsystem is supported if the hardware and kernel has support. We determine that by checking if allocation of a key succeeds or not. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/pkey-helpers.h| 22 -- tools/testing/selftests/vm/protection_keys.c |9

[PATCH v10 12/24] selftests/vm: generic cleanup

2018-01-22 Thread Ram Pai
cleanup the code to satisfy coding styles. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c | 81 ++ 1 files changed, 43 insertions(+), 38 deletions(-) diff --git a/tools/testing/selftests/vm/protection_keys.c b/tools/testing/selftests/vm

[PATCH v10 17/24] selftests/vm: associate key on a mapped page and detect access violation

2018-01-22 Thread Ram Pai
detect access-violation on a page to which access-disabled key is associated much after the page is mapped. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c | 19 +++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/tools/testing/selftests

[PATCH v10 06/24] selftests/vm: fix the wrong assert in pkey_disable_set()

2018-01-22 Thread Ram Pai
If the flag is 0, no bits will be set. Hence we cant expect the resulting bitmap to have a higher value than what it was earlier. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/tools/testing

[PATCH v10 00/24] selftests, powerpc, x86 : Memory Protection Keys

2018-01-22 Thread Ram Pai
architectures(using EC2 ubuntu VM instances). Ram Pai (21): selftests/x86: Move protecton key selftest to arch neutral directory selftests/vm: rename all references to pkru to a generic name selftests/vm: move generic definitions to header file selftests/vm: typecast the pkey register selftests/vm

[PATCH v10 01/24] selftests/x86: Move protecton key selftest to arch neutral directory

2018-01-22 Thread Ram Pai
Signed-off-by: Ram Pai --- tools/testing/selftests/vm/Makefile |1 + tools/testing/selftests/vm/pkey-helpers.h | 223 tools/testing/selftests/vm/protection_keys.c | 1407 + tools/testing/selftests/x86/Makefile |2 +- tools/testing

Re: [PATCH v10 00/27] powerpc, mm: Memory Protection Keys

2018-01-22 Thread Ram Pai
Sorry please ignore this series. It was a duplication mistake. I aborted the send midway, but a few escaped into the cyber. RP On Mon, Jan 22, 2018 at 10:26:29AM -0800, Ram Pai wrote: > Memory protection keys enable applications to protect its > address space from inadvertent access f

[PATCH v10 1/2] Documentation/x86: Move protecton key documentation to arch neutral directory

2018-01-22 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 | 90 + Documentation/x86/protection-keys.txt | 90

[PATCH v10 0/2] Documentation, powerpc, x86 : Memory Protection Keys

2018-01-22 Thread Ram Pai
Memory protection keys enable applications to protect its address space from inadvertent access from itself. This feature is now enabled on powerpc architecture. The patches moves the documentation to arch neutral directory and captures the latest information. Ram Pai (2): Documentation/x86

[PATCH v10 2/2] Documentation/vm: PowerPC specific updates to memory protection keys

2018-01-22 Thread Ram Pai
Add documentation updates that capture PowerPC specific changes. Signed-off-by: Thiago Jung Bauermann Signed-off-by: Ram Pai --- Documentation/vm/protection-keys.txt | 84 + 1 files changed, 63 insertions(+), 21 deletions(-) diff --git a/Documentation/vm

[PATCH v10 00/27] powerpc, mm: Memory Protection Keys

2018-01-22 Thread Ram Pai
version v1: Initial version Ram Pai (26): 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 powerpc: initial pkey plumbing powerpc: track allocation status of all pkeys powerpc: helper f

[PATCH v10 01/27] mm, powerpc, x86: define VM_PKEY_BITx bits if CONFIG_ARCH_HAS_PKEYS is enabled

2018-01-22 Thread Ram Pai
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. Signed-off-by: Ram Pai --- fs/proc/task_mmu.c |4 ++-- include/linux/mm.h

[PATCH v10 02/27] mm, powerpc, x86: introduce an additional vma bit for powerpc pkey

2018-01-22 Thread Ram Pai
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. Acked-by: Balbir Singh Signed-off-by: Ram Pai --- fs/proc/task_mmu.c |1 + include/linux/mm.h |3

Re: [PATCH v10 27/27] mm: display pkey in smaps if arch_pkeys_enabled() is true

2018-01-19 Thread Ram Pai
On Fri, Jan 19, 2018 at 10:09:41AM -0600, Eric W. Biederman wrote: > Ram Pai writes: > > > 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 diverg

[PATCH v10 10/27] powerpc: store and restore the pkey state across context switches

2018-01-18 Thread Ram Pai
Store and restore the AMR, IAMR and UAMOR register state of the task before scheduling out and after scheduling in, respectively. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/mmu_context.h |3 ++ arch/powerpc/include/asm/pkeys.h |4 ++ arch/powerpc/include/asm/processor.h

[PATCH v10 11/27] powerpc: introduce execute-only pkey

2018-01-18 Thread Ram Pai
This patch provides the implementation of execute-only pkey. The architecture-independent layer expects the arch-dependent layer, to support the ability to create and enable a special key which has execute-only permission. Acked-by: Balbir Singh Signed-off-by: Ram Pai --- arch/powerpc/include

[PATCH v10 13/27] powerpc: implementation for arch_override_mprotect_pkey()

2018-01-18 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/mmu_context.h |5 arch/powerpc/include/asm/pkeys.h | 21

[PATCH v10 12/27] powerpc: ability to associate pkey to a vma

2018-01-18 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 |7 ++- arch/powerpc/include/asm/pkeys.h | 11 +++ arch/powerpc/mm/pk

[PATCH v10 01/27] mm, powerpc, x86: define VM_PKEY_BITx bits if CONFIG_ARCH_HAS_PKEYS is enabled

2018-01-18 Thread Ram Pai
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. Signed-off-by: Ram Pai --- fs/proc/task_mmu.c |4 ++-- include/linux/mm.h

[PATCH v10 14/27] powerpc: map vma key-protection bits to pte key bits.

2018-01-18 Thread Ram Pai
BUT, on 4k kernel, bit 3, and 4 could not be freed up. remember? Hence we have to be satisfied with 5, 6 and 7. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/book3s/64/pgtable.h | 25 - arch/powerpc/include/asm/mman.h |6 ++ arch/powerpc/includ

[PATCH v10 15/27] powerpc: Program HPTE key protection bits

2018-01-18 Thread Ram Pai
Map the PTE protection key bits to the HPTE key protection bits, while creating HPTE entries. Acked-by: Balbir Singh Signed-off-by: Ram Pai --- arch/powerpc/include/asm/book3s/64/mmu-hash.h |5 + arch/powerpc/include/asm/mmu_context.h|6 ++ arch/powerpc/include/asm

[PATCH v10 16/27] powerpc: helper to validate key-access permissions of a pte

2018-01-18 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 |4 +++ arch/powerpc/include/asm/pkeys.h |9 arch/powerpc/mm/pkeys.c | 28

[PATCH v10 21/27] powerpc: Deliver SEGV signal on pkey violation

2018-01-18 Thread Ram Pai
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 Signed-off-by: Thiago Jung Bauermann --- arch/powerpc/include/asm/bug.h |1 + arch/powerpc/kernel/traps.c| 12 +++- arch/powerpc/mm

[PATCH v10 23/27] powerpc: Enable pkey subsystem

2018-01-18 Thread Ram Pai
ion access support for pkeys. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/cputable.h | 16 ++--- arch/powerpc/include/asm/pkeys.h|3 ++ arch/powerpc/mm/pkeys.c | 61 +- 3 files changed, 65 insertions(+), 15 deletions(-) diff --

[PATCH v10 17/27] powerpc: check key protection for user page access

2018-01-18 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 | 19 +++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64

[PATCH v10 22/27] powerpc/ptrace: Add memory protection key regset

2018-01-18 Thread Ram Pai
From: Thiago Jung Bauermann The AMR/IAMR/UAMOR are part of the program context. Allow it to be accessed via ptrace and through core files. Signed-off-by: Ram Pai Signed-off-by: Thiago Jung Bauermann --- arch/powerpc/include/asm/pkeys.h|5 +++ arch/powerpc/include/uapi/asm/elf.h

[PATCH v10 26/27] mm, x86 : introduce arch_pkeys_enabled()

2018-01-18 Thread Ram Pai
Arch neutral code needs to know if the architecture supports protection keys to display protection key in smaps. Hence introducing arch_pkeys_enabled(). This patch also provides x86 implementation for arch_pkeys_enabled(). Signed-off-by: Ram Pai --- arch/x86/include/asm/pkeys.h |1

[PATCH v10 25/27] powerpc: sys_pkey_mprotect() system call

2018-01-18 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

[PATCH v10 24/27] powerpc: sys_pkey_alloc() and sys_pkey_free() system calls

2018-01-18 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

[PATCH v10 27/27] mm: display pkey in smaps if arch_pkeys_enabled() is true

2018-01-18 Thread Ram Pai
architecture support pkeys. x86 arch_show_smap() function is not needed anymore. Delete it. Signed-off-by: Ram Pai --- arch/x86/kernel/setup.c |8 fs/proc/task_mmu.c | 11 ++- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/arch/x86/kernel/setup.c b/arch/x86

[PATCH v10 06/27] powerpc: helper functions to initialize AMR, IAMR and UAMOR registers

2018-01-18 Thread Ram Pai
Introduce helper functions that can initialize the bits in the AMR, IAMR and UAMOR register; the bits that correspond to the given pkey. Reviewed-by: Thiago Jung Bauermann Signed-off-by: Ram Pai --- arch/powerpc/mm/pkeys.c | 47 +++ 1 files

[PATCH v10 19/27] powerpc: Handle exceptions caused by pkey violation

2018-01-18 Thread Ram Pai
. Signed-off-by: Ram Pai Signed-off-by: Thiago Jung Bauermann --- arch/powerpc/include/asm/reg.h |1 - arch/powerpc/kernel/exceptions-64s.S |2 +- arch/powerpc/mm/fault.c | 22 ++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/arch

[PATCH v10 20/27] powerpc: introduce get_mm_addr_key() helper

2018-01-18 Thread Ram Pai
get_mm_addr_key() helper returns the pkey associated with an address corresponding to a given mm_struct. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/mmu.h |9 + arch/powerpc/mm/hash_utils_64.c | 24 2 files changed, 33 insertions(+), 0 deletions

[PATCH v10 09/27] powerpc: ability to create execute-disabled pkeys

2018-01-18 Thread Ram Pai
powerpc has hardware support to disable execute on a pkey. This patch enables the ability to create execute-disabled keys. Signed-off-by: Ram Pai --- arch/powerpc/include/uapi/asm/mman.h |6 ++ arch/powerpc/mm/pkeys.c | 16 2 files changed, 22 insertions

[PATCH v10 18/27] powerpc: implementation for arch_vma_access_permitted()

2018-01-18 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| 34

[PATCH v10 05/27] powerpc: helper function to read,write AMR,IAMR,UAMOR registers

2018-01-18 Thread Ram Pai
Bauermann Signed-off-by: Ram Pai --- arch/powerpc/mm/pkeys.c | 36 1 files changed, 36 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/mm/pkeys.c b/arch/powerpc/mm/pkeys.c index e2f3992..6e8df6e 100644 --- a/arch/powerpc/mm/pkeys.c +++ b/arch/powerpc/mm

[PATCH v10 08/27] powerpc: implementation for arch_set_user_pkey_access()

2018-01-18 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 till the system call is implemented. The next patch will do so. Reviewed-by: Thiago Jung Bauermann Signed-off-by: Ram Pai --- arch

[PATCH v10 03/27] powerpc: initial pkey plumbing

2018-01-18 Thread Ram Pai
Basic plumbing to initialize the pkey system. Nothing is enabled yet. A later patch will enable it once all the infrastructure is in place. Signed-off-by: Ram Pai --- arch/powerpc/Kconfig | 15 + arch/powerpc/include/asm/mmu_context.h |1 + arch/powerpc

[PATCH v10 04/27] powerpc: track allocation status of all pkeys

2018-01-18 Thread Ram Pai
pkeys. This patch keeps track of reserved keys, allocated keys and keys that are currently free. Also it adds skeletal functions and macros, that the architecture-independent code expects to be available. Reviewed-by: Thiago Jung Bauermann Signed-off-by: Ram Pai --- arch/powerpc/include/asm

[PATCH v10 07/27] powerpc: cleanup AMR, IAMR when a key is allocated or freed

2018-01-18 Thread Ram Pai
Cleanup the bits corresponding to a key in the AMR, and IAMR register, when the key is newly allocated/activated or is freed. We dont want some residual bits cause the hardware enforce unintended behavior when the key is activated or freed. Reviewed-by: Thiago Jung Bauermann Signed-off-by: Ram

[PATCH v10 00/27] powerpc, mm: Memory Protection Keys

2018-01-18 Thread Ram Pai
version v1: Initial version Ram Pai (26): 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 powerpc: initial pkey plumbing powerpc: track allocation status of all pkeys powerpc: helper f

[PATCH v10 02/27] mm, powerpc, x86: introduce an additional vma bit for powerpc pkey

2018-01-18 Thread Ram Pai
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. Acked-by: Balbir Singh Signed-off-by: Ram Pai --- fs/proc/task_mmu.c |1 + include/linux/mm.h |3

Re: [PATCH v9 29/51] mm/mprotect, powerpc/mm/pkeys, x86/mm/pkeys: Add sysfs interface

2017-12-20 Thread Ram Pai
On Wed, Dec 20, 2017 at 08:34:56AM +1100, Benjamin Herrenschmidt wrote: > On Mon, 2017-12-18 at 14:28 -0800, Dave Hansen wrote: > > > We do not have generic support for something like that on ppc. > > > The kernel looks at the device tree to determine what hardware features > > > are available. But

Re: [PATCH v9 29/51] mm/mprotect, powerpc/mm/pkeys, x86/mm/pkeys: Add sysfs interface

2017-12-19 Thread Ram Pai
On Tue, Dec 19, 2017 at 09:50:24PM +1100, Michael Ellerman wrote: > Dave Hansen writes: > > > On 11/06/2017 12:57 AM, Ram Pai wrote: > >> Expose useful information for programs using memory protection keys. > >> Provide implementation for powerpc and x86. >

Re: [PATCH v9 29/51] mm/mprotect, powerpc/mm/pkeys, x86/mm/pkeys: Add sysfs interface

2017-12-19 Thread Ram Pai
On Tue, Dec 19, 2017 at 09:31:22AM +0100, Gabriel Paubert wrote: > On Mon, Dec 18, 2017 at 03:15:51PM -0800, Ram Pai wrote: > > On Mon, Dec 18, 2017 at 02:28:14PM -0800, Dave Hansen wrote: > > > On 12/18/2017 02:18 PM, Ram Pai wrote: > > > snip... > > >

Re: [PATCH v9 29/51] mm/mprotect, powerpc/mm/pkeys, x86/mm/pkeys: Add sysfs interface

2017-12-18 Thread Ram Pai
On Mon, Dec 18, 2017 at 02:28:14PM -0800, Dave Hansen wrote: > On 12/18/2017 02:18 PM, Ram Pai wrote: > > b) minimum number of keys available to the application. > > if libraries consumes a few, they could provide a library > > interface to the application informing th

Re: [PATCH v9 29/51] mm/mprotect, powerpc/mm/pkeys, x86/mm/pkeys: Add sysfs interface

2017-12-18 Thread Ram Pai
On Mon, Dec 18, 2017 at 10:54:26AM -0800, Dave Hansen wrote: > On 11/06/2017 12:57 AM, Ram Pai wrote: > > Expose useful information for programs using memory protection keys. > > Provide implementation for powerpc and x86. > > > > On a powerpc system with pkeys sup

Re: Improving documentation of parent-ID field in /proc/PID/mountinfo

2017-11-20 Thread Ram Pai
> Hi Miklos, Ram > >> > >> Thanks for your comments. A question below. > >> > >> On 13 November 2017 at 09:11, Miklos Szeredi wrote: > >>> On Mon, Nov 13, 2017 at 8:55 AM, Ram Pai wrote: > >>>> On Mon, Nov 13, 2017 at 07:02:21AM +0

Re: Improving documentation of parent-ID field in /proc/PID/mountinfo

2017-11-12 Thread Ram Pai
On Mon, Nov 13, 2017 at 07:02:21AM +0100, Michael Kerrisk (man-pages) wrote: > Hello Ram, > > Long ago (2.6.29) you added the /proc/PID/mountinfo file and > associated documentation in Documentation/filesystems/proc.txt. Later, > I pasted much of that documentation into the proc(5) manual page. >

Re: [PATCH v9 23/51] powerpc: Enable pkey subsystem

2017-11-12 Thread Ram Pai
On Mon, Nov 06, 2017 at 12:57:15AM -0800, Ram Pai wrote: > PAPR defines 'ibm,processor-storage-keys' property. It exports two > values. The first value holds the number of data-access keys and the > second holds the number of instruction-access keys. Due to a bug in > the

Re: [PATCH v9 00/51] powerpc, mm: Memory Protection Keys

2017-11-12 Thread Ram Pai
On Fri, Nov 10, 2017 at 07:10:31PM +0100, Christophe LEROY wrote: > Hi > > Le 06/11/2017 à 09:56, Ram Pai a écrit : > >Memory protection keys enable applications to protect its > >address space from inadvertent access from or corruption > >by itself. > > > &

Re: [PATCH v9 44/51] selftest/vm: powerpc implementation for generic abstraction

2017-11-09 Thread Ram Pai
On Thu, Nov 09, 2017 at 04:47:15PM -0200, Breno Leitao wrote: > Hi Ram, > > On Mon, Nov 06, 2017 at 12:57:36AM -0800, Ram Pai wrote: > > @@ -206,12 +209,14 @@ void signal_handler(int signum, siginfo_t *si, void > > *vucontext) > > > > trapno = uc

Re: [PATCH v9 00/51] powerpc, mm: Memory Protection Keys

2017-11-09 Thread Ram Pai
On Mon, Nov 06, 2017 at 05:22:18PM -0800, Ram Pai wrote: > On Mon, Nov 06, 2017 at 10:28:41PM +0100, Florian Weimer wrote: > > * Ram Pai: > > > > > Testing: > > > --- > > > This patch series has passed all the protection key > > > tests avai

Re: [PATCH v9 00/51] powerpc, mm: Memory Protection Keys

2017-11-07 Thread Ram Pai
On Tue, Nov 07, 2017 at 02:47:10PM -0800, Dave Hansen wrote: > On 11/07/2017 02:39 PM, Ram Pai wrote: > > > > As per the current semantics of sys_pkey_free(); the way I understand it, > > the calling thread is saying disassociate me from this key. > > No. It is saying

Re: [PATCH v9 00/51] powerpc, mm: Memory Protection Keys

2017-11-07 Thread Ram Pai
On Tue, Nov 07, 2017 at 08:32:16AM +0100, Florian Weimer wrote: > * Ram Pai: > > > On Mon, Nov 06, 2017 at 10:28:41PM +0100, Florian Weimer wrote: > >> * Ram Pai: > >> > >> > Testing: > >> > --- > >> > This patch series has pa

Re: [PATCH v9 00/51] powerpc, mm: Memory Protection Keys

2017-11-06 Thread Ram Pai
On Mon, Nov 06, 2017 at 10:28:41PM +0100, Florian Weimer wrote: > * Ram Pai: > > > Testing: > > --- > > This patch series has passed all the protection key > > tests available in the selftest directory.The > > tests are updated to work on both x86 and power

[PATCH v9 03/51] powerpc: initial pkey plumbing

2017-11-06 Thread Ram Pai
Basic plumbing to initialize the pkey system. Nothing is enabled yet. A later patch will enable it ones all the infrastructure is in place. Signed-off-by: Ram Pai --- arch/powerpc/Kconfig | 15 arch/powerpc/include/asm/mmu_context.h |5 +++ arch/powerpc

[PATCH v9 02/51] mm, powerpc, x86: introduce an additional vma bit for powerpc pkey

2017-11-06 Thread Ram Pai
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. Acked-by: Balbir Singh Signed-off-by: Ram Pai --- fs/proc/task_mmu.c |1 + include/linux/mm.h |3

[PATCH v9 09/51] powerpc: ability to create execute-disabled pkeys

2017-11-06 Thread Ram Pai
powerpc has hardware support to disable execute on a pkey. This patch enables the ability to create execute-disabled keys. Signed-off-by: Ram Pai --- arch/powerpc/include/uapi/asm/mman.h |6 ++ arch/powerpc/mm/pkeys.c | 16 2 files changed, 22 insertions

[PATCH v9 04/51] powerpc: track allocation status of all pkeys

2017-11-06 Thread Ram Pai
pkeys. This patch keeps track of reserved keys, allocated keys and keys that are currently free. Also it adds skeletal functions and macros, that the architecture-independent code expects to be available. Reviewed-by: Thiago Jung Bauermann Signed-off-by: Ram Pai --- arch/powerpc/include/asm

[PATCH v9 05/51] powerpc: helper function to read,write AMR,IAMR,UAMOR registers

2017-11-06 Thread Ram Pai
Bauermann Signed-off-by: Ram Pai --- arch/powerpc/mm/pkeys.c | 36 1 files changed, 36 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/mm/pkeys.c b/arch/powerpc/mm/pkeys.c index 512bdf2..b6bdfdf 100644 --- a/arch/powerpc/mm/pkeys.c +++ b/arch/powerpc/mm

[PATCH v9 11/51] powerpc: introduce execute-only pkey

2017-11-06 Thread Ram Pai
This patch provides the implementation of execute-only pkey. The architecture-independent layer expects the arch-dependent layer, to support the ability to create and enable a special key which has execute-only permission. Acked-by: Balbir Singh Signed-off-by: Ram Pai --- arch/powerpc/include

[PATCH v9 06/51] powerpc: helper functions to initialize AMR, IAMR and UAMOR registers

2017-11-06 Thread Ram Pai
Introduce helper functions that can initialize the bits in the AMR, IAMR and UAMOR register; the bits that correspond to the given pkey. Reviewed-by: Thiago Jung Bauermann Signed-off-by: Ram Pai --- arch/powerpc/mm/pkeys.c | 47 +++ 1 files

[PATCH v9 07/51] powerpc: cleanup AMR, IAMR when a key is allocated or freed

2017-11-06 Thread Ram Pai
Cleanup the bits corresponding to a key in the AMR, and IAMR register, when the key is newly allocated/activated or is freed. We dont want some residual bits cause the hardware enforce unintended behavior when the key is activated or freed. Reviewed-by: Thiago Jung Bauermann Signed-off-by: Ram

[PATCH v9 13/51] powerpc: implementation for arch_override_mprotect_pkey()

2017-11-06 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/mmu_context.h |5 arch/powerpc/include/asm/pkeys.h | 21

[PATCH v9 16/51] powerpc: helper to validate key-access permissions of a pte

2017-11-06 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 |4 +++ arch/powerpc/include/asm/pkeys.h |9 arch/powerpc/mm/pkeys.c | 28

[PATCH v9 15/51] powerpc: Program HPTE key protection bits

2017-11-06 Thread Ram Pai
Map the PTE protection key bits to the HPTE key protection bits, while creating HPTE entries. Acked-by: Balbir Singh Signed-off-by: Ram Pai --- arch/powerpc/include/asm/book3s/64/mmu-hash.h |5 + arch/powerpc/include/asm/mmu_context.h|6 ++ arch/powerpc/include/asm

[PATCH v9 18/51] powerpc: implementation for arch_vma_access_permitted()

2017-11-06 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| 34

[PATCH v9 19/51] powerpc: Handle exceptions caused by pkey violation

2017-11-06 Thread Ram Pai
. Signed-off-by: Ram Pai --- arch/powerpc/mm/fault.c | 32 +++- 1 files changed, 27 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c index 4797d08..dfcd0e4 100644 --- a/arch/powerpc/mm/fault.c +++ b/arch/powerpc/mm/fault.c

[PATCH v9 21/51] powerpc: Deliver SEGV signal on pkey violation

2017-11-06 Thread Ram Pai
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/bug.h |1 + arch/powerpc/kernel/traps.c| 12 - arch/powerpc/mm/fault.c| 55

[PATCH v9 23/51] powerpc: Enable pkey subsystem

2017-11-06 Thread Ram Pai
e tree yet. Here, we hardcode CPUs that support pkey by consulting PowerISA3.0 This patch calculates the number of keys supported by the platform. Alsi it determines the platform support for read/write/execution access support for pkeys. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/

[PATCH v9 25/51] powerpc: sys_pkey_mprotect() system call

2017-11-06 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

[PATCH v9 22/51] powerpc/ptrace: Add memory protection key regset

2017-11-06 Thread Ram Pai
From: Thiago Jung Bauermann The AMR/IAMR/UAMOR are part of the program context. Allow it to be accessed via ptrace and through core files. Signed-off-by: Ram Pai Signed-off-by: Thiago Jung Bauermann --- arch/powerpc/include/asm/pkeys.h|5 +++ arch/powerpc/include/uapi/asm/elf.h

[PATCH v9 27/51] mm, x86 : introduce arch_pkeys_enabled()

2017-11-06 Thread Ram Pai
Arch neutral code needs to know if the architecture supports protection keys to display protection key in smaps. Hence introducing arch_pkeys_enabled(). This patch also provides x86 implementation for arch_pkeys_enabled(). Signed-off-by: Ram Pai --- arch/x86/include/asm/pkeys.h |1

[PATCH v9 24/51] powerpc: sys_pkey_alloc() and sys_pkey_free() system calls

2017-11-06 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

[PATCH v9 29/51] mm/mprotect, powerpc/mm/pkeys, x86/mm/pkeys: Add sysfs interface

2017-11-06 Thread Ram Pai
<== false ==> /sys/kernel/mm/protection_keys/total_keys <== 1 ==> /sys/kernel/mm/protection_keys/usable_keys <== 0 Signed-off-by: Ram Pai Signed-off-by: Thiago Jung Bauermann --- arch/powerpc/include/asm/pkeys.h |2 + arch/powerpc/mm/pkeys.c| 24 ++ arch/x

[PATCH v9 31/51] Documentation/vm: PowerPC specific updates to memory protection keys

2017-11-06 Thread Ram Pai
Add documentation updates that capture PowerPC specific changes. Signed-off-by: Thiago Jung Bauermann Signed-off-by: Ram Pai --- Documentation/vm/protection-keys.txt | 126 +++--- 1 files changed, 101 insertions(+), 25 deletions(-) diff --git a/Documentation/vm

[PATCH v9 33/51] selftest/vm: rename all references to pkru to a generic name

2017-11-06 Thread Ram Pai
some pkru references are named to pkey_reg and some prku references are renamed to pkey Signed-off-by: Ram Pai --- tools/testing/selftests/vm/pkey-helpers.h| 85 +- tools/testing/selftests/vm/protection_keys.c | 227 ++ 2 files changed, 164 insertions

[PATCH v9 37/51] selftest/vm: fix the wrong assert in pkey_disable_set()

2017-11-06 Thread Ram Pai
If the flag is 0, no bits will be set. Hence we cant expect the resulting bitmap to have a higher value than what it was earlier. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/tools/testing

[PATCH v9 34/51] selftest/vm: move generic definitions to header file

2017-11-06 Thread Ram Pai
Moved all the generic definition and helper functions to the header file Signed-off-by: Ram Pai --- tools/testing/selftests/vm/pkey-helpers.h| 62 +++-- tools/testing/selftests/vm/protection_keys.c | 54 -- 2 files changed, 57 insertions(+), 59

[PATCH v9 36/51] selftest/vm: generic function to handle shadow key register

2017-11-06 Thread Ram Pai
helper functions to handler shadow pkey register Signed-off-by: Ram Pai --- tools/testing/selftests/vm/pkey-helpers.h| 27 tools/testing/selftests/vm/protection_keys.c | 34 - 2 files changed, 49 insertions(+), 12 deletions(-) diff --git a

[PATCH v9 40/51] selftest/vm: fix alloc_random_pkey() to make it really random

2017-11-06 Thread Ram Pai
alloc_random_pkey() was allocating the same pkey every time. Not all pkeys were geting tested. fixed it. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c | 10 +++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/vm

[PATCH v9 39/51] selftest/vm: clear the bits in shadow reg when a pkey is freed.

2017-11-06 Thread Ram Pai
When a key is freed, the key is no more effective. Clear the bits corresponding to the pkey in the shadow register. Otherwise it will carry some spurious bits which can trigger false-positive asserts. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c |3 +++ 1

[PATCH v9 45/51] selftest/vm: fix an assertion in test_pkey_alloc_exhaust()

2017-11-06 Thread Ram Pai
The maximum number of keys that can be allocated has to take into consideration, that some keys are reserved by the architecture for specific purpose. Hence cannot be allocated. Fix the assertion in test_pkey_alloc_exhaust() Signed-off-by: Ram Pai --- tools/testing/selftests/vm/pkey

<    1   2   3   4   5   6   >