[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH][VT] patch make some share page can be accessed in vmx guest



This patch make some share page can be accessed in vmx guest
The share pages include shared_info, start_info, xen store share page
Also path store_evtchn, device_evtchn, control_evtchn to guest.
This patch are needed for para-driver in unmodified guest.

Signed-off-by: Xiaofeng Ling <xiaofeng.ling@xxxxxxxxx>
Signed-off-by: Arun Sharma <arun.sharma@xxxxxxxxx>

diff -r 23d8580d56b0 -r 2be69124cb06 tools/libxc/linux_boot_params.h
--- a/tools/libxc/linux_boot_params.h   Fri Sep  2 18:23:57 2005
+++ b/tools/libxc/linux_boot_params.h   Mon Sep  5 03:56:13 2005
@@ -18,6 +18,8 @@
 #define E820_IO         16
 #define E820_SHARED     17
 #define E820_XENSTORE   18
+#define E820_STARTINFO  19
+#define E820_SHAREDINFO  20

         u32 caching_attr;    /* used by hypervisor */
 #define MEMMAP_UC      0
diff -r 23d8580d56b0 -r 2be69124cb06 tools/libxc/xc_vmx_build.c
--- a/tools/libxc/xc_vmx_build.c        Fri Sep  2 18:23:57 2005
+++ b/tools/libxc/xc_vmx_build.c        Mon Sep  5 03:56:13 2005
@@ -62,7 +62,7 @@
     mem_mapp->map[nr_map].caching_attr = MEMMAP_UC;
     nr_map++;

-#define STATIC_PAGES    2       /* for ioreq_t and store_mfn */
+#define STATIC_PAGES 4 /* for ioreq_t and store_mfn and start_info*/
     /* Most of the ram goes here */
     mem_mapp->map[nr_map].addr = 0x100000;
mem_mapp->map[nr_map].size = mem_size - 0x100000 - STATIC_PAGES*PAGE_SIZE;
@@ -83,6 +83,24 @@
     mem_mapp->map[nr_map].addr = mem_size - 2*PAGE_SIZE;
     mem_mapp->map[nr_map].size = PAGE_SIZE;
     mem_mapp->map[nr_map].type = E820_XENSTORE;
+    mem_mapp->map[nr_map].caching_attr = MEMMAP_WB;
+    nr_map++;
+
+    mem_mapp->map[nr_map].addr = mem_size - 3 * PAGE_SIZE;
+    mem_mapp->map[nr_map].size = PAGE_SIZE;
+    mem_mapp->map[nr_map].type = E820_SHAREDINFO;
+    mem_mapp->map[nr_map].caching_attr = MEMMAP_WB;
+    nr_map++;
+
+    mem_mapp->map[nr_map].addr = mem_size - 4 * PAGE_SIZE;
+    mem_mapp->map[nr_map].size = PAGE_SIZE;
+    mem_mapp->map[nr_map].type = E820_STARTINFO;
+    mem_mapp->map[nr_map].caching_attr = MEMMAP_WB;
+    nr_map++;
+
+    mem_mapp->map[nr_map].addr = mem_size - PAGE_SIZE;
+    mem_mapp->map[nr_map].size = PAGE_SIZE;
+    mem_mapp->map[nr_map].type = E820_SHARED;
     mem_mapp->map[nr_map].caching_attr = MEMMAP_WB;
     nr_map++;

@@ -227,6 +245,7 @@
                          unsigned long flags,
                          unsigned int vcpus,
                          unsigned int store_evtchn,
+                         unsigned int device_evtchn,
                          unsigned long *store_mfn,
                          struct mem_map *mem_mapp
                          )
@@ -241,6 +260,7 @@
     unsigned long l2tab;
     unsigned long l1tab;
     unsigned long count, i;
+    start_info_t *start_info;
     shared_info_t *shared_info;
     struct linux_boot_params * boot_paramsp;
     __u16 * boot_gdtp;
@@ -262,6 +282,7 @@
     unsigned long v_end;

     unsigned long shared_page_frame = 0;
+    unsigned long startinfo_page_frame = 0;
     shared_iopage_t *sp;

     memset(&dsi, 0, sizeof(struct domain_setup_info));
@@ -289,7 +310,7 @@

     /* memsize is in megabytes */
     v_end              = memsize << 20;
- vinitrd_end = v_end - PAGE_SIZE; /* leaving the top 4k untouched for IO requests page use */ + vinitrd_end = v_end - 4 * PAGE_SIZE; /* leaving the top 4k untouched for IO requests page use */
     vinitrd_start      = vinitrd_end - initrd_len;
     vinitrd_start      = vinitrd_start & (~(PAGE_SIZE - 1));

@@ -368,6 +389,7 @@
     l2tab = page_array[ppt_alloc++] << PAGE_SHIFT;
     ctxt->ctrlreg[3] = l2tab;

+ page_array[((vpt_start - dsi.v_start)>>PAGE_SHIFT) - 3] = shared_info_frame;
     /* Initialise the page tables. */
     if ( (vl2tab = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
                                         PROT_READ|PROT_WRITE,
@@ -530,7 +552,7 @@
     /* If you need to create a special e820map, comment this line
        and use mem-map.sxp */
     build_e820map(mem_mapp, memsize << 20);
-    *store_mfn = page_array[(v_end-2) >> PAGE_SHIFT];
+    *store_mfn = page_array[((vpt_start - dsi.v_start)>>PAGE_SHIFT) - 2];
 #if defined (__i386__)
     if (zap_mmio_ranges(xc_handle, dom, l2tab, mem_mapp) == -1)
 #else
@@ -544,6 +566,8 @@
         boot_paramsp->e820_map[i].type = mem_mapp->map[i].type;
         if (mem_mapp->map[i].type == E820_SHARED)
             shared_page_frame = (mem_mapp->map[i].addr >> PAGE_SHIFT);
+        else if (mem_mapp->map[i].type == E820_STARTINFO)
+            startinfo_page_frame = (mem_mapp->map[i].addr >> PAGE_SHIFT);
     }
     munmap(boot_paramsp, PAGE_SIZE);

@@ -575,9 +599,22 @@
                page_array[shared_page_frame])) == 0)
        goto error_out;
     memset(sp, 0, PAGE_SIZE);
-    sp->sp_global.eport = control_evtchn;
+    sp->sp_global.eport = device_evtchn;
     munmap(sp, PAGE_SIZE);

+    start_info = xc_map_foreign_range(
+        xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
+        page_array[startinfo_page_frame]);
+    memset(start_info, 0, PAGE_SIZE);
+    start_info->nr_pages     = nr_pages;
+    start_info->shared_info  = shared_info_frame << PAGE_SHIFT;
+    start_info->flags        = flags;
+    start_info->pt_base      = vpt_start;
+    start_info->nr_pt_frames = nr_pt_pages;
+    start_info->domain_controller_evtchn = control_evtchn;
+    start_info->store_mfn    = *store_mfn;
+    start_info->store_evtchn = store_evtchn;
+    munmap(start_info, PAGE_SIZE);
     /*
      * Pin down l2tab addr as page dir page - causes hypervisor to provide
      * correct protection for the page
@@ -658,6 +695,7 @@
                    unsigned long flags,
                    unsigned int vcpus,
                    unsigned int store_evtchn,
+                   unsigned int device_evtchn,
                    unsigned long *store_mfn)
 {
     dom0_op_t launch_op, op;
@@ -733,7 +771,8 @@
                        initrd_gfd, initrd_size, nr_pages,
                        ctxt, cmdline,
                        op.u.getdomaininfo.shared_info_frame,
- control_evtchn, flags, vcpus, store_evtchn, store_mfn,
+                       control_evtchn, flags, vcpus, store_evtchn,
+                       device_evtchn, store_mfn,
                        mem_mapp) < 0 )
     {
         ERROR("Error constructing guest OS");
diff -r 23d8580d56b0 -r 2be69124cb06 tools/libxc/xenguest.h
--- a/tools/libxc/xenguest.h    Fri Sep  2 18:23:57 2005
+++ b/tools/libxc/xenguest.h    Mon Sep  5 03:56:13 2005
@@ -63,6 +63,7 @@
                  unsigned long flags,
                  unsigned int vcpus,
                  unsigned int store_evtchn,
+                 unsigned int device_evtchn,
                  unsigned long *store_mfn);

 #endif
diff -r 23d8580d56b0 -r 2be69124cb06 tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Fri Sep  2 18:23:57 2005
+++ b/tools/python/xen/lowlevel/xc/xc.c Mon Sep  5 03:56:13 2005
@@ -306,7 +306,7 @@
     u32   dom;
     char *image, *ramdisk = NULL, *cmdline = "";
     PyObject *memmap;
-    int   control_evtchn, store_evtchn;
+    int   control_evtchn, store_evtchn, device_evtchn;
     int flags = 0, vcpus = 1;
     int numItems, i;
     int memsize;
@@ -314,13 +314,13 @@
     unsigned long store_mfn = 0;

     static char *kwd_list[] = { "dom", "control_evtchn", "store_evtchn",
-                                "memsize", "image", "memmap",
+ "device_evtchn", "memsize", "image", "memmap",
                                "ramdisk", "cmdline", "flags",
                                "vcpus", NULL };

- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiisO!|ssii", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiiisO!|ssii", kwd_list, &dom, &control_evtchn, &store_evtchn,
-                                      &memsize,
+                                      &device_evtchn, &memsize,
                                       &image, &PyList_Type, &memmap,
                                      &ramdisk, &cmdline, &flags, &vcpus) )
         return NULL;
@@ -375,7 +375,7 @@

     if ( xc_vmx_build(xc->xc_handle, dom, memsize, image, &mem_map,
                         ramdisk, cmdline, control_evtchn, flags,
-                        vcpus, store_evtchn, &store_mfn) != 0 )
+ vcpus, store_evtchn, device_evtchn, &store_mfn) != 0 )
         return PyErr_SetFromErrno(xc_error);

     return Py_BuildValue("{s:i}", "store_mfn", store_mfn);
diff -r 23d8580d56b0 -r 2be69124cb06 tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py    Fri Sep  2 18:23:57 2005
+++ b/tools/python/xen/xend/image.py    Mon Sep  5 03:56:13 2005
@@ -302,8 +302,9 @@
             store_evtchn = 0
         ret = xc.vmx_build(dom            = self.vm.getDomain(),
                             image          = self.kernel,
-                            control_evtchn = self.device_channel.port2,
+ control_evtchn = self.vm.channel.getRemotePort(),
                             store_evtchn   = store_evtchn,
+                            device_evtchn  = self.device_channel.port2,
                             memsize        = self.vm.memory,
                             memmap         = self.memmap_value,
                             cmdline        = self.cmdline,

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.