From owner-svn-src-projects@FreeBSD.ORG Thu Oct 3 18:58:36 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 0371470; Thu, 3 Oct 2013 18:58:36 +0000 (UTC) (envelope-from neel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C9F0F28B3; Thu, 3 Oct 2013 18:58:35 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r93IwZHg057808; Thu, 3 Oct 2013 18:58:35 GMT (envelope-from neel@svn.freebsd.org) Received: (from neel@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r93IwZTK057807; Thu, 3 Oct 2013 18:58:35 GMT (envelope-from neel@svn.freebsd.org) Message-Id: <201310031858.r93IwZTK057807@svn.freebsd.org> From: Neel Natu Date: Thu, 3 Oct 2013 18:58:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r256029 - projects/bhyve_npt_pmap/sys/amd64/amd64 X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Oct 2013 18:58:36 -0000 Author: neel Date: Thu Oct 3 18:58:35 2013 New Revision: 256029 URL: http://svnweb.freebsd.org/changeset/base/256029 Log: Delay the initialization of the PG_xx bits until the point that it is actually needed. The PG_M bit can be set gratuitously for all unmanaged, writeable mappings regardless of the pmap type. Verify that the 'dst_pmap' and 'src_pmap' are of the same type in pmap_copy(). Pointed out by: alc@ Modified: projects/bhyve_npt_pmap/sys/amd64/amd64/pmap.c Modified: projects/bhyve_npt_pmap/sys/amd64/amd64/pmap.c ============================================================================== --- projects/bhyve_npt_pmap/sys/amd64/amd64/pmap.c Thu Oct 3 18:53:13 2013 (r256028) +++ projects/bhyve_npt_pmap/sys/amd64/amd64/pmap.c Thu Oct 3 18:58:35 2013 (r256029) @@ -3836,11 +3836,6 @@ pmap_protect(pmap_t pmap, vm_offset_t sv pt_entry_t *pte, PG_G, PG_M, PG_RW, PG_V; boolean_t anychanged, pv_lists_locked; - PG_G = pmap_global_bit(pmap); - PG_M = pmap_modified_bit(pmap); - PG_V = pmap_valid_bit(pmap); - PG_RW = pmap_rw_bit(pmap); - if ((prot & VM_PROT_READ) == VM_PROT_NONE) { pmap_remove(pmap, sva, eva); return; @@ -3850,6 +3845,10 @@ pmap_protect(pmap_t pmap, vm_offset_t sv (VM_PROT_WRITE|VM_PROT_EXECUTE)) return; + PG_G = pmap_global_bit(pmap); + PG_M = pmap_modified_bit(pmap); + PG_V = pmap_valid_bit(pmap); + PG_RW = pmap_rw_bit(pmap); pv_lists_locked = FALSE; resume: anychanged = FALSE; @@ -4154,16 +4153,14 @@ pmap_enter(pmap_t pmap, vm_offset_t va, newpte |= PG_G; newpte |= pmap_cache_bits(pmap, m->md.pat_mode, 0); - if (pmap_emulate_ad_bits(pmap)) { - /* - * Set modified bit gratuitously for writeable mappings if - * the page is unmanaged. We do not want to take a fault - * to do the dirty bit accounting for these mappings. - */ - if ((m->oflags & VPO_UNMANAGED) != 0) { - if ((newpte & PG_RW) != 0) - newpte |= PG_M; - } + /* + * Set modified bit gratuitously for writeable mappings if + * the page is unmanaged. We do not want to take a fault + * to do the dirty bit accounting for these mappings. + */ + if ((m->oflags & VPO_UNMANAGED) != 0) { + if ((newpte & PG_RW) != 0) + newpte |= PG_M; } mpte = NULL; @@ -4762,6 +4759,9 @@ pmap_copy(pmap_t dst_pmap, pmap_t src_pm if (dst_addr != src_addr) return; + if (dst_pmap->pm_type != src_pmap->pm_type) + return; + if (pmap_emulate_ad_bits(dst_pmap)) return;