Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/mm: Make hpte_need_flush() correctly mask for multiple page sizes

Currently, hpte_need_flush() only correctly flushes the given address
for normal pages. Callers for hugepages are required to mask the
address themselves.

But hpte_need_flush() already looks up the page sizes for its own
reasons, so this is a rather silly imposition on the callers. This
patch alters it to mask based on the pagesize it has looked up itself,
and removes the awkward masking code in the hugepage caller.

Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

authored by

David Gibson and committed by
Benjamin Herrenschmidt
f71dc176 8be8cf5b

+4 -10
+1 -5
arch/powerpc/mm/hugetlbpage.c
··· 445 445 * necessary anymore if we make hpte_need_flush() get the 446 446 * page size from the slices 447 447 */ 448 - unsigned int psize = get_slice_psize(mm, addr); 449 - unsigned int shift = mmu_psize_to_shift(psize); 450 - unsigned long sz = ((1UL) << shift); 451 - struct hstate *hstate = size_to_hstate(sz); 452 - pte_update(mm, addr & hstate->mask, ptep, ~0UL, 1); 448 + pte_update(mm, addr, ptep, ~0UL, 1); 453 449 } 454 450 *ptep = __pte(pte_val(pte) & ~_PAGE_HPTEFLAGS); 455 451 }
+3 -5
arch/powerpc/mm/tlb_hash64.c
··· 53 53 54 54 i = batch->index; 55 55 56 - /* We mask the address for the base page size. Huge pages will 57 - * have applied their own masking already 58 - */ 59 - addr &= PAGE_MASK; 60 - 61 56 /* Get page size (maybe move back to caller). 62 57 * 63 58 * NOTE: when using special 64K mappings in 4K environment like ··· 69 74 #endif 70 75 } else 71 76 psize = pte_pagesize_index(mm, addr, pte); 77 + 78 + /* Mask the address for the correct page size */ 79 + addr &= ~((1UL << mmu_psize_defs[psize].shift) - 1); 72 80 73 81 /* Build full vaddr */ 74 82 if (!is_kernel_addr(addr)) {