Skip to contentSkip to conversation

powerpc/64s/hash: Fix assert_slb_presence() use of the slbfee. instruction

PATCH Applied Nicholas Piggin 3 participants 3 messages Feb 15, 2019 – Feb 22, 2019 PowerPC

lore
Share & tools
lore

Nicholas Piggin

author reviewer
#0 lore raw

PATCH 1/1 powerpc/64s/hash: Fix assert_slb_presence() use of the slbfee. instruction

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")
---
 arch/powerpc/mm/slb.c | 5 +++++
 1 file changed, 5 insertions(+)
arch/powerpc/mm/slb.c +5 -0
index bc3914d54e26..5986df48359b 100644
@@ -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));
Signature · 1 line
2.18.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · 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.

Quoted 13 lines
Fixes e15a4fea4d ("powerpc/64s/hash: Add some SLB debugging tests")
---
 arch/powerpc/mm/slb.c | 5 +++++
 1 file changed, 5 insertions(+)
arch/powerpc/mm/slb.c +0 -0
index bc3914d54e26..5986df48359b 100644

arch/powerpc/mm/slb.c static void assert_slb_presence(bool present, unsigned long ea) · line 76

Quoted 8 lines
arch/powerpc/mm/slb.c +5 -0
@@ -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?

Quoted 5 lines
arch/powerpc/mm/slb.c +0 -0
 	asm volatile(__PPC_SLBFEE_DOT(%0, %1) : "=r"(tmp) : "r"(ea) : "cr0");
 
 	WARN_ON(present == (tmp == 0));
Signature · 1 line
2.18.0
#2 lore raw
In reply to Nicholas Piggin
Quoted 11 lines · 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.

Quoted 5 lines
Fixes e15a4fea4d ("powerpc/64s/hash: Add some SLB debugging tests")

Applied to powerpc next, thanks.

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

cheers