mirror of
https://github.com/torvalds/linux.git
synced 2026-09-25 21:21:09 -04:00
mm: add PTE pointer parameter to flush_tlb_fix_spurious_fault()
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. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Gerald Schaefer <[email protected]> Reviewed-by: Alexander Gordeev <[email protected]> Acked-by: Catalin Marinas <[email protected]> [arm64] Acked-by: Michael Ellerman <[email protected]> [powerpc] Acked-by: David Hildenbrand <[email protected]> Cc: Anshuman Khandual <[email protected]> Cc: Borislav Petkov (AMD) <[email protected]> Cc: Christophe Leroy <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Nicholas Piggin <[email protected]> Cc: Thomas Bogendoerfer <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Will Deacon <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
This commit is contained in:
committed by
Andrew Morton
parent
e1807d5d27
commit
99c2913363
@@ -57,7 +57,7 @@ static inline bool arch_thp_swp_supported(void)
|
||||
* 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
|
||||
|
||||
@@ -469,7 +469,8 @@ static inline pgprot_t pgprot_writecombine(pgprot_t _prot)
|
||||
}
|
||||
|
||||
static inline void flush_tlb_fix_spurious_fault(struct vm_area_struct *vma,
|
||||
unsigned long address)
|
||||
unsigned long address,
|
||||
pte_t *ptep)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,8 @@ static inline void flush_tlb_page(struct vm_area_struct *vma,
|
||||
|
||||
#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
|
||||
|
||||
@@ -1239,7 +1239,8 @@ static inline int pte_allow_rdp(pte_t old, pte_t new)
|
||||
}
|
||||
|
||||
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_spurious_fault(struct vm_area_struct *vma,
|
||||
* 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
|
||||
|
||||
|
||||
@@ -1097,7 +1097,7 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm,
|
||||
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))
|
||||
|
||||
|
||||
@@ -817,7 +817,7 @@ static inline void arch_swap_restore(swp_entry_t entry, struct folio *folio)
|
||||
#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
|
||||
|
||||
/*
|
||||
|
||||
+2
-1
@@ -4944,7 +4944,8 @@ static vm_fault_t handle_pte_fault(struct vm_fault *vmf)
|
||||
* 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);
|
||||
|
||||
@@ -69,7 +69,7 @@ int ptep_set_access_flags(struct vm_area_struct *vma,
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user