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

2017-07-15 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 v6 05/62] powerpc: capture the PTE format changes in the dump pte report

2017-07-15 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 v6 05/62] powerpc: capture the PTE format changes in the dump pte report

2017-07-15 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 v6 08/62] powerpc: use helper functions in __hash_page_4K() for 64K PTE

2017-07-15 Thread Ram Pai
replace redundant code in __hash_page_4K() with helper functions pte_get_hash_gslot() and pte_set_hash_slot() Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/mm/hash64_64k.c | 34 +- 1 files changed, 9 insertions(+), 25 deletions(-) diff

[RFC v6 08/62] powerpc: use helper functions in __hash_page_4K() for 64K PTE

2017-07-15 Thread Ram Pai
replace redundant code in __hash_page_4K() with helper functions pte_get_hash_gslot() and pte_set_hash_slot() Signed-off-by: Ram Pai --- arch/powerpc/mm/hash64_64k.c | 34 +- 1 files changed, 9 insertions(+), 25 deletions(-) diff --git a/arch/powerpc/mm

[RFC v6 09/62] powerpc: use helper functions in __hash_page_4K() for 4K PTE

2017-07-15 Thread Ram Pai
replace redundant code with helper functions pte_get_hash_gslot() and pte_set_hash_slot() Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/mm/hash64_4k.c | 14 ++ 1 files changed, 6 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/mm/hash64_4k.c b/arch/p

[RFC v6 09/62] powerpc: use helper functions in __hash_page_4K() for 4K PTE

2017-07-15 Thread Ram Pai
replace redundant code with helper functions pte_get_hash_gslot() and pte_set_hash_slot() Signed-off-by: Ram Pai --- arch/powerpc/mm/hash64_4k.c | 14 ++ 1 files changed, 6 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/mm/hash64_4k.c b/arch/powerpc/mm/hash64_4k.c index

[RFC v6 12/62] mm: introduce an additional vma bit for powerpc pkey

2017-07-15 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. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- fs/proc/task_mmu.c |6 -- include/linux/mm.h

[RFC v6 12/62] mm: introduce an additional vma bit for powerpc pkey

2017-07-15 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. Signed-off-by: Ram Pai --- fs/proc/task_mmu.c |6 -- include/linux/mm.h | 20

[RFC v6 10/62] powerpc: use helper functions in flush_hash_page()

2017-07-15 Thread Ram Pai
replace redundant code in flush_hash_page() with helper function pte_get_hash_gslot(). Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/mm/hash_utils_64.c | 13 - 1 files changed, 4 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/mm/hash_utils_64.c

[RFC v6 10/62] powerpc: use helper functions in flush_hash_page()

2017-07-15 Thread Ram Pai
replace redundant code in flush_hash_page() with helper function pte_get_hash_gslot(). Signed-off-by: Ram Pai --- arch/powerpc/mm/hash_utils_64.c | 13 - 1 files changed, 4 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64

[RFC v6 14/62] powerpc: helper function to read,write AMR,IAMR,UAMOR registers

2017-07-15 Thread Ram Pai
Implements helper functions to read and write the key related registers; AMR, IAMR, UAMOR. AMR register tracks the read,write permission of a key IAMR register tracks the execute permission of a key UAMOR register enables and disables a key Signed-off-by: Ram Pai <linux...@us.ibm.com> ---

[RFC v6 14/62] powerpc: helper function to read,write AMR,IAMR,UAMOR registers

2017-07-15 Thread Ram Pai
Implements helper functions to read and write the key related registers; AMR, IAMR, UAMOR. AMR register tracks the read,write permission of a key IAMR register tracks the execute permission of a key UAMOR register enables and disables a key Signed-off-by: Ram Pai --- arch/powerpc/include/asm

[RFC v6 18/62] powerpc: sys_pkey_alloc() and sys_pkey_free() system calls

2017-07-15 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 v6 18/62] powerpc: sys_pkey_alloc() and sys_pkey_free() system calls

2017-07-15 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 v6 13/62] powerpc: track allocation status of all pkeys

2017-07-15 Thread Ram Pai
to be available. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/include/asm/book3s/64/mmu.h |9 +++ arch/powerpc/include/asm/mmu_context.h |1 + arch/powerpc/include/asm/pkeys.h | 81 -- arch/powerpc/mm/mmu_context_book3s64.c

[RFC v6 13/62] powerpc: track allocation status of all pkeys

2017-07-15 Thread Ram Pai
to be available. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/book3s/64/mmu.h |9 +++ arch/powerpc/include/asm/mmu_context.h |1 + arch/powerpc/include/asm/pkeys.h | 81 -- arch/powerpc/mm/mmu_context_book3s64.c |2 + 4 files changed

[RFC v6 16/62] powerpc: cleaup AMR,iAMR when a key is allocated or freed

2017-07-15 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. Signed-off-by: Ram Pai <linux...@us.ibm.com> ---

[RFC v6 16/62] powerpc: cleaup AMR,iAMR when a key is allocated or freed

2017-07-15 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. Signed-off-by: Ram Pai --- arch/powerpc/include/asm

[RFC v6 20/62] powerpc: store and restore the pkey state across context switches

2017-07-15 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 v6 17/62] powerpc: implementation for arch_set_user_pkey_access()

2017-07-15 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. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/inclu

[RFC v6 20/62] powerpc: store and restore the pkey state across context switches

2017-07-15 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 v6 17/62] powerpc: implementation for arch_set_user_pkey_access()

2017-07-15 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. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/pkeys.h | 10

[RFC v6 21/62] powerpc: introduce execute-only pkey

2017-07-15 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 v6 21/62] powerpc: introduce execute-only pkey

2017-07-15 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 v6 24/62] powerpc: map vma key-protection bits to pte key bits.

2017-07-15 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 | 12 3 files changed, 39 insertions(+), 1 deletions(-) diff

[RFC v6 22/62] powerpc: ability to associate pkey to a vma

2017-07-15 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 | 18 +++--- 2

[RFC v6 24/62] powerpc: map vma key-protection bits to pte key bits.

2017-07-15 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 | 12 3 files changed, 39 insertions(+), 1 deletions(-) diff --git a/arch/powerpc

[RFC v6 22/62] powerpc: ability to associate pkey to a vma

2017-07-15 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 | 18 +++--- 2 files changed, 22 insertions

[RFC v6 25/62] powerpc: sys_pkey_mprotect() system call

2017-07-15 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 v6 27/62] powerpc: helper to validate key-access permissions of a pte

2017-07-15 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 |4 +++ arch/powerpc/include/asm/pkeys.h | 12 + arch/powerpc/mm/p

[RFC v6 25/62] powerpc: sys_pkey_mprotect() system call

2017-07-15 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 v6 27/62] powerpc: helper to validate key-access permissions of a pte

2017-07-15 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 | 12 + arch/powerpc/mm/pkeys.c | 33

[RFC v6 28/62] powerpc: check key protection for user page access

2017-07-15 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 v6 28/62] powerpc: check key protection for user page access

2017-07-15 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 v6 30/62] powerpc: implementation for arch_vma_access_permitted()

2017-07-15 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 v6 29/62] powerpc: Macro the mask used for checking DSI exception

2017-07-15 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 v6 30/62] powerpc: implementation for arch_vma_access_permitted()

2017-07-15 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| 43

[RFC v6 29/62] powerpc: Macro the mask used for checking DSI exception

2017-07-15 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 v6 34/62] powerpc: capture the violated protection key on fault

2017-07-15 Thread Ram Pai
Capture the protection key that got violated in paca. This value will be later 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 v6 32/62] powerpc: capture AMR register content on pkey violation

2017-07-15 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 v6 34/62] powerpc: capture the violated protection key on fault

2017-07-15 Thread Ram Pai
Capture the protection key that got violated in paca. This value will be later 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 |8 3 files changed

[RFC v6 32/62] powerpc: capture AMR register content on pkey violation

2017-07-15 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 v6 38/62] powerpc: implementation for arch_pkeys_enabled()

2017-07-15 Thread Ram Pai
arch_pkeys_enabled() returns true if the cpu supports protection key, and the kernel has it enabled. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/powerpc/include/asm/pkeys.h |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/include/asm/pke

[RFC v6 38/62] powerpc: implementation for arch_pkeys_enabled()

2017-07-15 Thread Ram Pai
arch_pkeys_enabled() returns true if the cpu supports protection key, and the kernel has it enabled. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/pkeys.h |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/include/asm/pkeys.h b/arch/powerpc/include

[RFC v6 36/62] mm: introduce arch_pkeys_enabled()

2017-07-15 Thread Ram Pai
Only the architecture knows if it supports protection keys. Hence introducing arch_pkeys_enabled(). This function is needed by arch neutral code. One use case is -- to determine if the protection key needs to be displayed in smaps. Signed-off-by: Ram Pai <linux...@us.ibm.

[RFC v6 36/62] mm: introduce arch_pkeys_enabled()

2017-07-15 Thread Ram Pai
Only the architecture knows if it supports protection keys. Hence introducing arch_pkeys_enabled(). This function is needed by arch neutral code. One use case is -- to determine if the protection key needs to be displayed in smaps. Signed-off-by: Ram Pai --- include/linux/pkeys.h

[RFC v6 37/62] x86: implementation for arch_pkeys_enabled()

2017-07-15 Thread Ram Pai
arch_pkeys_enabled() returns true if the cpu supports X86_FEATURE_OSPKE. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/x86/include/asm/pkeys.h |1 + arch/x86/kernel/fpu/xstate.c |5 + 2 files changed, 6 insertions(+), 0 deletions(-) diff --git a/arch/x86/include/asm/p

[RFC v6 39/62] mm: display pkey in smaps if arch_pkeys_enabled() is true

2017-07-15 Thread Ram Pai
support pkeys. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- fs/proc/task_mmu.c |9 - 1 files changed, 4 insertions(+), 5 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index e5710bc..d2b3e75 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -16,6

[RFC v6 37/62] x86: implementation for arch_pkeys_enabled()

2017-07-15 Thread Ram Pai
arch_pkeys_enabled() returns true if the cpu supports X86_FEATURE_OSPKE. Signed-off-by: Ram Pai --- arch/x86/include/asm/pkeys.h |1 + arch/x86/kernel/fpu/xstate.c |5 + 2 files changed, 6 insertions(+), 0 deletions(-) diff --git a/arch/x86/include/asm/pkeys.h b/arch/x86/include

[RFC v6 39/62] mm: display pkey in smaps if arch_pkeys_enabled() is true

2017-07-15 Thread Ram Pai
support pkeys. Signed-off-by: Ram Pai --- fs/proc/task_mmu.c |9 - 1 files changed, 4 insertions(+), 5 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index e5710bc..d2b3e75 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -16,6 +16,7 @@ #include #include

[RFC v6 40/62] x86: delete arch_show_smap()

2017-07-15 Thread Ram Pai
arch_show_smap() function is not needed anymore. Delete it. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- arch/x86/kernel/setup.c |8 1 files changed, 0 insertions(+), 8 deletions(-) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index f818236..5efe4c3

[RFC v6 40/62] x86: delete arch_show_smap()

2017-07-15 Thread Ram Pai
arch_show_smap() function is not needed anymore. Delete it. Signed-off-by: Ram Pai --- arch/x86/kernel/setup.c |8 1 files changed, 0 insertions(+), 8 deletions(-) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index f818236..5efe4c3 100644 --- a/arch/x86/kernel

[RFC v6 42/62] selftest/vm: rename all references to pkru to a generic name

2017-07-15 Thread Ram Pai
some pkru references are named to pkey_reg and some prku references are renamed to pkey Signed-off-by: Ram Pai <linux...@us.ibm.com> --- tools/testing/selftests/vm/pkey-helpers.h| 85 +- tools/testing/selftests/vm/protection_keys.c | 227 ++ 2 files c

[RFC v6 41/62] selftest/x86: Move protecton key selftest to arch neutral directory

2017-07-15 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 v6 42/62] selftest/vm: rename all references to pkru to a generic name

2017-07-15 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

[RFC v6 41/62] selftest/x86: Move protecton key selftest to arch neutral directory

2017-07-15 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 v6 44/62] selftest/vm: typecast the pkey register

2017-07-15 Thread Ram Pai
This is in preparation to accomadate a differing size register across architectures. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- tools/testing/selftests/vm/pkey-helpers.h| 27 +- tools/testing/selftests/vm/protection_keys.c | 75 ++ 2 files c

[RFC v6 44/62] selftest/vm: typecast the pkey register

2017-07-15 Thread Ram Pai
This is in preparation to accomadate a differing size register across architectures. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/pkey-helpers.h| 27 +- tools/testing/selftests/vm/protection_keys.c | 75 ++ 2 files changed, 54 insertions(+), 48

[RFC v6 48/62] selftest/vm: clear the bits in shadow reg when a pkey is freed.

2017-07-15 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 <linux...@us.ibm.com> --- tools/testing/selfte

[RFC v6 43/62] selftest/vm: move generic definitions to header file

2017-07-15 Thread Ram Pai
Moved all the generic definition and helper functions to the header file Signed-off-by: Ram Pai <linux...@us.ibm.com> --- tools/testing/selftests/vm/pkey-helpers.h| 62 +++-- tools/testing/selftests/vm/protection_keys.c | 54 -- 2 files chang

[RFC v6 45/62] selftest/vm: generics function to handle shadow key register

2017-07-15 Thread Ram Pai
helper functions to handler shadow pkey register Signed-off-by: Ram Pai <linux...@us.ibm.com> --- tools/testing/selftests/vm/pkey-helpers.h| 27 tools/testing/selftests/vm/protection_keys.c | 34 - 2 files changed, 49 insertions(

[RFC v6 45/62] selftest/vm: generics function to handle shadow key register

2017-07-15 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

[RFC v6 48/62] selftest/vm: clear the bits in shadow reg when a pkey is freed.

2017-07-15 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

[RFC v6 43/62] selftest/vm: move generic definitions to header file

2017-07-15 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

[RFC v6 50/62] selftest/vm: introduce two arch independent abstraction

2017-07-15 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 <linux...@us.ibm.com> --- tools/testing/selftests/vm/pkey-helpers.h| 11 +++ tools/testing/selftests/vm/protection_keys.c |6 +++--- 2 f

[RFC v6 46/62] selftest/vm: fix the wrong assert in pkey_disable_set()

2017-07-15 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 <linux...@us.ibm.com> --- tools/testing/selftests/vm/protection_keys.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff

[RFC v6 46/62] selftest/vm: fix the wrong assert in pkey_disable_set()

2017-07-15 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

[RFC v6 50/62] selftest/vm: introduce two arch independent abstraction

2017-07-15 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

[RFC v6 49/62] selftest/vm: fix alloc_random_pkey() to make it really random

2017-07-15 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 <linux...@us.ibm.com> --- tools/testing/selftests/vm/protection_keys.c | 10 +++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/t

[RFC v6 52/62] selftest/vm: generic cleanup

2017-07-15 Thread Ram Pai
cleanup the code to satisfy coding styles. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- 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

[RFC v6 49/62] selftest/vm: fix alloc_random_pkey() to make it really random

2017-07-15 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

[RFC v6 52/62] selftest/vm: generic cleanup

2017-07-15 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

[RFC v6 55/62] selftest/vm: associate key on a mapped page and detect access violation

2017-07-15 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 <linux...@us.ibm.com> --- tools/testing/selftests/vm/protection_keys.c | 19 +++ 1 files changed, 19 insertions(+), 0 deletions(-) diff

[RFC v6 55/62] selftest/vm: associate key on a mapped page and detect access violation

2017-07-15 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

[RFC v6 57/62] selftest/vm: associate key on a mapped page and detect write violation

2017-07-15 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 <linux...@us.ibm.com> --- tools/testing/selftests/vm/protection_keys.c | 12 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a

[RFC v6 54/62] selftest/vm: fix an assertion in test_pkey_alloc_exhaust()

2017-07-15 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 of specific purpose and cannot be allocated. Fix the assertion in test_pkey_alloc_exhaust() Signed-off-by: Ram Pai <linux...@us.ibm.com> --- tools/testing/selfte

[RFC v6 54/62] selftest/vm: fix an assertion in test_pkey_alloc_exhaust()

2017-07-15 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 of specific purpose and cannot be allocated. Fix the assertion in test_pkey_alloc_exhaust() Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c

[RFC v6 57/62] selftest/vm: associate key on a mapped page and detect write violation

2017-07-15 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

[RFC v6 60/62] selftest/vm: sub-page allocator

2017-07-15 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 <linux...@us.ibm.com> --- tools/testing/selftests/vm/protection_keys.c | 29 ++ 1 files changed, 29 insertions

[RFC v6 56/62] selftest/vm: detect no key violation on a freed key

2017-07-15 Thread Ram Pai
a access-denied key should not trigger any key violation after the key has been freed. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- tools/testing/selftests/vm/protection_keys.c | 25 + 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/tools/t

[RFC v6 60/62] selftest/vm: sub-page allocator

2017-07-15 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 | 29 ++ 1 files changed, 29 insertions(+), 0 deletions(-) diff

[RFC v6 56/62] selftest/vm: detect no key violation on a freed key

2017-07-15 Thread Ram Pai
a access-denied key should not trigger any key violation after the key has been freed. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c | 25 + 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/tools/testing/selftests/vm

[RFC v6 62/62] Documentation/vm: PowerPC specific updates to memory protection keys

2017-07-15 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 | 90 - 1 files changed, 65 insertions(+), 25 deletions(-) diff --git a/Documentation/vm/protection-ke

[RFC v6 62/62] Documentation/vm: PowerPC specific updates to memory protection keys

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

[RFC v6 58/62] selftest/vm: detect no write key-violation on a freed key

2017-07-15 Thread Ram Pai
a write-denied key should not trigger any key violation after the key has been freed. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- tools/testing/selftests/vm/protection_keys.c | 18 ++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/tools/testing/sel

[RFC v6 58/62] selftest/vm: detect no write key-violation on a freed key

2017-07-15 Thread Ram Pai
a write-denied key should not trigger any key violation after the key has been freed. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c | 18 ++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/tools/testing/selftests/vm/protection_keys.c

[RFC v6 47/62] selftest/vm: fixed bugs in pkey_disable_clear()

2017-07-15 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 <linux...@us.ibm.com> --- tools/testing/selfte

[RFC v6 61/62] Documentation/x86: Move protecton key documentation to arch neutral directory

2017-07-15 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 v6 51/62] selftest/vm: pkey register should match shadow pkey

2017-07-15 Thread Ram Pai
throughout Signed-off-by: Ram Pai <linux...@us.ibm.com> --- 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 20bab6d..f

[RFC v6 59/62] selftest/vm: detect write violation on a mapped access-denied-key page

2017-07-15 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 <linux...@us.ibm.com> --- tools/testing/selftests/vm/protection_keys.c | 13 + 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a

[RFC v6 47/62] selftest/vm: fixed bugs in pkey_disable_clear()

2017-07-15 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

[RFC v6 61/62] Documentation/x86: Move protecton key documentation to arch neutral directory

2017-07-15 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 v6 51/62] selftest/vm: pkey register should match shadow pkey

2017-07-15 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 20bab6d..f21e177 100644 --- a/tools

[RFC v6 59/62] selftest/vm: detect write violation on a mapped access-denied-key page

2017-07-15 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

[RFC v6 53/62] selftest/vm: powerpc implementation for generic abstraction

2017-07-15 Thread Ram Pai
Introduce powerpc implementation for the various abstactions. Signed-off-by: Ram Pai <linux...@us.ibm.com> --- tools/testing/selftests/vm/pkey-helpers.h| 97 +++-- tools/testing/selftests/vm/protection_keys.c | 33 + 2 files changed, 107 insertions(

[RFC v6 53/62] selftest/vm: powerpc implementation for generic abstraction

2017-07-15 Thread Ram Pai
Introduce powerpc implementation for the various abstactions. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/pkey-helpers.h| 97 +++-- tools/testing/selftests/vm/protection_keys.c | 33 + 2 files changed, 107 insertions(+), 23 deletions(-) diff --git

[RFC v6 33/62] powerpc: introduce get_pte_pkey() helper

2017-07-15 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 | 25 ++

[RFC v6 31/62] powerpc: Handle exceptions caused by pkey violation

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

[RFC v6 33/62] powerpc: introduce get_pte_pkey() helper

2017-07-15 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 | 25 + 2 files changed, 30

<    1   2   3   4   5   6   7   8   9   10   >