summaryrefslogtreecommitdiffstats
path: root/sys/i386/xen
diff options
context:
space:
mode:
authordfr <dfr@FreeBSD.org>2009-04-01 17:06:28 +0000
committerdfr <dfr@FreeBSD.org>2009-04-01 17:06:28 +0000
commitdf0ed71781b42b3334d3cf4200cf60ae4eb0ec19 (patch)
tree5494350917ada193418eaf287c32a9c53171fa67 /sys/i386/xen
parentce3adf17d25ae823e1c74998576355f7da16fe40 (diff)
downloadFreeBSD-src-df0ed71781b42b3334d3cf4200cf60ae4eb0ec19.zip
FreeBSD-src-df0ed71781b42b3334d3cf4200cf60ae4eb0ec19.tar.gz
Fix the Xen build for i386 PV mode.
Diffstat (limited to 'sys/i386/xen')
-rw-r--r--sys/i386/xen/pmap.c66
-rw-r--r--sys/i386/xen/xen_machdep.c36
2 files changed, 101 insertions, 1 deletions
diff --git a/sys/i386/xen/pmap.c b/sys/i386/xen/pmap.c
index 3725d0a..59947e8 100644
--- a/sys/i386/xen/pmap.c
+++ b/sys/i386/xen/pmap.c
@@ -4100,6 +4100,72 @@ pmap_align_superpage(vm_object_t object, vm_ooffset_t offset,
*addr = ((*addr + PDRMASK) & ~PDRMASK) + superpage_offset;
}
+#ifdef XEN
+
+void
+pmap_suspend()
+{
+ pmap_t pmap;
+ int i, pdir, offset;
+ vm_paddr_t pdirma;
+ mmu_update_t mu[4];
+
+ /*
+ * We need to remove the recursive mapping structure from all
+ * our pmaps so that Xen doesn't get confused when it restores
+ * the page tables. The recursive map lives at page directory
+ * index PTDPTDI. We assume that the suspend code has stopped
+ * the other vcpus (if any).
+ */
+ LIST_FOREACH(pmap, &allpmaps, pm_list) {
+ for (i = 0; i < 4; i++) {
+ /*
+ * Figure out which page directory (L2) page
+ * contains this bit of the recursive map and
+ * the offset within that page of the map
+ * entry
+ */
+ pdir = (PTDPTDI + i) / NPDEPG;
+ offset = (PTDPTDI + i) % NPDEPG;
+ pdirma = pmap->pm_pdpt[pdir] & PG_FRAME;
+ mu[i].ptr = pdirma + offset * sizeof(pd_entry_t);
+ mu[i].val = 0;
+ }
+ HYPERVISOR_mmu_update(mu, 4, NULL, DOMID_SELF);
+ }
+}
+
+void
+pmap_resume()
+{
+ pmap_t pmap;
+ int i, pdir, offset;
+ vm_paddr_t pdirma;
+ mmu_update_t mu[4];
+
+ /*
+ * Restore the recursive map that we removed on suspend.
+ */
+ LIST_FOREACH(pmap, &allpmaps, pm_list) {
+ for (i = 0; i < 4; i++) {
+ /*
+ * Figure out which page directory (L2) page
+ * contains this bit of the recursive map and
+ * the offset within that page of the map
+ * entry
+ */
+ pdir = (PTDPTDI + i) / NPDEPG;
+ offset = (PTDPTDI + i) % NPDEPG;
+ pdirma = pmap->pm_pdpt[pdir] & PG_FRAME;
+ mu[i].ptr = pdirma + offset * sizeof(pd_entry_t);
+ mu[i].val = (pmap->pm_pdpt[i] & PG_FRAME) | PG_V;
+ }
+ HYPERVISOR_mmu_update(mu, 4, NULL, DOMID_SELF);
+ }
+}
+
+#endif
+
#if defined(PMAP_DEBUG)
pmap_pid_dump(int pid)
{
diff --git a/sys/i386/xen/xen_machdep.c b/sys/i386/xen/xen_machdep.c
index c99d754..878f436 100644
--- a/sys/i386/xen/xen_machdep.c
+++ b/sys/i386/xen/xen_machdep.c
@@ -89,6 +89,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];
+xen_pfn_t *xen_pfn_to_mfn_frame_list_list;
int preemptable, init_first;
extern unsigned int avail_space;
@@ -810,6 +812,39 @@ shift_phys_machine(unsigned long *phys_machine, int nr_pages)
}
#endif /* ADD_ISA_HOLE */
+/*
+ * Build a directory of the pages that make up our Physical to Machine
+ * mapping table. The Xen suspend/restore code uses this to find our
+ * mapping table.
+ */
+static void
+init_frame_list_list(void *arg)
+{
+ unsigned long nr_pages = xen_start_info->nr_pages;
+#define FPP (PAGE_SIZE/sizeof(xen_pfn_t))
+ int i, j, k;
+
+ xen_pfn_to_mfn_frame_list_list = malloc(PAGE_SIZE, M_DEVBUF, M_WAITOK);
+ for (i = 0, j = 0, k = -1; i < nr_pages;
+ i += FPP, j++) {
+ if ((j & (FPP - 1)) == 0) {
+ k++;
+ xen_pfn_to_mfn_frame_list[k] =
+ malloc(PAGE_SIZE, M_DEVBUF, M_WAITOK);
+ xen_pfn_to_mfn_frame_list_list[k] =
+ VTOMFN(xen_pfn_to_mfn_frame_list[k]);
+ j = 0;
+ }
+ xen_pfn_to_mfn_frame_list[k][j] =
+ VTOMFN(&xen_phys_machine[i]);
+ }
+
+ HYPERVISOR_shared_info->arch.max_pfn = nr_pages;
+ HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list
+ = VTOMFN(xen_pfn_to_mfn_frame_list_list);
+}
+SYSINIT(init_fll, SI_SUB_DEVFS, SI_ORDER_ANY, init_frame_list_list, NULL);
+
extern unsigned long physfree;
int pdir, curoffset;
@@ -1081,7 +1116,6 @@ initvalues(start_info_t *startinfo)
PT_SET_MA(console_page, console_page_ma | PG_KERNEL);
printk("#5\n");
- HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list = (unsigned long)xen_phys_machine;
set_iopl.iopl = 1;
PANIC_IF(HYPERVISOR_physdev_op(PHYSDEVOP_SET_IOPL, &set_iopl));
OpenPOWER on IntegriCloud