Skip to contentSkip to conversation

powerpc/mm/radix: Properly clear process table entry

PATCH Applied Benjamin Herrenschmidt 5 participants 7 messages Jul 8, 2017 – Jul 11, 2017 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 powerpc/mm/radix: Properly clear process table entry

On radix, the process table entry we want to clear when destroying a context is entry 0, not entry 1

---
 arch/powerpc/mm/mmu_context_book3s64.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
arch/powerpc/mm/mmu_context_book3s64.c +9 -3
index 79d8c8a..9404b5e 100644
@@ -226,9 +226,15 @@ void destroy_context(struct mm_struct *mm)
 	mm->context.cop_lockp = NULL;
 #endif /* CONFIG_PPC_ICSWX */
 
-	if (radix_enabled())
-		process_tb[mm->context.id].prtb1 = 0;
-	else
+	if (radix_enabled()) {
+		/*
+		 * Radix doesn't have a valid bit in the process table
+		 * entries. However we know that at least P9 implementation
+		 * will avoid caching an entry with an invalid RTS field,
+		 * and 0 is invalid. So this will do.
+		 */
+		process_tb[mm->context.id].prtb0 = 0;
+	} else
 		subpage_prot_free(mm);
 	destroy_pagetable_page(mm);
 	__destroy_context(mm->context.id);
#1 lore raw
Quoted 2 lines · Benjamin Herrenschmidt

On radix, the process table entry we want to clear when destroying a context is entry 0, not entry 1

.. but has no real world consequence? Or causes the system to instantly catch fire?

I'll tag it:

Fixes 7e381c0ff618 ("powerpc/mm/radix: Add mmu context handling callback for radix")

cheers

Quoted 23 lines
arch/powerpc/mm/mmu_context_book3s64.c +9 -3
index 79d8c8a..9404b5e 100644
@@ -226,9 +226,15 @@ void destroy_context(struct mm_struct *mm)
 	mm->context.cop_lockp = NULL;
 #endif /* CONFIG_PPC_ICSWX */
 
-	if (radix_enabled())
-		process_tb[mm->context.id].prtb1 = 0;
-	else
+	if (radix_enabled()) {
+		/*
+		 * Radix doesn't have a valid bit in the process table
+		 * entries. However we know that at least P9 implementation
+		 * will avoid caching an entry with an invalid RTS field,
+		 * and 0 is invalid. So this will do.
+		 */
+		process_tb[mm->context.id].prtb0 = 0;
+	} else
 		subpage_prot_free(mm);
 	destroy_pagetable_page(mm);
 	__destroy_context(mm->context.id);
#2 lore raw
Quoted 7 lines · Michael Ellerman
Quoted 2 lines · Benjamin Herrenschmidt

On radix, the process table entry we want to clear when destroying a context is entry 0, not entry 1

.. but has no real world consequence? Or causes the system to instantly catch fire?

It has no *immediate* consequence on P9 , but it can cause other bugs to become worse (such as the KVM issue I'm chasing).

Quoted 30 lines

I'll tag it:

Fixes 7e381c0ff618 ("powerpc/mm/radix: Add mmu context handling callback for radix")

cheers

Quoted 23 lines
arch/powerpc/mm/mmu_context_book3s64.c +9 -3
index 79d8c8a..9404b5e 100644
@@ -226,9 +226,15 @@ void destroy_context(struct mm_struct *mm)
 	mm->context.cop_lockp = NULL;
 #endif /* CONFIG_PPC_ICSWX */
 
-	if (radix_enabled())
-		process_tb[mm->context.id].prtb1 = 0;
-	else
+	if (radix_enabled()) {
+		/*
+		 * Radix doesn't have a valid bit in the process table
+		 * entries. However we know that at least P9 implementation
+		 * will avoid caching an entry with an invalid RTS field,
+		 * and 0 is invalid. So this will do.
+		 */
+		process_tb[mm->context.id].prtb0 = 0;
+	} else
 		subpage_prot_free(mm);
 	destroy_pagetable_page(mm);
 	__destroy_context(mm->context.id);
#3 lore raw
Quoted 11 lines · Benjamin Herrenschmidt
Quoted 7 lines · Michael Ellerman
Quoted 2 lines · Benjamin Herrenschmidt

On radix, the process table entry we want to clear when destroying a context is entry 0, not entry 1

.. but has no real world consequence? Or causes the system to instantly catch fire?

It has no *immediate* consequence on P9 , but it can cause other bugs to become worse (such as the KVM issue I'm chasing).

OK, I'll flag it for stable then to be safe.

cheers

Reviewed-by on v1 1/2
#5 lore raw
In reply to Benjamin Herrenschmidt
Quoted 4 lines · Benjamin Herrenschmidt

On radix, the process table entry we want to clear when destroying a context is entry 0, not entry 1

Quoted 27 lines
---
 arch/powerpc/mm/mmu_context_book3s64.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
arch/powerpc/mm/mmu_context_book3s64.c +9 -3
index 79d8c8a..9404b5e 100644
@@ -226,9 +226,15 @@ void destroy_context(struct mm_struct *mm)
 	mm->context.cop_lockp = NULL;
 #endif /* CONFIG_PPC_ICSWX */
 
-	if (radix_enabled())
-		process_tb[mm->context.id].prtb1 = 0;
-	else
+	if (radix_enabled()) {
+		/*
+		 * Radix doesn't have a valid bit in the process table
+		 * entries. However we know that at least P9 implementation
+		 * will avoid caching an entry with an invalid RTS field,
+		 * and 0 is invalid. So this will do.
+		 */
+		process_tb[mm->context.id].prtb0 = 0;
+	} else
 		subpage_prot_free(mm);
 	destroy_pagetable_page(mm);
 	__destroy_context(mm->context.id);