Skip to contentSkip to conversation

mm-add-pte-pointer-parameter-to-flush_tlb_fix_spurious_fault.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Mar 28, 2023

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm: add PTE pointer parameter to flush_tlb_fix_spurious_fault()
has been removed from the -mm tree. Its filename was
mm-add-pte-pointer-parameter-to-flush_tlb_fix_spurious_fault.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Gerald Schaefer <[email protected]>
Subject: mm: add PTE pointer parameter to flush_tlb_fix_spurious_fault()
Date: Mon, 6 Mar 2023 17:15:48 +0100

s390 can do more fine-grained handling of spurious TLB protection faults, when there also is the PTE pointer available.

Therefore, pass on the PTE pointer to flush_tlb_fix_spurious_fault() as an additional parameter.

This will add no functional change to other architectures, but those with private flush_tlb_fix_spurious_fault() implementations need to be made aware of the new parameter.

---

 arch/arm64/include/asm/pgtable.h              |    2 +-
 arch/mips/include/asm/pgtable.h               |    3 ++-
 arch/powerpc/include/asm/book3s/64/tlbflush.h |    3 ++-
 arch/s390/include/asm/pgtable.h               |   12 +++++++-----
 arch/x86/include/asm/pgtable.h                |    2 +-
 include/linux/pgtable.h                       |    2 +-
 mm/memory.c                                   |    3 ++-
 mm/pgtable-generic.c                          |    2 +-
 8 files changed, 17 insertions(+), 12 deletions(-)
arch/arm64/include/asm/pgtable.h renamed from arch/arm64/include/asm/pgtable.h~mm-add-pte-pointer-parameter-to-flush_tlb_fix_spurious_fault +1 -1
@@ -57,7 +57,7 @@ static inline bool arch_thp_swp_supporte
  * fault on one CPU which has been handled concurrently by another CPU
  * does not need to perform additional invalidation.
  */
-#define flush_tlb_fix_spurious_fault(vma, address) do { } while (0)
+#define flush_tlb_fix_spurious_fault(vma, address, ptep) do { } while (0)
 
 /*
  * ZERO_PAGE is a global shared page that is always zero: used
arch/mips/include/asm/pgtable.h renamed from arch/mips/include/asm/pgtable.h~mm-add-pte-pointer-parameter-to-flush_tlb_fix_spurious_fault +2 -1
@@ -469,7 +469,8 @@ static inline pgprot_t pgprot_writecombi
 }
 
 static inline void flush_tlb_fix_spurious_fault(struct vm_area_struct *vma,
-						unsigned long address)
+						unsigned long address,
+						pte_t *ptep)
 {
 }
 
arch/powerpc/include/asm/book3s/64/tlbflush.h renamed from arch/powerpc/include/asm/book3s/64/tlbflush.h~mm-add-pte-pointer-parameter-to-flush_tlb_fix_spurious_fault +2 -1
@@ -121,7 +121,8 @@ static inline void flush_tlb_page(struct
 
 #define flush_tlb_fix_spurious_fault flush_tlb_fix_spurious_fault
 static inline void flush_tlb_fix_spurious_fault(struct vm_area_struct *vma,
-						unsigned long address)
+						unsigned long address,
+						pte_t *ptep)
 {
 	/*
 	 * Book3S 64 does not require spurious fault flushes because the PTE
arch/s390/include/asm/pgtable.h renamed from arch/s390/include/asm/pgtable.h~mm-add-pte-pointer-parameter-to-flush_tlb_fix_spurious_fault +7 -5
@@ -1239,7 +1239,8 @@ static inline int pte_allow_rdp(pte_t ol
 }
 
 static inline void flush_tlb_fix_spurious_fault(struct vm_area_struct *vma,
-						unsigned long address)
+						unsigned long address,
+						pte_t *ptep)
 {
 	/*
 	 * RDP might not have propagated the PTE protection reset to all CPUs,
@@ -1247,11 +1248,12 @@ static inline void flush_tlb_fix_spuriou
 	 * NOTE: This will also be called when a racing pagetable update on
 	 * another thread already installed the correct PTE. Both cases cannot
 	 * really be distinguished.
-	 * Therefore, only do the local TLB flush when RDP can be used, to avoid
-	 * unnecessary overhead.
+	 * Therefore, only do the local TLB flush when RDP can be used, and the
+	 * PTE does not have _PAGE_PROTECT set, to avoid unnecessary overhead.
+	 * A local RDP can be used to do the flush.
 	 */
-	if (MACHINE_HAS_RDP)
-		asm volatile("ptlb" : : : "memory");
+	if (MACHINE_HAS_RDP && !(pte_val(*ptep) & _PAGE_PROTECT))
+		__ptep_rdp(address, ptep, 0, 0, 1);
 }
 #define flush_tlb_fix_spurious_fault flush_tlb_fix_spurious_fault
 
arch/x86/include/asm/pgtable.h renamed from arch/x86/include/asm/pgtable.h~mm-add-pte-pointer-parameter-to-flush_tlb_fix_spurious_fault +1 -1
@@ -1097,7 +1097,7 @@ static inline void ptep_set_wrprotect(st
 	clear_bit(_PAGE_BIT_RW, (unsigned long *)&ptep->pte);
 }
 
-#define flush_tlb_fix_spurious_fault(vma, address) do { } while (0)
+#define flush_tlb_fix_spurious_fault(vma, address, ptep) do { } while (0)
 
 #define mk_pmd(page, pgprot)   pfn_pmd(page_to_pfn(page), (pgprot))
 
include/linux/pgtable.h renamed from include/linux/pgtable.h~mm-add-pte-pointer-parameter-to-flush_tlb_fix_spurious_fault +1 -1
@@ -817,7 +817,7 @@ static inline void arch_swap_restore(swp
 #endif
 
 #ifndef flush_tlb_fix_spurious_fault
-#define flush_tlb_fix_spurious_fault(vma, address) flush_tlb_page(vma, address)
+#define flush_tlb_fix_spurious_fault(vma, address, ptep) flush_tlb_page(vma, address)
 #endif
 
 /*
mm/memory.c renamed from mm/memory.c~mm-add-pte-pointer-parameter-to-flush_tlb_fix_spurious_fault +2 -1
@@ -4968,7 +4968,8 @@ static vm_fault_t handle_pte_fault(struc
 		 * with threads.
 		 */
 		if (vmf->flags & FAULT_FLAG_WRITE)
-			flush_tlb_fix_spurious_fault(vmf->vma, vmf->address);
+			flush_tlb_fix_spurious_fault(vmf->vma, vmf->address,
+						     vmf->pte);
 	}
 unlock:
 	pte_unmap_unlock(vmf->pte, vmf->ptl);
mm/pgtable-generic.c renamed from mm/pgtable-generic.c~mm-add-pte-pointer-parameter-to-flush_tlb_fix_spurious_fault +1 -1
@@ -69,7 +69,7 @@ int ptep_set_access_flags(struct vm_area
 	int changed = !pte_same(*ptep, entry);
 	if (changed) {
 		set_pte_at(vma->vm_mm, address, ptep, entry);
-		flush_tlb_fix_spurious_fault(vma, address);
+		flush_tlb_fix_spurious_fault(vma, address, ptep);
 	}
 	return changed;
 }

_

Patches currently in -mm which might be from [email protected] are