svn commit: r237443 - in projects/amd64_xen_pv/sys: amd64/include amd64/xen x86/x86

Cherry G. Mathew cherry at FreeBSD.org
Fri Jun 22 13:56:59 UTC 2012


Author: cherry
Date: Fri Jun 22 13:56:58 2012
New Revision: 237443
URL: http://svn.freebsd.org/changeset/base/237443

Log:
  Add stub functions and global variables for xen suspend/resume code.
  While at it, re-arrange pmap.[ch] a bit.
  Fix macro abuse.
  
  Approved by:	gibbs (implicit)

Modified:
  projects/amd64_xen_pv/sys/amd64/include/pmap.h
  projects/amd64_xen_pv/sys/amd64/xen/machdep.c
  projects/amd64_xen_pv/sys/amd64/xen/pmap.c
  projects/amd64_xen_pv/sys/x86/x86/busdma_machdep.c

Modified: projects/amd64_xen_pv/sys/amd64/include/pmap.h
==============================================================================
--- projects/amd64_xen_pv/sys/amd64/include/pmap.h	Fri Jun 22 13:56:01 2012	(r237442)
+++ projects/amd64_xen_pv/sys/amd64/include/pmap.h	Fri Jun 22 13:56:58 2012	(r237443)
@@ -241,21 +241,7 @@ pte_store(pt_entry_t *ptep, pt_entry_t p
 #define VM_PAGE_TO_MACH(m) xpmap_ptom(VM_PAGE_TO_PHYS((m)))
 
 #define VTOM(va) xpmap_ptom(VTOP(va))
-
-static __inline vm_paddr_t
-pmap_kextract_ma(vm_offset_t va)
-{
-        vm_paddr_t ma = 0;
-	KASSERT(0, ("XXX: Please implement"));
-        return ma;
-}
-
-static __inline vm_paddr_t
-pmap_kextract(vm_offset_t va)
-{
-        return xpmap_mtop(pmap_kextract_ma(va));
-}
-
+vm_paddr_t pmap_kextract_ma(vm_offset_t);
 #define vtomach(va)     pmap_kextract_ma(((vm_offset_t) (va)))
 
 vm_paddr_t pmap_extract_ma(struct pmap *pmap, vm_offset_t va);
@@ -358,9 +344,7 @@ void	pmap_demote_DMAP(vm_paddr_t base, v
 void	pmap_init_pat(void);
 void	pmap_kenter(vm_offset_t va, vm_paddr_t pa);
 void	*pmap_kenter_temporary(vm_paddr_t pa, int i);
-#ifndef XEN
 vm_paddr_t pmap_kextract(vm_offset_t);
-#endif /* XEN */
 void	pmap_kremove(vm_offset_t);
 void	*pmap_mapbios(vm_paddr_t, vm_size_t);
 void	*pmap_mapdev(vm_paddr_t, vm_size_t);

Modified: projects/amd64_xen_pv/sys/amd64/xen/machdep.c
==============================================================================
--- projects/amd64_xen_pv/sys/amd64/xen/machdep.c	Fri Jun 22 13:56:01 2012	(r237442)
+++ projects/amd64_xen_pv/sys/amd64/xen/machdep.c	Fri Jun 22 13:56:58 2012	(r237443)
@@ -102,6 +102,8 @@ start_info_t *xen_start_info;
 shared_info_t *HYPERVISOR_shared_info;
 xen_pfn_t *xen_machine_phys = machine_to_phys_mapping;
 xen_pfn_t *xen_phys_machine;
+xen_pfn_t *xen_pfn_to_mfn_frame_list[16]; /* XXX: TODO init for suspend/resume */
+xen_pfn_t *xen_pfn_to_mfn_frame_list_list; /* XXX: TODO init for suspend/resume */
 
 #define	PHYSMAP_SIZE	(2 * VM_PHYSSEG_MAX)
 vm_offset_t pa_index = 0;

Modified: projects/amd64_xen_pv/sys/amd64/xen/pmap.c
==============================================================================
--- projects/amd64_xen_pv/sys/amd64/xen/pmap.c	Fri Jun 22 13:56:01 2012	(r237442)
+++ projects/amd64_xen_pv/sys/amd64/xen/pmap.c	Fri Jun 22 13:56:58 2012	(r237443)
@@ -303,7 +303,7 @@ create_boot_pagetables(vm_paddr_t *first
 	/* Fill in the underlying page table pages */
 	for (i = 0; ptoa(i) < ptoa(nkmapped); i++) {
 		((pt_entry_t *)KPTphys)[i] = phystomach(i << PAGE_SHIFT);
-		((pt_entry_t *)KPTphys)[i] |= PG_V | PG_G | PG_U;
+		((pt_entry_t *)KPTphys)[i] |= PG_V | PG_U;
 		((pt_entry_t *)KPTphys)[i] |= 
 			pmap_xen_kernel_vaflags(PTOV(i << PAGE_SHIFT));	
 	}
@@ -773,6 +773,45 @@ pmap_extract_and_hold(pmap_t pmap, vm_of
 	return 0;
 }
 
+vm_paddr_t
+pmap_kextract(vm_offset_t va)
+{
+	return xpmap_mtop(pmap_kextract_ma(va));
+}
+
+vm_paddr_t
+pmap_kextract_ma(vm_offset_t va)
+{
+	vm_paddr_t ma;
+
+	/* Walk the PT hierarchy to get the ma */
+	char tbuf[tsz]; /* Safe to do this on the stack since tsz is
+			 * effectively const.
+			 */
+
+	mmu_map_t tptr = tbuf;
+
+	struct mmu_map_mbackend mb = {
+		ptmb_mappedalloc,
+		ptmb_mappedfree,
+		ptmb_ptov,
+		ptmb_vtop
+	};
+	mmu_map_t_init(tptr, &mb);
+
+	if (!mmu_map_inspect_va(kernel_pmap, tptr, va)) {
+		ma = 0;
+		goto nomapping;
+	}
+
+	ma = mmu_map_pt(tptr)[(~PDRMASK & PAGE_MASK & va) >> PAGE_SHIFT];
+
+	mmu_map_t_fini(tptr);
+
+nomapping:
+	return ma;
+}
+
 /***************************************************
  * Low level mapping routines.....
  ***************************************************/
@@ -787,6 +826,12 @@ pmap_extract_and_hold(pmap_t pmap, vm_of
 void 
 pmap_kenter(vm_offset_t va, vm_paddr_t pa)
 {
+	pmap_kenter_ma(va, xpmap_ptom(pa));
+}
+
+void 
+pmap_kenter_ma(vm_offset_t va, vm_paddr_t ma)
+{
 
 	char tbuf[tsz]; /* Safe to do this on the stack since tsz is
 			 * effectively const.
@@ -808,7 +853,7 @@ pmap_kenter(vm_offset_t va, vm_paddr_t p
 	}
 
 	/* Backing page tables are in place, let xen do the maths */
-	PT_SET_MA(va, xpmap_ptom(pa) | PG_RW | PG_V | PG_U);
+	PT_SET_MA(va, ma | PG_RW | PG_V | PG_U);
 	PT_UPDATES_FLUSH();
 
 	mmu_map_release_va(kernel_pmap, tptr, va);
@@ -1038,6 +1083,18 @@ pmap_align_superpage(vm_object_t object,
 		*addr = ((*addr + PDRMASK) & ~PDRMASK) + superpage_offset;
 }
 
+void
+pmap_suspend()
+{
+	KASSERT(0, ("XXX: TODO\n"));
+}
+
+void
+pmap_resume()
+{
+	KASSERT(0, ("XXX: TODO\n"));
+}
+
 int
 pmap_mincore(pmap_t pmap, vm_offset_t addr, vm_paddr_t *locked_pa)
 {	

Modified: projects/amd64_xen_pv/sys/x86/x86/busdma_machdep.c
==============================================================================
--- projects/amd64_xen_pv/sys/x86/x86/busdma_machdep.c	Fri Jun 22 13:56:01 2012	(r237442)
+++ projects/amd64_xen_pv/sys/x86/x86/busdma_machdep.c	Fri Jun 22 13:56:58 2012	(r237443)
@@ -147,7 +147,7 @@ int _bus_dmamap_count_pages(bus_dma_tag_
 
 #ifdef XEN
 #undef pmap_kextract
-#define pmap_kextract pmap_kextract_ma
+#define pmap_kextract(va) pmap_kextract_ma((va))
 #endif
 
 /*


More information about the svn-src-projects mailing list