From owner-svn-src-projects@FreeBSD.ORG Thu Jul 10 02:15:17 2014 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 699BFDDF; Thu, 10 Jul 2014 02:15:17 +0000 (UTC) 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)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4B0DE236E; Thu, 10 Jul 2014 02:15:17 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s6A2FH9p068455; Thu, 10 Jul 2014 02:15:17 GMT (envelope-from cherry@svn.freebsd.org) Received: (from cherry@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s6A2FGmZ068453; Thu, 10 Jul 2014 02:15:16 GMT (envelope-from cherry@svn.freebsd.org) Message-Id: <201407100215.s6A2FGmZ068453@svn.freebsd.org> From: "Cherry G. Mathew" Date: Thu, 10 Jul 2014 02:15:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r268478 - in projects/amd64_xen_pv/sys/amd64: include/xen xen 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.18 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, 10 Jul 2014 02:15:17 -0000 Author: cherry Date: Thu Jul 10 02:15:16 2014 New Revision: 268478 URL: http://svnweb.freebsd.org/changeset/base/268478 Log: Clear aliased user pagetables in kernel VA space before trying to destroy the user pmap. Kernel now boots to single user mode, with 4K backed pages and direct mapped physical memory. Approved by: gibbs(implicit) Modified: projects/amd64_xen_pv/sys/amd64/include/xen/xenpmap.h projects/amd64_xen_pv/sys/amd64/xen/pmap.c Modified: projects/amd64_xen_pv/sys/amd64/include/xen/xenpmap.h ============================================================================== --- projects/amd64_xen_pv/sys/amd64/include/xen/xenpmap.h Thu Jul 10 00:15:55 2014 (r268477) +++ projects/amd64_xen_pv/sys/amd64/include/xen/xenpmap.h Thu Jul 10 02:15:16 2014 (r268478) @@ -233,7 +233,12 @@ static inline pt_entry_t pte_load_store( pte = *ptep; pte_store(ptep, npte); - /* XXX: SMP race! */ + + /* + * The hypervisor pte write implementation is atomic (see + * xen/include/asm-x86/x86_64/page.h) so our saved value is + * consistent. + */ return pte; } Modified: projects/amd64_xen_pv/sys/amd64/xen/pmap.c ============================================================================== --- projects/amd64_xen_pv/sys/amd64/xen/pmap.c Thu Jul 10 00:15:55 2014 (r268477) +++ projects/amd64_xen_pv/sys/amd64/xen/pmap.c Thu Jul 10 02:15:16 2014 (r268478) @@ -1058,26 +1058,6 @@ pmap_xen_bootpages(vm_paddr_t *firstaddr } -/* alloc from linear mapped boot time virtual address space */ -static uintptr_t -mmu_alloc(void) -{ - uintptr_t va; - - KASSERT(physfree != 0, - ("physfree must have been set before using mmu_alloc")); - - va = PTOV(allocpages(&physfree, atop(PAGE_SIZE))); - - /* - * Xen requires the page table hierarchy to be R/O. - */ - - pmap_xen_setpages_ro(va, atop(PAGE_SIZE)); - - return va; -} - void pmap_bootstrap(vm_paddr_t *firstaddr) { @@ -2596,7 +2576,16 @@ void pmap_xen_userload(pmap_t pmap) xen_pt_user_switch(pmap->pm_cr3); } - +/* Clear kernel alias to user VA mappings */ +static void pmap_xen_userclear(void) +{ + int i; + for (i = 0; i < NUPML4E; i++) { + PT_CLEAR_VA((pml4_entry_t *)PTOV(KPML4phys) + i, false); + } + PT_UPDATES_FLUSH(); + invltlb(); +} /* * First find and then destroy the pv entry for the specified pmap and virtual * address. This operation can be performed on pv lists for either 4KB or 2MB @@ -2892,7 +2881,6 @@ retry: * deallocated. */ mpte = _pmap_allocpte(pmap, pmap_pde_pindex(va), &lock); - //panic(__func__); goto retry; } else panic("pmap_enter: invalid page directory va=%#lx", va); @@ -3982,6 +3970,9 @@ pmap_remove_pages(pmap_t pmap) SLIST_INIT(&free); rw_rlock(&pvh_global_lock); PMAP_LOCK(pmap); + /* Kill the Xen user alias mappings, if any */ + /* XXX: If pmap is current pmap ? */ + pmap_xen_userclear(); TAILQ_FOREACH_SAFE(pc, &pmap->pm_pvchunk, pc_list, npc) { allfree = 1; freed = 0; @@ -4001,7 +3992,7 @@ pmap_remove_pages(pmap_t pmap) if ((tpte & (PG_PS | PG_V)) == PG_V) { superpage = FALSE; ptepde = tpte; - pte = (pt_entry_t *)PHYS_TO_DMAP(tpte & + pte = (pt_entry_t *)MACH_TO_DMAP(tpte & PG_FRAME); pte = &pte[pmap_pte_index(pv->pv_va)]; tpte = *pte;