All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc: Fix faults caused by radix patching of SLB miss handler
@ 2016-06-21 10:36 Michael Ellerman
  2016-06-22  1:56 ` Aneesh Kumar K.V
  2016-06-23  9:26 ` Michael Ellerman
  0 siblings, 2 replies; 3+ messages in thread
From: Michael Ellerman @ 2016-06-21 10:36 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: aneesh.kumar, Benjamin Herrenschmidt, kda

As part of the Radix MMU support we added some feature sections in the
SLB miss handler. These are intended to catch the case that we
incorrectly take an SLB miss when Radix is enabled, and instead of
crashing weirdly they bail out to a well defined exit path and trigger
an oops.

However the way they were written meant the bailout case was enabled by
default until we did CPU feature patching.

On powermacs the early debug prints in setup_system() can cause an SLB
miss, which happens before code patching, and so the SLB miss handler
would incorrectly bailout and crash during boot.

Fix it by inverting the sense of the feature section, so that the code
which is in place at boot is correct for the hash case. Once we
determine we are using Radix - which will never happen on a powermac -
only then do we patch in the bailout case which unconditionally jumps.

Fixes: caca285e5ab4 ("powerpc/mm/radix: Use STD_MMU_64 to properly isolate hash related code")
Reported-by: Denis Kirjanov <kda@linux-powerpc.org>
Tested-by: Denis Kirjanov <kda@linux-powerpc.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/kernel/exceptions-64s.S | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 4c9440629128..8bcc1b457115 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1399,11 +1399,12 @@ END_MMU_FTR_SECTION_IFCLR(MMU_FTR_RADIX)
 	lwz	r9,PACA_EXSLB+EX_CCR(r13)	/* get saved CR */
 
 	mtlr	r10
-BEGIN_MMU_FTR_SECTION
-	b	2f
-END_MMU_FTR_SECTION_IFSET(MMU_FTR_RADIX)
 	andi.	r10,r12,MSR_RI	/* check for unrecoverable exception */
+BEGIN_MMU_FTR_SECTION
 	beq-	2f
+FTR_SECTION_ELSE
+	b	2f
+ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_RADIX)
 
 .machine	push
 .machine	"power4"
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] powerpc: Fix faults caused by radix patching of SLB miss handler
  2016-06-21 10:36 [PATCH] powerpc: Fix faults caused by radix patching of SLB miss handler Michael Ellerman
@ 2016-06-22  1:56 ` Aneesh Kumar K.V
  2016-06-23  9:26 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Aneesh Kumar K.V @ 2016-06-22  1:56 UTC (permalink / raw)
  To: Michael Ellerman, linuxppc-dev; +Cc: Benjamin Herrenschmidt, kda

Michael Ellerman <mpe@ellerman.id.au> writes:

> As part of the Radix MMU support we added some feature sections in the
> SLB miss handler. These are intended to catch the case that we
> incorrectly take an SLB miss when Radix is enabled, and instead of
> crashing weirdly they bail out to a well defined exit path and trigger
> an oops.
>
> However the way they were written meant the bailout case was enabled by
> default until we did CPU feature patching.
>
> On powermacs the early debug prints in setup_system() can cause an SLB
> miss, which happens before code patching, and so the SLB miss handler
> would incorrectly bailout and crash during boot.
>
> Fix it by inverting the sense of the feature section, so that the code
> which is in place at boot is correct for the hash case. Once we
> determine we are using Radix - which will never happen on a powermac -
> only then do we patch in the bailout case which unconditionally jumps.
>
> Fixes: caca285e5ab4 ("powerpc/mm/radix: Use STD_MMU_64 to properly isolate hash related code")
> Reported-by: Denis Kirjanov <kda@linux-powerpc.org>
> Tested-by: Denis Kirjanov <kda@linux-powerpc.org>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>


Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

> ---
>  arch/powerpc/kernel/exceptions-64s.S | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
> index 4c9440629128..8bcc1b457115 100644
> --- a/arch/powerpc/kernel/exceptions-64s.S
> +++ b/arch/powerpc/kernel/exceptions-64s.S
> @@ -1399,11 +1399,12 @@ END_MMU_FTR_SECTION_IFCLR(MMU_FTR_RADIX)
>  	lwz	r9,PACA_EXSLB+EX_CCR(r13)	/* get saved CR */
>
>  	mtlr	r10
> -BEGIN_MMU_FTR_SECTION
> -	b	2f
> -END_MMU_FTR_SECTION_IFSET(MMU_FTR_RADIX)
>  	andi.	r10,r12,MSR_RI	/* check for unrecoverable exception */
> +BEGIN_MMU_FTR_SECTION
>  	beq-	2f
> +FTR_SECTION_ELSE
> +	b	2f
> +ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_RADIX)
>
>  .machine	push
>  .machine	"power4"
> -- 
> 2.5.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: powerpc: Fix faults caused by radix patching of SLB miss handler
  2016-06-21 10:36 [PATCH] powerpc: Fix faults caused by radix patching of SLB miss handler Michael Ellerman
  2016-06-22  1:56 ` Aneesh Kumar K.V
@ 2016-06-23  9:26 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2016-06-23  9:26 UTC (permalink / raw)
  To: Michael Ellerman, linuxppc-dev; +Cc: kda, aneesh.kumar

On Tue, 2016-21-06 at 10:36:19 UTC, Michael Ellerman wrote:
> As part of the Radix MMU support we added some feature sections in the
> SLB miss handler. These are intended to catch the case that we
> incorrectly take an SLB miss when Radix is enabled, and instead of
> crashing weirdly they bail out to a well defined exit path and trigger
> an oops.
> 
> However the way they were written meant the bailout case was enabled by
> default until we did CPU feature patching.
> 
> On powermacs the early debug prints in setup_system() can cause an SLB
> miss, which happens before code patching, and so the SLB miss handler
> would incorrectly bailout and crash during boot.
> 
> Fix it by inverting the sense of the feature section, so that the code
> which is in place at boot is correct for the hash case. Once we
> determine we are using Radix - which will never happen on a powermac -
> only then do we patch in the bailout case which unconditionally jumps.
> 
> Fixes: caca285e5ab4 ("powerpc/mm/radix: Use STD_MMU_64 to properly isolate hash related code")
> Reported-by: Denis Kirjanov <kda@linux-powerpc.org>
> Tested-by: Denis Kirjanov <kda@linux-powerpc.org>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

Applied to powerpc fixes.

https://git.kernel.org/powerpc/c/6e914ee629c411d9c6d160399c

cheers

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-06-23  9:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-21 10:36 [PATCH] powerpc: Fix faults caused by radix patching of SLB miss handler Michael Ellerman
2016-06-22  1:56 ` Aneesh Kumar K.V
2016-06-23  9:26 ` Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.