Re: [PATCH v5 17/22] powerpc/syscall: Do not check unsupported scv vector on PPC32

2021-02-08 Thread Nicholas Piggin
Excerpts from Christophe Leroy's message of February 9, 2021 4:13 pm: > > > Le 09/02/2021 à 03:00, Nicholas Piggin a écrit : >> Excerpts from Christophe Leroy's message of February 9, 2021 1:10 am: >>> Only PPC64 has scv. No need to check the 0x7ff0 trap on PPC32. >>> For that, add a helper

Re: [PATCH v5 09/22] powerpc/syscall: Make interrupt.c buildable on PPC32

2021-02-08 Thread Nicholas Piggin
Excerpts from Christophe Leroy's message of February 9, 2021 4:02 pm: > > > Le 09/02/2021 à 02:27, Nicholas Piggin a écrit : >> Excerpts from Christophe Leroy's message of February 9, 2021 1:10 am: >>> To allow building interrupt.c on PPC32, ifdef out specific PPC64 >>> code or use helpers which

Re: [PATCH v5 05/22] powerpc/irq: Add helper to set regs->softe

2021-02-08 Thread Nicholas Piggin
Excerpts from Christophe Leroy's message of February 9, 2021 4:18 pm: > > > Le 09/02/2021 à 02:11, Nicholas Piggin a écrit : >> Excerpts from Christophe Leroy's message of February 9, 2021 1:10 am: >>> regs->softe doesn't exist on PPC32. >>> >>> Add irq_soft_mask_regs_set_state() helper to set

Re: [PATCH v5 05/22] powerpc/irq: Add helper to set regs->softe

2021-02-08 Thread Nicholas Piggin
Excerpts from Christophe Leroy's message of February 9, 2021 3:57 pm: > > > Le 09/02/2021 à 02:11, Nicholas Piggin a écrit : >> Excerpts from Christophe Leroy's message of February 9, 2021 1:10 am: >>> regs->softe doesn't exist on PPC32. >>> >>> Add irq_soft_mask_regs_set_state() helper to set

Re: [PATCH v7 32/42] powerpc/64: context tracking move to interrupt wrappers

2021-02-08 Thread Nicholas Piggin
Excerpts from Christophe Leroy's message of February 9, 2021 3:49 pm: > > > Le 30/01/2021 à 14:08, Nicholas Piggin a écrit : >> This moves exception_enter/exit calls to wrapper functions for >> synchronous interrupts. More interrupt handlers are covered by >> this than previously. > > Why did

Re: [RFC PATCH v3 0/6] Restricted DMA

2021-02-08 Thread Claire Chang
v4 here: https://lore.kernel.org/patchwork/cover/1378113/

[PATCH v4 14/14] of: Add plumbing for restricted DMA pool

2021-02-08 Thread Claire Chang
If a device is not behind an IOMMU, we look up the device node and set up the restricted DMA when the restricted-dma-pool is presented. Signed-off-by: Claire Chang --- drivers/of/address.c| 25 + drivers/of/device.c | 3 +++ drivers/of/of_private.h | 5 + 3

[PATCH v4 13/14] dt-bindings: of: Add restricted DMA pool

2021-02-08 Thread Claire Chang
Introduce the new compatible string, restricted-dma-pool, for restricted DMA. One can specify the address and length of the restricted DMA memory region by restricted-dma-pool in the reserved-memory node. Signed-off-by: Claire Chang --- .../reserved-memory/reserved-memory.txt | 24

[PATCH v4 12/14] swiotlb: Add restricted DMA alloc/free support.

2021-02-08 Thread Claire Chang
Add the functions, dev_swiotlb_{alloc,free} to support the memory allocation from restricted DMA pool. Signed-off-by: Claire Chang --- include/linux/swiotlb.h | 2 ++ kernel/dma/direct.c | 30 ++ kernel/dma/swiotlb.c| 34 ++ 3

[PATCH v4 11/14] swiotlb: Add is_dev_swiotlb_force()

2021-02-08 Thread Claire Chang
Add is_dev_swiotlb_force() which returns true if the device has restricted DMA pool (e.g. dev->dev_swiotlb is set). Signed-off-by: Claire Chang --- include/linux/swiotlb.h | 9 + kernel/dma/swiotlb.c| 5 + 2 files changed, 14 insertions(+) diff --git a/include/linux/swiotlb.h

[PATCH v4 10/14] dma-direct: Add a new wrapper __dma_direct_free_pages()

2021-02-08 Thread Claire Chang
Add a new wrapper __dma_direct_free_pages() that will be useful later for dev_swiotlb_free(). Signed-off-by: Claire Chang --- kernel/dma/direct.c | 13 + 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index

[PATCH v4 09/14] swiotlb: Refactor swiotlb_tbl_{map,unmap}_single

2021-02-08 Thread Claire Chang
Refactor swiotlb_tbl_{map,unmap}_single to make the code reusable for dev_swiotlb_{alloc,free}. Signed-off-by: Claire Chang --- kernel/dma/swiotlb.c | 116 ++- 1 file changed, 71 insertions(+), 45 deletions(-) diff --git a/kernel/dma/swiotlb.c

[PATCH v4 08/14] swiotlb: Use restricted DMA pool if available

2021-02-08 Thread Claire Chang
Regardless of swiotlb setting, the restricted DMA pool is preferred if available. The restricted DMA pools provide a basic level of protection against the DMA overwriting buffer contents at unexpected times. However, to protect against general data leakage and system memory corruption, the system

[PATCH v4 07/14] swiotlb: Update swiotlb API to gain a struct device argument

2021-02-08 Thread Claire Chang
Introduce the get_swiotlb() getter and update all callers of is_swiotlb_active(), is_swiotlb_buffer() and get_swiotlb_start() to gain a struct device argument. Signed-off-by: Claire Chang --- drivers/iommu/dma-iommu.c | 12 ++-- drivers/xen/swiotlb-xen.c | 4 ++--

[PATCH v4 06/14] swiotlb: Add restricted DMA pool

2021-02-08 Thread Claire Chang
Add the initialization function to create restricted DMA pools from matching reserved-memory nodes. Signed-off-by: Claire Chang --- include/linux/device.h | 4 ++ kernel/dma/swiotlb.c | 94 +- 2 files changed, 97 insertions(+), 1 deletion(-) diff

[PATCH v4 05/14] swiotlb: Add DMA_RESTRICTED_POOL

2021-02-08 Thread Claire Chang
Add a new kconfig symbol, DMA_RESTRICTED_POOL, for restricted DMA pool. Signed-off-by: Claire Chang --- kernel/dma/Kconfig | 14 ++ 1 file changed, 14 insertions(+) diff --git a/kernel/dma/Kconfig b/kernel/dma/Kconfig index 479fc145acfc..97ff9f8dd3c8 100644 --- a/kernel/dma/Kconfig

[PATCH v4 04/14] swiotlb: Refactor swiotlb_late_init_with_tbl

2021-02-08 Thread Claire Chang
Refactor swiotlb_late_init_with_tbl to make the code reusable for restricted DMA pool initialization. Signed-off-by: Claire Chang --- kernel/dma/swiotlb.c | 65 1 file changed, 42 insertions(+), 23 deletions(-) diff --git a/kernel/dma/swiotlb.c

[PATCH v4 03/14] swiotlb: Add struct swiotlb

2021-02-08 Thread Claire Chang
Added a new struct, swiotlb, as the IO TLB memory pool descriptor and moved relevant global variables into that struct. This will be useful later to allow for restricted DMA pool. Signed-off-by: Claire Chang --- kernel/dma/swiotlb.c | 327 +++ 1 file

[PATCH v4 02/14] swiotlb: Move is_swiotlb_buffer() to swiotlb.c

2021-02-08 Thread Claire Chang
Move is_swiotlb_buffer() to swiotlb.c and make io_tlb_{start,end} static, so we can entirely hide struct swiotlb inside of swiotlb.c in the following patches. Signed-off-by: Claire Chang --- include/linux/swiotlb.h | 7 +-- kernel/dma/swiotlb.c| 7 ++- 2 files changed, 7

[PATCH v4 01/14] swiotlb: Remove external access to io_tlb_start

2021-02-08 Thread Claire Chang
Add a new function, get_swiotlb_start(), and remove external access to io_tlb_start, so we can entirely hide struct swiotlb inside of swiotlb.c in the following patches. Signed-off-by: Claire Chang --- arch/powerpc/platforms/pseries/svm.c | 4 ++-- drivers/xen/swiotlb-xen.c| 4 ++--

[PATCH v4 00/14] Restricted DMA

2021-02-08 Thread Claire Chang
This series implements mitigations for lack of DMA access control on systems without an IOMMU, which could result in the DMA accessing the system memory at unexpected times and/or unexpected addresses, possibly leading to data leakage or corruption. For example, we plan to use the PCI-e bus for

Re: [PATCH v5 05/22] powerpc/irq: Add helper to set regs->softe

2021-02-08 Thread Christophe Leroy
Le 09/02/2021 à 02:11, Nicholas Piggin a écrit : Excerpts from Christophe Leroy's message of February 9, 2021 1:10 am: regs->softe doesn't exist on PPC32. Add irq_soft_mask_regs_set_state() helper to set regs->softe. This helper will void on PPC32. Signed-off-by: Christophe Leroy ---

Re: [PATCH v5 17/22] powerpc/syscall: Do not check unsupported scv vector on PPC32

2021-02-08 Thread Christophe Leroy
Le 09/02/2021 à 03:00, Nicholas Piggin a écrit : Excerpts from Christophe Leroy's message of February 9, 2021 1:10 am: Only PPC64 has scv. No need to check the 0x7ff0 trap on PPC32. For that, add a helper trap_is_unsupported_scv() similar to trap_is_scv(). And ignore the scv parameter in

Re: [PATCH v5 09/22] powerpc/syscall: Make interrupt.c buildable on PPC32

2021-02-08 Thread Christophe Leroy
Le 09/02/2021 à 02:27, Nicholas Piggin a écrit : Excerpts from Christophe Leroy's message of February 9, 2021 1:10 am: To allow building interrupt.c on PPC32, ifdef out specific PPC64 code or use helpers which are available on both PP32 and PPC64 Modify Makefile to always build interrupt.o

Re: [PATCH v5 05/22] powerpc/irq: Add helper to set regs->softe

2021-02-08 Thread Christophe Leroy
Le 09/02/2021 à 02:11, Nicholas Piggin a écrit : Excerpts from Christophe Leroy's message of February 9, 2021 1:10 am: regs->softe doesn't exist on PPC32. Add irq_soft_mask_regs_set_state() helper to set regs->softe. This helper will void on PPC32. Signed-off-by: Christophe Leroy ---

Re: [PATCH v7 32/42] powerpc/64: context tracking move to interrupt wrappers

2021-02-08 Thread Christophe Leroy
Le 30/01/2021 à 14:08, Nicholas Piggin a écrit : This moves exception_enter/exit calls to wrapper functions for synchronous interrupts. More interrupt handlers are covered by this than previously. Why did you enclose everything in #ifdef CONFIG_PPC64 ? As far as I understand, before this

Re: [PATCH v5 20/22] powerpc/syscall: Avoid storing 'current' in another pointer

2021-02-08 Thread Nicholas Piggin
Excerpts from Christophe Leroy's message of February 9, 2021 1:10 am: > By saving the pointer pointing to thread_info.flags, gcc copies r2 > in a non-volatile register. > > We know 'current' doesn't change, so avoid that intermediaite pointer. > > Reduces null_syscall benchmark by 2 cycles (322

Re: [PATCH v5 19/22] powerpc/syscall: Optimise checks in beginning of system_call_exception()

2021-02-08 Thread Nicholas Piggin
Excerpts from Christophe Leroy's message of February 9, 2021 1:10 am: > Combine all tests of regs->msr into a single logical one. Okay by me unless we choose to do the config option and put these all under it. I think I would prefer that because sometimes the registers are in a state you can't

Re: [PATCH v5 18/22] powerpc/syscall: Remove FULL_REGS verification in system_call_exception

2021-02-08 Thread Nicholas Piggin
Excerpts from Christophe Leroy's message of February 9, 2021 1:10 am: > For book3s/64, FULL_REGS() is 'true' at all time, so the test voids. > For others, non volatile registers are saved inconditionally. > > So the verification is pointless. > > Should one fail to do it, it would anyway be

Re: [PATCH v5 17/22] powerpc/syscall: Do not check unsupported scv vector on PPC32

2021-02-08 Thread Nicholas Piggin
Excerpts from Christophe Leroy's message of February 9, 2021 1:10 am: > Only PPC64 has scv. No need to check the 0x7ff0 trap on PPC32. > For that, add a helper trap_is_unsupported_scv() similar to > trap_is_scv(). > > And ignore the scv parameter in syscall_exit_prepare (Save 14 cycles > 346 =>

Re: [PATCH v5 16/22] powerpc/syscall: Avoid stack frame in likely part of system_call_exception()

2021-02-08 Thread Nicholas Piggin
Excerpts from Christophe Leroy's message of February 9, 2021 1:10 am: > When r3 is not modified, reload it from regs->orig_r3 to free > volatile registers. This avoids a stack frame for the likely part > of system_call_exception() This doesn't on my 64s build, but it does reduce one non volatile

Re: [PATCH v5 12/22] powerpc/syscall: Change condition to check MSR_RI

2021-02-08 Thread Nicholas Piggin
Excerpts from Christophe Leroy's message of February 9, 2021 1:10 am: > In system_call_exception(), MSR_RI also needs to be checked on 8xx. > Only booke and 40x doesn't have MSR_RI. Reviewed-by: Nicholas Piggin ... > > Signed-off-by: Christophe Leroy > --- > v5: Also in interrupt exit prepare

Re: [PATCH v5 11/22] powerpc/syscall: Save r3 in regs->orig_r3

2021-02-08 Thread Nicholas Piggin
Excerpts from Christophe Leroy's message of February 9, 2021 1:10 am: > Save r3 in regs->orig_r3 in system_call_exception() > > Signed-off-by: Christophe Leroy Reviewed-by: Nicholas Piggin > --- > v5: Removed the assembly one on SCV type system call > --- > arch/powerpc/kernel/entry_64.S |

Re: [PATCH v5 10/22] powerpc/syscall: Use is_compat_task()

2021-02-08 Thread Nicholas Piggin
Excerpts from Christophe Leroy's message of February 9, 2021 1:10 am: > Instead of hard comparing task flags with _TIF_32BIT, use > is_compat_task(). The advantage is that it returns 0 on PPC32 > allthough _TIF_32BIT is always set. > > Signed-off-by: Christophe Leroy Reviewed-by: Nicholas

Re: [PATCH v5 09/22] powerpc/syscall: Make interrupt.c buildable on PPC32

2021-02-08 Thread Nicholas Piggin
Excerpts from Christophe Leroy's message of February 9, 2021 1:10 am: > To allow building interrupt.c on PPC32, ifdef out specific PPC64 > code or use helpers which are available on both PP32 and PPC64 > > Modify Makefile to always build interrupt.o > > Signed-off-by: Christophe Leroy > --- >

Re: [PATCH v5 08/22] powerpc/syscall: Rename syscall_64.c into interrupt.c

2021-02-08 Thread Nicholas Piggin
Excerpts from Christophe Leroy's message of February 9, 2021 1:10 am: > syscall_64.c will be reused almost as is for PPC32. > > As this file also contains functions to handle other types > of interrupts rename it interrupt.c > > Signed-off-by: Christophe Leroy Reviewed-by: Nicholas Piggin >

Re: [PATCH v5 07/22] powerpc/irq: Add stub irq_soft_mask_return() for PPC32

2021-02-08 Thread Nicholas Piggin
Excerpts from Christophe Leroy's message of February 9, 2021 1:10 am: > To allow building syscall_64.c smoothly on PPC32, add stub version > of irq_soft_mask_return(). > > Signed-off-by: Christophe Leroy Same kind of comment as the other soft mask stuff. Again not a big deal but there might be

Re: [PATCH v5 06/22] powerpc/irq: Rework helpers that manipulate MSR[EE/RI]

2021-02-08 Thread Nicholas Piggin
Excerpts from Christophe Leroy's message of February 9, 2021 1:10 am: > In preparation of porting PPC32 to C syscall entry/exit, > rewrite the following helpers as static inline functions and > add support for PPC32 in them: > __hard_irq_enable() > __hard_irq_disable() >

Re: [PATCH v5 05/22] powerpc/irq: Add helper to set regs->softe

2021-02-08 Thread Nicholas Piggin
Excerpts from Christophe Leroy's message of February 9, 2021 1:10 am: > regs->softe doesn't exist on PPC32. > > Add irq_soft_mask_regs_set_state() helper to set regs->softe. > This helper will void on PPC32. > > Signed-off-by: Christophe Leroy > --- > arch/powerpc/include/asm/hw_irq.h | 11

Re: [PATCH v5 00/22] powerpc/32: Implement C syscall entry/exit

2021-02-08 Thread Nicholas Piggin
Excerpts from Christophe Leroy's message of February 9, 2021 1:10 am: > This series implements C syscall entry/exit for PPC32. It reuses > the work already done for PPC64. > > This series is based on today's merge-test > (b6f72fc05389e3fc694bf5a5fa1bbd33f61879e0) > > In terms on performance we

Re: [PATCH v2 2/2] memblock: do not start bottom-up allocations with kernel_end

2021-02-08 Thread Thiago Jung Bauermann
Mike Rapoport writes: > On Sat, Jan 23, 2021 at 06:09:11PM -0800, Andrew Morton wrote: >> On Fri, 22 Jan 2021 01:37:14 -0300 Thiago Jung Bauermann >> wrote: >> >> > Mike Rapoport writes: >> > >> > > > Signed-off-by: Roman Gushchin >> > > >> > > Reviewed-by: Mike Rapoport >> > >> >

[PATCH v5 05/10] powerpc: dts: akebono: Harmonize EHCI/OHCI DT nodes name

2021-02-08 Thread Serge Semin
In accordance with the Generic EHCI/OHCI bindings the corresponding node name is suppose to comply with the Generic USB HCD DT schema, which requires the USB nodes to have the name acceptable by the regexp: "^usb(@.*)?" . Make sure the "generic-ehci" and "generic-ohci"-compatible nodes are

[PATCH v5 00/10] dt-bindings: usb: Harmonize xHCI/EHCI/OHCI/DWC3 nodes name

2021-02-08 Thread Serge Semin
As the subject states this series is an attempt to harmonize the xHCI, EHCI, OHCI and DWC USB3 DT nodes with the DT schema introduced in the framework of the patchset [1]. Firstly as Krzysztof suggested we've deprecated a support of DWC USB3 controllers with "synopsys,"-vendor prefix compatible

Re: [PATCH] ASoC: fsl: constify static snd_soc_dai_ops structs

2021-02-08 Thread Mark Brown
On Sat, 6 Feb 2021 23:58:49 +0100, Rikard Falkeborn wrote: > The only usage of these is to assign their address to the 'ops' field in > the snd_soc_dai_driver struct, which is a pointer to const. Make them > const to allow the compiler to put them in read-only memory. Applied to

Re: [PATCH v4 11/23] powerpc/syscall: Rename syscall_64.c into syscall.c

2021-02-08 Thread Christophe Leroy
Le 26/01/2021 à 11:21, Nicholas Piggin a écrit : Excerpts from Christophe Leroy's message of January 26, 2021 12:48 am: syscall_64.c will be reused almost as is for PPC32. Rename it syscall.c Could you rename it to interrupt.c instead? A system call is an interrupt, and the file now also

Re: [PATCH v4 14/23] powerpc/syscall: Save r3 in regs->orig_r3

2021-02-08 Thread Christophe Leroy
Le 26/01/2021 à 11:18, Nicholas Piggin a écrit : Excerpts from Christophe Leroy's message of January 26, 2021 12:48 am: Save r3 in regs->orig_r3 in system_call_exception() Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/entry_64.S | 1 - arch/powerpc/kernel/syscall.c | 2 ++ 2

Re: [PATCH v4 20/23] powerpc/syscall: Do not check unsupported scv vector on PPC32

2021-02-08 Thread Christophe Leroy
Le 26/01/2021 à 11:16, Nicholas Piggin a écrit : Excerpts from Christophe Leroy's message of January 26, 2021 12:48 am: Only PPC64 has scv. No need to check the 0x7ff0 trap on PPC32. And ignore the scv parameter in syscall_exit_prepare (Save 14 cycles 346 => 332 cycles) Signed-off-by:

Re: [RFC PATCH 1/3] powerpc/lib: implement strlen() in assembly for PPC64

2021-02-08 Thread Christophe Leroy
Le 05/07/2018 à 10:53, Christophe Leroy a écrit : The generic implementation of strlen() reads strings byte per byte. This patch implements strlen() in assembly based on a read of entire words, in the same spirit as what some other arches and glibc do. strlen() selftest on an

Re: [PATCH 2/8] powerpc/signal: Add unsafe_copy_{vsx, fpr}_from_user()

2021-02-08 Thread Christophe Leroy
Le 08/02/2021 à 18:14, Christopher M. Riedl a écrit : On Sun Feb 7, 2021 at 4:12 AM CST, Christophe Leroy wrote: Le 06/02/2021 à 18:39, Christopher M. Riedl a écrit : On Sat Feb 6, 2021 at 10:32 AM CST, Christophe Leroy wrote: Le 20/10/2020 à 04:01, Christopher M. Riedl a écrit : On

Re: [PATCH 2/8] powerpc/signal: Add unsafe_copy_{vsx,fpr}_from_user()

2021-02-08 Thread Christopher M. Riedl
On Sun Feb 7, 2021 at 4:12 AM CST, Christophe Leroy wrote: > > > Le 06/02/2021 à 18:39, Christopher M. Riedl a écrit : > > On Sat Feb 6, 2021 at 10:32 AM CST, Christophe Leroy wrote: > >> > >> > >> Le 20/10/2020 à 04:01, Christopher M. Riedl a écrit : > >>> On Fri Oct 16, 2020 at 10:48 AM CDT,

Re: [PATCH v2 1/1] powerpc/kvm: Save Timebase Offset to fix sched_clock() while running guest code.

2021-02-08 Thread Leonardo Bras
Hello Nick, On Sat, 2021-02-06 at 13:03 +1000, Nicholas Piggin wrote: > Excerpts from Leonardo Bras's message of February 5, 2021 5:01 pm: > > Hey Nick, thanks for reviewing :) > > > > On Fri, 2021-02-05 at 16:28 +1000, Nicholas Piggin wrote: > > > Excerpts from Leonardo Bras's message of

[PATCH v5 22/22] powerpc/32: Handle bookE debugging in C in syscall entry/exit

2021-02-08 Thread Christophe Leroy
The handling of SPRN_DBCR0 and other registers can easily be done in C instead of ASM. Signed-off-by: Christophe Leroy --- v5: New --- arch/powerpc/include/asm/reg_booke.h | 3 +++ arch/powerpc/kernel/entry_32.S | 7 --- arch/powerpc/kernel/head_32.h| 15 --

[PATCH v5 21/22] powerpc/32: Remove the counter in global_dbcr0

2021-02-08 Thread Christophe Leroy
global_dbcr0 has two parts, 4 bytes to save/restore the value of SPRN_DBCR0, and 4 bytes that are incremented/decremented everytime something is saving/loading the above value. This counter is only incremented/decremented, its value is never used and never read. Remove the counter and devide the

[PATCH v5 20/22] powerpc/syscall: Avoid storing 'current' in another pointer

2021-02-08 Thread Christophe Leroy
By saving the pointer pointing to thread_info.flags, gcc copies r2 in a non-volatile register. We know 'current' doesn't change, so avoid that intermediaite pointer. Reduces null_syscall benchmark by 2 cycles (322 => 320 cycles) On PPC64, gcc seems to know that 'current' is not changing, and it

[PATCH v5 19/22] powerpc/syscall: Optimise checks in beginning of system_call_exception()

2021-02-08 Thread Christophe Leroy
Combine all tests of regs->msr into a single logical one. Before the patch: 0: 81 6a 00 84 lwz r11,132(r10) 4: 90 6a 00 88 stw r3,136(r10) 8: 69 60 00 02 xorir0,r11,2 c: 54 00 ff fe rlwinm r0,r0,31,31,31 10: 0f 00 00 00 twnei r0,0 14:

[PATCH v5 18/22] powerpc/syscall: Remove FULL_REGS verification in system_call_exception

2021-02-08 Thread Christophe Leroy
For book3s/64, FULL_REGS() is 'true' at all time, so the test voids. For others, non volatile registers are saved inconditionally. So the verification is pointless. Should one fail to do it, it would anyway be caught by the CHECK_FULL_REGS() in copy_thread() as we have removed the special

[PATCH v5 17/22] powerpc/syscall: Do not check unsupported scv vector on PPC32

2021-02-08 Thread Christophe Leroy
Only PPC64 has scv. No need to check the 0x7ff0 trap on PPC32. For that, add a helper trap_is_unsupported_scv() similar to trap_is_scv(). And ignore the scv parameter in syscall_exit_prepare (Save 14 cycles 346 => 332 cycles) Signed-off-by: Christophe Leroy --- v5: Added a helper

[PATCH v5 16/22] powerpc/syscall: Avoid stack frame in likely part of system_call_exception()

2021-02-08 Thread Christophe Leroy
When r3 is not modified, reload it from regs->orig_r3 to free volatile registers. This avoids a stack frame for the likely part of system_call_exception() Before the patch: c000b4d4 : c000b4d4: 7c 08 02 a6 mflrr0 c000b4d8: 94 21 ff e0 stwur1,-32(r1) c000b4dc: 93

[PATCH v5 15/22] powerpc/32: Remove verification of MSR_PR on syscall in the ASM entry

2021-02-08 Thread Christophe Leroy
system_call_exception() checks MSR_PR and BUGs if a syscall is issued from kernel mode. No need to handle it anymore from the ASM entry code. null_syscall reduction 2 cycles (348 => 346 cycles) Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/entry_32.S | 30

[PATCH v5 13/22] powerpc/32: Always save non volatile GPRs at syscall entry

2021-02-08 Thread Christophe Leroy
In preparation for porting syscall entry/exit to C, inconditionally save non volatile general purpose registers. Commit 965dd3ad3076 ("powerpc/64/syscall: Remove non-volatile GPR save optimisation") provides detailed explanation. This increases the number of cycles by 24 cycles on 8xx with

[PATCH v5 14/22] powerpc/syscall: implement system call entry/exit logic in C for PPC32

2021-02-08 Thread Christophe Leroy
That's port of PPC64 syscall entry/exit logic in C to PPC32. Performancewise on 8xx: Before : 304 cycles on null_syscall After : 348 cycles on null_syscall Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/entry_32.S | 224 +-- arch/powerpc/kernel/head_32.h

[PATCH v5 12/22] powerpc/syscall: Change condition to check MSR_RI

2021-02-08 Thread Christophe Leroy
In system_call_exception(), MSR_RI also needs to be checked on 8xx. Only booke and 40x doesn't have MSR_RI. Signed-off-by: Christophe Leroy --- v5: Also in interrupt exit prepare --- arch/powerpc/kernel/interrupt.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git

[PATCH v5 09/22] powerpc/syscall: Make interrupt.c buildable on PPC32

2021-02-08 Thread Christophe Leroy
To allow building interrupt.c on PPC32, ifdef out specific PPC64 code or use helpers which are available on both PP32 and PPC64 Modify Makefile to always build interrupt.o Signed-off-by: Christophe Leroy --- v5: - Also for interrupt exit preparation - Opted out kuap related code, ppc32 keeps it

[PATCH v5 10/22] powerpc/syscall: Use is_compat_task()

2021-02-08 Thread Christophe Leroy
Instead of hard comparing task flags with _TIF_32BIT, use is_compat_task(). The advantage is that it returns 0 on PPC32 allthough _TIF_32BIT is always set. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/interrupt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git

[PATCH v5 07/22] powerpc/irq: Add stub irq_soft_mask_return() for PPC32

2021-02-08 Thread Christophe Leroy
To allow building syscall_64.c smoothly on PPC32, add stub version of irq_soft_mask_return(). Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/hw_irq.h | 5 + 1 file changed, 5 insertions(+) diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h

[PATCH v5 11/22] powerpc/syscall: Save r3 in regs->orig_r3

2021-02-08 Thread Christophe Leroy
Save r3 in regs->orig_r3 in system_call_exception() Signed-off-by: Christophe Leroy --- v5: Removed the assembly one on SCV type system call --- arch/powerpc/kernel/entry_64.S | 2 -- arch/powerpc/kernel/interrupt.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git

[PATCH v5 08/22] powerpc/syscall: Rename syscall_64.c into interrupt.c

2021-02-08 Thread Christophe Leroy
syscall_64.c will be reused almost as is for PPC32. As this file also contains functions to handle other types of interrupts rename it interrupt.c Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/Makefile | 2 +- arch/powerpc/kernel/{syscall_64.c => interrupt.c} | 0

[PATCH v5 06/22] powerpc/irq: Rework helpers that manipulate MSR[EE/RI]

2021-02-08 Thread Christophe Leroy
In preparation of porting PPC32 to C syscall entry/exit, rewrite the following helpers as static inline functions and add support for PPC32 in them: __hard_irq_enable() __hard_irq_disable() __hard_EE_RI_disable() __hard_RI_enable() Then use them in PPC32 version of

[PATCH v5 02/22] powerpc/32: Always enable data translation on syscall entry

2021-02-08 Thread Christophe Leroy
If the code can use a stack in vm area, it can also use a stack in linear space. Simplify code by removing old non VMAP stack code on PPC32 in syscall. That means the data translation is now re-enabled early in syscall entry in all cases, not only when using VMAP stacks. Signed-off-by:

[PATCH v5 05/22] powerpc/irq: Add helper to set regs->softe

2021-02-08 Thread Christophe Leroy
regs->softe doesn't exist on PPC32. Add irq_soft_mask_regs_set_state() helper to set regs->softe. This helper will void on PPC32. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/hw_irq.h | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git

[PATCH v5 00/22] powerpc/32: Implement C syscall entry/exit

2021-02-08 Thread Christophe Leroy
This series implements C syscall entry/exit for PPC32. It reuses the work already done for PPC64. This series is based on today's merge-test (b6f72fc05389e3fc694bf5a5fa1bbd33f61879e0) In terms on performance we have the following number of cycles on an 8xx running null_syscall benchmark: -

[PATCH v5 04/22] powerpc/32: Reorder instructions to avoid using CTR in syscall entry

2021-02-08 Thread Christophe Leroy
Now that we are using rfi instead of mtmsr to reactivate MMU, it is possible to reorder instructions and avoid the need to use CTR for stashing SRR0. null_syscall on 8xx is reduced by 3 cycles (283 => 280 cycles). Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/head_32.h | 22

[PATCH v5 03/22] powerpc/32: On syscall entry, enable instruction translation at the same time as data

2021-02-08 Thread Christophe Leroy
On 40x and 8xx, kernel text is pinned. On book3s/32, kernel text is mapped by BATs. Enable instruction translation at the same time as data translation, it makes things simpler. MSR_RI can also be set at the same time because srr0/srr1 are already saved and r1 is set properly. On booke,

[PATCH v5 01/22] powerpc/32s: Add missing call to kuep_lock on syscall entry

2021-02-08 Thread Christophe Leroy
Userspace Execution protection and fast syscall entry were implemented independently from each other and were both merged in kernel 5.2, leading to syscall entry missing userspace execution protection. On syscall entry, execution of user space memory must be locked in the same way as on exception

[PATCH 2/2] powerpc/uaccess: Move might_fault() into user_access_begin()

2021-02-08 Thread Michael Ellerman
We have a might_fault() check in __unsafe_put_user_goto(), but that is dangerous as it potentially calls lots of code while user access is enabled. It also triggers the check Alexey added to the irq restore path to catch cases like that: WARNING: CPU: 30 PID: 1 at

[PATCH 1/2] powerpc/uaccess: Simplify unsafe_put_user() implementation

2021-02-08 Thread Michael Ellerman
Currently unsafe_put_user() expands to __put_user_goto(), which expands to __put_user_nocheck_goto(). There are no other uses of __put_user_nocheck_goto(), and although there are some other uses of __put_user_goto() those could just use unsafe_put_user(). Every layer of indirection introduces

Re: [PATCH v7 07/42] powerpc/fsl_booke/32: CacheLockingException remove args

2021-02-08 Thread Michael Ellerman
Gautham R Shenoy writes: > On Sat, Jan 30, 2021 at 11:08:17PM +1000, Nicholas Piggin wrote: >> Like other interrupt handler conversions, switch to getting registers >> from the pt_regs argument. >> >> Signed-off-by: Nicholas Piggin >> --- >> arch/powerpc/kernel/head_fsl_booke.S | 6 +++--- >>

Re: module loader dead code removal and cleanups v3

2021-02-08 Thread Jessica Yu
+++ Christoph Hellwig [02/02/21 13:13 +0100]: Hi all, this series removes support for long term unused export types and cleans up various loose ends in the module loader. Changes since v2: - clean up klp_find_object_symbol a bit - remove the now unused module_assert_mutex helper Changes since

Re: [PATCH v2] powerpc/uprobes: Validation for prefixed instruction

2021-02-08 Thread Ravi Bangoria
On 2/4/21 6:38 PM, Naveen N. Rao wrote: On 2021/02/04 04:17PM, Ravi Bangoria wrote: Don't allow Uprobe on 2nd word of a prefixed instruction. As per ISA 3.1, prefixed instruction should not cross 64-byte boundary. So don't allow Uprobe on such prefixed instruction as well. There are two

Re: [PATCH v2] powerpc/uprobes: Validation for prefixed instruction

2021-02-08 Thread Ravi Bangoria
On 2/4/21 9:42 PM, Naveen N. Rao wrote: On 2021/02/04 06:38PM, Naveen N. Rao wrote: On 2021/02/04 04:17PM, Ravi Bangoria wrote: Don't allow Uprobe on 2nd word of a prefixed instruction. As per ISA 3.1, prefixed instruction should not cross 64-byte boundary. So don't allow Uprobe on such

Re: [PATCH v2] powerpc/uprobes: Validation for prefixed instruction

2021-02-08 Thread Ravi Bangoria
On 2/4/21 6:45 PM, Naveen N. Rao wrote: On 2021/02/04 04:19PM, Ravi Bangoria wrote: On 2/4/21 4:17 PM, Ravi Bangoria wrote: Don't allow Uprobe on 2nd word of a prefixed instruction. As per ISA 3.1, prefixed instruction should not cross 64-byte boundary. So don't allow Uprobe on such

Re: [PATCH v2] powerpc/uprobes: Validation for prefixed instruction

2021-02-08 Thread Ravi Bangoria
On 2/6/21 11:36 PM, Oleg Nesterov wrote: On 02/04, Ravi Bangoria wrote: +static int get_instr(struct mm_struct *mm, unsigned long addr, u32 *instr) +{ + struct page *page; + struct vm_area_struct *vma; + void *kaddr; + unsigned int gup_flags = FOLL_FORCE |

[PATCH] selftests/powerpc: remove unneeded semicolon

2021-02-08 Thread Yang Li
Eliminate the following coccicheck warning: ./tools/testing/selftests/powerpc/nx-gzip/gzfht_test.c:327:4-5: Unneeded semicolon Reported-by: Abaci Robot Signed-off-by: Yang Li --- tools/testing/selftests/powerpc/nx-gzip/gzfht_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff

Re: [PATCH v7 07/42] powerpc/fsl_booke/32: CacheLockingException remove args

2021-02-08 Thread Gautham R Shenoy
On Sat, Jan 30, 2021 at 11:08:17PM +1000, Nicholas Piggin wrote: > Like other interrupt handler conversions, switch to getting registers > from the pt_regs argument. > > Signed-off-by: Nicholas Piggin > --- > arch/powerpc/kernel/head_fsl_booke.S | 6 +++--- > arch/powerpc/kernel/traps.c

[PATCH] crypto: sha: remove unneeded semicolon

2021-02-08 Thread Yang Li
Eliminate the following coccicheck warning: ./arch/powerpc/crypto/sha1-spe-glue.c:110:2-3: Unneeded semicolon Reported-by: Abaci Robot Signed-off-by: Yang Li --- arch/powerpc/crypto/sha1-spe-glue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git