Modify the tlb demap API to take a pmap instead of a tlb context number.

Due to allocating tlb contexts on the fly, we only ever need to demap the
primary context, non-primary contexts have already been implicitly flushed
by context switching.  All we really need to tell is if its a kernel demap
or not, and its easier just to compare against the kernel_pmap which is a
constant.
This commit is contained in:
Jake Burkholder 2002-03-07 05:25:15 +00:00
parent bc9b764621
commit 39028e8396
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=91782
5 changed files with 40 additions and 36 deletions

View File

@ -104,8 +104,11 @@ tlb_dtlb_context_primary_demap(void)
}
static __inline void
tlb_dtlb_page_demap(u_long ctx, vm_offset_t va)
tlb_dtlb_page_demap(struct pmap *pm, vm_offset_t va)
{
u_int ctx;
ctx = pm->pm_context[PCPU_GET(cpuid)];
if (ctx == TLB_CTX_KERNEL) {
stxa(TLB_DEMAP_VA(va) | TLB_DEMAP_NUCLEUS | TLB_DEMAP_PAGE,
ASI_DMMU_DEMAP, 0);
@ -150,8 +153,11 @@ tlb_itlb_context_primary_demap(void)
}
static __inline void
tlb_itlb_page_demap(u_long ctx, vm_offset_t va)
tlb_itlb_page_demap(struct pmap *pm, vm_offset_t va)
{
u_int ctx;
ctx = pm->pm_context[PCPU_GET(cpuid)];
if (ctx == TLB_CTX_KERNEL) {
stxa(TLB_DEMAP_VA(va) | TLB_DEMAP_NUCLEUS | TLB_DEMAP_PAGE,
ASI_IMMU_DEMAP, 0);
@ -184,8 +190,11 @@ tlb_itlb_store(vm_offset_t va, u_long ctx, struct tte tte)
}
static __inline void
tlb_context_demap(u_int ctx)
tlb_context_demap(struct pmap *pm)
{
u_int ctx;
ctx = pm->pm_context[PCPU_GET(cpuid)];
if (ctx != -1) {
tlb_dtlb_context_primary_demap();
tlb_itlb_context_primary_demap();
@ -205,25 +214,25 @@ tlb_itlb_store_slot(vm_offset_t va, u_long ctx, struct tte tte, int slot)
}
static __inline void
tlb_page_demap(u_int tlb, u_int ctx, vm_offset_t va)
tlb_page_demap(u_int tlb, struct pmap *pm, vm_offset_t va)
{
if (tlb & TLB_DTLB)
tlb_dtlb_page_demap(ctx, va);
tlb_dtlb_page_demap(pm, va);
if (tlb & TLB_ITLB)
tlb_itlb_page_demap(ctx, va);
tlb_itlb_page_demap(pm, va);
}
static __inline void
tlb_range_demap(u_int ctx, vm_offset_t start, vm_offset_t end)
tlb_range_demap(struct pmap *pm, vm_offset_t start, vm_offset_t end)
{
for (; start < end; start += PAGE_SIZE)
tlb_page_demap(TLB_DTLB | TLB_ITLB, ctx, start);
tlb_page_demap(TLB_DTLB | TLB_ITLB, pm, start);
}
static __inline void
tlb_tte_demap(struct tte tte, u_int ctx)
tlb_tte_demap(struct tte tte, struct pmap *pm)
{
tlb_page_demap(TD_GET_TLB(tte.tte_data), ctx, TV_GET_VA(tte.tte_vpn));
tlb_page_demap(TD_GET_TLB(tte.tte_data), pm, TV_GET_VA(tte.tte_vpn));
}
static __inline void

View File

@ -549,7 +549,7 @@ sparc64_bus_mem_map(bus_space_tag_t tag, bus_space_handle_t handle,
va += PAGE_SIZE;
pa += PAGE_SIZE;
} while ((vsz -= PAGE_SIZE) > 0);
tlb_range_demap(TLB_CTX_KERNEL, sva, sva + size - 1);
tlb_range_demap(kernel_pmap, sva, sva + size - 1);
return (0);
}
@ -564,7 +564,7 @@ sparc64_bus_mem_unmap(void *bh, bus_size_t size)
endva = sva + round_page(size);
for (va = sva; va < endva; va += PAGE_SIZE)
pmap_kremove(va);
tlb_range_demap(TLB_CTX_KERNEL, sva, sva + size - 1);
tlb_range_demap(kernel_pmap, sva, sva + size - 1);
kmem_free(kernel_map, va, size);
return (0);
}

View File

@ -336,7 +336,7 @@ pmap_bootstrap(vm_offset_t ekva)
pa = kstack0_phys + i * PAGE_SIZE;
va = kstack0 + i * PAGE_SIZE;
pmap_kenter(va, pa);
tlb_page_demap(TLB_DTLB, TLB_CTX_KERNEL, va);
/* tlb_page_demap(TLB_DTLB, kernel_pmap, va); */
}
/*
@ -628,8 +628,7 @@ pmap_cache_enter(vm_page_t m, vm_offset_t va)
TAILQ_FOREACH(pv, &m->md.pv_list, pv_list) {
if ((tp = tsb_tte_lookup(pv->pv_pmap, pv->pv_va)) != NULL) {
atomic_clear_long(&tp->tte_data, TD_CV);
tlb_page_demap(TLB_DTLB | TLB_ITLB,
pv->pv_pmap->pm_context[PCPU_GET(cpuid)],
tlb_page_demap(TLB_DTLB | TLB_ITLB, pv->pv_pmap,
pv->pv_va);
}
}
@ -742,7 +741,7 @@ pmap_map(vm_offset_t *virt, vm_offset_t pa_start, vm_offset_t pa_end, int prot)
va = sva;
for (; pa < pa_end; pa += PAGE_SIZE, va += PAGE_SIZE)
pmap_kenter(va, pa);
tlb_range_demap(TLB_CTX_KERNEL, sva, sva + (pa_end - pa_start) - 1);
tlb_range_demap(kernel_pmap, sva, sva + (pa_end - pa_start) - 1);
*virt = va;
return (sva);
}
@ -761,7 +760,7 @@ pmap_qenter(vm_offset_t sva, vm_page_t *m, int count)
va = sva;
for (i = 0; i < count; i++, va += PAGE_SIZE)
pmap_kenter(va, VM_PAGE_TO_PHYS(m[i]));
tlb_range_demap(TLB_CTX_KERNEL, sva, sva + (count * PAGE_SIZE) - 1);
tlb_range_demap(kernel_pmap, sva, sva + (count * PAGE_SIZE) - 1);
}
/*
@ -777,7 +776,7 @@ pmap_qenter_flags(vm_offset_t sva, vm_page_t *m, int count, u_long fl)
va = sva;
for (i = 0; i < count; i++, va += PAGE_SIZE)
pmap_kenter_flags(va, VM_PAGE_TO_PHYS(m[i]), fl);
tlb_range_demap(TLB_CTX_KERNEL, sva, sva + (count * PAGE_SIZE) - 1);
tlb_range_demap(kernel_pmap, sva, sva + (count * PAGE_SIZE) - 1);
}
/*
@ -793,7 +792,7 @@ pmap_qremove(vm_offset_t sva, int count)
va = sva;
for (i = 0; i < count; i++, va += PAGE_SIZE)
pmap_kremove(va);
tlb_range_demap(TLB_CTX_KERNEL, sva, sva + (count * PAGE_SIZE) - 1);
tlb_range_demap(kernel_pmap, sva, sva + (count * PAGE_SIZE) - 1);
}
/*
@ -976,7 +975,7 @@ pmap_new_thread(struct thread *td)
(KSTACK_PAGES + KSTACK_GUARD_PAGES) * PAGE_SIZE);
if (ks == 0)
panic("pmap_new_thread: kstack allocation failed");
tlb_page_demap(TLB_DTLB, TLB_CTX_KERNEL, ks);
tlb_page_demap(TLB_DTLB, kernel_pmap, ks);
ks += KSTACK_GUARD_PAGES * PAGE_SIZE;
td->td_kstack = ks;
}
@ -1295,7 +1294,7 @@ pmap_remove(pmap_t pm, vm_offset_t start, vm_offset_t end)
return;
if (end - start > PMAP_TSB_THRESH) {
tsb_foreach(pm, NULL, start, end, pmap_remove_tte);
tlb_context_demap(pm->pm_context[PCPU_GET(cpuid)]);
tlb_context_demap(pm);
} else {
for (va = start; va < end; va += PAGE_SIZE) {
if ((tp = tsb_tte_lookup(pm, va)) != NULL) {
@ -1303,8 +1302,7 @@ pmap_remove(pmap_t pm, vm_offset_t start, vm_offset_t end)
break;
}
}
tlb_range_demap(pm->pm_context[PCPU_GET(cpuid)],
start, end - 1);
tlb_range_demap(pm, start, end - 1);
}
}
@ -1360,13 +1358,13 @@ pmap_protect(pmap_t pm, vm_offset_t sva, vm_offset_t eva, vm_prot_t prot)
if (eva - sva > PMAP_TSB_THRESH) {
tsb_foreach(pm, NULL, sva, eva, pmap_protect_tte);
tlb_context_demap(pm->pm_context[PCPU_GET(cpuid)]);
tlb_context_demap(pm);
} else {
for (va = sva; va < eva; va += PAGE_SIZE) {
if ((tp = tsb_tte_lookup(pm, va)) != NULL)
pmap_protect_tte(pm, NULL, tp, va);
}
tlb_range_demap(pm->pm_context[PCPU_GET(cpuid)], sva, eva - 1);
tlb_range_demap(pm, sva, eva - 1);
}
}
@ -1436,8 +1434,7 @@ pmap_enter(pmap_t pm, vm_offset_t va, vm_page_t m, vm_prot_t prot,
if (pmap_track_modified(pm, va))
vm_page_dirty(m);
}
tlb_tte_demap(otte,
pm->pm_context[PCPU_GET(cpuid)]);
tlb_tte_demap(otte, pm);
}
} else {
CTR0(KTR_PMAP, "pmap_enter: replace");
@ -1468,7 +1465,7 @@ pmap_enter(pmap_t pm, vm_offset_t va, vm_page_t m, vm_prot_t prot,
if (pmap_cache_enter(m, va) != 0)
tte.tte_data |= TD_CV;
}
tlb_tte_demap(otte, pm->pm_context[PCPU_GET(cpuid)]);
tlb_tte_demap(otte, pm);
}
} else {
CTR0(KTR_PMAP, "pmap_enter: new");
@ -1592,14 +1589,13 @@ pmap_copy(pmap_t dst_pmap, pmap_t src_pmap, vm_offset_t dst_addr,
if (len > PMAP_TSB_THRESH) {
tsb_foreach(src_pmap, dst_pmap, src_addr, src_addr + len,
pmap_copy_tte);
tlb_context_demap(dst_pmap->pm_context[PCPU_GET(cpuid)]);
tlb_context_demap(dst_pmap);
} else {
for (va = src_addr; va < src_addr + len; va += PAGE_SIZE) {
if ((tp = tsb_tte_lookup(src_pmap, va)) != NULL)
pmap_copy_tte(src_pmap, dst_pmap, tp, va);
}
tlb_range_demap(dst_pmap->pm_context[PCPU_GET(cpuid)],
src_addr, src_addr + len - 1);
tlb_range_demap(dst_pmap, src_addr, src_addr + len - 1);
}
}
@ -1707,7 +1703,7 @@ pmap_remove_pages(pmap_t pm, vm_offset_t sva, vm_offset_t eva)
vm_page_flag_clear(m, PG_MAPPED | PG_WRITEABLE);
pv_free(pv);
}
tlb_context_demap(pm->pm_context[PCPU_GET(cpuid)]);
tlb_context_demap(pm);
}
/*

View File

@ -157,8 +157,7 @@ pv_bit_clear(vm_page_t m, u_long bits)
vm_page_dirty(m);
}
atomic_clear_long(&tp->tte_data, bits);
tlb_tte_demap(*tp,
pv->pv_pmap->pm_context[PCPU_GET(cpuid)]);
tlb_tte_demap(*tp, pv->pv_pmap);
}
}
}
@ -260,7 +259,7 @@ pv_remove_all(vm_page_t m)
vm_page_dirty(m);
}
atomic_clear_long(&tp->tte_data, TD_V);
tlb_tte_demap(*tp, pv->pv_pmap->pm_context[PCPU_GET(cpuid)]);
tlb_tte_demap(*tp, pv->pv_pmap);
tp->tte_vpn = 0;
tp->tte_data = 0;
pv->pv_pmap->pm_stats.resident_count--;

View File

@ -189,7 +189,7 @@ tsb_tte_enter(pmap_t pm, vm_page_t m, vm_offset_t va, struct tte tte)
pmap_cache_remove(om, ova);
pv_remove(pm, om, ova);
}
tlb_tte_demap(*tp, pm->pm_context[PCPU_GET(cpuid)]);
tlb_tte_demap(*tp, pm);
}
*tp = tte;