From owner-p4-projects@FreeBSD.ORG Fri Jan 18 21:14:06 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 7AB7816A469; Fri, 18 Jan 2008 21:14:06 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3FBA116A421 for ; Fri, 18 Jan 2008 21:14:06 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 194F413C4D9 for ; Fri, 18 Jan 2008 21:14:06 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m0ILE5Jv079796 for ; Fri, 18 Jan 2008 21:14:05 GMT (envelope-from kmacy@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m0ILE5N8079792 for perforce@freebsd.org; Fri, 18 Jan 2008 21:14:05 GMT (envelope-from kmacy@freebsd.org) Date: Fri, 18 Jan 2008 21:14:05 GMT Message-Id: <200801182114.m0ILE5N8079792@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to kmacy@freebsd.org using -f From: Kip Macy To: Perforce Change Reviews Cc: Subject: PERFORCE change 133595 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jan 2008 21:14:06 -0000 http://perforce.freebsd.org/chv.cgi?CH=133595 Change 133595 by kmacy@pandemonium:kmacy:xen31 on 2008/01/18 21:13:58 Set the modified bit when mapping page tables - not doing so was causing us to lose the OS resrved bits which in turn confused process page accounting. Not quite diagnosed by alc, but prompted by him pressing me for why I wasn't setting the modified bit when mapping page table pages. He has my gratitude for pushing me on the issue. Affected files ... .. //depot/projects/xen31/sys/i386/xen/pmap.c#23 edit Differences ... ==== //depot/projects/xen31/sys/i386/xen/pmap.c#23 (text+ko) ==== @@ -332,13 +332,13 @@ switch (type) { case SH_PD_SET_VA: xen_queue_pt_update(shadow_pdir_ma, - xpmap_ptom(val & ~(PG_RW|PG_M))); + xpmap_ptom(val & ~(PG_RW))); xen_queue_pt_update(pdir_ma, xpmap_ptom(val)); break; case SH_PD_SET_VA_MA: xen_queue_pt_update(shadow_pdir_ma, - val & ~(PG_RW|PG_M)); + val & ~(PG_RW)); xen_queue_pt_update(pdir_ma, val); break; case SH_PD_SET_VA_CLEAR: @@ -948,7 +948,7 @@ mtx_lock(&PMAP2mutex); newpf = *pde & PG_FRAME; if ((*PMAP2 & PG_FRAME) != newpf) { - *PMAP2 = newpf | PG_V | PG_A; + *PMAP2 = newpf | PG_V | PG_A | PG_M; pmap_invalidate_page(kernel_pmap, (vm_offset_t)PADDR2); } return (PADDR2 + (i386_btop(va) & (NPTEPG - 1))); @@ -1005,7 +1005,7 @@ KASSERT(curthread->td_pinned > 0, ("curthread not pinned")); newpf = *pde & PG_FRAME; if ((*PMAP1 & PG_FRAME) != newpf) { - *PMAP1 = newpf | PG_V | PG_A; + *PMAP1 = newpf | PG_V | PG_A | PG_M; #ifdef SMP PMAP1cpu = PCPU_GET(cpuid); #endif @@ -1457,7 +1457,7 @@ pmap->pm_pdir[PTDPTDI + i] = xpmap_ptom(VM_PAGE_TO_PHYS(ptdpg[i + NPGPTD])) | PG_V; for (i = KPTDI; i < KPTDI + nkpt; i++) - pmap->pm_pdir_shadow[i] = PTD[i] & ~(PG_RW|PG_M|PG_A); + pmap->pm_pdir_shadow[i] = PTD[i] & ~(PG_RW); for (i = 0; i < NPGPTD; i++) { pt_entry_t *pd; @@ -2161,8 +2161,16 @@ * why, but I think the most likely explanation is that xen's writable * page table implementation doesn't respect the unused bits. */ - if ((oldpte & PG_MANAGED) || ((oldpte & PG_V) && (va < VM_MAXUSER_ADDRESS))) { + if ((oldpte & PG_MANAGED) +#ifdef PTEBROKEN + || ((oldpte & PG_V) && (va < VM_MAXUSER_ADDRESS)) +#endif + ) { m = PHYS_TO_VM_PAGE(xpmap_mtop(oldpte) & PG_FRAME); + + if (!(oldpte & PG_MANAGED)) + printf("va=0x%x is unmanaged :-( pte=0x%llx\n", va, oldpte); + if (oldpte & PG_M) { KASSERT((oldpte & PG_RW), ("pmap_remove_pte: modified page not writable: va: %#x, pte: %#jx", @@ -2172,11 +2180,9 @@ if (oldpte & PG_A) vm_page_flag_set(m, PG_REFERENCED); pmap_remove_entry(pmap, m, va); - } -#ifdef DEBUG - else if (va < VM_MAXUSER_ADDRESS) - printf("va=0x%x is unmanaged :-( \n", va); -#endif + } else if ((va < VM_MAXUSER_ADDRESS) && (oldpte & PG_V)) + printf("va=0x%x is unmanaged :-( pte=0x%llx\n", va, oldpte); + return (pmap_unuse_pt(pmap, va, free)); } @@ -2932,7 +2938,7 @@ npdes = size >> PDRSHIFT; for(i = 0; i < npdes; i++) { PD_SET_VA(pmap, ptepindex, - ptepa | PG_U | PG_RW | PG_V | PG_PS, FALSE); + ptepa | PG_U | PG_M | PG_RW | PG_V | PG_PS, FALSE); ptepa += NBPDR; ptepindex += 1; }