LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v1 16/16] powerpc/32: don't do syscall stuff in transfer_to_handler on non BOOKE
From: Christophe Leroy @ 2019-02-08 12:52 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Nicholas Piggin
  Cc: linuxppc-dev, linux-kernel
In-Reply-To: <cover.1549630193.git.christophe.leroy@c-s.fr>

As syscalls are now handled via a fast entry path, syscall related
actions can be removed from the generic transfer_to_handler path.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/kernel/entry_32.S | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 0927d5ff1e79..85f1fc88c237 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -211,7 +211,9 @@ transfer_to_handler_cont:
 	 */
 	tophys(r12, r1)
 	lwz	r12,_MSR(r12)
+#ifdef CONFIG_BOOKE	/* to be removed once BOOKE uses fast syscall entry */
 	xor	r12,r10,r12
+#endif
 	andi.	r12,r12,MSR_EE
 	bne	1f
 
@@ -252,8 +254,10 @@ reenable_mmu:
 	 * the rest is restored from the exception frame.
 	 */
 
+#ifdef CONFIG_BOOKE	/* to be removed once BOOKE uses fast syscall entry */
 	/* Are we enabling or disabling interrupts ? */
 	andi.	r0,r10,MSR_EE
+#endif
 
 	stwu	r1,-32(r1)
 	stw	r9,8(r1)
@@ -262,7 +266,9 @@ reenable_mmu:
 	stw	r4,20(r1)
 	stw	r5,24(r1)
 
+#ifdef CONFIG_BOOKE	/* to be removed once BOOKE uses fast syscall entry */
 	bne-	0f
+#endif
 
 	/* If we are disabling interrupts (normal case), simply log it with
 	 * lockdep
@@ -282,6 +288,7 @@ reenable_mmu:
 	mtlr	r9
 	bctr				/* jump to handler */
 
+#ifdef CONFIG_BOOKE	/* to be removed once BOOKE uses fast syscall entry */
 	/* If we are enabling interrupt, this is a syscall. They shouldn't
 	 * happen while interrupts are disabled, so let's do a warning here.
 	 */
@@ -294,6 +301,7 @@ reenable_mmu:
 	ori	r10,r10,MSR_EE
 	mtmsr	r10
 	b	2b
+#endif
 #endif /* CONFIG_TRACE_IRQFLAGS */
 
 #if defined (CONFIG_PPC_BOOK3S_32) || defined(CONFIG_E500)
-- 
2.13.3


^ permalink raw reply related

* Re: [PATCH 5/7] powerpc/pci: Add pci_find_hose_for_domain()
From: Oliver @ 2019-02-08 12:53 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev
In-Reply-To: <8736oyk3gz.fsf@concordia.ellerman.id.au>

On Fri, Feb 8, 2019 at 8:57 PM Michael Ellerman <mpe@ellerman.id.au> wrote:
>
> Oliver O'Halloran <oohall@gmail.com> writes:
> > diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h
> > index aee4fcc24990..149053b7f481 100644
> > --- a/arch/powerpc/include/asm/pci-bridge.h
> > +++ b/arch/powerpc/include/asm/pci-bridge.h
> > @@ -274,6 +274,8 @@ extern int pcibios_map_io_space(struct pci_bus *bus);
> >  extern struct pci_controller *pci_find_hose_for_OF_device(
> >                       struct device_node* node);
> >
> > +extern struct pci_controller *pci_find_hose_for_domain(uint32_t domain_nr);
>
> I know we use "hose" a lot in the PCI code, but it's a stupid name. Can
> we not introduce new usages?

I was tempted to call it pci_find_horse_for_domain(), but neigh.

>
> It returns a pci_controller so pci_find_controller_for_domain()?

ok

>
> cheers

^ permalink raw reply

* Re: [PATCH] powerpc: Make PPC_64K_PAGES depend on only 44x or PPC_BOOK3S_64
From: Christophe Leroy @ 2019-02-08 13:01 UTC (permalink / raw)
  To: Michael Ellerman, linuxppc-dev; +Cc: oss, aneesh.kumar
In-Reply-To: <20190208123416.1051-1-mpe@ellerman.id.au>



On 02/08/2019 12:34 PM, Michael Ellerman wrote:
> In commit 7820856a4fcd ("powerpc/mm/book3e/64: Remove unsupported
> 64Kpage size from 64bit booke") we dropped the 64K page size support
> from the 64-bit nohash (Book3E) code.
> 
> But we didn't update the dependencies of the PPC_64K_PAGES option,
> meaning a randconfig can still trigger this code and cause a build
> breakage, eg:
>    arch/powerpc/include/asm/nohash/64/pgtable.h:14:2: error: #error "Page size not supported"
>    arch/powerpc/include/asm/nohash/mmu-book3e.h:275:2: error: #error Unsupported page size
> 
> So remove PPC_BOOK3E_64 from the dependencies. This also means we
> don't need to worry about PPC_FSL_BOOK3E, because that was just trying
> to prevent the PPC_BOOK3E_64=y && PPC_FSL_BOOK3E=y case.

Does it means some cleanup could be done, for instance:

arch/powerpc/include/asm/nohash/64/pgalloc.h:#ifndef CONFIG_PPC_64K_PAGES
arch/powerpc/include/asm/nohash/64/pgalloc.h:#endif /* 
CONFIG_PPC_64K_PAGES */
arch/powerpc/include/asm/nohash/64/pgtable.h:#ifdef CONFIG_PPC_64K_PAGES
arch/powerpc/include/asm/nohash/64/slice.h:#ifdef CONFIG_PPC_64K_PAGES
arch/powerpc/include/asm/nohash/64/slice.h:#else /* CONFIG_PPC_64K_PAGES */
arch/powerpc/include/asm/nohash/64/slice.h:#endif /* 
!CONFIG_PPC_64K_PAGES */
arch/powerpc/include/asm/nohash/pte-book3e.h:#ifdef CONFIG_PPC_64K_PAGES

arch/powerpc/mm/tlb_low_64e.S:#ifdef CONFIG_PPC_64K_PAGES
arch/powerpc/mm/tlb_low_64e.S:#ifndef CONFIG_PPC_64K_PAGES
arch/powerpc/mm/tlb_low_64e.S:#endif /* CONFIG_PPC_64K_PAGES */
arch/powerpc/mm/tlb_low_64e.S:#ifdef CONFIG_PPC_64K_PAGES
arch/powerpc/mm/tlb_low_64e.S:#ifdef CONFIG_PPC_64K_PAGES
arch/powerpc/mm/tlb_low_64e.S:#ifndef CONFIG_PPC_64K_PAGES
arch/powerpc/mm/tlb_low_64e.S:#endif /* CONFIG_PPC_64K_PAGES */
arch/powerpc/mm/tlb_low_64e.S:#ifndef CONFIG_PPC_64K_PAGES
arch/powerpc/mm/tlb_low_64e.S:#endif /* CONFIG_PPC_64K_PAGES */
arch/powerpc/mm/tlb_low_64e.S:#ifndef CONFIG_PPC_64K_PAGES
arch/powerpc/mm/tlb_low_64e.S:#ifdef CONFIG_PPC_64K_PAGES


Christophe

> 
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>   arch/powerpc/Kconfig | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 3f237ffa0649..7a16b8a7b54b 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -694,7 +694,7 @@ config PPC_16K_PAGES
>   
>   config PPC_64K_PAGES
>   	bool "64k page size"
> -	depends on !PPC_FSL_BOOK3E && (44x || PPC_BOOK3S_64 || PPC_BOOK3E_64)
> +	depends on 44x || PPC_BOOK3S_64
>   	select HAVE_ARCH_SOFT_DIRTY if PPC_BOOK3S_64
>   
>   config PPC_256K_PAGES
> 

^ permalink raw reply

* Re: [1/6] powerpc/eeh: Cleanup eeh_pe_clear_frozen_state()
From: Michael Ellerman @ 2019-02-08 13:02 UTC (permalink / raw)
  To: Sam Bobroff, linuxppc-dev
In-Reply-To: <44d3c23aa1c58abb6e1790e68b34e613a7ec6909.1543460917.git.sbobroff@linux.ibm.com>

On Thu, 2018-11-29 at 03:16:37 UTC, Sam Bobroff wrote:
> The 'clear_sw_state' parameter for eeh_pe_clear_frozen_state() is
> redundant because it has no effect (except in the rare case of a
> hardware error part way through unfreezing a tree of PEs, where it
> would dangerously allow partial de-isolation before returning
> failure).
> 
> It is passed down to __eeh_pe_clear_frozen_state(), and from there to
> eeh_unfreeze_pe(), where it causes EEH_PE_ISOLATED to be removed
> from the state of each PE during the traversal.  However, when the
> traversal finishes, EEH_PE_ISOLATED is unconditionally removed by a
> call to eeh_pe_state_clear() regardless of the parameter's value.
> 
> So remove the flag and pass false to eeh_unfreeze_pe() (to avoid the
> rare case described above, as it was before the flag was introduced).
> Also, perform the recursion directly in the function and eliminate a
> bit of boilerplate.
> 
> There should be no change in functionality, except as mentioned above.
> 
> Signed-off-by: Sam Bobroff <sbobroff@linux.ibm.com>

Series applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/3376cb91ed908eb0728900894a77d820

cheers

^ permalink raw reply

* Re: [v2] powerpc/perf: Add mem access events to sysfs
From: Michael Ellerman @ 2019-02-08 13:02 UTC (permalink / raw)
  To: Madhavan Srinivasan; +Cc: Madhavan Srinivasan, linuxppc-dev
In-Reply-To: <1544414345-13031-1-git-send-email-maddy@linux.vnet.ibm.com>

On Mon, 2018-12-10 at 03:59:05 UTC, Madhavan Srinivasan wrote:
> Add mem-loads/mem-stores events to sysfs.
> The event is formed based on raw event encoding.
> Primary PMU event used here is PM_MRK_INST_CMPL
> along with MMCRA[SM] modes and Thresholding bit
> 
> Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/ab4510e9ac6dcdd5e9ec0380bec279b5

cheers

^ permalink raw reply

* Re: powerpc/powernv: Remove duplicate header
From: Michael Ellerman @ 2019-02-08 13:02 UTC (permalink / raw)
  To: Sabyasachi Gupta, benh, paulus, npiggin, msuchanek, haren, oohall,
	bsingharora
  Cc: linux-kernel, linuxppc-dev, jrdr.linux, brajeswar.linux
In-Reply-To: <5c40a8fd.1c69fb81.e4b1b.8f85@mx.google.com>

On Thu, 2019-01-17 at 16:10:33 UTC, Sabyasachi Gupta wrote:
> Remove linux/printk.h which is included more than once.
> 
> Signed-off-by: Sabyasachi Gupta <sabyasachi.linux@gmail.com>
> Acked-by: Souptick Joarder <jrdr.linux@gmail.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/f069a062ecce7ccc17221c24097826e8

cheers

^ permalink raw reply

* Re: powerpc/cell: Remove duplicate header
From: Michael Ellerman @ 2019-02-08 13:02 UTC (permalink / raw)
  To: Sabyasachi Gupta, arnd, benh, paulus
  Cc: linux-kernel, linuxppc-dev, jrdr.linux, brajeswar.linux
In-Reply-To: <5c40aafc.1c69fb81.a0ba0.67a7@mx.google.com>

On Thu, 2019-01-17 at 16:19:05 UTC, Sabyasachi Gupta wrote:
> Remove linux/syscalls.h which is included more than once
> 
> Signed-off-by: Sabyasachi Gupta <sabyasachi.linux@gmail.com>
> Acked-by: Souptick Joarder <jrdr.linux@gmail.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/45a202a3fefc6ee7b19b1222bfb5b067

cheers

^ permalink raw reply

* Re: [1/4] powerpc/64s: Clear on-stack exception marker upon exception return
From: Michael Ellerman @ 2019-02-08 13:02 UTC (permalink / raw)
  To: Joe Lawrence, linux-kernel, linuxppc-dev, live-patching
  Cc: Jiri Kosina, Torsten Duwe, Nicolai Stange, Josh Poimboeuf
In-Reply-To: <20190122155724.27557-2-joe.lawrence@redhat.com>

On Tue, 2019-01-22 at 15:57:21 UTC, Joe Lawrence wrote:
> From: Nicolai Stange <nstange@suse.de>
> 
> The ppc64 specific implementation of the reliable stacktracer,
> save_stack_trace_tsk_reliable(), bails out and reports an "unreliable
> trace" whenever it finds an exception frame on the stack. Stack frames
> are classified as exception frames if the STACK_FRAME_REGS_MARKER magic,
> as written by exception prologues, is found at a particular location.
> 
> However, as observed by Joe Lawrence, it is possible in practice that
> non-exception stack frames can alias with prior exception frames and thus,
> that the reliable stacktracer can find a stale STACK_FRAME_REGS_MARKER on
> the stack. It in turn falsely reports an unreliable stacktrace and blocks
> any live patching transition to finish. Said condition lasts until the
> stack frame is overwritten/initialized by function call or other means.
> 
> In principle, we could mitigate this by making the exception frame
> classification condition in save_stack_trace_tsk_reliable() stronger:
> in addition to testing for STACK_FRAME_REGS_MARKER, we could also take into
> account that for all exceptions executing on the kernel stack
> - their stack frames's backlink pointers always match what is saved
>   in their pt_regs instance's ->gpr[1] slot and that
> - their exception frame size equals STACK_INT_FRAME_SIZE, a value
>   uncommonly large for non-exception frames.
> 
> However, while these are currently true, relying on them would make the
> reliable stacktrace implementation more sensitive towards future changes in
> the exception entry code. Note that false negatives, i.e. not detecting
> exception frames, would silently break the live patching consistency model.
> 
> Furthermore, certain other places (diagnostic stacktraces, perf, xmon)
> rely on STACK_FRAME_REGS_MARKER as well.
> 
> Make the exception exit code clear the on-stack STACK_FRAME_REGS_MARKER
> for those exceptions running on the "normal" kernel stack and returning
> to kernelspace: because the topmost frame is ignored by the reliable stack
> tracer anyway, returns to userspace don't need to take care of clearing
> the marker.
> 
> Furthermore, as I don't have the ability to test this on Book 3E or
> 32 bits, limit the change to Book 3S and 64 bits.
> 
> Finally, make the HAVE_RELIABLE_STACKTRACE Kconfig option depend on
> PPC_BOOK3S_64 for documentation purposes. Before this patch, it depended
> on PPC64 && CPU_LITTLE_ENDIAN and because CPU_LITTLE_ENDIAN implies
> PPC_BOOK3S_64, there's no functional change here.
> 
> Fixes: df78d3f61480 ("powerpc/livepatch: Implement reliable stack tracing for the consistency model")
> Reported-by: Joe Lawrence <joe.lawrence@redhat.com>
> Signed-off-by: Nicolai Stange <nstange@suse.de>
> Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>

Series applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/eddd0b332304d554ad6243942f87c2fc

cheers

^ permalink raw reply

* Re: powerpc/mm: Add _PAGE_SAO to _PAGE_CACHE_CTL mask
From: Michael Ellerman @ 2019-02-08 13:02 UTC (permalink / raw)
  To: Reza Arbab, linuxppc-dev; +Cc: Aneesh Kumar K.V, Charles Johns, Paul Mackerras
In-Reply-To: <1548696702-20686-1-git-send-email-arbab@linux.ibm.com>

On Mon, 2019-01-28 at 17:31:42 UTC, Reza Arbab wrote:
> In htab_convert_pte_flags(), _PAGE_CACHE_CTL is used to check for the
> _PAGE_SAO flag:
> 
>   else if ((pteflags & _PAGE_CACHE_CTL) == _PAGE_SAO)
>           rflags |= (HPTE_R_W | HPTE_R_I | HPTE_R_M);
> 
> But, it isn't defined to include that flag:
> 
>   #define _PAGE_CACHE_CTL (_PAGE_NON_IDEMPOTENT | _PAGE_TOLERANT)
> 
> This happens to work, but only because of the flag values:
> 
>   #define _PAGE_SAO               0x00010 /* Strong access order */
>   #define _PAGE_NON_IDEMPOTENT    0x00020 /* non idempotent memory */
>   #define _PAGE_TOLERANT          0x00030 /* tolerant memory, cache inhibited */
> 
> To prevent any issues if these particulars ever change, add _PAGE_SAO to
> the mask.
> 
> Suggested-by: Charles Johns <crjohns@us.ibm.com>
> Signed-off-by: Reza Arbab <arbab@linux.ibm.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/865a9432d16fe2f40a1a52005fd30778

cheers

^ permalink raw reply

* Re: powerpc/kernel/time: Remove duplicate header
From: Michael Ellerman @ 2019-02-08 13:02 UTC (permalink / raw)
  To: Brajeswar Ghosh, benh, paulus, npiggin, christophe.leroy, arnd,
	anton, aneesh.kumar
  Cc: linux-kernel, linuxppc-dev, jrdr.linux, sabyasachi.linux
In-Reply-To: <20190128161136.GA2266@hp-pavilion-15-notebook-pc-brajeswar>

On Mon, 2019-01-28 at 16:11:36 UTC, Brajeswar Ghosh wrote:
> Remove linux/rtc.h which is included more than once
> 
> Signed-off-by: Brajeswar Ghosh <brajeswar.linux@gmail.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/75f8a37580b64f87c223fbd08db6b2f7

cheers

^ permalink raw reply

* Re: [RESEND, v3] cxl: Wrap iterations over afu slices inside 'afu_list_lock'
From: Michael Ellerman @ 2019-02-08 13:02 UTC (permalink / raw)
  To: Vaibhav Jain, linuxppc-dev, Frederic Barrat
  Cc: Philippe Bergheaud, Christophe Lombard, stable,
	Alastair D'Silva, Andrew Donnellan, Vaibhav Jain,
	Christophe Lombard
In-Reply-To: <20190129110618.13481-1-vaibhav@linux.ibm.com>

On Tue, 2019-01-29 at 11:06:18 UTC, Vaibhav Jain wrote:
> Within cxl module, iteration over array 'adapter->afu' may be racy
> at few points as it might be simultaneously read during an EEH and its
> contents being set to NULL while driver is being unloaded or unbound
> from the adapter. This might result in a NULL pointer to 'struct afu'
> being de-referenced during an EEH thereby causing a kernel oops.
> 
> This patch fixes this by making sure that all access to the array
> 'adapter->afu' is wrapped within the context of spin-lock
> 'adapter->afu_list_lock'.
> 
> Cc: stable@vger.kernel.org
> Fixes: 9e8df8a2196("cxl: EEH support")
> Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
> Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>
> Acked-by: Christophe Lombard <clombard@linux.vnet.ibm.com>
> Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/edeb304f659792fb5bab90d7d6f3408b

cheers

^ permalink raw reply

* Re: [v2] powerpc/traps: fix the message printed when stack overflows
From: Michael Ellerman @ 2019-02-08 13:02 UTC (permalink / raw)
  To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras
  Cc: linuxppc-dev, linux-kernel
In-Reply-To: <5aa3c84a675405ac99382a5893406ef7e8dfd455.1548779831.git.christophe.leroy@c-s.fr>

On Tue, 2019-01-29 at 16:37:55 UTC, Christophe Leroy wrote:
> Today's message is useless:
> 
> [   42.253267] Kernel stack overflow in process (ptrval), r1=c65500b0
> 
> This patch fixes it:
> 
> [   66.905235] Kernel stack overflow in process sh[356], r1=c65560b0
> 
> Fixes: ad67b74d2469 ("printk: hash addresses printed with %p")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/9bf3d3c4e4fd82c7174f4856df372ab2

cheers

^ permalink raw reply

* Re: powerpc: Enable kernel XZ compression option on 44x
From: Michael Ellerman @ 2019-02-08 13:02 UTC (permalink / raw)
  To: Christian Lamparter, linuxppc-dev; +Cc: Paul Mackerras
In-Reply-To: <20190131205904.23723-1-chunkeey@gmail.com>

On Thu, 2019-01-31 at 20:59:04 UTC, Christian Lamparter wrote:
> Enable kernel XZ compression option on 44x.
> Tested on a Western Digital - MyBook Live NAS.
> It takes 22 seconds for the 800 MHz CPU to decompress
> and boot a 2.63 MiB XZ-compressed kernel simpleImage.
> 
> Signed-off-by: Christian Lamparter <chunkeey@gmail.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/423bfc69d7f491c47fc35921f7d460be

cheers

^ permalink raw reply

* Re: [V2] powerpc/ptrace: Mitigate potential Spectre v1
From: Michael Ellerman @ 2019-02-08 13:02 UTC (permalink / raw)
  To: Breno Leitao, linuxppc-dev; +Cc: Breno Leitao, gustavo
In-Reply-To: <1548852360-29886-1-git-send-email-leitao@debian.org>

On Wed, 2019-01-30 at 12:46:00 UTC, Breno Leitao wrote:
> 'regno' is directly controlled by user space, hence leading to a potential
> exploitation of the Spectre variant 1 vulnerability.
> 
> On PTRACE_SETREGS and PTRACE_GETREGS requests, user space passes the
> register number that would be read or written. This register number is
> called 'regno' which is part of the 'addr' syscall parameter.
> 
> This 'regno' value is checked against the maximum pt_regs structure size,
> and then used to dereference it, which matches the initial part of a
> Spectre v1 (and Spectre v1.1) attack. The dereferenced value, then,
> is returned to userspace in the GETREGS case.
> 
> This patch sanitizes 'regno' before using it to dereference pt_reg.
> 
> Notice that given that speculation windows are large, the policy is
> to kill the speculation on the first load and not worry if it can be
> completed with a dependent load/store [1].
> 
> [1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2
> 
> Signed-off-by: Breno Leitao <leitao@debian.org>
> Acked-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/ebb0e13ead2ddc186a80b1b0235deeef

cheers

^ permalink raw reply

* Re: powerpc/powernv: Escalate reset when IODA reset fails
From: Michael Ellerman @ 2019-02-08 13:02 UTC (permalink / raw)
  To: Oliver O'Halloran, linuxppc-dev; +Cc: Oliver O'Halloran
In-Reply-To: <20190201004201.6512-1-oohall@gmail.com>

On Fri, 2019-02-01 at 00:42:01 UTC, Oliver O'Halloran wrote:
> The IODA reset is used to flush out any OS controlled state from the PHB.
> This reset can fail if a PHB fatal error has occurred in early boot,
> probably due to a because of a bad device. We already do a fundemental
> reset of the device in some cases, so this patch just adds a test to force
> a full reset if firmware reports an error when performing the IODA reset.
> 
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
> Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/b174b4fb919d118d9ac546b99a69574d

cheers

^ permalink raw reply

* Re: [v2] powerpc: drop page_is_ram() and walk_system_ram_range()
From: Michael Ellerman @ 2019-02-08 13:02 UTC (permalink / raw)
  To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras
  Cc: linuxppc-dev, linux-kernel
In-Reply-To: <a14aac5408f98cf8ad8723ffa874764ccb42d4d4.1548978750.git.christophe.leroy@c-s.fr>

On Fri, 2019-02-01 at 10:46:52 UTC, Christophe Leroy wrote:
> Since commit c40dd2f76644 ("powerpc: Add System RAM to /proc/iomem")
> it is possible to use the generic walk_system_ram_range() and
> the generic page_is_ram().
> 
> To enable the use of walk_system_ram_range() by the IBM EHEA
> ethernet driver, the generic function has to be exported.
> 
> As powerpc was the only (last?) user of CONFIG_ARCH_HAS_WALK_MEMORY,
> the #ifdef around the generic walk_system_ram_range() has become
> useless and can be dropped.
> 
> Fixes: c40dd2f76644 ("powerpc: Add System RAM to /proc/iomem")
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/26b523356f49a0117c8f9e32ca98aa6d

cheers

^ permalink raw reply

* Re: powerpc: Remove trailing semicolon after curly brace
From: Michael Ellerman @ 2019-02-08 13:02 UTC (permalink / raw)
  To: Mathieu Malaterre
  Cc: Mathieu Malaterre, linuxppc-dev, Paul Mackerras, linux-kernel
In-Reply-To: <20190202125427.2309-1-malat@debian.org>

On Sat, 2019-02-02 at 12:54:27 UTC, Mathieu Malaterre wrote:
> There is not point in having a trailing semicolon after a closing curly
> brace. Remove it.
> 
> Signed-off-by: Mathieu Malaterre <malat@debian.org>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/e5c27ef7a5f204ff2f894f0dd7ed3774

cheers

^ permalink raw reply

* Re: Move static keyword at beginning of declaration
From: Michael Ellerman @ 2019-02-08 13:02 UTC (permalink / raw)
  To: Mathieu Malaterre
  Cc: Mathieu Malaterre, Geoff Levand, linuxppc-dev, Paul Mackerras,
	linux-kernel
In-Reply-To: <20190202130535.2761-1-malat@debian.org>

On Sat, 2019-02-02 at 13:05:35 UTC, Mathieu Malaterre wrote:
> Move the static keyword around to remove the following warnings (W=1):
> 
>   arch/powerpc/platforms/ps3/os-area.c:212:1: error: 'static' is not at beginning of declaration [-Werror=old-style-declaration]
>   arch/powerpc/platforms/ps3/system-bus.c:45:1: error: 'static' is not at beginning of declaration [-Werror=old-style-declaration]
> 
> Signed-off-by: Mathieu Malaterre <malat@debian.org>
> Acked-by: Geoff Levand <geoff@infradead.org>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/8e0f97357533aa5b57b333de47eb008c

cheers

^ permalink raw reply

* Re: powerpc/pseries: Perform full re-add of CPU for topology update post-migration
From: Michael Ellerman @ 2019-02-08 13:02 UTC (permalink / raw)
  To: Nathan Fontenot, linuxppc-dev; +Cc: ldufour
In-Reply-To: <154083861636.18916.18172276232185726281.stgit@ltcalpine2-lp14.aus.stglabs.ibm.com>

On Mon, 2018-10-29 at 18:43:36 UTC, Nathan Fontenot wrote:
> On pseries systems, performing a partition migration can result in
> altering the nodes a CPU is assigned to on the destination system. For
> exampl, pre-migration on the source system CPUs are in node 1 and 3,
> post-migration on the destination system CPUs are in nodes 2 and 3.
> 
> Handling the node change for a CPU can cause corruption in the slab
> cache if we hit a timing where a CPUs node is changed while cache_reap()
> is invoked. The corruption occurs because the slab cache code appears
> to rely on the CPU and slab cache pages being on the same node.
> 
> The current dynamic updating of a CPUs node done in arch/powerpc/mm/numa.c
> does not prevent us from hitting this scenario.
> 
> Changing the device tree property update notification handler that
> recognizes an affinity change for a CPU to do a full DLPAR remove and
> add of the CPU instead of dynamically changing its node resolves this
> issue.
> 
> Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
> Signed-off-by: Michael W. Bringmann <mwb@linux.vnet.ibm.com>
> Tested-by: Michael W. Bringmann <mwb@linux.vnet.ibm.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/81b61324922c67f73813d8a9c175f3c1

cheers

^ permalink raw reply

* Re: powerpc/32: Include .branch_lt in data section
From: Michael Ellerman @ 2019-02-08 13:02 UTC (permalink / raw)
  To: Joel Stanley, linuxppc-dev; +Cc: Alan Modra
In-Reply-To: <20181114030218.25508-1-joel@jms.id.au>

On Wed, 2018-11-14 at 03:02:18 UTC, Joel Stanley wrote:
> When building a 32 bit powerpc kernel with Binutils 2.31.1 this warning
> is emitted:
> 
>  powerpc-linux-gnu-ld: warning: orphan section `.branch_lt' from
>  `arch/powerpc/kernel/head_44x.o' being placed in section `.branch_lt'
> 
> As of binutils commit 2d7ad24e8726 ("Support PLT16 relocs against local
> symbols")[1], 32 bit targets can produce .branch_lt sections in their
> output.
> 
> Include these symbols in the .data section as the ppc64 kernel does.
> 
> [1] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=2d7ad24e8726ba4c45c9e67be08223a146a837ce
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> Reviewed-by: Alan Modra <amodra@gmail.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/98ecc6768e8fdba95da1fc1efa0ef2d7

cheers

^ permalink raw reply

* [GIT PULL] Please pull powerpc/linux.git powerpc-5.0-4 tag
From: Michael Ellerman @ 2019-02-08 13:12 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: aneesh.kumar, oohall, linuxppc-dev, linux-kernel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Linus,

Please pull some more powerpc fixes for 5.0:

The following changes since commit 7bea7ac0ca0121798f3618d16201ca4dc4e67a00:

  powerpc/syscalls: Fix syscall tracing (2019-01-15 21:32:25 +1100)

are available in the git repository at:

  https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git tags/powerpc-5.0-4

for you to fetch changes up to 5a3840a470c41ec0b85cd36ca80370330656b163:

  powerpc/papr_scm: Use the correct bind address (2019-02-01 10:13:51 +1100)

- ------------------------------------------------------------------
powerpc fixes for 5.0 #4

Just two fixes, both going to stable.

Our support for split pmd page table lock had a bug which could lead to a crash
on mremap() when using the Radix MMU (Power9 only).

A fix for the PAPR SCM driver (nvdimm) we added last release, which had a bug
where we might mis-handle a hypervisor response leading to us failing to attach
the memory region.

Thanks to:
  Aneesh Kumar K.V, Oliver O'Halloran.

- ------------------------------------------------------------------
Aneesh Kumar K.V (1):
      powerpc/radix: Fix kernel crash with mremap()

Oliver O'Halloran (1):
      powerpc/papr_scm: Use the correct bind address


 arch/powerpc/include/asm/book3s/64/pgtable.h | 22 +++++++---------------
 arch/powerpc/mm/pgtable-book3s64.c           | 22 ++++++++++++++++++++++
 arch/powerpc/platforms/pseries/papr_scm.c    |  5 ++++-
 3 files changed, 33 insertions(+), 16 deletions(-)
-----BEGIN PGP SIGNATURE-----

iQIcBAEBAgAGBQJcXYAdAAoJEFHr6jzI4aWAGAwP/1VlkYVIU0gA+x3iifUW0vD+
MhDhWuzFYpP1xfy5rMvEtwQ+IbwgO/j4220NilCAbCNbB69Ccj6x4mdPayTLWswi
lVb8VVKG0kre0sj0hXm15j/ZEhkIwGuAzu1FH/q6mf0kyEOCsdUiZ1k+vDjWtgJS
TzrpmstgCMlkAtJSq2RfGdWTqQc2N5uZktyjobpmkubvBm9PoEgjA/f+LwMmxZEa
M83cOdQ8HXKV+tZVMftUR9dfDuDo2L+5EhXdrBgreAF0haEtVo9JALp4rwvCdS4H
c5SzuJSNnaBvGTzCVmwOadWJHH8/Ok3N0ryC991SeAonYLedOQhSVZRzgqN9nCF2
KIGahudY5djIMTe41FXDsHC95yYuH6C8rfDPJBZUj6o9I6N98Xjz0gASoMFRJ71p
25kskxbH7ehL3ZdAENp93MmNS0gXyBkfhYs2JGKy+ufdlELUh8Yn6q0kJxrqgGnj
Cc9i221OXkRbi8Z0eZeAdWzzz48cdmqio2bvT679xwghRtFXfy1BhGv0m9F9evS4
TGTIKL/al/UVtCEStjdbTT9XGovGqrUSbIqe7MDaH478cGrQjBTVdwn6eU2G48Vh
nZMyY7g5J3BQWeE9vOkX8T9T/9ChwIIXDDjiXYr76+7jcgamWH9VL6bCwKQO00Lx
+9G3ikkFDRcFqleuTrf3
=BKaS
-----END PGP SIGNATURE-----

^ permalink raw reply

* Re: [PATCH 3/7] powerpc/eeh_cache: Add a way to dump the EEH address cache
From: Oliver @ 2019-02-08 13:14 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev
In-Reply-To: <875ztuk3x0.fsf@concordia.ellerman.id.au>

On Fri, Feb 8, 2019 at 8:47 PM Michael Ellerman <mpe@ellerman.id.au> wrote:
>
> Oliver O'Halloran <oohall@gmail.com> writes:
> > diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
> > index f6e65375a8de..d1f0bdf41fac 100644
> > --- a/arch/powerpc/kernel/eeh.c
> > +++ b/arch/powerpc/kernel/eeh.c
> > @@ -1810,7 +1810,7 @@ static int __init eeh_init_proc(void)
> >                                          &eeh_enable_dbgfs_ops);
> >               debugfs_create_u32("eeh_max_freezes", 0600,
> >                               powerpc_debugfs_root, &eeh_max_freezes);
> > -#endif
> > +             eeh_cache_debugfs_init();
>
> Oops :)

Yeah :(

> > diff --git a/arch/powerpc/kernel/eeh_cache.c b/arch/powerpc/kernel/eeh_cache.c
> > index b2c320e0fcef..dba421a577e7 100644
> > --- a/arch/powerpc/kernel/eeh_cache.c
> > +++ b/arch/powerpc/kernel/eeh_cache.c
> > @@ -298,9 +299,34 @@ void eeh_addr_cache_build(void)
> >               eeh_addr_cache_insert_dev(dev);
> >               eeh_sysfs_add_device(dev);
> >       }
> > +}
> >
> > -#ifdef DEBUG
> > -     /* Verify tree built up above, echo back the list of addrs. */
> > -     eeh_addr_cache_print(&pci_io_addr_cache_root);
> > -#endif
> > +static int eeh_addr_cache_show(struct seq_file *s, void *v)
> > +{
> > +     struct rb_node *n = rb_first(&pci_io_addr_cache_root.rb_root);
> > +     struct pci_io_addr_range *piar;
> > +     int cnt = 0;
> > +
> > +     spin_lock(&pci_io_addr_cache_root.piar_lock);
> > +     while (n) {
> > +             piar = rb_entry(n, struct pci_io_addr_range, rb_node);
> > +
> > +             seq_printf(s, "%s addr range %3d [%pap-%pap]: %s\n",
> > +                    (piar->flags & IORESOURCE_IO) ? "i/o" : "mem", cnt,
> > +                    &piar->addr_lo, &piar->addr_hi, pci_name(piar->pcidev));
> > +
> > +             n = rb_next(n);
> > +             cnt++;
> > +     }
>
> You can write that as a for loop can't you?
>
>         struct rb_node *n;
>         int i = 0;
>
>         for (n = rb_first(&pci_io_addr_cache_root.rb_root); n; n = rb_next(n), i++) {

IIRC I did try that, but it's too long. 85 cols wide according to my editor.

>                 piar = rb_entry(n, struct pci_io_addr_range, rb_node);
>
>                 seq_printf(s, "%s addr range %3d [%pap-%pap]: %s\n",
>                        (piar->flags & IORESOURCE_IO) ? "i/o" : "mem", i,
>                        &piar->addr_lo, &piar->addr_hi, pci_name(piar->pcidev));
>         }
>
> cheers

^ permalink raw reply

* Re: [PATCH-tip 15/22] locking/rwsem: Merge owner into count on x86-64
From: Waiman Long @ 2019-02-08 14:19 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: linux-arch, linux-xtensa, Davidlohr Bueso, linux-ia64, Tim Chen,
	Arnd Bergmann, linux-sh, linux-hexagon, x86, Will Deacon,
	linux-kernel, Linus Torvalds, Ingo Molnar, Borislav Petkov,
	H. Peter Anvin, linux-alpha, sparclinux, Thomas Gleixner,
	linuxppc-dev, Andrew Morton, linux-arm-kernel
In-Reply-To: <d157be4f-fbbe-4541-439b-7f6ab3b1dbdc@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1529 bytes --]

On 02/07/2019 03:54 PM, Waiman Long wrote:
> On 02/07/2019 03:08 PM, Peter Zijlstra wrote:
>> On Thu, Feb 07, 2019 at 02:07:19PM -0500, Waiman Long wrote:
>>> On 32-bit architectures, there aren't enough bits to hold both.
>>> 64-bit architectures, however, can have enough bits to do that. For
>>> x86-64, the physical address can use up to 52 bits. That is 4PB of
>>> memory. That leaves 12 bits available for other use. The task structure
>>> pointer is also aligned to the L1 cache size. That means another 6 bits
>>> (64 bytes cacheline) will be available. Reserving 2 bits for status
>>> flags, we will have 16 bits for the reader count.  That can supports
>>> up to (64k-1) readers.
>> 64k readers sounds like a number that is fairly 'easy' to reach, esp. on
>> 64bit. These are preemptible locks after all, all we need to do is get
>> 64k tasks nested on enough CPUs.
>>
>> I'm sure there's some willing Java proglet around that spawns more than
>> 64k threads just because it can. Run it on a big enough machine (ISTR
>> there's a number of >1k CPU systems out there) and voila.
> Yes, that can be a problem.
>
> One possible solution is to check if the count goes negative. If so,
> fail the read lock and make the readers wait in the wait queue until the
> count is in positive territory. That effectively reduces the reader
> count to 15 bits, but it will avoid the overflow situation. I will try
> to add that support into the next version.
>
> Cheers,
> Longman

Something like the attached patch.

Cheers,
Longman

[-- Attachment #2: 0023-locking-rwsem-Make-MSbit-of-count-as-guard-bit-to-fa.patch --]
[-- Type: text/x-patch, Size: 8766 bytes --]

From 746913e7d14e874eeace1e146e63bdaea4dfd4a5 Mon Sep 17 00:00:00 2001
From: Waiman Long <longman@redhat.com>
Date: Fri, 8 Feb 2019 08:58:10 -0500
Subject: [PATCH 23/23] locking/rwsem: Make MSbit of count as guard bit to fail
 readlock

With the merging of owner into count for x86-64, there is only 16 bits
left for reader count. It is theoretically possible for an application to
cause more than 64k readers to acquire a rwsem leading to count overflow.

To prevent this dire situation, the most significant bit of the count
is now treated as a guard bit (RWSEM_FLAG_READFAIL). Read-lock will now
fails for both the fast and optimistic spinning paths whenever this bit
is set. So all those extra readers will be put to sleep in the wait
queue. Wakeup will not happen until the reader count reaches 0.

A limit of 256 is also imposed on the number of readers that can be woken
up in one wakeup function call. This will eliminate the possibility of
waking up more than 64k readers and overflowing the count.

Signed-off-by: Waiman Long <longman@redhat.com>
---
 kernel/locking/lock_events_list.h |  1 +
 kernel/locking/rwsem-xadd.c       | 40 ++++++++++++++++++++++++++++++++------
 kernel/locking/rwsem-xadd.h       | 41 ++++++++++++++++++++++++++-------------
 3 files changed, 62 insertions(+), 20 deletions(-)

diff --git a/kernel/locking/lock_events_list.h b/kernel/locking/lock_events_list.h
index 0052534..9ecdeac 100644
--- a/kernel/locking/lock_events_list.h
+++ b/kernel/locking/lock_events_list.h
@@ -60,6 +60,7 @@
 LOCK_EVENT(rwsem_opt_rlock)	/* # of read locks opt-spin acquired	*/
 LOCK_EVENT(rwsem_opt_wlock)	/* # of write locks opt-spin acquired	*/
 LOCK_EVENT(rwsem_opt_fail)	/* # of failed opt-spinnings		*/
+LOCK_EVENT(rwsem_opt_rfail)	/* # of failed reader-owned readlocks	*/
 LOCK_EVENT(rwsem_opt_nospin)	/* # of disabled reader opt-spinnings	*/
 LOCK_EVENT(rwsem_rlock)		/* # of read locks acquired		*/
 LOCK_EVENT(rwsem_rlock_fast)	/* # of fast read locks acquired	*/
diff --git a/kernel/locking/rwsem-xadd.c b/kernel/locking/rwsem-xadd.c
index 213c2aa..a993055 100644
--- a/kernel/locking/rwsem-xadd.c
+++ b/kernel/locking/rwsem-xadd.c
@@ -110,6 +110,8 @@ enum rwsem_wake_type {
 # define RWSEM_RSPIN_MAX	(1 << 12)
 #endif
 
+#define MAX_READERS_WAKEUP	0x100
+
 /*
  * handle the lock release when processes blocked on it that can now run
  * - if we come here from up_xxxx(), then the RWSEM_FLAG_WAITERS bit must
@@ -208,6 +210,12 @@ static void __rwsem_mark_wake(struct rw_semaphore *sem,
 		 * after setting the reader waiter to nil.
 		 */
 		wake_q_add_safe(wake_q, tsk);
+
+		/*
+		 * Limit # of readers that can be woken up per wakeup call.
+		 */
+		if (woken >= MAX_READERS_WAKEUP)
+			break;
 	}
 
 	adjustment = woken * RWSEM_READER_BIAS - adjustment;
@@ -445,6 +453,16 @@ static bool rwsem_optimistic_spin(struct rw_semaphore *sem, const long wlock)
 			break;
 
 		/*
+		 * If a reader cannot acquire a reader-owned lock, we
+		 * have to quit. It is either the handoff bit just got
+		 * set or (unlikely) readfail bit is somehow set.
+		 */
+		if (unlikely(!wlock && (owner_state == OWNER_READER))) {
+			lockevent_inc(rwsem_opt_rfail);
+			break;
+		}
+
+		/*
 		 * An RT task cannot do optimistic spinning if it cannot
 		 * be sure the lock holder is running. When there's no owner
 		 * or is reader-owned, an RT task has to stop spinning or
@@ -526,12 +544,22 @@ static inline bool rwsem_optimistic_spin(struct rw_semaphore *sem,
  * Wait for the read lock to be granted
  */
 static inline struct rw_semaphore __sched *
-__rwsem_down_read_failed_common(struct rw_semaphore *sem, int state)
+__rwsem_down_read_failed_common(struct rw_semaphore *sem, int state, long count)
 {
-	long count, adjustment = -RWSEM_READER_BIAS;
+	long adjustment = -RWSEM_READER_BIAS;
 	struct rwsem_waiter waiter;
 	DEFINE_WAKE_Q(wake_q);
 
+	if (unlikely(count < 0)) {
+		/*
+		 * Too many active readers, decrement count &
+		 * enter the wait queue.
+		 */
+		atomic_long_add(-RWSEM_READER_BIAS, &sem->count);
+		adjustment = 0;
+		goto queue;
+	}
+
 	if (!rwsem_can_spin_on_owner(sem))
 		goto queue;
 
@@ -635,16 +663,16 @@ static inline bool rwsem_optimistic_spin(struct rw_semaphore *sem,
 }
 
 __visible struct rw_semaphore * __sched
-rwsem_down_read_failed(struct rw_semaphore *sem)
+rwsem_down_read_failed(struct rw_semaphore *sem, long cnt)
 {
-	return __rwsem_down_read_failed_common(sem, TASK_UNINTERRUPTIBLE);
+	return __rwsem_down_read_failed_common(sem, TASK_UNINTERRUPTIBLE, cnt);
 }
 EXPORT_SYMBOL(rwsem_down_read_failed);
 
 __visible struct rw_semaphore * __sched
-rwsem_down_read_failed_killable(struct rw_semaphore *sem)
+rwsem_down_read_failed_killable(struct rw_semaphore *sem, long cnt)
 {
-	return __rwsem_down_read_failed_common(sem, TASK_KILLABLE);
+	return __rwsem_down_read_failed_common(sem, TASK_KILLABLE, cnt);
 }
 EXPORT_SYMBOL(rwsem_down_read_failed_killable);
 
diff --git a/kernel/locking/rwsem-xadd.h b/kernel/locking/rwsem-xadd.h
index be67dbd..72308b7 100644
--- a/kernel/locking/rwsem-xadd.h
+++ b/kernel/locking/rwsem-xadd.h
@@ -63,7 +63,8 @@
  * Bit   0    - waiters present bit
  * Bit   1    - lock handoff bit
  * Bits  2-47 - compressed task structure pointer
- * Bits 48-63 - 16-bit reader counts
+ * Bits 48-62 - 15-bit reader counts
+ * Bit  63    - read fail bit
  *
  * On other 64-bit architectures, the bit definitions are:
  *
@@ -71,7 +72,8 @@
  * Bit  1    - lock handoff bit
  * Bits 2-6  - reserved
  * Bit  7    - writer lock bit
- * Bits 8-63 - 56-bit reader counts
+ * Bits 8-62 - 55-bit reader counts
+ * Bit  63   - read fail bit
  *
  * On 32-bit architectures, the bit definitions of the count are:
  *
@@ -79,13 +81,15 @@
  * Bit  1    - lock handoff bit
  * Bits 2-6  - reserved
  * Bit  7    - writer lock bit
- * Bits 8-31 - 24-bit reader counts
+ * Bits 8-30 - 23-bit reader counts
+ * Bit  32   - read fail bit
  *
  * atomic_long_fetch_add() is used to obtain reader lock, whereas
  * atomic_long_cmpxchg() will be used to obtain writer lock.
  */
 #define RWSEM_FLAG_WAITERS	(1UL << 0)
 #define RWSEM_FLAG_HANDOFF	(1UL << 1)
+#define RWSEM_FLAG_READFAIL	(1UL << (BITS_PER_LONG - 1))
 
 #ifdef CONFIG_X86_64
 
@@ -108,7 +112,7 @@
 #define RWSEM_READER_MASK	(~(RWSEM_READER_BIAS - 1))
 #define RWSEM_LOCK_MASK		(RWSEM_WRITER_MASK|RWSEM_READER_MASK)
 #define RWSEM_READ_FAILED_MASK	(RWSEM_WRITER_MASK|RWSEM_FLAG_WAITERS|\
-				 RWSEM_FLAG_HANDOFF)
+				 RWSEM_FLAG_HANDOFF|RWSEM_FLAG_READFAIL)
 
 #define RWSEM_COUNT_LOCKED(c)	((c) & RWSEM_LOCK_MASK)
 #define RWSEM_COUNT_WLOCKED(c)	((c) & RWSEM_WRITER_MASK)
@@ -302,10 +306,15 @@ static inline void rwsem_clear_reader_owned(struct rw_semaphore *sem)
 }
 #endif
 
-extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem);
-extern struct rw_semaphore *rwsem_down_read_failed_killable(struct rw_semaphore *sem);
-extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem);
-extern struct rw_semaphore *rwsem_down_write_failed_killable(struct rw_semaphore *sem);
+extern struct rw_semaphore *
+rwsem_down_read_failed(struct rw_semaphore *sem, long count);
+extern struct rw_semaphore *
+rwsem_down_read_failed_killable(struct rw_semaphore *sem, long count);
+extern struct rw_semaphore *
+rwsem_down_write_failed(struct rw_semaphore *sem);
+extern struct rw_semaphore *
+rwsem_down_write_failed_killable(struct rw_semaphore *sem);
+
 extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem, long count);
 extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem);
 
@@ -314,9 +323,11 @@ static inline void rwsem_clear_reader_owned(struct rw_semaphore *sem)
  */
 static inline void __down_read(struct rw_semaphore *sem)
 {
-	if (unlikely(atomic_long_fetch_add_acquire(RWSEM_READER_BIAS,
-			&sem->count) & RWSEM_READ_FAILED_MASK)) {
-		rwsem_down_read_failed(sem);
+	long count = atomic_long_fetch_add_acquire(RWSEM_READER_BIAS,
+						   &sem->count);
+
+	if (unlikely(count & RWSEM_READ_FAILED_MASK)) {
+		rwsem_down_read_failed(sem, count);
 		DEBUG_RWSEMS_WARN_ON(!is_rwsem_reader_owned(sem), sem);
 	} else {
 		rwsem_set_reader_owned(sem);
@@ -325,9 +336,11 @@ static inline void __down_read(struct rw_semaphore *sem)
 
 static inline int __down_read_killable(struct rw_semaphore *sem)
 {
-	if (unlikely(atomic_long_fetch_add_acquire(RWSEM_READER_BIAS,
-			&sem->count) & RWSEM_READ_FAILED_MASK)) {
-		if (IS_ERR(rwsem_down_read_failed_killable(sem)))
+	long count = atomic_long_fetch_add_acquire(RWSEM_READER_BIAS,
+						   &sem->count);
+
+	if (unlikely(count & RWSEM_READ_FAILED_MASK)) {
+		if (IS_ERR(rwsem_down_read_failed_killable(sem, count)))
 			return -EINTR;
 		DEBUG_RWSEMS_WARN_ON(!is_rwsem_reader_owned(sem), sem);
 	} else {
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH] powerpc: fix 32-bit KVM-PR lockup and panic with MacOS guest
From: Mark Cave-Ayland @ 2019-02-08 14:33 UTC (permalink / raw)
  To: benh, paulus, mpe, npiggin, christophe.leroy, linuxppc-dev,
	linux-kernel, kvm-ppc

Commit 8792468da5e1 "powerpc: Add the ability to save FPU without giving it up"
unexpectedly removed the MSR_FE0 and MSR_FE1 bits from the bitmask used to
update the MSR of the previous thread in __giveup_fpu() causing a KVM-PR MacOS
guest to lockup and panic the kernel.

Reinstate these bits to the MSR bitmask to enable MacOS guests to run under
32-bit KVM-PR once again without issue.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 arch/powerpc/kernel/process.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index ce393df243aa..71bad4b6f80d 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -176,7 +176,7 @@ static void __giveup_fpu(struct task_struct *tsk)
 
 	save_fpu(tsk);
 	msr = tsk->thread.regs->msr;
-	msr &= ~MSR_FP;
+	msr &= ~(MSR_FP|MSR_FE0|MSR_FE1);
 #ifdef CONFIG_VSX
 	if (cpu_has_feature(CPU_FTR_VSX))
 		msr &= ~MSR_VSX;
-- 
2.11.0


^ permalink raw reply related

* [RFC PATCH v1] powerpc/accounting: do not account system time on transition to user.
From: Christophe Leroy @ 2019-02-08 14:40 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Nicholas Piggin
  Cc: linuxppc-dev, linux-kernel

Time spent in kernel mode don't need to be accounted on transition
to user space. As far as the time spent in user is known, it
is possible to calculate the time spent in kernel by substracting
the time spent in user.

To do so, this patch modifies vtime_delta() to substract the
time spent in user since the last call to vtime_delta().

This patch gives a 2% improvment of null_syscall() selftest on a 83xx.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
But surprisingly, this patch degrades the null_syscall selftest by 20% on the 8xx. Any idea of the reason ?

 arch/powerpc/include/asm/accounting.h | 1 +
 arch/powerpc/include/asm/ppc_asm.h    | 8 +-------
 arch/powerpc/kernel/asm-offsets.c     | 8 ++------
 arch/powerpc/kernel/time.c            | 4 +++-
 4 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/arch/powerpc/include/asm/accounting.h b/arch/powerpc/include/asm/accounting.h
index c607c5d835cc..2f1ff5f9fd7a 100644
--- a/arch/powerpc/include/asm/accounting.h
+++ b/arch/powerpc/include/asm/accounting.h
@@ -27,6 +27,7 @@ struct cpu_accounting_data {
 	/* Internal counters */
 	unsigned long starttime;	/* TB value snapshot */
 	unsigned long starttime_user;	/* TB value on exit to usermode */
+	unsigned long utime_asm;
 #ifdef CONFIG_ARCH_HAS_SCALED_CPUTIME
 	unsigned long startspurr;	/* SPURR value snapshot */
 	unsigned long utime_sspurr;	/* ->user_time when ->startspurr set */
diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h
index e0637730a8e7..be17d570d484 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -28,9 +28,8 @@
 #define ACCOUNT_STOLEN_TIME
 #else
 #define ACCOUNT_CPU_USER_ENTRY(ptr, ra, rb)				\
-	MFTB(ra);			/* get timebase */		\
 	PPC_LL	rb, ACCOUNT_STARTTIME_USER(ptr);			\
-	PPC_STL	ra, ACCOUNT_STARTTIME(ptr);				\
+	MFTB(ra);			/* get timebase */		\
 	subf	rb,rb,ra;		/* subtract start value */	\
 	PPC_LL	ra, ACCOUNT_USER_TIME(ptr);				\
 	add	ra,ra,rb;		/* add on to user time */	\
@@ -38,12 +37,7 @@
 
 #define ACCOUNT_CPU_USER_EXIT(ptr, ra, rb)				\
 	MFTB(ra);			/* get timebase */		\
-	PPC_LL	rb, ACCOUNT_STARTTIME(ptr);				\
 	PPC_STL	ra, ACCOUNT_STARTTIME_USER(ptr);			\
-	subf	rb,rb,ra;		/* subtract start value */	\
-	PPC_LL	ra, ACCOUNT_SYSTEM_TIME(ptr);				\
-	add	ra,ra,rb;		/* add on to system time */	\
-	PPC_STL	ra, ACCOUNT_SYSTEM_TIME(ptr)
 
 #ifdef CONFIG_PPC_SPLPAR
 #define ACCOUNT_STOLEN_TIME						\
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index 7a1b93c5af63..f2ba7735f56f 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -260,19 +260,15 @@ int main(void)
 	OFFSET(PACAHWCPUID, paca_struct, hw_cpu_id);
 	OFFSET(PACAKEXECSTATE, paca_struct, kexec_state);
 	OFFSET(PACA_DSCR_DEFAULT, paca_struct, dscr_default);
-	OFFSET(ACCOUNT_STARTTIME, paca_struct, accounting.starttime);
 	OFFSET(ACCOUNT_STARTTIME_USER, paca_struct, accounting.starttime_user);
-	OFFSET(ACCOUNT_USER_TIME, paca_struct, accounting.utime);
-	OFFSET(ACCOUNT_SYSTEM_TIME, paca_struct, accounting.stime);
+	OFFSET(ACCOUNT_USER_TIME, paca_struct, accounting.utime_asm);
 	OFFSET(PACA_TRAP_SAVE, paca_struct, trap_save);
 	OFFSET(PACA_NAPSTATELOST, paca_struct, nap_state_lost);
 	OFFSET(PACA_SPRG_VDSO, paca_struct, sprg_vdso);
 #else /* CONFIG_PPC64 */
 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
-	OFFSET(ACCOUNT_STARTTIME, thread_info, accounting.starttime);
 	OFFSET(ACCOUNT_STARTTIME_USER, thread_info, accounting.starttime_user);
-	OFFSET(ACCOUNT_USER_TIME, thread_info, accounting.utime);
-	OFFSET(ACCOUNT_SYSTEM_TIME, thread_info, accounting.stime);
+	OFFSET(ACCOUNT_USER_TIME, thread_info, accounting.utime_asm);
 #endif
 #endif /* CONFIG_PPC64 */
 
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index bc0503ef9c9c..79420643b45f 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -331,8 +331,10 @@ static unsigned long vtime_delta(struct task_struct *tsk,
 	WARN_ON_ONCE(!irqs_disabled());
 
 	now = mftb();
-	stime = now - acct->starttime;
+	stime = now - acct->starttime - acct->utime_asm;
 	acct->starttime = now;
+	acct->utime += acct->utime_asm;
+	acct->utime_asm = 0;
 
 	*stime_scaled = vtime_delta_scaled(acct, now, stime);
 
-- 
2.13.3


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox