ia64/xen-unstable

changeset 6520:02121365cfff

Initialize the xenstore MFN for VMX domains

Signed-off-by: Arun Sharma <arun.sharma@intel.com>
author adsharma@los-vmm.sc.intel.com
date Tue Aug 09 14:21:18 2005 -0800 (2005-08-09)
parents 990288245c00
children 3d31c0ecdbd8
files tools/libxc/linux_boot_params.h tools/libxc/xc.h tools/libxc/xc_vmx_build.c tools/python/xen/lowlevel/xc/xc.c tools/python/xen/xend/image.py
line diff
     1.1 --- a/tools/libxc/linux_boot_params.h	Tue Aug 09 11:20:28 2005 -0800
     1.2 +++ b/tools/libxc/linux_boot_params.h	Tue Aug 09 14:21:18 2005 -0800
     1.3 @@ -17,6 +17,7 @@ struct mem_map {
     1.4  #define E820_NVS        4
     1.5  #define E820_IO         16
     1.6  #define E820_SHARED     17
     1.7 +#define E820_XENSTORE   18
     1.8  
     1.9          u32 caching_attr;    /* used by hypervisor */
    1.10  #define MEMMAP_UC	0
     2.1 --- a/tools/libxc/xc.h	Tue Aug 09 11:20:28 2005 -0800
     2.2 +++ b/tools/libxc/xc.h	Tue Aug 09 14:21:18 2005 -0800
     2.3 @@ -306,7 +306,10 @@ int xc_vmx_build(int xc_handle,
     2.4                   const char *ramdisk_name,
     2.5                   const char *cmdline,
     2.6                   unsigned int control_evtchn,
     2.7 -                 unsigned long flags);
     2.8 +                 unsigned long flags,
     2.9 +                 unsigned int vcpus,
    2.10 +                 unsigned int store_evtchn,
    2.11 +                 unsigned long *store_mfn);
    2.12  
    2.13  int xc_bvtsched_global_set(int xc_handle,
    2.14                             unsigned long ctx_allow);
     3.1 --- a/tools/libxc/xc_vmx_build.c	Tue Aug 09 11:20:28 2005 -0800
     3.2 +++ b/tools/libxc/xc_vmx_build.c	Tue Aug 09 14:21:18 2005 -0800
     3.3 @@ -37,58 +37,70 @@ static void build_e820map(struct mem_map
     3.4      int nr_map = 0;
     3.5  
     3.6      /* XXX: Doesn't work for > 4GB yet */
     3.7 -    mem_mapp->map[0].addr = 0x0;
     3.8 -    mem_mapp->map[0].size = 0x9F800;
     3.9 -    mem_mapp->map[0].type = E820_RAM;
    3.10 -    mem_mapp->map[0].caching_attr = MEMMAP_WB;
    3.11 +    mem_mapp->map[nr_map].addr = 0x0;
    3.12 +    mem_mapp->map[nr_map].size = 0x9F800;
    3.13 +    mem_mapp->map[nr_map].type = E820_RAM;
    3.14 +    mem_mapp->map[nr_map].caching_attr = MEMMAP_WB;
    3.15 +    nr_map++;
    3.16 +
    3.17 +    mem_mapp->map[nr_map].addr = 0x9F800;
    3.18 +    mem_mapp->map[nr_map].size = 0x800;
    3.19 +    mem_mapp->map[nr_map].type = E820_RESERVED;
    3.20 +    mem_mapp->map[nr_map].caching_attr = MEMMAP_UC;
    3.21      nr_map++;
    3.22  
    3.23 -    mem_mapp->map[1].addr = 0x9F800;
    3.24 -    mem_mapp->map[1].size = 0x800;
    3.25 -    mem_mapp->map[1].type = E820_RESERVED;
    3.26 -    mem_mapp->map[1].caching_attr = MEMMAP_UC;
    3.27 +    mem_mapp->map[nr_map].addr = 0xA0000;
    3.28 +    mem_mapp->map[nr_map].size = 0x20000;
    3.29 +    mem_mapp->map[nr_map].type = E820_IO;
    3.30 +    mem_mapp->map[nr_map].caching_attr = MEMMAP_UC;
    3.31      nr_map++;
    3.32  
    3.33 -    mem_mapp->map[2].addr = 0xA0000;
    3.34 -    mem_mapp->map[2].size = 0x20000;
    3.35 -    mem_mapp->map[2].type = E820_IO;
    3.36 -    mem_mapp->map[2].caching_attr = MEMMAP_UC;
    3.37 +    mem_mapp->map[nr_map].addr = 0xF0000;
    3.38 +    mem_mapp->map[nr_map].size = 0x10000;
    3.39 +    mem_mapp->map[nr_map].type = E820_RESERVED;
    3.40 +    mem_mapp->map[nr_map].caching_attr = MEMMAP_UC;
    3.41      nr_map++;
    3.42  
    3.43 -    mem_mapp->map[3].addr = 0xF0000;
    3.44 -    mem_mapp->map[3].size = 0x10000;
    3.45 -    mem_mapp->map[3].type = E820_RESERVED;
    3.46 -    mem_mapp->map[3].caching_attr = MEMMAP_UC;
    3.47 +#define STATIC_PAGES    2       /* for ioreq_t and store_mfn */
    3.48 +    /* Most of the ram goes here */
    3.49 +    mem_mapp->map[nr_map].addr = 0x100000;
    3.50 +    mem_mapp->map[nr_map].size = mem_size - 0x100000 - STATIC_PAGES*PAGE_SIZE;
    3.51 +    mem_mapp->map[nr_map].type = E820_RAM;
    3.52 +    mem_mapp->map[nr_map].caching_attr = MEMMAP_WB;
    3.53      nr_map++;
    3.54  
    3.55 -    mem_mapp->map[4].addr = 0x100000;
    3.56 -    mem_mapp->map[4].size = mem_size - 0x100000 - PAGE_SIZE;
    3.57 -    mem_mapp->map[4].type = E820_RAM;
    3.58 -    mem_mapp->map[4].caching_attr = MEMMAP_WB;
    3.59 +    /* Statically allocated special pages */
    3.60 +
    3.61 +    /* Shared ioreq_t page */
    3.62 +    mem_mapp->map[nr_map].addr = mem_size - PAGE_SIZE;
    3.63 +    mem_mapp->map[nr_map].size = PAGE_SIZE;
    3.64 +    mem_mapp->map[nr_map].type = E820_SHARED;
    3.65 +    mem_mapp->map[nr_map].caching_attr = MEMMAP_WB;
    3.66      nr_map++;
    3.67  
    3.68 -    mem_mapp->map[5].addr = mem_size - PAGE_SIZE;
    3.69 -    mem_mapp->map[5].size = PAGE_SIZE;
    3.70 -    mem_mapp->map[5].type = E820_SHARED;
    3.71 -    mem_mapp->map[5].caching_attr = MEMMAP_WB;
    3.72 +    /* For xenstore */
    3.73 +    mem_mapp->map[nr_map].addr = mem_size - 2*PAGE_SIZE;
    3.74 +    mem_mapp->map[nr_map].size = PAGE_SIZE;
    3.75 +    mem_mapp->map[nr_map].type = E820_XENSTORE;
    3.76 +    mem_mapp->map[nr_map].caching_attr = MEMMAP_WB;
    3.77      nr_map++;
    3.78  
    3.79 -    mem_mapp->map[6].addr = mem_size;
    3.80 -    mem_mapp->map[6].size = 0x3 * PAGE_SIZE;
    3.81 -    mem_mapp->map[6].type = E820_NVS;
    3.82 -    mem_mapp->map[6].caching_attr = MEMMAP_UC;
    3.83 +    mem_mapp->map[nr_map].addr = mem_size;
    3.84 +    mem_mapp->map[nr_map].size = 0x3 * PAGE_SIZE;
    3.85 +    mem_mapp->map[nr_map].type = E820_NVS;
    3.86 +    mem_mapp->map[nr_map].caching_attr = MEMMAP_UC;
    3.87      nr_map++;
    3.88  
    3.89 -    mem_mapp->map[7].addr = mem_size + 0x3 * PAGE_SIZE;
    3.90 -    mem_mapp->map[7].size = 0xA * PAGE_SIZE;
    3.91 -    mem_mapp->map[7].type = E820_ACPI;
    3.92 -    mem_mapp->map[7].caching_attr = MEMMAP_WB;
    3.93 +    mem_mapp->map[nr_map].addr = mem_size + 0x3 * PAGE_SIZE;
    3.94 +    mem_mapp->map[nr_map].size = 0xA * PAGE_SIZE;
    3.95 +    mem_mapp->map[nr_map].type = E820_ACPI;
    3.96 +    mem_mapp->map[nr_map].caching_attr = MEMMAP_WB;
    3.97      nr_map++;
    3.98  
    3.99 -    mem_mapp->map[8].addr = 0xFEC00000;
   3.100 -    mem_mapp->map[8].size = 0x1400000;
   3.101 -    mem_mapp->map[8].type = E820_IO;
   3.102 -    mem_mapp->map[8].caching_attr = MEMMAP_UC;
   3.103 +    mem_mapp->map[nr_map].addr = 0xFEC00000;
   3.104 +    mem_mapp->map[nr_map].size = 0x1400000;
   3.105 +    mem_mapp->map[nr_map].type = E820_IO;
   3.106 +    mem_mapp->map[nr_map].caching_attr = MEMMAP_UC;
   3.107      nr_map++;
   3.108  
   3.109      mem_mapp->nr_map = nr_map;
   3.110 @@ -212,7 +224,11 @@ static int setup_guest(int xc_handle,
   3.111                           unsigned long shared_info_frame,
   3.112                           unsigned int control_evtchn,
   3.113                           unsigned long flags,
   3.114 -                         struct mem_map * mem_mapp)
   3.115 +                         unsigned int vcpus,
   3.116 +                         unsigned int store_evtchn,
   3.117 +                         unsigned long *store_mfn,
   3.118 +                         struct mem_map *mem_mapp
   3.119 +                         )
   3.120  {
   3.121      l1_pgentry_t *vl1tab=NULL, *vl1e=NULL;
   3.122      l2_pgentry_t *vl2tab=NULL, *vl2e=NULL;
   3.123 @@ -510,7 +526,10 @@ static int setup_guest(int xc_handle,
   3.124      boot_paramsp->drive_info.dummy[14] = 32;
   3.125  
   3.126      /* memsize is in megabytes */
   3.127 +    /* If you need to create a special e820map, comment this line
   3.128 +       and use mem-map.sxp */
   3.129      build_e820map(mem_mapp, memsize << 20);
   3.130 +    *store_mfn = page_array[(v_end-2) >> PAGE_SHIFT];
   3.131  #if defined (__i386__)
   3.132      if (zap_mmio_ranges(xc_handle, dom, l2tab, mem_mapp) == -1)
   3.133  #else
   3.134 @@ -637,7 +656,10 @@ int xc_vmx_build(int xc_handle,
   3.135                     const char *ramdisk_name,
   3.136                     const char *cmdline,
   3.137                     unsigned int control_evtchn,
   3.138 -                   unsigned long flags)
   3.139 +                   unsigned long flags,
   3.140 +                   unsigned int vcpus,
   3.141 +                   unsigned int store_evtchn,
   3.142 +                   unsigned long *store_mfn)
   3.143  {
   3.144      dom0_op_t launch_op, op;
   3.145      int initrd_fd = -1;
   3.146 @@ -712,7 +734,8 @@ int xc_vmx_build(int xc_handle,
   3.147                         initrd_gfd, initrd_size, nr_pages, 
   3.148                         ctxt, cmdline,
   3.149                         op.u.getdomaininfo.shared_info_frame,
   3.150 -                       control_evtchn, flags, mem_mapp) < 0 )
   3.151 +                       control_evtchn, flags, vcpus, store_evtchn, store_mfn,
   3.152 +                       mem_mapp) < 0 )
   3.153      {
   3.154          ERROR("Error constructing guest OS");
   3.155          goto error_out;
     4.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Tue Aug 09 11:20:28 2005 -0800
     4.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Tue Aug 09 14:21:18 2005 -0800
     4.3 @@ -297,22 +297,23 @@ static PyObject *pyxc_vmx_build(PyObject
     4.4      u32   dom;
     4.5      char *image, *ramdisk = NULL, *cmdline = "";
     4.6      PyObject *memmap;
     4.7 -    int   control_evtchn, flags = 0;
     4.8 +    int   control_evtchn, store_evtchn;
     4.9 +    int flags = 0, vcpus = 1;
    4.10      int numItems, i;
    4.11      int memsize;
    4.12      struct mem_map mem_map;
    4.13 +    unsigned long store_mfn = 0;
    4.14  
    4.15 -    static char *kwd_list[] = { "dom", "control_evtchn",
    4.16 -                                "memsize",
    4.17 -                                "image", "memmap",
    4.18 +    static char *kwd_list[] = { "dom", "control_evtchn", "store_evtchn",
    4.19 +                                "memsize", "image", "memmap",
    4.20  				"ramdisk", "cmdline", "flags",
    4.21 -                                NULL };
    4.22 +				"vcpus", NULL };
    4.23  
    4.24 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiisO!|ssi", kwd_list, 
    4.25 -                                      &dom, &control_evtchn, 
    4.26 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiisO!|ssii", kwd_list, 
    4.27 +                                      &dom, &control_evtchn, &store_evtchn,
    4.28                                        &memsize,
    4.29                                        &image, &PyList_Type, &memmap,
    4.30 -				      &ramdisk, &cmdline, &flags) )
    4.31 +				      &ramdisk, &cmdline, &flags, &vcpus) )
    4.32          return NULL;
    4.33  
    4.34      memset(&mem_map, 0, sizeof(mem_map));
    4.35 @@ -321,7 +322,6 @@ static PyObject *pyxc_vmx_build(PyObject
    4.36      /* get the number of lines passed to us */
    4.37      numItems = PyList_Size(memmap) - 1;	/* removing the line 
    4.38  					   containing "memmap" */
    4.39 -    printf ("numItems: %d\n", numItems);
    4.40      mem_map.nr_map = numItems;
    4.41     
    4.42      /* should raise an error here. */
    4.43 @@ -365,11 +365,11 @@ static PyObject *pyxc_vmx_build(PyObject
    4.44      }
    4.45  
    4.46      if ( xc_vmx_build(xc->xc_handle, dom, memsize, image, &mem_map,
    4.47 -                        ramdisk, cmdline, control_evtchn, flags) != 0 )
    4.48 +                        ramdisk, cmdline, control_evtchn, flags,
    4.49 +                        vcpus, store_evtchn, &store_mfn) != 0 )
    4.50          return PyErr_SetFromErrno(xc_error);
    4.51      
    4.52 -    Py_INCREF(zero);
    4.53 -    return zero;
    4.54 +    return Py_BuildValue("{s:i}", "store_mfn", store_mfn);
    4.55  }
    4.56  
    4.57  static PyObject *pyxc_bvtsched_global_set(PyObject *self,
     5.1 --- a/tools/python/xen/xend/image.py	Tue Aug 09 11:20:28 2005 -0800
     5.2 +++ b/tools/python/xen/xend/image.py	Tue Aug 09 14:21:18 2005 -0800
     5.3 @@ -274,14 +274,24 @@ class VmxImageHandler(ImageHandler):
     5.4          # Create an event channel
     5.5          self.device_channel = channel.eventChannel(0, self.vm.getDomain())
     5.6          log.info("VMX device model port: %d", self.device_channel.port2)
     5.7 -        return xc.vmx_build(dom            = self.vm.getDomain(),
     5.8 +        if self.vm.store_channel:
     5.9 +            store_evtchn = self.vm.store_channel.port2
    5.10 +        else:
    5.11 +            store_evtchn = 0
    5.12 +        ret = xc.vmx_build(dom            = self.vm.getDomain(),
    5.13                              image          = self.kernel,
    5.14                              control_evtchn = self.device_channel.port2,
    5.15 +                            store_evtchn   = store_evtchn,
    5.16                              memsize        = self.vm.memory,
    5.17                              memmap         = self.memmap_value,
    5.18                              cmdline        = self.cmdline,
    5.19                              ramdisk        = self.ramdisk,
    5.20 -                            flags          = self.flags)
    5.21 +                            flags          = self.flags,
    5.22 +                            vcpus          = self.vm.vcpus)
    5.23 +        if isinstance(ret, dict):
    5.24 +            self.vm.store_mfn = ret.get('store_mfn')
    5.25 +            return 0
    5.26 +        return ret
    5.27  
    5.28      def parseMemmap(self):
    5.29          self.memmap = sxp.child_value(self.vm.config, "memmap")
    5.30 @@ -396,7 +406,9 @@ class VmxImageHandler(ImageHandler):
    5.31          self.pid = 0
    5.32  
    5.33      def getDomainMemory(self, mem_mb):
    5.34 -        return (mem_mb * 1024) + self.getPageTableSize(mem_mb)
    5.35 +        # for ioreq_t and xenstore
    5.36 +        static_pages = 2
    5.37 +        return (mem_mb * 1024) + self.getPageTableSize(mem_mb) + 4 * static_pages
    5.38              
    5.39      def getPageTableSize(self, mem_mb):
    5.40          """Return the size of memory needed for 1:1 page tables for physical