Commit f71dc176 authored by David Gibson's avatar David Gibson Committed by Benjamin Herrenschmidt

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: default avatarDavid Gibson <dwg@au1.ibm.com>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent 8be8cf5b
...@@ -445,11 +445,7 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, ...@@ -445,11 +445,7 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
* necessary anymore if we make hpte_need_flush() get the * necessary anymore if we make hpte_need_flush() get the
* page size from the slices * page size from the slices
*/ */
unsigned int psize = get_slice_psize(mm, addr); pte_update(mm, addr, ptep, ~0UL, 1);
unsigned int shift = mmu_psize_to_shift(psize);
unsigned long sz = ((1UL) << shift);
struct hstate *hstate = size_to_hstate(sz);
pte_update(mm, addr & hstate->mask, ptep, ~0UL, 1);
} }
*ptep = __pte(pte_val(pte) & ~_PAGE_HPTEFLAGS); *ptep = __pte(pte_val(pte) & ~_PAGE_HPTEFLAGS);
} }
......
...@@ -53,11 +53,6 @@ void hpte_need_flush(struct mm_struct *mm, unsigned long addr, ...@@ -53,11 +53,6 @@ void hpte_need_flush(struct mm_struct *mm, unsigned long addr,
i = batch->index; i = batch->index;
/* We mask the address for the base page size. Huge pages will
* have applied their own masking already
*/
addr &= PAGE_MASK;
/* Get page size (maybe move back to caller). /* Get page size (maybe move back to caller).
* *
* NOTE: when using special 64K mappings in 4K environment like * NOTE: when using special 64K mappings in 4K environment like
...@@ -75,6 +70,9 @@ void hpte_need_flush(struct mm_struct *mm, unsigned long addr, ...@@ -75,6 +70,9 @@ void hpte_need_flush(struct mm_struct *mm, unsigned long addr,
} else } else
psize = pte_pagesize_index(mm, addr, pte); psize = pte_pagesize_index(mm, addr, pte);
/* Mask the address for the correct page size */
addr &= ~((1UL << mmu_psize_defs[psize].shift) - 1);
/* Build full vaddr */ /* Build full vaddr */
if (!is_kernel_addr(addr)) { if (!is_kernel_addr(addr)) {
ssize = user_segment_size(addr); ssize = user_segment_size(addr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment