All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/64s/hash: Fix assert_slb_presence() use of the slbfee. instruction
@ 2019-02-15 10:20 Nicholas Piggin
  2019-02-15 10:27 ` Aneesh Kumar K.V
  2019-02-22  9:48 ` Michael Ellerman
  0 siblings, 2 replies; 3+ messages in thread
From: Nicholas Piggin @ 2019-02-15 10:20 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Aneesh Kumar K . V, Nicholas Piggin

The slbfee. instruction must have bit 24 of RB clear, failure to do
so can result in false negatives that result in incorrect assertions.

This is not obvious from the ISA v3.0B document, which only says:

    The hardware ignores the contents of RB 36:38 40:63 -- p.1032

This patch fixes the bug and also clears all other bits from PPC bit
36-63, which is good practice when dealing with reserved or ignored
bits.

Fixes: e15a4fea4d ("powerpc/64s/hash: Add some SLB debugging tests")
Reported-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Tested-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/mm/slb.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/powerpc/mm/slb.c b/arch/powerpc/mm/slb.c
index bc3914d54e26..5986df48359b 100644
--- a/arch/powerpc/mm/slb.c
+++ b/arch/powerpc/mm/slb.c
@@ -69,6 +69,11 @@ static void assert_slb_presence(bool present, unsigned long ea)
 	if (!cpu_has_feature(CPU_FTR_ARCH_206))
 		return;
 
+	/*
+	 * slbfee. requires bit 24 (PPC bit 39) be clear in RB. Hardware
+	 * ignores all other bits from 0-27, so just clear them all.
+	 */
+	ea &= ~((1UL << 28) - 1);
 	asm volatile(__PPC_SLBFEE_DOT(%0, %1) : "=r"(tmp) : "r"(ea) : "cr0");
 
 	WARN_ON(present == (tmp == 0));
-- 
2.18.0


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

* Re: [PATCH] powerpc/64s/hash: Fix assert_slb_presence() use of the slbfee. instruction
  2019-02-15 10:20 [PATCH] powerpc/64s/hash: Fix assert_slb_presence() use of the slbfee. instruction Nicholas Piggin
@ 2019-02-15 10:27 ` Aneesh Kumar K.V
  2019-02-22  9:48 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Aneesh Kumar K.V @ 2019-02-15 10:27 UTC (permalink / raw)
  To: Nicholas Piggin, linuxppc-dev; +Cc: Nicholas Piggin

Nicholas Piggin <npiggin@gmail.com> writes:

> The slbfee. instruction must have bit 24 of RB clear, failure to do
> so can result in false negatives that result in incorrect assertions.
>
> This is not obvious from the ISA v3.0B document, which only says:
>
>     The hardware ignores the contents of RB 36:38 40:63 -- p.1032
>
> This patch fixes the bug and also clears all other bits from PPC bit
> 36-63, which is good practice when dealing with reserved or ignored
> bits.
>

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

> Fixes: e15a4fea4d ("powerpc/64s/hash: Add some SLB debugging tests")
> Reported-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> Tested-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
>  arch/powerpc/mm/slb.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/arch/powerpc/mm/slb.c b/arch/powerpc/mm/slb.c
> index bc3914d54e26..5986df48359b 100644
> --- a/arch/powerpc/mm/slb.c
> +++ b/arch/powerpc/mm/slb.c
> @@ -69,6 +69,11 @@ static void assert_slb_presence(bool present, unsigned long ea)
>  	if (!cpu_has_feature(CPU_FTR_ARCH_206))
>  		return;
>  
> +	/*
> +	 * slbfee. requires bit 24 (PPC bit 39) be clear in RB. Hardware
> +	 * ignores all other bits from 0-27, so just clear them all.
> +	 */
> +	ea &= ~((1UL << 28) - 1);

I guess these numbers '28' are derived from the size of the smallest
segment we support. If co can we use ESID_MASK?


>  	asm volatile(__PPC_SLBFEE_DOT(%0, %1) : "=r"(tmp) : "r"(ea) : "cr0");
>  
>  	WARN_ON(present == (tmp == 0));
> -- 
> 2.18.0


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

* Re: powerpc/64s/hash: Fix assert_slb_presence() use of the slbfee. instruction
  2019-02-15 10:20 [PATCH] powerpc/64s/hash: Fix assert_slb_presence() use of the slbfee. instruction Nicholas Piggin
  2019-02-15 10:27 ` Aneesh Kumar K.V
@ 2019-02-22  9:48 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2019-02-22  9:48 UTC (permalink / raw)
  To: Nicholas Piggin, linuxppc-dev; +Cc: Aneesh Kumar K . V, Nicholas Piggin

On Fri, 2019-02-15 at 10:20:20 UTC, Nicholas Piggin wrote:
> The slbfee. instruction must have bit 24 of RB clear, failure to do
> so can result in false negatives that result in incorrect assertions.
> 
> This is not obvious from the ISA v3.0B document, which only says:
> 
>     The hardware ignores the contents of RB 36:38 40:63 -- p.1032
> 
> This patch fixes the bug and also clears all other bits from PPC bit
> 36-63, which is good practice when dealing with reserved or ignored
> bits.
> 
> Fixes: e15a4fea4d ("powerpc/64s/hash: Add some SLB debugging tests")
> Reported-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> Tested-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/7104dccfd052fde51eecc9972dad9c40

cheers

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

end of thread, other threads:[~2019-02-22 10:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-15 10:20 [PATCH] powerpc/64s/hash: Fix assert_slb_presence() use of the slbfee. instruction Nicholas Piggin
2019-02-15 10:27 ` Aneesh Kumar K.V
2019-02-22  9:48 ` 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.