mm: Fix TLB flush for not-first PFNMAP mappings in unmap_region()
PATCH 1/1 mm: Fix TLB flush for not-first PFNMAP mappings in unmap_region()
This is a stable-specific patch.
I botched the stable-specific rewrite of
commit b67fbebd4cf98 ("mmu_gather: Force tlb-flush VM_PFNMAP vmas"):
As Hugh pointed out, unmap_region() actually operates on a list of VMAs, and the variable "vma" merely points to the first VMA in that list. So if we want to check whether any of the VMAs we're operating on is PFNMAP or MIXEDMAP, we have to iterate through the list and check each VMA.
--- mm/mmap.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
mm/mmap.c +7 -2
@@ -2638,6 +2638,7 @@ static void unmap_region(struct mm_struct *mm, {struct vm_area_struct *next =vma_next (mm, prev);struct mmu_gather tlb; +struct vm_area_struct *cur_vma;lru_add_drain ();tlb_gather_mmu (&tlb, mm);
@@ -2652,8 +2653,12 @@ static void unmap_region(struct mm_struct *mm,* concurrent flush in this region has to be coming through the rmap, * and we synchronize against that using the rmap lock. */ -if ((vma->vm_flags & (VM_PFNMAP |VM_MIXEDMAP )) !=0 ) -tlb_flush_mmu (&tlb); +for (cur_vma = vma; cur_vma; cur_vma = cur_vma->vm_next) { +if ((cur_vma->vm_flags & (VM_PFNMAP |VM_MIXEDMAP )) !=0 ) { +tlb_flush_mmu (&tlb); +break ; + } + }free_pgtables (&tlb, vma, prev ? prev->vm_end :FIRST_USER_ADDRESS , next ? next->vm_start :USER_PGTABLES_CEILING );
base-commit: dd20085f2a88b6cdb12bdcdbd2d7a761c86b184a
Signature · 1 line
2.37.2.789.g6183377224-goog
Greg Kroah-Hartman
maintainerQuoted 8 lines · Jann Horn
This is a stable-specific patch.
I botched the stable-specific rewrite of
commitb67fbebd4cf98("mmu_gather: Force tlb-flushVM_PFNMAPvmas"):
As Hugh pointed out,unmap_region()actually operates on a list of VMAs, and the variable "vma" merely points to the first VMA in that list. So if we want to check whether any of the VMAs we're operating on is PFNMAP or MIXEDMAP, we have to iterate through the list and check each VMA.
Quoted 4 lines
Signed-off-by Jann Horn <[email protected]>--- mm/mmap.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
Now queued up everywhere, thanks.
greg k-h