linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] powerpc/mm/mce: Keep irq disabled during lockless page table walk
@ 2019-09-18 14:53 Aneesh Kumar K.V
  2019-09-20  8:36 ` Michael Ellerman
  0 siblings, 1 reply; 2+ messages in thread
From: Aneesh Kumar K.V @ 2019-09-18 14:53 UTC (permalink / raw)
  To: mpe; +Cc: Reza Arbab, Aneesh Kumar K.V, linuxppc-dev, Santosh Sivaraj

__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 <arbab@linux.ibm.com>
Cc: Santosh Sivaraj <santosh@fossix.org>
Fixes: ba41e1e1ccb9 ("powerpc/mce: Hookup derror (load/store) UE errors")
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
 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


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

* Re: [RFC PATCH] powerpc/mm/mce: Keep irq disabled during lockless page table walk
  2019-09-18 14:53 [RFC PATCH] powerpc/mm/mce: Keep irq disabled during lockless page table walk Aneesh Kumar K.V
@ 2019-09-20  8:36 ` Michael Ellerman
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2019-09-20  8:36 UTC (permalink / raw)
  To: Aneesh Kumar K.V
  Cc: Aneesh Kumar K.V, Santosh Sivaraj, Reza Arbab, linuxppc-dev

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 <arbab@linux.ibm.com>
> Cc: Santosh Sivaraj <santosh@fossix.org>
> Fixes: ba41e1e1ccb9 ("powerpc/mce: Hookup derror (load/store) UE errors")
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>

Applied to powerpc next, thanks.

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

cheers

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

end of thread, other threads:[~2019-09-20  8:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-18 14:53 [RFC PATCH] powerpc/mm/mce: Keep irq disabled during lockless page table walk Aneesh Kumar K.V
2019-09-20  8:36 ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).