[PATCH v2 04/14] powerpc/40x: Change CRITICAL_EXCEPTION_PROLOG macro to a gas macro

2021-01-22 Thread Christophe Leroy
Change CRITICAL_EXCEPTION_PROLOG macro to a gas macro to remove the ugly ; and \ on each line. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/head_40x.S | 71 +- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/arch/powerpc/kernel/head_40x.

[PATCH v2 02/14] NOT TO BE MERGED - Squash of patches 2-7 of v6 series "powerpc: interrupt wrappers"

2021-01-22 Thread Christophe Leroy
powerpc/32s: move DABR match out of handle_page_fault handle_page_fault() has some code dedicated to book3s/32 to call do_break() when the DSI is a DABR match. On other platforms, do_break() is handled separately. Do the same for book3s/32, do it earlier in the process of DSI. This change also

[PATCH v2 03/14] powerpc/40x: Don't use SPRN_SPRG_SCRATCH0/1 in TLB miss handlers

2021-01-22 Thread Christophe Leroy
SPRN_SPRG_SCRATCH5 is used to save SPRN_PID. SPRN_SPRG_SCRATCH6 is already available. SPRN_PID is only 8 bits. We have r12 that contains CR. We only need to preserve CR0, so we have space available in r12 to save PID. Keep PID in r12 and free up SPRN_SPRG_SCRATCH5. Then In TLB miss handlers, ins

[PATCH v2 01/14] powerpc/32s: Only build hash code when CONFIG_PPC_BOOK3S_604 is selected

2021-01-22 Thread Christophe Leroy
It is now possible to only build book3s/32 kernel for CPUs without hash table. Opt out hash related code when CONFIG_PPC_BOOK3S_604 is not selected. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/head_book3s_32.S | 12 arch/powerpc/mm/book3s32/Makefile| 4 +++- 2 file

[PATCH v2 00/14] powerpc/32: Reduce head complexity and re-activate MMU earlier

2021-01-22 Thread Christophe Leroy
This series is a first step on the way to C syscall/exception entry/exit. This series aims at reducing exception/syscall prologs complexity. It also brings earlier MMU re-activation. This series is based on Nick's v6 series "powerpc: interrupt wrappers". It takes benefit of the removal of traps a

[PATCH v2 09/14] powerpc/32: Preserve cr1 in exception prolog stack check

2021-01-22 Thread Christophe Leroy
THREAD_ALIGN_SHIFT = THREAD_SHIFT + 1 = PAGE_SHIFT + 1 Maximum PAGE_SHIFT is 18 for 256k pages so THREAD_ALIGN_SHIFT is 19 at the maximum. No need to clobber cr1, it can be preserved when moving r1 into CR when we check stack overflow. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/hea

[PATCH v2 10/14] powerpc/32: Use LOAD_REG_IMMEDIATE() to load MSR values

2021-01-22 Thread Christophe Leroy
40x MSR value doesn't fit on 15 bits. LOAD_REG_IMMEDIATE() in places that will be used also with 40x in the next patch. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/head_32.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/head_32.h b/arch/

[PATCH v2 13/14] powerpc/32: Remove msr argument in EXC_XFER_TEMPLATE()

2021-01-22 Thread Christophe Leroy
msr argument is not used anymore, remove it. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/head_32.h | 8 +++- arch/powerpc/kernel/head_40x.S | 5 + 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/kernel/head_32.h b/arch/powerpc/kernel/head_32.h ind

[PATCH v2 05/14] powerpc/40x: Save SRR0/SRR1 and r10/r11 earlier in critical exception

2021-01-22 Thread Christophe Leroy
In order to be able to switch MMU on in exception prolog, save SRR0 and SRR1 earlier. Also save r10 and r11 into stack earlier to better match with the normal exception prolog. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/entry_32.S | 9 - arch/powerpc/kernel/head_40x.S | 8 +

[PATCH v2 07/14] powerpc/40x: Prepare for enabling MMU in critical exception prolog

2021-01-22 Thread Christophe Leroy
In order the enable MMU early in exception prolog, implement CONFIG_VMAP_STACK principles in critical exception prolog. There is no intention to use CONFIG_VMAP_STACK on 40x, but related code will be used to enable MMU early in exception in a later patch. Also address (critirq_ctx-PAGE_OFFSET) di

[PATCH v2 11/14] powerpc/32: Always enable data translation in exception prolog

2021-01-22 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. That means the data translation is now re-enabled early in exception prolog in all cases, not only when using VMAP stacks. Signed-off-by: Christophe Leroy

[PATCH v2 12/14] powerpc/32: Enable instruction translation at the same time as data translation

2021-01-22 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. In syscall handler, MSR_RI can also be set at the same time because srr0/srr1 are already saved and r1 is set properly.

[PATCH v2 08/14] powerpc/40x: Prepare normal exception handler for enabling MMU early

2021-01-22 Thread Christophe Leroy
Ensure normal exception handler are able to manage stuff with MMU enabled. For that we use CONFIG_VMAP_STACK related code allthough there is no intention to really activate CONFIG_VMAP_STACK on powerpc 40x for the moment. 40x uses SPRN_DEAR instead of SPRN_DAR and SPRN_ESR instead of SPRN_DSISR. T

[PATCH v2 06/14] powerpc/40x: Reorder a few instructions in critical exception prolog

2021-01-22 Thread Christophe Leroy
In order to ease preparation for CONFIG_VMAP_STACK, reorder a few instruction, especially save r1 into stack frame earlier. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/head_40x.S | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/kernel/head_40x.

[PATCH v2 14/14] powerpc/32: Use fast instructions to change MSR EE/RI when available

2021-01-22 Thread Christophe Leroy
Booke and 40x have wrtee and wrteei to quickly change MSR EE. 8xx has registers SPRN_NRI, SPRN_EID and SPRN_EIE for changing MSR EE and RI. Use them in syscall and exception handler when possible. On an 8xx, it reduces the null_syscall test by 6 cycles (Two instances are changed in this patch, m

Re: [PATCH v2] powerpc/64/signal: balance return predictor stack in signal trampoline

2021-01-22 Thread Florian Weimer
* Nicholas Piggin: > diff --git a/arch/powerpc/kernel/vdso64/sigtramp.S > b/arch/powerpc/kernel/vdso64/sigtramp.S > index a8cc0409d7d2..bbf68cd01088 100644 > --- a/arch/powerpc/kernel/vdso64/sigtramp.S > +++ b/arch/powerpc/kernel/vdso64/sigtramp.S > @@ -6,6 +6,7 @@ > * Copyright (C) 2004 Benjam

[PATCH v4 1/2] powerpc/mce: Reduce the size of event arrays

2021-01-22 Thread Ganesh Goudar
Maximum recursive depth of MCE is 4, Considering the maximum depth allowed reduce the size of event to 10 from 100. This saves us ~19kB of memory and has no fatal consequences. Signed-off-by: Ganesh Goudar --- v4: This patch is a fragment of the orignal patch which is split into two. --- ar

[PATCH v4 2/2] powerpc/mce: Remove per cpu variables from MCE handlers

2021-01-22 Thread Ganesh Goudar
Access to per-cpu variables requires translation to be enabled on pseries machine running in hash mmu mode, Since part of MCE handler runs in realmode and part of MCE handling code is shared between ppc architectures pseries and powernv, it becomes difficult to manage these variables differently on

Re: [PATCH] powerpc/prom: Fix "ibm,arch-vec-5-platform-support" scan

2021-01-22 Thread Fabiano Rosas
Cédric Le Goater writes: > The "ibm,arch-vec-5-platform-support" property is a list of pairs of > bytes representing the options and values supported by the platform > firmware. At boot time, Linux scans this list and activates the > available features it recognizes : Radix and XIVE. > > A recent

Re: [musl] Re: [PATCH v2] powerpc/64/signal: balance return predictor stack in signal trampoline

2021-01-22 Thread Rich Felker
On Fri, Jan 22, 2021 at 12:27:14PM +0100, Florian Weimer wrote: > * Nicholas Piggin: > > > diff --git a/arch/powerpc/kernel/vdso64/sigtramp.S > > b/arch/powerpc/kernel/vdso64/sigtramp.S > > index a8cc0409d7d2..bbf68cd01088 100644 > > --- a/arch/powerpc/kernel/vdso64/sigtramp.S > > +++ b/arch/powe

Re: [PATCH v2] powerpc/64/signal: balance return predictor stack in signal trampoline

2021-01-22 Thread Raoni Fassina Firmino
On Fri, Jan 22, 2021 at 12:27:14PM +0100, AL glibc-alpha wrote: > * Nicholas Piggin: > > > diff --git a/arch/powerpc/kernel/vdso64/sigtramp.S > > b/arch/powerpc/kernel/vdso64/sigtramp.S > > index a8cc0409d7d2..bbf68cd01088 100644 > > --- a/arch/powerpc/kernel/vdso64/sigtramp.S > > +++ b/arch/powe

Re: [musl] Re: [PATCH v2] powerpc/64/signal: balance return predictor stack in signal trampoline

2021-01-22 Thread Raoni Fassina Firmino
On Fri, Jan 22, 2021 at 09:44:05AM -0500, Rich Felker wrote: > Maybe I'm missing something but I don't see how this would break musl; > we just inspect the PC in the mcontext, which I don't see any changes > to and which should still point to the next instruction of the > interrupted context. I don

Re: [musl] Re: [PATCH v2] powerpc/64/signal: balance return predictor stack in signal trampoline

2021-01-22 Thread Rich Felker
On Fri, Jan 22, 2021 at 03:19:22PM -0300, Raoni Fassina Firmino wrote: > On Fri, Jan 22, 2021 at 09:44:05AM -0500, Rich Felker wrote: > > Maybe I'm missing something but I don't see how this would break musl; > > we just inspect the PC in the mcontext, which I don't see any changes > > to and which

Re: [musl] Re: [PATCH v2] powerpc/64/signal: balance return predictor stack in signal trampoline

2021-01-22 Thread Raoni Fassina Firmino
On Fri, Jan 22, 2021 at 01:31:27PM -0500, Rich Felker wrote: > On Fri, Jan 22, 2021 at 03:19:22PM -0300, Raoni Fassina Firmino wrote: > > On Fri, Jan 22, 2021 at 09:44:05AM -0500, Rich Felker wrote: > > > Maybe I'm missing something but I don't see how this would break musl; > > > we just inspect t

Re: [PATCH 1/2] ima: Free IMA measurement buffer on error

2021-01-22 Thread Thiago Jung Bauermann
Hi Lakshmi, Lakshmi Ramasubramanian writes: > IMA allocates kernel virtual memory to carry forward the measurement > list, from the current kernel to the next kernel on kexec system call, > in ima_add_kexec_buffer() function. In error code paths this memory > is not freed resulting in memory

Re: [PATCH 2/2] ima: Free IMA measurement buffer after kexec syscall

2021-01-22 Thread Thiago Jung Bauermann
Lakshmi Ramasubramanian writes: > IMA allocates kernel virtual memory to carry forward the measurement > list, from the current kernel to the next kernel on kexec system call, > in ima_add_kexec_buffer() function. This buffer is not freed before > completing the kexec system call resulting in

Re: [PATCH] lib/sstep: Fix incorrect return from analyze_instr()

2021-01-22 Thread Michael Ellerman
Ananth N Mavinakayanahalli writes: > We currently just percolate the return value from analyze_instr() > to the caller of emulate_step(), especially if it is a -1. > > For one particular case (opcode = 4) for instructions that > aren't currently emulated, we are returning 'should not be > single-s

Re: [PATCH 6/6] powerpc/rtas: constrain user region allocation to RMA

2021-01-22 Thread Alexey Kardashevskiy
On 22/01/2021 02:27, Nathan Lynch wrote: Michael Ellerman writes: Nathan Lynch writes: Alexey Kardashevskiy writes: On 16/01/2021 02:38, Nathan Lynch wrote: Alexey Kardashevskiy writes: On 15/01/2021 09:00, Nathan Lynch wrote: Memory locations passed as arguments from the OS to RTAS

Re: [PATCH][next] scsi: ibmvfc: Fix spelling mistake "succeded" -> "succeeded"

2021-01-22 Thread Martin K. Petersen
On Mon, 18 Jan 2021 11:13:46 +, Colin King wrote: > There is a spelling mistake in a ibmvfc_dbg debug message. Fix it. Applied to 5.12/scsi-queue, thanks! [1/1] scsi: ibmvfc: Fix spelling mistake "succeded" -> "succeeded" https://git.kernel.org/mkp/scsi/c/ff79acc49af8 -- Martin K. Pe

[PATCH] powerpc/64s: prevent recursive replay_soft_interrupts causing superfluous interrupt

2021-01-22 Thread Nicholas Piggin
When an asynchronous interrupt calls irq_exit, it checks for softirqs that may have been created, and runs them. Running softirqs enables local irqs, which can replay pending interrupts causing recursion in replay_soft_interrupts. This abridged trace shows how this can occur: ! NIP replay_soft_int

[PATCH] powerpc/64s: interrupt exit improve bounding of interrupt recursion

2021-01-22 Thread Nicholas Piggin
When replaying pending soft-masked interrupts when an interrupt returns to an irqs-enabled context, there is a special case required if this was an asynchronous interrupt to avoid unbounded interrupt recursion. This case was not tested for in the case the asynchronous interrupt hit in user context