diff options
author | kib <kib@FreeBSD.org> | 2014-09-01 07:58:15 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2014-09-01 07:58:15 +0000 |
commit | 798eea16149d6a39c6fb5f721410f61b5bb1134a (patch) | |
tree | 8a38ed27916582f1759cfcc70e76cd5fabbebce1 /sys/powerpc/booke | |
parent | 14d8fe45061d6304d3e6438cfe4267aa7e17c705 (diff) | |
download | FreeBSD-src-798eea16149d6a39c6fb5f721410f61b5bb1134a.zip FreeBSD-src-798eea16149d6a39c6fb5f721410f61b5bb1134a.tar.gz |
Fix a leak of the wired pages when unwiring of the PROT_NONE-mapped
wired region. Rework the handling of unwire to do the it in batch,
both at pmap and object level.
All commits below are by alc.
MFC r268327:
Introduce pmap_unwire().
MFC r268591:
Implement pmap_unwire() for powerpc.
MFC r268776:
Implement pmap_unwire() for arm.
MFC r268806:
pmap_unwire(9) man page.
MFC r269134:
When unwiring a region of an address space, do not assume that the
underlying physical pages are mapped by the pmap. This fixes a leak
of the wired pages on the unwiring of the region mapped with no access
allowed.
MFC r269339:
In the implementation of the new function pmap_unwire(), the call to
MOEA64_PVO_TO_PTE() must be performed before any changes are made to the
PVO. Otherwise, MOEA64_PVO_TO_PTE() will panic.
MFC r269365:
Correct a long-standing problem in moea{,64}_pvo_enter() that was revealed
by the combination of r268591 and r269134: When we attempt to add the
wired attribute to an existing mapping, moea{,64}_pvo_enter() do nothing.
(They only set the wired attribute on newly created mappings.)
MFC r269433:
Handle wiring failures in vm_map_wire() with the new functions
pmap_unwire() and vm_object_unwire().
Retire vm_fault_{un,}wire(), since they are no longer used.
MFC r269438:
Rewrite a loop in vm_map_wire() so that gcc doesn't think that the variable
"rv" is uninitialized.
MFC r269485:
Retire pmap_change_wiring().
Reviewed by: alc
Diffstat (limited to 'sys/powerpc/booke')
-rw-r--r-- | sys/powerpc/booke/pmap.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/sys/powerpc/booke/pmap.c b/sys/powerpc/booke/pmap.c index 0862b99..a65eff6 100644 --- a/sys/powerpc/booke/pmap.c +++ b/sys/powerpc/booke/pmap.c @@ -266,7 +266,6 @@ void pmap_bootstrap_ap(volatile uint32_t *); /* * Kernel MMU interface */ -static void mmu_booke_change_wiring(mmu_t, pmap_t, vm_offset_t, boolean_t); static void mmu_booke_clear_modify(mmu_t, vm_page_t); static void mmu_booke_copy(mmu_t, pmap_t, pmap_t, vm_offset_t, vm_size_t, vm_offset_t); @@ -306,6 +305,7 @@ static void mmu_booke_release(mmu_t, pmap_t); static void mmu_booke_remove(mmu_t, pmap_t, vm_offset_t, vm_offset_t); static void mmu_booke_remove_all(mmu_t, vm_page_t); static void mmu_booke_remove_write(mmu_t, vm_page_t); +static void mmu_booke_unwire(mmu_t, pmap_t, vm_offset_t, vm_offset_t); static void mmu_booke_zero_page(mmu_t, vm_page_t); static void mmu_booke_zero_page_area(mmu_t, vm_page_t, int, int); static void mmu_booke_zero_page_idle(mmu_t, vm_page_t); @@ -330,7 +330,6 @@ static struct pmap_md *mmu_booke_scan_md(mmu_t, struct pmap_md *); static mmu_method_t mmu_booke_methods[] = { /* pmap dispatcher interface */ - MMUMETHOD(mmu_change_wiring, mmu_booke_change_wiring), MMUMETHOD(mmu_clear_modify, mmu_booke_clear_modify), MMUMETHOD(mmu_copy, mmu_booke_copy), MMUMETHOD(mmu_copy_page, mmu_booke_copy_page), @@ -361,6 +360,7 @@ static mmu_method_t mmu_booke_methods[] = { MMUMETHOD(mmu_remove_all, mmu_booke_remove_all), MMUMETHOD(mmu_remove_write, mmu_booke_remove_write), MMUMETHOD(mmu_sync_icache, mmu_booke_sync_icache), + MMUMETHOD(mmu_unwire, mmu_booke_unwire), MMUMETHOD(mmu_zero_page, mmu_booke_zero_page), MMUMETHOD(mmu_zero_page_area, mmu_booke_zero_page_area), MMUMETHOD(mmu_zero_page_idle, mmu_booke_zero_page_idle), @@ -2432,28 +2432,33 @@ mmu_booke_ts_referenced(mmu_t mmu, vm_page_t m) } /* - * Change wiring attribute for a map/virtual-address pair. + * Clear the wired attribute from the mappings for the specified range of + * addresses in the given pmap. Every valid mapping within that range must + * have the wired attribute set. In contrast, invalid mappings cannot have + * the wired attribute set, so they are ignored. + * + * The wired attribute of the page table entry is not a hardware feature, so + * there is no need to invalidate any TLB entries. */ static void -mmu_booke_change_wiring(mmu_t mmu, pmap_t pmap, vm_offset_t va, boolean_t wired) +mmu_booke_unwire(mmu_t mmu, pmap_t pmap, vm_offset_t sva, vm_offset_t eva) { + vm_offset_t va; pte_t *pte; PMAP_LOCK(pmap); - if ((pte = pte_find(mmu, pmap, va)) != NULL) { - if (wired) { - if (!PTE_ISWIRED(pte)) { - pte->flags |= PTE_WIRED; - pmap->pm_stats.wired_count++; - } - } else { - if (PTE_ISWIRED(pte)) { - pte->flags &= ~PTE_WIRED; - pmap->pm_stats.wired_count--; - } + for (va = sva; va < eva; va += PAGE_SIZE) { + if ((pte = pte_find(mmu, pmap, va)) != NULL && + PTE_ISVALID(pte)) { + if (!PTE_ISWIRED(pte)) + panic("mmu_booke_unwire: pte %p isn't wired", + pte); + pte->flags &= ~PTE_WIRED; + pmap->pm_stats.wired_count--; } } PMAP_UNLOCK(pmap); + } /* |