All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/64s/radix: Fix radix segment exception handling
@ 2019-03-29  7:42 Nicholas Piggin
  2019-03-30  5:58 ` Aneesh Kumar K.V
  2019-04-10 14:49 ` Michael Ellerman
  0 siblings, 2 replies; 6+ messages in thread
From: Nicholas Piggin @ 2019-03-29  7:42 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Aneesh Kumar K . V, Nicholas Piggin, Anton Blanchard

Commit 48e7b76957 ("powerpc/64s/hash: Convert SLB miss handlers to C")
broke the radix-mode segment exception handler. In radix mode, this is
exception is not an SLB miss, rather it signals that the EA is outside
the range translated by any page table.

The commit lost the radix feature alternate code patch, which can
cause faults to some EAs to kernel BUG at arch/powerpc/mm/slb.c:639!

The original radix code would send faults to slb_miss_large_addr,
which would end up faulting due to slb_addr_limit being 0. This patch
sends radix directly to do_bad_slb_fault, which is a bit clearer.

Fixes: 48e7b76957 ("powerpc/64s/hash: Convert SLB miss handlers to C")
Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Reported-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/kernel/exceptions-64s.S | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index a5b8fbae56a0..9481a117e242 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -656,11 +656,17 @@ EXC_COMMON_BEGIN(data_access_slb_common)
 	ld	r4,PACA_EXSLB+EX_DAR(r13)
 	std	r4,_DAR(r1)
 	addi	r3,r1,STACK_FRAME_OVERHEAD
+BEGIN_MMU_FTR_SECTION
+	/* HPT case, do SLB fault */
 	bl	do_slb_fault
 	cmpdi	r3,0
 	bne-	1f
 	b	fast_exception_return
 1:	/* Error case */
+MMU_FTR_SECTION_ELSE
+	/* Radix case, access is outside page table range */
+	li	r3,-EFAULT
+ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX)
 	std	r3,RESULT(r1)
 	bl	save_nvgprs
 	RECONCILE_IRQ_STATE(r10, r11)
@@ -705,11 +711,17 @@ EXC_COMMON_BEGIN(instruction_access_slb_common)
 	EXCEPTION_PROLOG_COMMON(0x480, PACA_EXSLB)
 	ld	r4,_NIP(r1)
 	addi	r3,r1,STACK_FRAME_OVERHEAD
+BEGIN_MMU_FTR_SECTION
+	/* HPT case, do SLB fault */
 	bl	do_slb_fault
 	cmpdi	r3,0
 	bne-	1f
 	b	fast_exception_return
 1:	/* Error case */
+MMU_FTR_SECTION_ELSE
+	/* Radix case, access is outside page table range */
+	li	r3,-EFAULT
+ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX)
 	std	r3,RESULT(r1)
 	bl	save_nvgprs
 	RECONCILE_IRQ_STATE(r10, r11)
-- 
2.20.1


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

* Re: [PATCH] powerpc/64s/radix: Fix radix segment exception handling
  2019-03-29  7:42 [PATCH] powerpc/64s/radix: Fix radix segment exception handling Nicholas Piggin
@ 2019-03-30  5:58 ` Aneesh Kumar K.V
  2019-04-10 14:49 ` Michael Ellerman
  1 sibling, 0 replies; 6+ messages in thread
From: Aneesh Kumar K.V @ 2019-03-30  5:58 UTC (permalink / raw)
  To: Nicholas Piggin, linuxppc-dev
  Cc: Aneesh Kumar K . V, Nicholas Piggin, Anton Blanchard

Nicholas Piggin <npiggin@gmail.com> writes:

> Commit 48e7b76957 ("powerpc/64s/hash: Convert SLB miss handlers to C")
> broke the radix-mode segment exception handler. In radix mode, this is
> exception is not an SLB miss, rather it signals that the EA is outside
> the range translated by any page table.
>
> The commit lost the radix feature alternate code patch, which can
> cause faults to some EAs to kernel BUG at arch/powerpc/mm/slb.c:639!
>
> The original radix code would send faults to slb_miss_large_addr,
> which would end up faulting due to slb_addr_limit being 0. This patch
> sends radix directly to do_bad_slb_fault, which is a bit clearer.
>

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

> Fixes: 48e7b76957 ("powerpc/64s/hash: Convert SLB miss handlers to C")
> Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> Reported-by: Anton Blanchard <anton@samba.org>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
>  arch/powerpc/kernel/exceptions-64s.S | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
> index a5b8fbae56a0..9481a117e242 100644
> --- a/arch/powerpc/kernel/exceptions-64s.S
> +++ b/arch/powerpc/kernel/exceptions-64s.S
> @@ -656,11 +656,17 @@ EXC_COMMON_BEGIN(data_access_slb_common)
>  	ld	r4,PACA_EXSLB+EX_DAR(r13)
>  	std	r4,_DAR(r1)
>  	addi	r3,r1,STACK_FRAME_OVERHEAD
> +BEGIN_MMU_FTR_SECTION
> +	/* HPT case, do SLB fault */
>  	bl	do_slb_fault
>  	cmpdi	r3,0
>  	bne-	1f
>  	b	fast_exception_return
>  1:	/* Error case */
> +MMU_FTR_SECTION_ELSE
> +	/* Radix case, access is outside page table range */
> +	li	r3,-EFAULT
> +ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX)
>  	std	r3,RESULT(r1)
>  	bl	save_nvgprs
>  	RECONCILE_IRQ_STATE(r10, r11)
> @@ -705,11 +711,17 @@ EXC_COMMON_BEGIN(instruction_access_slb_common)
>  	EXCEPTION_PROLOG_COMMON(0x480, PACA_EXSLB)
>  	ld	r4,_NIP(r1)
>  	addi	r3,r1,STACK_FRAME_OVERHEAD
> +BEGIN_MMU_FTR_SECTION
> +	/* HPT case, do SLB fault */
>  	bl	do_slb_fault
>  	cmpdi	r3,0
>  	bne-	1f
>  	b	fast_exception_return
>  1:	/* Error case */
> +MMU_FTR_SECTION_ELSE
> +	/* Radix case, access is outside page table range */
> +	li	r3,-EFAULT
> +ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX)
>  	std	r3,RESULT(r1)
>  	bl	save_nvgprs
>  	RECONCILE_IRQ_STATE(r10, r11)
> -- 
> 2.20.1


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

* Re: powerpc/64s/radix: Fix radix segment exception handling
  2019-03-29  7:42 [PATCH] powerpc/64s/radix: Fix radix segment exception handling Nicholas Piggin
  2019-03-30  5:58 ` Aneesh Kumar K.V
@ 2019-04-10 14:49 ` Michael Ellerman
  2019-04-12  3:35   ` Nicholas Piggin
  1 sibling, 1 reply; 6+ messages in thread
From: Michael Ellerman @ 2019-04-10 14:49 UTC (permalink / raw)
  To: Nicholas Piggin, linuxppc-dev
  Cc: Aneesh Kumar K . V, Nicholas Piggin, Anton Blanchard

On Fri, 2019-03-29 at 07:42:57 UTC, Nicholas Piggin wrote:
> Commit 48e7b76957 ("powerpc/64s/hash: Convert SLB miss handlers to C")
> broke the radix-mode segment exception handler. In radix mode, this is
> exception is not an SLB miss, rather it signals that the EA is outside
> the range translated by any page table.
> 
> The commit lost the radix feature alternate code patch, which can
> cause faults to some EAs to kernel BUG at arch/powerpc/mm/slb.c:639!
> 
> The original radix code would send faults to slb_miss_large_addr,
> which would end up faulting due to slb_addr_limit being 0. This patch
> sends radix directly to do_bad_slb_fault, which is a bit clearer.
> 
> Fixes: 48e7b76957 ("powerpc/64s/hash: Convert SLB miss handlers to C")
> Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> Reported-by: Anton Blanchard <anton@samba.org>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/7100e8704b61247649c50551b965e71d

cheers

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

* Re: powerpc/64s/radix: Fix radix segment exception handling
  2019-04-10 14:49 ` Michael Ellerman
@ 2019-04-12  3:35   ` Nicholas Piggin
  2019-04-13  3:39     ` Michael Ellerman
  0 siblings, 1 reply; 6+ messages in thread
From: Nicholas Piggin @ 2019-04-12  3:35 UTC (permalink / raw)
  To: linuxppc-dev, Michael Ellerman; +Cc: Aneesh Kumar K . V, Anton Blanchard

Michael Ellerman's on April 11, 2019 12:49 am:
> On Fri, 2019-03-29 at 07:42:57 UTC, Nicholas Piggin wrote:
>> Commit 48e7b76957 ("powerpc/64s/hash: Convert SLB miss handlers to C")
>> broke the radix-mode segment exception handler. In radix mode, this is
>> exception is not an SLB miss, rather it signals that the EA is outside
>> the range translated by any page table.
>> 
>> The commit lost the radix feature alternate code patch, which can
>> cause faults to some EAs to kernel BUG at arch/powerpc/mm/slb.c:639!
>> 
>> The original radix code would send faults to slb_miss_large_addr,
>> which would end up faulting due to slb_addr_limit being 0. This patch
>> sends radix directly to do_bad_slb_fault, which is a bit clearer.
>> 
>> Fixes: 48e7b76957 ("powerpc/64s/hash: Convert SLB miss handlers to C")
>> Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
>> Reported-by: Anton Blanchard <anton@samba.org>
>> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>> Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> 
> Applied to powerpc fixes, thanks.
> 
> https://git.kernel.org/powerpc/c/7100e8704b61247649c50551b965e71d

I sent a v2 with a selftests that triggers the crash if you want it.
Code was unchanged to no big deal there.

Thanks,
Nick


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

* Re: powerpc/64s/radix: Fix radix segment exception handling
  2019-04-12  3:35   ` Nicholas Piggin
@ 2019-04-13  3:39     ` Michael Ellerman
  2019-04-13  5:59       ` Nicholas Piggin
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Ellerman @ 2019-04-13  3:39 UTC (permalink / raw)
  To: Nicholas Piggin, linuxppc-dev, Michael Ellerman
  Cc: Aneesh Kumar K . V, Anton Blanchard

Nicholas Piggin <npiggin@gmail.com> writes:
> Michael Ellerman's on April 11, 2019 12:49 am:
>> On Fri, 2019-03-29 at 07:42:57 UTC, Nicholas Piggin wrote:
>>> Commit 48e7b76957 ("powerpc/64s/hash: Convert SLB miss handlers to C")
>>> broke the radix-mode segment exception handler. In radix mode, this is
>>> exception is not an SLB miss, rather it signals that the EA is outside
>>> the range translated by any page table.
>>> 
>>> The commit lost the radix feature alternate code patch, which can
>>> cause faults to some EAs to kernel BUG at arch/powerpc/mm/slb.c:639!
>>> 
>>> The original radix code would send faults to slb_miss_large_addr,
>>> which would end up faulting due to slb_addr_limit being 0. This patch
>>> sends radix directly to do_bad_slb_fault, which is a bit clearer.
>>> 
>>> Fixes: 48e7b76957 ("powerpc/64s/hash: Convert SLB miss handlers to C")
>>> Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
>>> Reported-by: Anton Blanchard <anton@samba.org>
>>> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>>> Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
>> 
>> Applied to powerpc fixes, thanks.
>> 
>> https://git.kernel.org/powerpc/c/7100e8704b61247649c50551b965e71d
>
> I sent a v2 with a selftests that triggers the crash if you want it.
> Code was unchanged to no big deal there.

Yeah I checked the kernel part was unchanged so stuck with v1.

I also sent a self test, which is similar but slightly different to
yours, though yours is better in general. I'll try and merge them into
one test.

cheers

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

* Re: powerpc/64s/radix: Fix radix segment exception handling
  2019-04-13  3:39     ` Michael Ellerman
@ 2019-04-13  5:59       ` Nicholas Piggin
  0 siblings, 0 replies; 6+ messages in thread
From: Nicholas Piggin @ 2019-04-13  5:59 UTC (permalink / raw)
  To: linuxppc-dev, Michael Ellerman, Michael Ellerman
  Cc: Aneesh Kumar K . V, Anton Blanchard

Michael Ellerman's on April 13, 2019 1:39 pm:
> Nicholas Piggin <npiggin@gmail.com> writes:
>> Michael Ellerman's on April 11, 2019 12:49 am:
>>> On Fri, 2019-03-29 at 07:42:57 UTC, Nicholas Piggin wrote:
>>>> Commit 48e7b76957 ("powerpc/64s/hash: Convert SLB miss handlers to C")
>>>> broke the radix-mode segment exception handler. In radix mode, this is
>>>> exception is not an SLB miss, rather it signals that the EA is outside
>>>> the range translated by any page table.
>>>> 
>>>> The commit lost the radix feature alternate code patch, which can
>>>> cause faults to some EAs to kernel BUG at arch/powerpc/mm/slb.c:639!
>>>> 
>>>> The original radix code would send faults to slb_miss_large_addr,
>>>> which would end up faulting due to slb_addr_limit being 0. This patch
>>>> sends radix directly to do_bad_slb_fault, which is a bit clearer.
>>>> 
>>>> Fixes: 48e7b76957 ("powerpc/64s/hash: Convert SLB miss handlers to C")
>>>> Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
>>>> Reported-by: Anton Blanchard <anton@samba.org>
>>>> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>>>> Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
>>> 
>>> Applied to powerpc fixes, thanks.
>>> 
>>> https://git.kernel.org/powerpc/c/7100e8704b61247649c50551b965e71d
>>
>> I sent a v2 with a selftests that triggers the crash if you want it.
>> Code was unchanged to no big deal there.
> 
> Yeah I checked the kernel part was unchanged so stuck with v1.
> 
> I also sent a self test, which is similar but slightly different to
> yours, though yours is better in general. I'll try and merge them into
> one test.

If you don't mind that would be good. The siglongjmp handler is
cleaner though, and should make it simpler to test ifetch accesses.
We just need to get the sig info into yours, and an array of
interesting addresses.

Thanks,
Nick


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

end of thread, other threads:[~2019-04-13  6:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-29  7:42 [PATCH] powerpc/64s/radix: Fix radix segment exception handling Nicholas Piggin
2019-03-30  5:58 ` Aneesh Kumar K.V
2019-04-10 14:49 ` Michael Ellerman
2019-04-12  3:35   ` Nicholas Piggin
2019-04-13  3:39     ` Michael Ellerman
2019-04-13  5:59       ` Nicholas Piggin

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.