Date: Fri, 17 Mar 2006 02:29:34 GMT From: Kip Macy <kmacy@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 93426 for review Message-ID: <200603170229.k2H2TY0k030164@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=93426 Change 93426 by kmacy@kmacy_storage:sun4v_work on 2006/03/17 02:28:47 numerous small fixes add toggle for debug noise Affected files ... .. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/pmap.c#28 edit Differences ... ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/pmap.c#28 (text+ko) ==== @@ -72,9 +72,9 @@ #include <machine/hypervisor_api.h> - +#if 0 #define PMAP_DEBUG - +#endif #ifndef PMAP_SHPGPERPROC #define PMAP_SHPGPERPROC 200 #endif @@ -167,7 +167,13 @@ #define UNIMPLEMENTED panic("%s not implemented", __FUNCTION__) #define IMPLEMENTME printf("don't forget %s not implemented\n", __FUNCTION__) +#ifdef PMAP_DEBUG +#define DPRINTF printf +#else +#define DPRINTF(...) +#endif + static void free_pv_entry(pv_entry_t pv); static pv_entry_t get_pv_entry(pmap_t locked_pmap); @@ -344,7 +350,7 @@ pmap_activate(struct thread *td) { pmap_t pmap, oldpmap; - printf("activating pmap\n"); + DPRINTF("activating pmap\n"); critical_enter(); pmap = vmspace_pmap(td->td_proc->p_vmspace); @@ -566,7 +572,7 @@ "translation: start=%#lx size=%#lx tte=%#lx", translations[i].om_start, translations[i].om_size, translations[i].om_tte); - printf("om_size=%ld om_start=%lx om_tte=%lx\n", + DPRINTF("om_size=%ld om_start=%lx om_tte=%lx\n", translations[i].om_size, translations[i].om_start, translations[i].om_tte); @@ -574,7 +580,7 @@ if (translations[i].om_size == PAGE_SIZE_4M && translations[i].om_start == KERNBASE) { kernel_phys = pa = TTE_GET_PA(translations[i].om_tte); - printf("mapping permanent translation\n"); + DPRINTF("mapping permanent translation\n"); error = hv_mmu_map_perm_addr((char *)translations[i].om_start, KCONTEXT, pa | TTE_KERNEL | VTD_4M, MAP_ITLB | MAP_DTLB); if (error != H_EOK) @@ -681,12 +687,14 @@ void pmap_clear_modify(vm_page_t m) { + DPRINTF("pmap_clear_modify(0x%lx)\n", VM_PAGE_TO_PHYS(m)); tte_clear_phys_bit(m, VTD_W); } void pmap_clear_reference(vm_page_t m) { + DPRINTF("pmap_clear_reference(0x%lx)\n", VM_PAGE_TO_PHYS(m)); tte_clear_phys_bit(m, VTD_REF); } @@ -695,6 +703,7 @@ vm_size_t len, vm_offset_t src_addr) { vm_offset_t addr, end_addr; + return; end_addr = src_addr + len; @@ -750,6 +759,7 @@ vm_paddr_t srcpa, dstpa; srcpa = VM_PAGE_TO_PHYS(src); dstpa = VM_PAGE_TO_PHYS(dst); + DPRINTF("pmap_copy_page(srcpa=0x%lx, dstpa=0x%lx)\n", srcpa, dstpa); bcopy((char *)TLB_PHYS_TO_DIRECT(srcpa), (char *)TLB_PHYS_TO_DIRECT(dstpa), PAGE_SIZE); @@ -771,8 +781,7 @@ int invlva; if (pmap->pm_context) - printf("ctx=%d va=%lx prot=%x wired=%x\n", (int)pmap->pm_context, - va, prot, wired); + DPRINTF("pmap_enter(va=%lx, pa=0x%lx, prot=%x)\n", va, VM_PAGE_TO_PHYS(m), prot); om = NULL; @@ -870,7 +879,9 @@ if ((prot & VM_PROT_WRITE) == 0) invlva = TRUE; } +#ifdef notyet if (invlva) +#endif pmap_invalidate_page(pmap, va); } else { tte_hash_insert(pmap->pm_hash, va, tte_data); @@ -891,6 +902,9 @@ { uint64_t tte_data; + + if (pmap->pm_context) + DPRINTF("pmap_enter_quick(va=%lx, pa=0x%lx prot=%x)\n", va, VM_PAGE_TO_PHYS(m), prot); mtx_assert(&vm_page_queue_mtx, MA_OWNED); VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED); @@ -908,8 +922,6 @@ tte_data = VM_PAGE_TO_PHYS(m); - if ((prot & VM_PROT_WRITE) != 0) - tte_data |= VTD_SW_W; if ((prot & VM_PROT_EXECUTE) != 0) tte_data |= VTD_X; @@ -1030,10 +1042,8 @@ #ifdef SMP #error __FUNCTION_ not implemented #else -#if 0 - /* XXX SUN4V_FIXME - need to clear multiple TSBs */ - tsb_clear_tte(va, pmap->pm_context); -#endif + tsb_clear_tte(&pmap->pm_tsb, va); + DPRINTF("pmap_invalidate_page(va=0x%lx)\n", va); invlpg(va, pmap->pm_context); #endif } @@ -1042,20 +1052,19 @@ pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) { vm_offset_t tva; -#if 0 - printf("pmap_invalidate_range(sva=%lx, eva=%lx)\n", sva, eva); -#endif + DPRINTF("pmap_invalidate_range(sva=%lx, eva=%lx)\n", sva, eva); /* XXX SUN4V_FIXME - oversimplified logic */ tsb_clear_range(&pmap->pm_tsb, sva, eva); - if ((((eva - sva) >> PAGE_SHIFT) < MAX_INVALIDATES) || - ((sva & PAGE_MASK_4M) != 0) || ((eva & PAGE_MASK_4M) != 0)) { + if ((((eva - sva) >> PAGE_SHIFT) < MAX_INVALIDATES)) { for (tva = sva; tva < eva; tva += PAGE_SIZE_8K) invlpg(tva, pmap->pm_context); - } else + } else if (pmap->pm_context) invlctx(pmap->pm_context); + else + invltlb(); } @@ -1222,9 +1231,12 @@ void pmap_page_protect(vm_page_t m, vm_prot_t prot) { + + DPRINTF("pmap_page_protect(0x%lx, %d)\n", VM_PAGE_TO_PHYS(m), prot); + if ((prot & VM_PROT_WRITE) == 0) { if (prot & (VM_PROT_READ | VM_PROT_EXECUTE)) { - tte_clear_phys_bit(m, VTD_SW_W | VTD_W); + tte_clear_phys_bit(m, VTD_SW_W); } else { pmap_remove_all(m); } @@ -1277,7 +1289,9 @@ int anychanged; uint64_t *tte; - + vm_offset_t tva; + + DPRINTF("pmap_protect(0x%lx, 0x%lx, %d)\n", sva, eva, prot); if ((prot & VM_PROT_READ) == VM_PROT_NONE) { pmap_remove(pmap, sva, eva); @@ -1293,11 +1307,11 @@ PMAP_LOCK(pmap); sched_pin(); - for (; sva < eva; sva += PAGE_SIZE) { + for (tva = sva; tva < eva; tva += PAGE_SIZE) { uint64_t otte_data, tte_data; vm_page_t m; retry: - tte = tte_hash_lookup(pmap->pm_hash, sva); + tte = tte_hash_lookup(pmap->pm_hash, tva); otte_data = tte_data = tte ? *tte : 0; if (tte_data & VTD_MANAGED) { m = NULL; @@ -1306,7 +1320,7 @@ vm_page_flag_set(m, PG_REFERENCED); tte_data &= ~VTD_REF; } - if ((tte_data & VTD_W) && pmap_track_modified(pmap, sva)) { + if ((tte_data & VTD_W) && pmap_track_modified(pmap, tva)) { m = PHYS_TO_VM_PAGE(TTE_GET_PA(tte_data)); vm_page_dirty(m); } @@ -1325,6 +1339,7 @@ sched_unpin(); if (anychanged) pmap_invalidate_range(pmap, sva, eva); + vm_page_unlock_queues(); PMAP_UNLOCK(pmap); } @@ -1462,6 +1477,7 @@ { pv_entry_t pv; uint64_t *tte, tte_data; + DPRINTF("pmap_remove_all 0x%lx\n", VM_PAGE_TO_PHYS(m)); mtx_assert(&vm_page_queue_mtx, MA_OWNED); sched_pin(); @@ -1547,7 +1563,7 @@ tte_data = tte ? *tte : 0; if (tte_data == 0) { - printf("TTE at %p IS ZERO @ VA %016lx\n", + printf("TTE at %p IS ZERO @ VA %016lx\n", tte, pv->pv_va); panic("bad tte"); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200603170229.k2H2TY0k030164>