Re: [PATCH v3 34/41] KVM: PPC: Book3S HV: Remove support for dependent threads mode on P9

2021-03-17 Thread Aneesh Kumar K.V
Nicholas Piggin writes: > Radix guest support will be removed from the P7/8 path, so disallow > dependent threads mode on P9. > > Signed-off-by: Nicholas Piggin > --- > arch/powerpc/include/asm/kvm_host.h | 1 - > arch/powerpc/kvm/book3s_hv.c| 27 +-- > 2 files

Re: [PATCH v6 19/22] powerpc/book3s64/hash/kuap: Enable kuap on hash

2021-03-15 Thread Aneesh Kumar K.V
On 3/15/21 5:36 PM, Christophe Leroy wrote: Le 25/11/2020 à 06:16, Aneesh Kumar K.V a écrit : Reviewed-by: Sandipan Das Signed-off-by: Aneesh Kumar K.V PPC_HAVE_KUAP is only selected on book3s/64 when PPC_RADIX_MMU is selected. Is that normal ? I guess we missed fixing

[PATCH v2 0/6] Speedup mremap on ppc64

2021-03-15 Thread Aneesh Kumar K.V
the page table update to use mmu gather interface instead of direct tlb flush. mmu gather allows the architecture to manage page walk cache invalidate separately. Changes from V1: * Rebase to recent upstream * Fix build issues with tlb_gather_mmu changes Aneesh Kumar K.V (6): selftest/mremap_test

[PATCH v2 6/6] powerpc/mm: Enable move pmd/pud

2021-03-15 Thread Aneesh Kumar K.V
, Destination PUD-aligned mremap time:26851ns Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/platforms/Kconfig.cputype | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype index 3ce907523b1e..2e666e569fdf

[PATCH v2 2/6] selftest/mremap_test: Avoid crash with static build

2021-03-15 Thread Aneesh Kumar K.V
With a large mmap map size, we can overlap with the text area and using MAP_FIXED results in unmapping that area. Switch to MAP_FIXED_NOREPLACE and handle the EEXIST error. Signed-off-by: Aneesh Kumar K.V --- tools/testing/selftests/vm/mremap_test.c | 5 +++-- 1 file changed, 3 insertions(+), 2

[PATCH v2 4/6] mm/mremap: Use mmu gather interface instead of flush_tlb_range

2021-03-15 Thread Aneesh Kumar K.V
gather to flush TLB and mark tlb.freed_tables = 1. No page table pages need to be freed here. With this the tlb flush is done outside page table lock (ptl). Signed-off-by: Aneesh Kumar K.V --- mm/mremap.c | 33 + 1 file changed, 29 insertions(+), 4 deletions(-) diff

[PATCH v2 5/6] mm/mremap: Allow arch runtime override

2021-03-15 Thread Aneesh Kumar K.V
Architectures like ppc64 can only support faster mremap only with radix translation. Hence allow a runtime check w.r.t support for fast mremap. Signed-off-by: Aneesh Kumar K.V --- arch/arc/include/asm/tlb.h | 5 + arch/arm64/include/asm/tlb.h | 6 ++ arch/powerpc/include/asm

[PATCH v2 3/6] mm/mremap: Use pmd/pud_poplulate to update page table entries

2021-03-15 Thread Aneesh Kumar K.V
-by: Aneesh Kumar K.V --- mm/mremap.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mm/mremap.c b/mm/mremap.c index ec8f840399ed..574287f9bb39 100644 --- a/mm/mremap.c +++ b/mm/mremap.c @@ -26,6 +26,7 @@ #include #include +#include #include "internal.h"

[PATCH v2 1/6] selftest/mremap_test: Update the test to handle pagesize other than 4K

2021-03-15 Thread Aneesh Kumar K.V
Instead of hardcoding 4K page size fetch it using sysconf(). For the performance measurements test still assume 2M and 1G are hugepage sizes. Signed-off-by: Aneesh Kumar K.V --- tools/testing/selftests/vm/mremap_test.c | 113 --- 1 file changed, 61 insertions(+), 52

[PATCH v3] powerpc/kuap: Allow kernel thread to access userspace after kthread_use_mm

2021-02-05 Thread Aneesh Kumar K.V
] io_worker_handle_work+0x248/0x4a0 [c0001c4efd30] [c06746e8] io_wqe_worker+0x228/0x2a0 [c0001c4efda0] [c019d994] kthread+0x1b4/0x1c0 Cc: Zorro Lang Cc: Jens Axboe Cc: Christophe Leroy Cc: Nicholas Piggin Signed-off-by: Aneesh Kumar K.V --- Changes from v2: * Fix build

[PATCH v2] powerpc/kuap: Allow kernel thread to access userspace after kthread_use_mm

2021-02-05 Thread Aneesh Kumar K.V
] [c0674268] io_worker_handle_work+0x248/0x4a0 [c0001c4efd30] [c06746e8] io_wqe_worker+0x228/0x2a0 [c0001c4efda0] [c019d994] kthread+0x1b4/0x1c0 Cc: Zorro Lang Cc: Jens Axboe Cc: Christophe Leroy Cc: Nicholas Piggin Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm

Re: [PATCH] powerpc/kuap: Allow kernel thread to access userspace after kthread_use_mm

2021-02-05 Thread Aneesh Kumar K.V
s > port_srp xts vmx_crypto > [ 530.708049] CPU: 13 PID: 5587 Comm: io_wqe_worker-0 Not tainted 5.11.0-r ok so we call current_thread_amr() with kthread. commit ae33fb7b069ebb41e32f55ae397c887031e47472 Author: Aneesh Kumar K.V Date: Fri Feb 5 19:11:49 2021 +0530 The other stack that mat

[PATCH] powerpc/kuap: Allow kernel thread to access userspace after kthread_use_mm

2021-02-04 Thread Aneesh Kumar K.V
space. But, the AMR value is thread-specific and we inherit the address space and not thread access restrictions. Because of this ignore AMR value when accessing userspace via kernel thread. Cc: Zorro Lang Cc: Jens Axboe Cc: Christophe Leroy Cc: Nicholas Piggin Signed-off-by: Aneesh Kumar K.V

[PATCH] mm/pmem: Avoid inserting hugepage PTE entry with fsdax if hugepage support is disabled

2021-02-04 Thread Aneesh Kumar K.V
THP via sysfs file (/sys/kernel/mm/transparent_hugepage/enabled). Hence differentiate between hardware/firmware lacking support vs user-controlled disable of THP and prevent a huge fault if the hardware lacks hugepage support. Signed-off-by: Aneesh Kumar K.V --- include/linux/huge_mm.h |

Re: [PATCH] powerpc/fault: fix wrong KUAP fault for IO_URING

2021-02-04 Thread Aneesh Kumar K.V
On 2/4/21 11:27 PM, Zorro Lang wrote: On Thu, Feb 04, 2021 at 10:31:59PM +0530, Aneesh Kumar K.V wrote: On 2/4/21 10:23 PM, Jens Axboe wrote: On 2/1/21 11:30 PM, Aneesh Kumar K.V wrote: On 2/2/21 11:50 AM, Christophe Leroy wrote: Le 02/02/2021 à 07:16, Aneesh Kumar K.V a écrit : On 2/2/21

Re: [PATCH] powerpc/fault: fix wrong KUAP fault for IO_URING

2021-02-04 Thread Aneesh Kumar K.V
On 2/4/21 10:23 PM, Jens Axboe wrote: On 2/1/21 11:30 PM, Aneesh Kumar K.V wrote: On 2/2/21 11:50 AM, Christophe Leroy wrote: Le 02/02/2021 à 07:16, Aneesh Kumar K.V a écrit : On 2/2/21 11:32 AM, Christophe Leroy wrote: Le 02/02/2021 à 06:55, Aneesh Kumar K.V a écrit : Aneesh Kumar K.V

[PATCH 3/3] powerpc/mm: Remove dcache flush from memory remove.

2021-02-02 Thread Aneesh Kumar K.V
/powernv/npu: Remove NPU DMA ops") and commit 25b2995a35b6 ("mm: remove MEMORY_DEVICE_PUBLIC support") Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/mm/mem.c | 22 - arch/powerpc/platforms/powernv/memtrace.c | 29 +++ 2 files changed,

[PATCH 2/3] powerpc/mm: Add PG_dcache_clean to indicate dcache clean state

2021-02-02 Thread Aneesh Kumar K.V
This just add a better name for PG_arch_1. No functional change in this patch. Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/cacheflush.h | 6 ++ arch/powerpc/include/asm/kvm_ppc.h| 4 ++-- arch/powerpc/mm/book3s64/hash_utils.c | 4 ++-- arch/powerpc/mm/mem.c

[PATCH 1/3] powerpc/mm: Enable compound page check for both THP and HugeTLB

2021-02-02 Thread Aneesh Kumar K.V
support COHERENT_ICACHE. Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/hugetlb.h | 2 -- arch/powerpc/mm/hugetlbpage.c | 18 -- arch/powerpc/mm/mem.c | 28 ++-- 3 files changed, 22 insertions(+), 26 deletions(-) diff --git

Re: [RFC PATCH 1/6] selftest/mremap_test: Update the test to handle pagesize other than 4K

2021-02-02 Thread Aneesh Kumar K.V
On 2/2/21 6:59 PM, Li Xinhai wrote: what is the overall purpose of this patch set? maybe need a cover letter? The goal of the patch series was to enable MOVE_PMD/PUD on ppc64. But the series itself achieves that by fixing the existing code rather than adding changes to arch/ppc64. With

Re: [RFC PATCH 3/6] mm/mremap: Use pmd/pud_poplulate to update page table entries

2021-02-02 Thread Aneesh Kumar K.V
On 2/2/21 4:17 PM, Peter Zijlstra wrote: On Tue, Feb 02, 2021 at 02:41:13PM +0530, Aneesh Kumar K.V wrote: pmd/pud_populate is the right interface to be used to set the respective page table entries. Some architectures do assume that set_pmd/pud_at can only be used to set a hugepage PTE. Since

[RFC PATCH 6/6] powerpc/mm: Enable move pmd/pud

2021-02-02 Thread Aneesh Kumar K.V
, Destination PUD-aligned mremap time:26851ns Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/platforms/Kconfig.cputype | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype index 3ce907523b1e..2e666e569fdf

[RFC PATCH 5/6] mm/mremap: Allow arch runtime override

2021-02-02 Thread Aneesh Kumar K.V
Architectures like ppc64 can only support faster mremap only with radix translation. Hence allow a runtime check w.r.t support for fast mremap. Signed-off-by: Aneesh Kumar K.V --- arch/arm64/include/asm/tlb.h | 6 ++ arch/powerpc/include/asm/tlb.h | 6 ++ arch/x86/include/asm/tlb.h

[RFC PATCH 2/6] selftest/mremap_test: Avoid crash with static build

2021-02-02 Thread Aneesh Kumar K.V
With a large mmap map size, we can overlap with the text area and using MAP_FIXED results in unmapping that area. Switch to MAP_FIXED_NOREPLACE and handle the EEXIST error. Signed-off-by: Aneesh Kumar K.V --- tools/testing/selftests/vm/mremap_test.c | 5 +++-- 1 file changed, 3 insertions(+), 2

[RFC PATCH 4/6] mm/mremap: Use mmu gather interface instead of flush_tlb_range

2021-02-02 Thread Aneesh Kumar K.V
gather to flush TLB and mark tlb.freed_tables = 1. No page table pages need to be freed here. With this the tlb flush is done outside page table lock (ptl). Signed-off-by: Aneesh Kumar K.V --- mm/mremap.c | 33 + 1 file changed, 29 insertions(+), 4 deletions(-) diff

[RFC PATCH 1/6] selftest/mremap_test: Update the test to handle pagesize other than 4K

2021-02-02 Thread Aneesh Kumar K.V
Instead of hardcoding 4K page size fetch it using sysconf(). For the performance measurements test still assume 2M and 1G are hugepage sizes. Signed-off-by: Aneesh Kumar K.V --- tools/testing/selftests/vm/mremap_test.c | 113 --- 1 file changed, 61 insertions(+), 52

[RFC PATCH 3/6] mm/mremap: Use pmd/pud_poplulate to update page table entries

2021-02-02 Thread Aneesh Kumar K.V
pmd/pud_populate is the right interface to be used to set the respective page table entries. Some architectures do assume that set_pmd/pud_at can only be used to set a hugepage PTE. Since we are not setting up a hugepage PTE here, use the pmd/pud_populate interface. Signed-off-by: Aneesh Kumar

Re: [PATCH] powerpc/fault: fix wrong KUAP fault for IO_URING

2021-02-01 Thread Aneesh Kumar K.V
On 2/2/21 11:50 AM, Christophe Leroy wrote: Le 02/02/2021 à 07:16, Aneesh Kumar K.V a écrit : On 2/2/21 11:32 AM, Christophe Leroy wrote: Le 02/02/2021 à 06:55, Aneesh Kumar K.V a écrit : Aneesh Kumar K.V writes: Nicholas Piggin writes: Excerpts from Michael Ellerman's message

Re: [PATCH] powerpc/fault: fix wrong KUAP fault for IO_URING

2021-02-01 Thread Aneesh Kumar K.V
On 2/2/21 11:32 AM, Christophe Leroy wrote: Le 02/02/2021 à 06:55, Aneesh Kumar K.V a écrit : Aneesh Kumar K.V writes: Nicholas Piggin writes: Excerpts from Michael Ellerman's message of January 30, 2021 9:22 pm: Christophe Leroy writes: +Aneesh Le 29/01/2021 à 07:52, Zorro Lang

Re: [PATCH] powerpc/fault: fix wrong KUAP fault for IO_URING

2021-02-01 Thread Aneesh Kumar K.V
Aneesh Kumar K.V writes: > Nicholas Piggin writes: > >> Excerpts from Michael Ellerman's message of January 30, 2021 9:22 pm: >>> Christophe Leroy writes: >>>> +Aneesh >>>> >>>> Le 29/01/2021 à 07:52, Zorro Lang a é

Re: [PATCH] powerpc/fault: fix wrong KUAP fault for IO_URING

2021-02-01 Thread Aneesh Kumar K.V
simply move the AMR into the mm, precisely because it's >> per thread, not per mm. >> >> So TBH I don't know how we're going to fix this. >> >> I guess we could return AMR=unblocked for kernel threads, but that's >> arguably a bug because it allows a proces

Re: [PATCH] selftests/powerpc: Fix exit status of pkey tests

2021-01-18 Thread Aneesh Kumar K.V
eviewed-by: Aneesh Kumar K.V > Reported-by: Eirik Fuller > Fixes: 1addb6444791 ("selftests/powerpc: Add test for execute-disabled pkeys") > Fixes: c27f2fd1705a ("selftests/powerpc: Add test for pkey siginfo > verification") > Signed-off-by: Sandipan Das > --

[PATCH v2] powerpc/book3s/kup: Mark the kuap/keup function non __init

2020-12-14 Thread Aneesh Kumar K.V
The kernel call these functions on cpu online and hence they should not be marked __init. Fixes: 3b47b7549ead ("powerpc/book3s64/kuap: Move KUAP related function outside radix") Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/mm/book3s64/pkeys.c | 4 ++-- 1 file changed, 2 insert

[PATCH] powerpc/kup: Mark the kuap/keup function non __init

2020-12-13 Thread Aneesh Kumar K.V
Kernel call these functions on cpu online and hence they should not be marked __init. Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/mm/book3s32/mmu.c | 4 ++-- arch/powerpc/mm/book3s64/pkeys.c | 4 ++-- arch/powerpc/mm/init-common.c| 2 +- arch/powerpc/mm/nohash/8xx.c | 4 ++-- 4

Re: [PATCH] powerpc/mm: Refactor the floor/ceiling check in hugetlb range freeing functions

2020-12-08 Thread Aneesh Kumar K.V
eturning true when [start;end[ is not fully > contained inside [floor;ceiling[ > Reviewed-by: Aneesh Kumar K.V > Signed-off-by: Christophe Leroy > --- > arch/powerpc/mm/hugetlbpage.c | 56 --- > 1 file changed, 19 insertions(+), 37 deletions(-

Re: [PATCH 04/13] powerpc/xive: Use cpu_to_node() instead of ibm, chip-id property

2020-12-08 Thread Aneesh Kumar K.V
Cédric Le Goater writes: > The 'chip_id' field of the XIVE CPU structure is used to choose a > target for a source located on the same chip when possible. This field > is assigned on the PowerNV platform using the "ibm,chip-id" property > on pSeries under KVM when NUMA nodes are defined but it

Re: [PATCH v3 4/5] powerpc/fault: Avoid heavy search_exception_tables() verification

2020-12-08 Thread Aneesh Kumar K.V
Christophe Leroy writes: > search_exception_tables() is an heavy operation, we have to avoid it. > When KUAP is selected, we'll know the fault has been blocked by KUAP. > Otherwise, it behaves just as if the address was already in the TLBs > and no fault was generated. > > Signed-off-by:

Re: [PATCH v3 4/5] powerpc/fault: Avoid heavy search_exception_tables() verification

2020-12-08 Thread Aneesh Kumar K.V
Christophe Leroy writes: > Le 08/12/2020 à 14:00, Aneesh Kumar K.V a écrit : >> On 12/8/20 2:07 PM, Christophe Leroy wrote: >>> search_exception_tables() is an heavy operation, we have to avoid it. >>> When KUAP is selected, we'll know the fault has been blo

Re: [PATCH v3 4/5] powerpc/fault: Avoid heavy search_exception_tables() verification

2020-12-08 Thread Aneesh Kumar K.V
On 12/8/20 2:07 PM, Christophe Leroy wrote: search_exception_tables() is an heavy operation, we have to avoid it. When KUAP is selected, we'll know the fault has been blocked by KUAP. Otherwise, it behaves just as if the address was already in the TLBs and no fault was generated. Signed-off-by:

[PATCH] powerpc/book3s64/kuap: Improve error reporting with KUAP

2020-12-07 Thread Aneesh Kumar K.V
erpc/mm: Detect bad KUAP faults") to catch userspace access incorrectly blocked by AMR. Hence retain the full stack dump there even with hash translation. Also, add a comment explaining the difference between hash and radix. Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/book

Re: [PATCH kernel v2] powerpc/kuap: Restore AMR after replaying soft interrupts

2020-12-02 Thread Aneesh Kumar K.V
Alexey Kardashevskiy writes: > When interrupted in raw_copy_from_user()/... after user memory access > is enabled, a nested handler may also access user memory (perf is > one example) and when it does so, it calls prevent_read_from_user() > which prevents the upper handler from accessing user

[PATCH v7 updated 21/22 ] powerpc/book3s64/kup: Check max key supported before enabling kup

2020-12-01 Thread Aneesh Kumar K.V
Don't enable KUEP/KUAP if we support less than or equal to 3 keys. Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/kup.h | 3 +++ arch/powerpc/mm/book3s64/pkeys.c | 33 arch/powerpc/mm/init-common.c| 4 ++-- 3 files changed, 26 insertions

Re: [RFC PATCH] powerpc/papr_scm: Implement scm async flush

2020-12-01 Thread Aneesh Kumar K.V
On 12/1/20 6:17 PM, Pankaj Gupta wrote: Tha patch implements SCM async-flush hcall and sets the ND_REGION_ASYNC capability when the platform device tree has "ibm,async-flush-required" set. So, you are reusing the existing ND_REGION_ASYNC flag for the hypercall based async flush with device

Re: [PATCH v7 00/22] Kernel userspace access/execution prevention with hash translation

2020-11-30 Thread Aneesh Kumar K.V
"Aneesh Kumar K.V" writes: > This patch series implements KUAP and KUEP with hash translation mode using > memory keys. The kernel now uses memory protection key 3 to control access > to the kernel. Kernel page table entries are now configured with key 3. > Access t

Re: [PATCH v3 05/19] powerpc: interrupt handler wrapper functions

2020-11-29 Thread Aneesh Kumar K.V
Nicholas Piggin writes: . +#endif > +DECLARE_INTERRUPT_HANDLER(emulation_assist_interrupt); > +DECLARE_INTERRUPT_HANDLER_RAW(do_slb_fault); Can we add comments here explaining why some of these handlers need to remain RAW()? > +DECLARE_INTERRUPT_HANDLER(do_bad_slb_fault); >

Re: [PATCH v3 03/19] powerpc: bad_page_fault, do_break get registers from regs

2020-11-29 Thread Aneesh Kumar K.V
Nicholas Piggin writes: > Similar to the previous patch this makes interrupt handler function > types more regular so they can be wrapped with the next patch. > > bad_page_fault and do_break are not performance critical. > Reviewed-by: Aneesh Kumar K.V > [32s DABR code fro

Re: [PATCH v3 02/19] powerpc: remove arguments from fault handler functions

2020-11-29 Thread Aneesh Kumar K.V
ppers. Explicit arguments could > be added for performance but that would require more wrapper macro > variants. Reviewed-by: Aneesh Kumar K.V > > Signed-off-by: Nicholas Piggin > --- > arch/powerpc/include/asm/asm-prototypes.h | 4 ++-- > arch/powerpc/include/asm/

Re: [PATCH v3 01/19] powerpc/64s: move the last of the page fault handling logic to C

2020-11-29 Thread Aneesh Kumar K.V
Nicholas Piggin writes: > The page fault handling still has some complex logic particularly around > hash table handling, in asm. Implement this in C instead. > Reviewed-by: Aneesh Kumar K.V > Signed-off-by: Nicholas Piggin > --- > arch/powerpc/include/asm/book3s/6

[PATCH v7 17/22] powerpc/book3s64/kuap: Use Key 3 to implement KUAP with hash translation.

2020-11-26 Thread Aneesh Kumar K.V
Radix use AMR Key 0 and hash translation use AMR key 3. Reviewed-by: Sandipan Das Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/book3s/64/kup.h | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/kup.h b/arch/powerpc

[PATCH v7 22/22] powerpc/book3s64/pkeys: Optimize KUAP and KUEP feature disabled case

2020-11-26 Thread Aneesh Kumar K.V
2489.30 cycles With smap/smep enabled: Without patch: 1017.26 ns2950.36 cycles With patch: 1021.51 ns2962.44 cycles Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/book3s/64/kup.h | 63 +--- arch/powerpc/kernel/entry_64.S | 2

[PATCH v7 21/22] powerpc/book3s64/hash/kup: Don't hardcode kup key

2020-11-26 Thread Aneesh Kumar K.V
Make KUAP/KUEP key a variable and also check whether the platform limit the max key such that we can't use the key for KUAP/KEUP. Signed-off-by: Aneesh Kumar K.V --- .../powerpc/include/asm/book3s/64/hash-pkey.h | 23 +-- arch/powerpc/include/asm/book3s/64/pkeys.h| 1 + arch/powerpc/mm

[PATCH v7 20/22] powerpc/book3s64/hash/kuep: Enable KUEP on hash

2020-11-26 Thread Aneesh Kumar K.V
Reviewed-by: Sandipan Das Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/mm/book3s64/pkeys.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/mm/book3s64/pkeys.c b/arch/powerpc/mm/book3s64/pkeys.c index 9f01c86d2beb..4a3aeddbe0c7 100644 --- a/arch/powerpc

[PATCH v7 19/22] powerpc/book3s64/hash/kuap: Enable kuap on hash

2020-11-26 Thread Aneesh Kumar K.V
Reviewed-by: Sandipan Das Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/mm/book3s64/pkeys.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/mm/book3s64/pkeys.c b/arch/powerpc/mm/book3s64/pkeys.c index 8d1bf2f18ca4..9f01c86d2beb 100644 --- a/arch/powerpc

[PATCH v7 18/22] powerpc/book3s64/kuep: Use Key 3 to implement KUEP with hash translation.

2020-11-26 Thread Aneesh Kumar K.V
Radix use IAMR Key 0 and hash translation use IAMR key 3. Reviewed-by: Sandipan Das Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/book3s/64/kup.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/book3s/64/kup.h b/arch/powerpc/include

[PATCH v7 16/22] powerpc/book3s64/kuap: Improve error reporting with KUAP

2020-11-26 Thread Aneesh Kumar K.V
With hash translation use DSISR_KEYFAULT to identify a wrong access. With Radix we look at the AMR value and type of fault. Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/book3s/32/kup.h | 4 +-- arch/powerpc/include/asm/book3s/64/kup.h | 27 arch

[PATCH v7 15/22] powerpc/book3s64/kuap: Restrict access to userspace based on userspace AMR

2020-11-26 Thread Aneesh Kumar K.V
If an application has configured address protection such that read/write is denied using pkey even the kernel should receive a FAULT on accessing the same. This patch use user AMR value stored in pt_regs.amr to achieve the same. Reviewed-by: Sandipan Das Signed-off-by: Aneesh Kumar K.V

[PATCH v7 13/22] powerpc/ptrace-view: Use pt_regs values instead of thread_struct based one.

2020-11-26 Thread Aneesh Kumar K.V
We will remove thread.amr/iamr/uamor in a later patch Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/kernel/ptrace/ptrace-view.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/kernel/ptrace/ptrace-view.c b/arch/powerpc/kernel/ptrace/ptrace-view.c

[PATCH v7 14/22] powerpc/book3s64/pkeys: Don't update SPRN_AMR when in kernel mode.

2020-11-26 Thread Aneesh Kumar K.V
Now that kernel correctly store/restore userspace AMR/IAMR values, avoid manipulating AMR and IAMR from the kernel on behalf of userspace. Reviewed-by: Sandipan Das Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/book3s/64/kup.h | 21 + arch/powerpc/include/asm/processor.h

[PATCH v7 12/22] powerpc/book3s64/pkeys: Reset userspace AMR correctly on exec

2020-11-26 Thread Aneesh Kumar K.V
On fork, we inherit from the parent and on exec, we should switch to default_amr values. Also, avoid changing the AMR register value within the kernel. The kernel now runs with different AMR values. Reviewed-by: Sandipan Das Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm

[PATCH v7 11/22] powerpc/book3s64/pkeys: Inherit correctly on fork.

2020-11-26 Thread Aneesh Kumar K.V
Child thread.kuap value is inherited from the parent in copy_thread_tls. We still need to make sure when the child returns from a fork in the kernel we start with the kernel default AMR value. Reviewed-by: Sandipan Das Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/kernel/process.c | 10

[PATCH v7 10/22] powerpc/book3s64/pkeys: Store/restore userspace AMR/IAMR correctly on entry and exit from kernel

2020-11-26 Thread Aneesh Kumar K.V
-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/book3s/64/kup.h | 222 +++ arch/powerpc/include/asm/ptrace.h| 5 +- arch/powerpc/kernel/asm-offsets.c| 2 + arch/powerpc/kernel/entry_64.S | 6 +- arch/powerpc/kernel/exceptions-64s.S | 4

[PATCH v7 09/22] powerpc/exec: Set thread.regs early during exec

2020-11-26 Thread Aneesh Kumar K.V
In later patches during exec, we would like to access default regs.amr to control access to the user mapping. Having thread.regs set early makes the code changes simpler. Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/thread_info.h | 2 -- arch/powerpc/kernel/process.c

[PATCH v7 08/22] powerpc/book3s64/kuap: Use Key 3 for kernel mapping with hash translation

2020-11-26 Thread Aneesh Kumar K.V
. Reviewed-by: Sandipan Das Signed-off-by: Aneesh Kumar K.V --- .../powerpc/include/asm/book3s/64/hash-pkey.h | 25 ++- arch/powerpc/include/asm/book3s/64/hash.h | 2 +- arch/powerpc/include/asm/book3s/64/mmu-hash.h | 1 + arch/powerpc/include/asm/mmu_context.h| 2 +- arch

[PATCH v7 07/22] powerpc/book3s64/kuap: Rename MMU_FTR_RADIX_KUAP and MMU_FTR_KUEP

2020-11-26 Thread Aneesh Kumar K.V
to BOOK3S_64 Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/book3s/64/kup.h | 18 +- arch/powerpc/include/asm/mmu.h | 24 ++-- arch/powerpc/mm/book3s64/pkeys.c | 4 ++-- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git

[PATCH v7 06/22] powerpc/book3s64/kuep: Move KUEP related function outside radix

2020-11-26 Thread Aneesh Kumar K.V
The next set of patches adds support for kuep with hash translation. In preparation for that rename/move kuap related functions to non radix names. Also set MMU_FTR_KUEP and add the missing isync(). Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/book3s/64/kup.h | 1 + arch

[PATCH v7 05/22] powerpc/book3s64/kuap: Move KUAP related function outside radix

2020-11-26 Thread Aneesh Kumar K.V
The next set of patches adds support for kuap with hash translation. In preparation for that rename/move kuap related functions to non radix names. Signed-off-by: Aneesh Kumar K.V --- .../asm/book3s/64/{kup-radix.h => kup.h} | 6 ++--- arch/powerpc/include/asm/kup.h|

[PATCH v7 03/22] powerpc/book3s64/kuap/kuep: Add PPC_PKEY config on book3s64

2020-11-26 Thread Aneesh Kumar K.V
The config CONFIG_PPC_PKEY is used to select the base support that is required for PPC_MEM_KEYS, KUAP, and KUEP. Adding this dependency reduces the code complexity(in terms of #ifdefs) and enables us to move some of the initialization code to pkeys.c Signed-off-by: Aneesh Kumar K.V

[PATCH v7 04/22] powerpc/book3s64/kuap/kuep: Move uamor setup to pkey init

2020-11-26 Thread Aneesh Kumar K.V
CPUs supporting radix translation. The old code was not updating UAMOR if we had smap disabled and smep enabled. This change handles that case. Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/mm/book3s64/radix_pgtable.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git

[PATCH v7 02/22] KVM: PPC: BOOK3S: PR: Ignore UAMOR SPR

2020-11-26 Thread Aneesh Kumar K.V
ignore access to them and for mfstpr return 0 indicating no AMR/IAMR update is no allowed. Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/kvm/book3s_emulate.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/arch/powerpc/kvm/book3s_emulate.c b/arch/powerpc/kvm/book3s_emulate.c index

[PATCH v7 00/22] Kernel userspace access/execution prevention with hash translation

2020-11-26 Thread Aneesh Kumar K.V
* Added a patch to make kup key dynamic. Changes from V1: * Rebased on latest kernel Aneesh Kumar K.V (22): powerpc: Add new macro to handle NESTED_IFCLR KVM: PPC: BOOK3S: PR: Ignore UAMOR SPR powerpc/book3s64/kuap/kuep: Add PPC_PKEY config on book3s64 powerpc/book3s64/kuap/kuep: Move

[PATCH v7 01/22] powerpc: Add new macro to handle NESTED_IFCLR

2020-11-26 Thread Aneesh Kumar K.V
This will be used by the following patches Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/feature-fixups.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/powerpc/include/asm/feature-fixups.h b/arch/powerpc/include/asm/feature-fixups.h index fbd406cd6916..5cdba929a8ae

Re: [PATCH 0/4] powerpc/64s: Fix for radix TLB invalidation bug

2020-11-26 Thread Aneesh Kumar K.V
owerpc/platforms/pseries/hotplug-cpu.c | 3 +++ > kernel/cpu.c | 6 - > 7 files changed, 60 insertions(+), 9 deletions(-) > You can add for the series Reviewed-by: Aneesh Kumar K.V -aneesh

Re: [PATCH v6 16/22] powerpc/book3s64/kuap: Improve error reporting with KUAP

2020-11-25 Thread Aneesh Kumar K.V
Christophe Leroy writes: > Le 25/11/2020 à 06:16, Aneesh Kumar K.V a écrit : >> With hash translation use DSISR_KEYFAULT to identify a wrong access. >> With Radix we look at the AMR value and type of fault. >> >> Signed-off-by: Aneesh Kumar K.V >> --- >&g

Re: [PATCH v6 09/22] powerpc/exec: Set thread.regs early during exec

2020-11-25 Thread Aneesh Kumar K.V
Christophe Leroy writes: > Le 25/11/2020 à 06:16, Aneesh Kumar K.V a écrit : > +++ b/arch/powerpc/kernel/process.c >> @@ -1530,10 +1530,32 @@ void flush_thread(void) >> #ifdef CONFIG_PPC_BOOK3S_64 >> void arch_setup_new_exec(void) >>

Re: [PATCH v6 03/22] powerpc/book3s64/kuap/kuep: Make KUAP and KUEP a subfeature of PPC_MEM_KEYS

2020-11-25 Thread Aneesh Kumar K.V
Christophe Leroy writes: > Le 25/11/2020 à 06:16, Aneesh Kumar K.V a écrit : > diff --git a/arch/powerpc/mm/book3s64/pkeys.c > b/arch/powerpc/mm/book3s64/pkeys.c >> index b1d091a97611..7dc71f85683d 100644 >> --- a/arch/powerpc/mm/book3s64/pkeys.c >> +++ b/arch/

Re: [PATCH v6 11/22] powerpc/book3s64/pkeys: Inherit correctly on fork.

2020-11-25 Thread Aneesh Kumar K.V
On 11/25/20 7:24 PM, Christophe Leroy wrote: Le 25/11/2020 à 06:16, Aneesh Kumar K.V a écrit : Child thread.kuap value is inherited from the parent in copy_thread_tls. We still need to make sure when the child returns from a fork in the kernel we start with the kernel default AMR value

Re: [PATCH v6 10/22] powerpc/book3s64/pkeys: Store/restore userspace AMR/IAMR correctly on entry and exit from kernel

2020-11-25 Thread Aneesh Kumar K.V
On 11/25/20 7:22 PM, Christophe Leroy wrote: Le 25/11/2020 à 06:16, Aneesh Kumar K.V a écrit : This prepare kernel to operate with a different value than userspace AMR/IAMR. For this, AMR/IAMR need to be saved and restored on entry and return from the kernel. With KUAP we modify kernel AMR

Re: [PATCH v6 07/22] powerpc/book3s64/kuap: Rename MMU_FTR_RADIX_KUAP to MMU_FTR_KUAP

2020-11-25 Thread Aneesh Kumar K.V
On 11/25/20 7:13 PM, Christophe Leroy wrote: Le 25/11/2020 à 06:16, Aneesh Kumar K.V a écrit : This is in preparate to adding support for kuap with hash translation. In preparation for that rename/move kuap related functions to non radix names. Also move the feature bit closer to MMU_FTR_KUEP

[PATCH v6 22/22] powerpc/book3s64/pkeys: Optimize FTR_KUAP and FTR_KUEP disabled case

2020-11-24 Thread Aneesh Kumar K.V
cycles With smap/smep enabled: Without patch: 1017.26 ns2950.36 cycles With patch: 1021.51 ns2962.44 cycles Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/book3s/64/kup.h | 61 +--- arch/powerpc/kernel/entry_64.S | 2 +- arch

[PATCH v6 21/22] powerpc/book3s64/hash/kup: Don't hardcode kup key

2020-11-24 Thread Aneesh Kumar K.V
Make KUAP/KUEP key a variable and also check whether the platform limit the max key such that we can't use the key for KUAP/KEUP. Signed-off-by: Aneesh Kumar K.V --- .../powerpc/include/asm/book3s/64/hash-pkey.h | 22 +--- arch/powerpc/include/asm/book3s/64/pkeys.h| 1 + arch/powerpc

[PATCH v6 20/22] powerpc/book3s64/hash/kuep: Enable KUEP on hash

2020-11-24 Thread Aneesh Kumar K.V
Reviewed-by: Sandipan Das Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/mm/book3s64/pkeys.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/mm/book3s64/pkeys.c b/arch/powerpc/mm/book3s64/pkeys.c index 84f8664ffc47..f029e7bf5ca2 100644 --- a/arch/powerpc

[PATCH v6 19/22] powerpc/book3s64/hash/kuap: Enable kuap on hash

2020-11-24 Thread Aneesh Kumar K.V
Reviewed-by: Sandipan Das Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/mm/book3s64/pkeys.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/mm/book3s64/pkeys.c b/arch/powerpc/mm/book3s64/pkeys.c index f747d66cc87d..84f8664ffc47 100644 --- a/arch/powerpc

[PATCH v6 18/22] powerpc/book3s64/kuep: Use Key 3 to implement KUEP with hash translation.

2020-11-24 Thread Aneesh Kumar K.V
Radix use IAMR Key 0 and hash translation use IAMR key 3. Reviewed-by: Sandipan Das Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/book3s/64/kup.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/book3s/64/kup.h b/arch/powerpc/include

[PATCH v6 17/22] powerpc/book3s64/kuap: Use Key 3 to implement KUAP with hash translation.

2020-11-24 Thread Aneesh Kumar K.V
Radix use AMR Key 0 and hash translation use AMR key 3. Reviewed-by: Sandipan Das Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/book3s/64/kup.h | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/kup.h b/arch/powerpc

[PATCH v6 16/22] powerpc/book3s64/kuap: Improve error reporting with KUAP

2020-11-24 Thread Aneesh Kumar K.V
With hash translation use DSISR_KEYFAULT to identify a wrong access. With Radix we look at the AMR value and type of fault. Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/book3s/32/kup.h | 4 +-- arch/powerpc/include/asm/book3s/64/kup.h | 27 arch

[PATCH v6 15/22] powerpc/book3s64/kuap: Restrict access to userspace based on userspace AMR

2020-11-24 Thread Aneesh Kumar K.V
If an application has configured address protection such that read/write is denied using pkey even the kernel should receive a FAULT on accessing the same. This patch use user AMR value stored in pt_regs.amr to achieve the same. Reviewed-by: Sandipan Das Signed-off-by: Aneesh Kumar K.V

[PATCH v6 14/22] powerpc/book3s64/pkeys: Don't update SPRN_AMR when in kernel mode.

2020-11-24 Thread Aneesh Kumar K.V
Now that kernel correctly store/restore userspace AMR/IAMR values, avoid manipulating AMR and IAMR from the kernel on behalf of userspace. Reviewed-by: Sandipan Das Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/book3s/64/kup.h | 21 + arch/powerpc/include/asm/processor.h

[PATCH v6 13/22] powerpc/ptrace-view: Use pt_regs values instead of thread_struct based one.

2020-11-24 Thread Aneesh Kumar K.V
We will remove thread.amr/iamr/uamor in a later patch Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/kernel/ptrace/ptrace-view.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/kernel/ptrace/ptrace-view.c b/arch/powerpc/kernel/ptrace/ptrace-view.c

[PATCH v6 12/22] powerpc/book3s64/pkeys: Reset userspace AMR correctly on exec

2020-11-24 Thread Aneesh Kumar K.V
On fork, we inherit from the parent and on exec, we should switch to default_amr values. Also, avoid changing the AMR register value within the kernel. The kernel now runs with different AMR values. Reviewed-by: Sandipan Das Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm

[PATCH v6 11/22] powerpc/book3s64/pkeys: Inherit correctly on fork.

2020-11-24 Thread Aneesh Kumar K.V
Child thread.kuap value is inherited from the parent in copy_thread_tls. We still need to make sure when the child returns from a fork in the kernel we start with the kernel default AMR value. Reviewed-by: Sandipan Das Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/kernel/process.c | 11

[PATCH v6 10/22] powerpc/book3s64/pkeys: Store/restore userspace AMR/IAMR correctly on entry and exit from kernel

2020-11-24 Thread Aneesh Kumar K.V
. This is required so that if we get interrupted within copy_to/from_user we continue with the right AMR value. If we hae MMU_FTR_KUEP enabled we need to restore IAMR on return to userspace beause kernel will be running with a different IAMR value. Reviewed-by: Sandipan Das Signed-off-by: Aneesh Kumar

[PATCH v6 09/22] powerpc/exec: Set thread.regs early during exec

2020-11-24 Thread Aneesh Kumar K.V
In later patches during exec, we would like to access default regs.amr to control access to the user mapping. Having thread.regs set early makes the code changes simpler. Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/thread_info.h | 2 -- arch/powerpc/kernel/process.c

[PATCH v6 08/22] powerpc/book3s64/kuap: Use Key 3 for kernel mapping with hash translation

2020-11-24 Thread Aneesh Kumar K.V
. Reviewed-by: Sandipan Das Signed-off-by: Aneesh Kumar K.V --- .../powerpc/include/asm/book3s/64/hash-pkey.h | 24 ++- arch/powerpc/include/asm/book3s/64/hash.h | 2 +- arch/powerpc/include/asm/book3s/64/mmu-hash.h | 1 + arch/powerpc/include/asm/mmu_context.h| 2 +- arch

[PATCH v6 07/22] powerpc/book3s64/kuap: Rename MMU_FTR_RADIX_KUAP to MMU_FTR_KUAP

2020-11-24 Thread Aneesh Kumar K.V
This is in preparate to adding support for kuap with hash translation. In preparation for that rename/move kuap related functions to non radix names. Also move the feature bit closer to MMU_FTR_KUEP. Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/book3s/64/kup.h | 18

[PATCH v6 06/22] powerpc/book3s64/kuep: Move KUEP related function outside radix

2020-11-24 Thread Aneesh Kumar K.V
The next set of patches adds support for kuep with hash translation. In preparation for that rename/move kuap related functions to non radix names. Also set MMU_FTR_KUEP and add the missing isync(). Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/book3s/64/kup.h | 1 + arch

[PATCH v6 05/22] powerpc/book3s64/kuap: Move KUAP related function outside radix

2020-11-24 Thread Aneesh Kumar K.V
The next set of patches adds support for kuap with hash translation. In preparation for that rename/move kuap related functions to non radix names. Signed-off-by: Aneesh Kumar K.V --- .../asm/book3s/64/{kup-radix.h => kup.h} | 6 ++--- arch/powerpc/include/asm/kup.h|

[PATCH v6 04/22] powerpc/book3s64/kuap/kuep: Move uamor setup to pkey init

2020-11-24 Thread Aneesh Kumar K.V
CPUs supporting radix translation. The old code was not updating UAMOR if we had smap disabled and smep enabled. This change handles that case. Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/mm/book3s64/radix_pgtable.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git

[PATCH v6 03/22] powerpc/book3s64/kuap/kuep: Make KUAP and KUEP a subfeature of PPC_MEM_KEYS

2020-11-24 Thread Aneesh Kumar K.V
of the initialization code to pkeys.c Signed-off-by: Aneesh Kumar K.V --- .../powerpc/include/asm/book3s/64/kup-radix.h | 4 ++-- arch/powerpc/include/asm/book3s/64/mmu.h | 2 +- arch/powerpc/include/asm/ptrace.h | 7 +- arch/powerpc/kernel/asm-offsets.c | 3 +++ arch

[PATCH v6 00/22] Kernel userspace access/execution prevention with hash translation

2020-11-24 Thread Aneesh Kumar K.V
on latest kernel Aneesh Kumar K.V (22): powerpc: Add new macro to handle NESTED_IFCLR KVM: PPC: BOOK3S: PR: Ignore UAMOR SPR powerpc/book3s64/kuap/kuep: Make KUAP and KUEP a subfeature of PPC_MEM_KEYS powerpc/book3s64/kuap/kuep: Move uamor setup to pkey init powerpc/book3s64/kuap

[PATCH v6 02/22] KVM: PPC: BOOK3S: PR: Ignore UAMOR SPR

2020-11-24 Thread Aneesh Kumar K.V
ignore access to them and for mfstpr return 0 indicating no AMR/IAMR update is no allowed. Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/kvm/book3s_emulate.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/arch/powerpc/kvm/book3s_emulate.c b/arch/powerpc/kvm/book3s_emulate.c index

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