From owner-svn-src-projects@FreeBSD.ORG Thu Apr 12 00:45:43 2012 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BB84E1065700; Thu, 12 Apr 2012 00:45:43 +0000 (UTC) (envelope-from cherry@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9D3BB8FC14; Thu, 12 Apr 2012 00:45:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3C0jhD7003028; Thu, 12 Apr 2012 00:45:43 GMT (envelope-from cherry@svn.freebsd.org) Received: (from cherry@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3C0jhg5003026; Thu, 12 Apr 2012 00:45:43 GMT (envelope-from cherry@svn.freebsd.org) Message-Id: <201204120045.q3C0jhg5003026@svn.freebsd.org> From: "Cherry G. Mathew" Date: Thu, 12 Apr 2012 00:45:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234161 - projects/amd64_xen_pv/sys/amd64/xen X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 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, 12 Apr 2012 00:45:43 -0000 Author: cherry Date: Thu Apr 12 00:45:43 2012 New Revision: 234161 URL: http://svn.freebsd.org/changeset/base/234161 Log: Map in the xen shared_info page into kernel virtual memory. Approved by: gibbs (implicit) Modified: projects/amd64_xen_pv/sys/amd64/xen/pmap.c Modified: projects/amd64_xen_pv/sys/amd64/xen/pmap.c ============================================================================== --- projects/amd64_xen_pv/sys/amd64/xen/pmap.c Thu Apr 12 00:38:34 2012 (r234160) +++ projects/amd64_xen_pv/sys/amd64/xen/pmap.c Thu Apr 12 00:45:43 2012 (r234161) @@ -135,7 +135,7 @@ create_boot_pagetables(vm_paddr_t *first boot_ptphys = *firstaddr; /* lowest available r/w area */ - /* Allocate pages */ + /* Allocate pseudo-physical pages for kernel page tables. */ nkpt = howmany(mapspan, NPTEPG); nkpdpe = howmany(nkpt, NPDEPG); KPML4phys = vallocpages(firstaddr, 1); @@ -281,6 +281,53 @@ create_boot_pagetables(vm_paddr_t *first xen_pgdir_pin(phystomach(VTOP(KPML4phys))); } +/* + * Note: pmap_xen_bootpages assumes and asserts for the fact that the + * kernel virtual start and end values have been initialised. + * + * Map in the xen provided shared pages. They are: + * - shared info page + * - console page (XXX:) + * - XXX: + */ + +static void +pmap_xen_bootpages(vm_paddr_t *firstaddr) +{ + vm_offset_t va; + vm_paddr_t ma; + + KASSERT(virtual_avail != 0, + ("kernel virtual address space un-initialised!")); + KASSERT(virtual_avail >= (KERNBASE + physmem), + ("kernel virtual address space inconsistent!")); + + /* Share info */ + ma = xen_start_info->shared_info; + + /* This is a bit of a hack right now - we waste a physical + * page by overwriting its original mapping to point to + * the page we want ( thereby losing access to the + * original page ). + * + * The clean solution would have been to map it in at + * KERNBASE + pa, where pa is the "pseudo-physical" address of + * the shared page that xen gives us. We can't seem to be able + * to use the pseudo-physical address in this way because the + * linear mapped virtual address seems to be outside of the + * range of PTEs that we have available during bootup (ptes + * take virtual address space which is limited to under + * (512KB - (kernal binaries, stack et al.)) during xen + * bootup). + */ + + va = vallocpages(firstaddr, 1); + PT_SET_MA(va, ma | PG_RW | PG_V | PG_U); + + + HYPERVISOR_shared_info = (void *) va; +} + void pmap_bootstrap(vm_paddr_t *firstaddr) { @@ -290,7 +337,7 @@ pmap_bootstrap(vm_paddr_t *firstaddr) /* Switch to the new kernel tables */ xen_pt_switch(VTOP(KPML4phys)); - /* Unpin old page table, and make it r/w */ + /* Unpin old page table hierarchy, and mark all its pages r/w */ xen_pgdir_unpin(phystomach(VTOP(xen_start_info->pt_base))); pmap_xen_setpages_rw(xen_start_info->pt_base, xen_start_info->nr_pt_frames); @@ -302,6 +349,10 @@ pmap_bootstrap(vm_paddr_t *firstaddr) virtual_avail = (vm_offset_t) KERNBASE + *firstaddr; virtual_end = VM_MAX_KERNEL_ADDRESS; /* XXX: Check we don't overlap xen pgdir entries. */ + + /* Map in Xen related pages into VA space */ + pmap_xen_bootpages(firstaddr); + } void