[RFC PATCH] powerpc/mm/mce: Keep irq disabled during lockless page table walk

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

STALE2508d LANDED

Landed in mainline as d9101bfa6adc on 2019-09-19.

2 messages, 2 authors, 2019-09-20 · open the first message on its own page

[RFC PATCH] powerpc/mm/mce: Keep irq disabled during lockless page table walk

From: Aneesh Kumar K.V <hidden>
Date: 2019-09-18 15:02:23

__find_linux_mm_pte return a page table entry pointer walking the
page table without holding locks. To make it safe against a THP
split and collapse, we disable interrupts around the lockless
page table walk. We need to keep the interrupts disabled as long
as we use the page table entry pointer.

Cc: Balbir Singh <bsingharora@gmail.com>
Cc: Reza Arbab <redacted>
Cc: Santosh Sivaraj <redacted>
Fixes: ba41e1e1ccb9 ("powerpc/mce: Hookup derror (load/store) UE errors")
Signed-off-by: Aneesh Kumar K.V <redacted>
---
 arch/powerpc/kernel/mce_power.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/arch/powerpc/kernel/mce_power.c b/arch/powerpc/kernel/mce_power.c
index 356e7b99f661..585c37dc1b18 100644
--- a/arch/powerpc/kernel/mce_power.c
+++ b/arch/powerpc/kernel/mce_power.c
@@ -28,6 +28,7 @@
 unsigned long addr_to_pfn(struct pt_regs *regs, unsigned long addr)
 {
 	pte_t *ptep;
+	unsigned long pfn;
 	unsigned int shift;
 	unsigned long flags;
 	struct mm_struct *mm;
@@ -39,18 +40,21 @@ unsigned long addr_to_pfn(struct pt_regs *regs, unsigned long addr)
 
 	local_irq_save(flags);
 	ptep = __find_linux_pte(mm->pgd, addr, NULL, &shift);
-	local_irq_restore(flags);
 
-	if (!ptep || pte_special(*ptep))
-		return ULONG_MAX;
+	if (!ptep || pte_special(*ptep)) {
+		pfn = ULONG_MAX;
+		goto err_out;
+	}
 
 	if (shift > PAGE_SHIFT) {
 		unsigned long rpnmask = (1ul << shift) - PAGE_SIZE;
 
-		return pte_pfn(__pte(pte_val(*ptep) | (addr & rpnmask)));
-	}
-
-	return pte_pfn(*ptep);
+		pfn = pte_pfn(__pte(pte_val(*ptep) | (addr & rpnmask)));
+	} else
+		pfn = pte_pfn(*ptep);
+err_out:
+	local_irq_restore(flags);
+	return pfn;
 }
 
 /* flush SLBs and reload */
-- 
2.21.0

Re: [RFC PATCH] powerpc/mm/mce: Keep irq disabled during lockless page table walk

From: Michael Ellerman <hidden>
Date: 2019-09-20 08:38:11

On Wed, 2019-09-18 at 14:53:28 UTC, "Aneesh Kumar K.V" wrote:
__find_linux_mm_pte return a page table entry pointer walking the
page table without holding locks. To make it safe against a THP
split and collapse, we disable interrupts around the lockless
page table walk. We need to keep the interrupts disabled as long
as we use the page table entry pointer.

Cc: Balbir Singh <bsingharora@gmail.com>
Cc: Reza Arbab <redacted>
Cc: Santosh Sivaraj <redacted>
Fixes: ba41e1e1ccb9 ("powerpc/mce: Hookup derror (load/store) UE errors")
Signed-off-by: Aneesh Kumar K.V <redacted>
Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/d9101bfa6adc831bda8836c4d774820553c14942

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help