direct-io.hg

changeset 12211:722cc2390021

Merge with tip
author Alastair Tse <atse@xensource.com>
date Thu Nov 02 14:27:16 2006 +0000 (2006-11-02)
parents 41ad2c673fdb 002856e70ca1
children 45e34f00a78f 96ad1d72fccf
files
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/xencomm.c	Thu Nov 02 14:26:01 2006 +0000
     1.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/xencomm.c	Thu Nov 02 14:27:16 2006 +0000
     1.3 @@ -20,6 +20,11 @@
     1.4  #include <linux/mm.h>
     1.5  #include <xen/interface/xen.h>
     1.6  #include <asm/page.h>
     1.7 +
     1.8 +#ifdef HAVE_XEN_PLATFORM_COMPAT_H
     1.9 +#include <xen/platform-compat.h>
    1.10 +#endif
    1.11 +
    1.12  #include <asm/xen/xencomm.h>
    1.13  
    1.14  static int xencomm_debug = 0;
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/reboot.c	Thu Nov 02 14:26:01 2006 +0000
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/reboot.c	Thu Nov 02 14:27:16 2006 +0000
     2.3 @@ -30,7 +30,7 @@ static DECLARE_WORK(shutdown_work, __shu
     2.4  #ifdef CONFIG_XEN
     2.5  int __xen_suspend(void);
     2.6  #else
     2.7 -#define __xen_suspend() 0
     2.8 +#define __xen_suspend() (void)0
     2.9  #endif
    2.10  
    2.11  static int shutdown_process(void *__unused)
    2.12 @@ -44,7 +44,7 @@ static int shutdown_process(void *__unus
    2.13  
    2.14  	if ((shutting_down == SHUTDOWN_POWEROFF) ||
    2.15  	    (shutting_down == SHUTDOWN_HALT)) {
    2.16 -		if (call_usermodehelper_keys("/sbin/poweroff", poweroff_argv, envp, NULL, 0) < 0) {
    2.17 +		if (call_usermodehelper("/sbin/poweroff", poweroff_argv, envp, 0) < 0) {
    2.18  #ifdef CONFIG_XEN
    2.19  			sys_reboot(LINUX_REBOOT_MAGIC1,
    2.20  				   LINUX_REBOOT_MAGIC2,
     3.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu Nov 02 14:26:01 2006 +0000
     3.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu Nov 02 14:27:16 2006 +0000
     3.3 @@ -101,6 +101,14 @@ static inline void dev_disable_gso_featu
     3.4  }
     3.5  #elif defined(NETIF_F_TSO)
     3.6  #define HAVE_TSO                       1
     3.7 +
     3.8 +/* Some older kernels cannot cope with incorrect checksums,
     3.9 + * particularly in netfilter. I'm not sure there is 100% correlation
    3.10 + * with the presence of NETIF_F_TSO but it appears to be a good first
    3.11 + * approximiation.
    3.12 + */
    3.13 +#define HAVE_NO_CSUM_OFFLOAD           1
    3.14 +
    3.15  #define gso_size tso_size
    3.16  #define gso_segs tso_segs
    3.17  static inline void dev_disable_gso_features(struct net_device *dev)
    3.18 @@ -394,6 +402,14 @@ again:
    3.19  		goto abort_transaction;
    3.20  	}
    3.21  
    3.22 +#ifdef HAVE_NO_CSUM_OFFLOAD
    3.23 +	err = xenbus_printf(xbt, dev->nodename, "feature-no-csum-offload", "%d", 1);
    3.24 +	if (err) {
    3.25 +		message = "writing feature-no-csum-offload";
    3.26 +		goto abort_transaction;
    3.27 +	}
    3.28 +#endif
    3.29 +
    3.30  	err = xenbus_printf(xbt, dev->nodename, "feature-sg", "%d", 1);
    3.31  	if (err) {
    3.32  		message = "writing feature-sg";
     4.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c	Thu Nov 02 14:26:01 2006 +0000
     4.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c	Thu Nov 02 14:27:16 2006 +0000
     4.3 @@ -30,13 +30,16 @@
     4.4   * IN THE SOFTWARE.
     4.5   */
     4.6  
     4.7 -#include <asm/hypervisor.h>
     4.8 -#include <xen/evtchn.h>
     4.9  #include <linux/wait.h>
    4.10  #include <linux/interrupt.h>
    4.11  #include <linux/sched.h>
    4.12  #include <linux/err.h>
    4.13 +#include <linux/ptrace.h>
    4.14 +#include <xen/evtchn.h>
    4.15  #include <xen/xenbus.h>
    4.16 +
    4.17 +#include <asm/hypervisor.h>
    4.18 +
    4.19  #include "xenbus_comms.h"
    4.20  
    4.21  #ifdef HAVE_XEN_PLATFORM_COMPAT_H
     5.1 --- a/linux-2.6-xen-sparse/include/asm-ia64/hypercall.h	Thu Nov 02 14:26:01 2006 +0000
     5.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/hypercall.h	Thu Nov 02 14:27:16 2006 +0000
     5.3 @@ -283,6 +283,9 @@ static inline void exit_idle(void) {}
     5.4  #ifdef CONFIG_XEN
     5.5  #include <asm/xen/privop.h>
     5.6  #endif /* CONFIG_XEN */
     5.7 +#ifdef HAVE_XEN_PLATFORM_COMPAT_H
     5.8 +#include <xen/platform-compat.h>
     5.9 +#endif
    5.10  
    5.11  static inline unsigned long
    5.12  __HYPERVISOR_ioremap(unsigned long ioaddr, unsigned long size)
     6.1 --- a/tools/libxc/xc_linux_build.c	Thu Nov 02 14:26:01 2006 +0000
     6.2 +++ b/tools/libxc/xc_linux_build.c	Thu Nov 02 14:27:16 2006 +0000
     6.3 @@ -25,12 +25,6 @@
     6.4  #define L4_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
     6.5  #endif
     6.6  
     6.7 -#ifdef __ia64__
     6.8 -#define get_tot_pages xc_get_max_pages
     6.9 -#else
    6.10 -#define get_tot_pages xc_get_tot_pages
    6.11 -#endif
    6.12 -
    6.13  #define round_pgup(_p)    (((_p)+(PAGE_SIZE-1))&PAGE_MASK)
    6.14  #define round_pgdown(_p)  ((_p)&PAGE_MASK)
    6.15  
    6.16 @@ -674,7 +668,6 @@ static int setup_guest(int xc_handle,
    6.17      int hypercall_page_defined;
    6.18      start_info_t *start_info;
    6.19      shared_info_t *shared_info;
    6.20 -    xc_mmu_t *mmu = NULL;
    6.21      const char *p;
    6.22      DECLARE_DOMCTL;
    6.23      int rc;
    6.24 @@ -716,7 +709,7 @@ static int setup_guest(int xc_handle,
    6.25          goto error_out;
    6.26      }
    6.27  
    6.28 -    if (!compat_check(xc_handle, &dsi))
    6.29 +    if ( !compat_check(xc_handle, &dsi) )
    6.30          goto error_out;
    6.31  
    6.32      /* Parse and validate kernel features. */
    6.33 @@ -751,9 +744,13 @@ static int setup_guest(int xc_handle,
    6.34          goto error_out;
    6.35      }
    6.36  
    6.37 -    if ( xc_get_pfn_list(xc_handle, dom, page_array, nr_pages) != nr_pages )
    6.38 +    for ( i = 0; i < nr_pages; i++ )
    6.39 +        page_array[i] = i;
    6.40 +
    6.41 +    if ( xc_domain_memory_populate_physmap(xc_handle, dom, nr_pages,
    6.42 +                                           0, 0, page_array) )
    6.43      {
    6.44 -        PERROR("Could not get the page frame list");
    6.45 +        PERROR("Could not allocate memory for PV guest.\n");
    6.46          goto error_out;
    6.47      }
    6.48  
    6.49 @@ -885,9 +882,8 @@ static int setup_guest(int xc_handle,
    6.50          goto error_out;
    6.51      }
    6.52  
    6.53 -    /* setup page tables */
    6.54  #if defined(__i386__)
    6.55 -    if (dsi.pae_kernel != PAEKERN_no)
    6.56 +    if ( dsi.pae_kernel != PAEKERN_no )
    6.57          rc = setup_pg_tables_pae(xc_handle, dom, ctxt,
    6.58                                   dsi.v_start, v_end,
    6.59                                   page_array, vpt_start, vpt_end,
    6.60 @@ -904,16 +900,16 @@ static int setup_guest(int xc_handle,
    6.61                              page_array, vpt_start, vpt_end,
    6.62                              shadow_mode_enabled);
    6.63  #endif
    6.64 -    if (0 != rc)
    6.65 +    if ( rc != 0 )
    6.66          goto error_out;
    6.67  
    6.68 -#if defined(__i386__)
    6.69      /*
    6.70       * Pin down l2tab addr as page dir page - causes hypervisor to provide
    6.71       * correct protection for the page
    6.72       */
    6.73      if ( !shadow_mode_enabled )
    6.74      {
    6.75 +#if defined(__i386__)
    6.76          if ( dsi.pae_kernel != PAEKERN_no )
    6.77          {
    6.78              if ( pin_table(xc_handle, MMUEXT_PIN_L3_TABLE,
    6.79 @@ -926,40 +922,24 @@ static int setup_guest(int xc_handle,
    6.80                             xen_cr3_to_pfn(ctxt->ctrlreg[3]), dom) )
    6.81                  goto error_out;
    6.82          }
    6.83 +#elif defined(__x86_64__)
    6.84 +        /*
    6.85 +         * Pin down l4tab addr as page dir page - causes hypervisor to  provide
    6.86 +         * correct protection for the page
    6.87 +         */
    6.88 +        if ( pin_table(xc_handle, MMUEXT_PIN_L4_TABLE,
    6.89 +                       xen_cr3_to_pfn(ctxt->ctrlreg[3]), dom) )
    6.90 +            goto error_out;
    6.91 +#endif
    6.92      }
    6.93 -#endif
    6.94  
    6.95 -#if defined(__x86_64__)
    6.96 -    /*
    6.97 -     * Pin down l4tab addr as page dir page - causes hypervisor to  provide
    6.98 -     * correct protection for the page
    6.99 -     */
   6.100 -    if ( pin_table(xc_handle, MMUEXT_PIN_L4_TABLE,
   6.101 -                   xen_cr3_to_pfn(ctxt->ctrlreg[3]), dom) )
   6.102 -        goto error_out;
   6.103 -#endif
   6.104 -
   6.105 -    if ( (mmu = xc_init_mmu_updates(xc_handle, dom)) == NULL )
   6.106 -        goto error_out;
   6.107 -
   6.108 -    /* Write the phys->machine and machine->phys table entries. */
   6.109 +    /* Write the phys->machine table entries (machine->phys already done). */
   6.110      physmap_pfn = (vphysmap_start - dsi.v_start) >> PAGE_SHIFT;
   6.111      physmap = physmap_e = xc_map_foreign_range(
   6.112          xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
   6.113          page_array[physmap_pfn++]);
   6.114 -
   6.115      for ( count = 0; count < nr_pages; count++ )
   6.116      {
   6.117 -        if ( xc_add_mmu_update(
   6.118 -            xc_handle, mmu,
   6.119 -            ((uint64_t)page_array[count] << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE,
   6.120 -            count) )
   6.121 -        {
   6.122 -            DPRINTF("m2p update failure p=%lx m=%"PRIx64"\n",
   6.123 -                    count, (uint64_t)page_array[count]);
   6.124 -            munmap(physmap, PAGE_SIZE);
   6.125 -            goto error_out;
   6.126 -        }
   6.127          *physmap_e++ = page_array[count];
   6.128          if ( ((unsigned long)physmap_e & (PAGE_SIZE-1)) == 0 )
   6.129          {
   6.130 @@ -971,10 +951,6 @@ static int setup_guest(int xc_handle,
   6.131      }
   6.132      munmap(physmap, PAGE_SIZE);
   6.133  
   6.134 -    /* Send the page update requests down to the hypervisor. */
   6.135 -    if ( xc_finish_mmu_updates(xc_handle, mmu) )
   6.136 -        goto error_out;
   6.137 -
   6.138      if ( shadow_mode_enabled )
   6.139      {
   6.140          struct xen_add_to_physmap xatp;
   6.141 @@ -1081,10 +1057,6 @@ static int setup_guest(int xc_handle,
   6.142  
   6.143      munmap(shared_info, PAGE_SIZE);
   6.144  
   6.145 -    /* Send the page update requests down to the hypervisor. */
   6.146 -    if ( xc_finish_mmu_updates(xc_handle, mmu) )
   6.147 -        goto error_out;
   6.148 -
   6.149      hypercall_page = xen_elfnote_numeric(&dsi, XEN_ELFNOTE_HYPERCALL_PAGE,
   6.150                                           &hypercall_page_defined);
   6.151      if ( hypercall_page_defined )
   6.152 @@ -1100,7 +1072,6 @@ static int setup_guest(int xc_handle,
   6.153              goto error_out;
   6.154      }
   6.155  
   6.156 -    free(mmu);
   6.157      free(page_array);
   6.158  
   6.159      *pvsi = vstartinfo_start;
   6.160 @@ -1110,7 +1081,6 @@ static int setup_guest(int xc_handle,
   6.161      return 0;
   6.162  
   6.163   error_out:
   6.164 -    free(mmu);
   6.165      free(page_array);
   6.166      return -1;
   6.167  }
   6.168 @@ -1118,6 +1088,7 @@ static int setup_guest(int xc_handle,
   6.169  
   6.170  static int xc_linux_build_internal(int xc_handle,
   6.171                                     uint32_t domid,
   6.172 +                                   unsigned int mem_mb,
   6.173                                     char *image,
   6.174                                     unsigned long image_size,
   6.175                                     struct initrd_info *initrd,
   6.176 @@ -1132,8 +1103,7 @@ static int xc_linux_build_internal(int x
   6.177      struct xen_domctl launch_domctl;
   6.178      DECLARE_DOMCTL;
   6.179      int rc, i;
   6.180 -    vcpu_guest_context_t st_ctxt, *ctxt = &st_ctxt;
   6.181 -    unsigned long nr_pages;
   6.182 +    struct vcpu_guest_context st_ctxt, *ctxt = &st_ctxt;
   6.183      unsigned long vstartinfo_start, vkern_entry, vstack_start;
   6.184      uint32_t      features_bitmap[XENFEAT_NR_SUBMAPS] = { 0, };
   6.185  
   6.186 @@ -1146,12 +1116,6 @@ static int xc_linux_build_internal(int x
   6.187          }
   6.188      }
   6.189  
   6.190 -    if ( (nr_pages = get_tot_pages(xc_handle, domid)) < 0 )
   6.191 -    {
   6.192 -        PERROR("Could not find total pages for domain");
   6.193 -        goto error_out;
   6.194 -    }
   6.195 -
   6.196  #ifdef VALGRIND
   6.197      memset(&st_ctxt, 0, sizeof(st_ctxt));
   6.198  #endif
   6.199 @@ -1175,7 +1139,7 @@ static int xc_linux_build_internal(int x
   6.200  
   6.201      if ( setup_guest(xc_handle, domid, image, image_size,
   6.202                       initrd,
   6.203 -                     nr_pages,
   6.204 +                     mem_mb << (20 - PAGE_SHIFT),
   6.205                       &vstartinfo_start, &vkern_entry,
   6.206                       &vstack_start, ctxt, cmdline,
   6.207                       domctl.u.getdomaininfo.shared_info_frame,
   6.208 @@ -1271,6 +1235,7 @@ static int xc_linux_build_internal(int x
   6.209  
   6.210  int xc_linux_build_mem(int xc_handle,
   6.211                         uint32_t domid,
   6.212 +                       unsigned int mem_mb,
   6.213                         const char *image_buffer,
   6.214                         unsigned long image_size,
   6.215                         const char *initrd,
   6.216 @@ -1319,7 +1284,7 @@ int xc_linux_build_mem(int xc_handle,
   6.217          }
   6.218      }
   6.219  
   6.220 -    sts = xc_linux_build_internal(xc_handle, domid, img_buf, img_len,
   6.221 +    sts = xc_linux_build_internal(xc_handle, domid, mem_mb, img_buf, img_len,
   6.222                                    &initrd_info, cmdline, features, flags,
   6.223                                    store_evtchn, store_mfn,
   6.224                                    console_evtchn, console_mfn);
   6.225 @@ -1339,6 +1304,7 @@ int xc_linux_build_mem(int xc_handle,
   6.226  
   6.227  int xc_linux_build(int xc_handle,
   6.228                     uint32_t domid,
   6.229 +                   unsigned int mem_mb,
   6.230                     const char *image_name,
   6.231                     const char *initrd_name,
   6.232                     const char *cmdline,
   6.233 @@ -1375,7 +1341,7 @@ int xc_linux_build(int xc_handle,
   6.234          }
   6.235      }
   6.236  
   6.237 -    sts = xc_linux_build_internal(xc_handle, domid, image, image_size,
   6.238 +    sts = xc_linux_build_internal(xc_handle, domid, mem_mb, image, image_size,
   6.239                                    &initrd_info, cmdline, features, flags,
   6.240                                    store_evtchn, store_mfn,
   6.241                                    console_evtchn, console_mfn);
     7.1 --- a/tools/libxc/xenguest.h	Thu Nov 02 14:26:01 2006 +0000
     7.2 +++ b/tools/libxc/xenguest.h	Thu Nov 02 14:27:16 2006 +0000
     7.3 @@ -48,8 +48,9 @@ int xc_linux_restore(int xc_handle, int 
     7.4   *
     7.5   * @parm xc_handle a handle to an open hypervisor interface
     7.6   * @parm domid the id of the domain
     7.7 - * @param image_name name of the kernel image file
     7.8 - * @param ramdisk_name name of the ramdisk image file
     7.9 + * @parm mem_mb memory size in megabytes
    7.10 + * @parm image_name name of the kernel image file
    7.11 + * @parm ramdisk_name name of the ramdisk image file
    7.12   * @parm cmdline command line string
    7.13   * @parm flags domain creation flags
    7.14   * @parm store_evtchn the store event channel for this domain to use
    7.15 @@ -60,6 +61,7 @@ int xc_linux_restore(int xc_handle, int 
    7.16   */
    7.17  int xc_linux_build(int xc_handle,
    7.18                     uint32_t domid,
    7.19 +                   unsigned int mem_mb,
    7.20                     const char *image_name,
    7.21                     const char *ramdisk_name,
    7.22                     const char *cmdline,
    7.23 @@ -74,22 +76,24 @@ int xc_linux_build(int xc_handle,
    7.24   * This function will create a domain for a paravirtualized Linux
    7.25   * using buffers for kernel and initrd
    7.26   *
    7.27 - * @param xc_handle a handle to an open hypervisor interface
    7.28 - * @param domid the id of the domain
    7.29 - * @param image_buffer buffer containing kernel image
    7.30 - * @param image_size size of the kernel image buffer
    7.31 - * @param initrd_buffer name of the ramdisk image file
    7.32 - * @param initrd_size size of the ramdisk buffer
    7.33 - * @param cmdline command line string
    7.34 - * @param flags domain creation flags
    7.35 - * @param store_evtchn the store event channel for this domain to use
    7.36 - * @param store_mfn returned with the mfn of the store page
    7.37 - * @param console_evtchn the console event channel for this domain to use
    7.38 - * @param conole_mfn returned with the mfn of the console page
    7.39 + * @parm xc_handle a handle to an open hypervisor interface
    7.40 + * @parm domid the id of the domain
    7.41 + * @parm mem_mb memory size in megabytes
    7.42 + * @parm image_buffer buffer containing kernel image
    7.43 + * @parm image_size size of the kernel image buffer
    7.44 + * @parm initrd_buffer name of the ramdisk image file
    7.45 + * @parm initrd_size size of the ramdisk buffer
    7.46 + * @parm cmdline command line string
    7.47 + * @parm flags domain creation flags
    7.48 + * @parm store_evtchn the store event channel for this domain to use
    7.49 + * @parm store_mfn returned with the mfn of the store page
    7.50 + * @parm console_evtchn the console event channel for this domain to use
    7.51 + * @parm conole_mfn returned with the mfn of the console page
    7.52   * @return 0 on success, -1 on failure
    7.53   */
    7.54  int xc_linux_build_mem(int xc_handle,
    7.55                         uint32_t domid,
    7.56 +                       unsigned int mem_mb,
    7.57                         const char *image_buffer,
    7.58                         unsigned long image_size,
    7.59                         const char *initrd_buffer,
     8.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Thu Nov 02 14:26:01 2006 +0000
     8.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Thu Nov 02 14:27:16 2006 +0000
     8.3 @@ -334,24 +334,25 @@ static PyObject *pyxc_linux_build(XcObje
     8.4      char *image, *ramdisk = NULL, *cmdline = "", *features = NULL;
     8.5      int flags = 0;
     8.6      int store_evtchn, console_evtchn;
     8.7 +    unsigned int mem_mb;
     8.8      unsigned long store_mfn = 0;
     8.9      unsigned long console_mfn = 0;
    8.10  
    8.11 -    static char *kwd_list[] = { "domid", "store_evtchn",
    8.12 +    static char *kwd_list[] = { "domid", "store_evtchn", "memsize",
    8.13                                  "console_evtchn", "image",
    8.14                                  /* optional */
    8.15                                  "ramdisk", "cmdline", "flags",
    8.16                                  "features", NULL };
    8.17  
    8.18 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiis|ssis", kwd_list,
    8.19 -                                      &dom, &store_evtchn,
    8.20 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiis|ssis", kwd_list,
    8.21 +                                      &dom, &store_evtchn, &mem_mb,
    8.22                                        &console_evtchn, &image,
    8.23                                        /* optional */
    8.24                                        &ramdisk, &cmdline, &flags,
    8.25                                        &features) )
    8.26          return NULL;
    8.27  
    8.28 -    if ( xc_linux_build(self->xc_handle, dom, image,
    8.29 +    if ( xc_linux_build(self->xc_handle, dom, mem_mb, image,
    8.30                          ramdisk, cmdline, features, flags,
    8.31                          store_evtchn, &store_mfn,
    8.32                          console_evtchn, &console_mfn) != 0 ) {
     9.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Thu Nov 02 14:26:01 2006 +0000
     9.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Thu Nov 02 14:27:16 2006 +0000
     9.3 @@ -1270,10 +1270,7 @@ class XendDomainInfo:
     9.4  
     9.5              # Use architecture- and image-specific calculations to determine
     9.6              # the various headrooms necessary, given the raw configured
     9.7 -            # values.
     9.8 -            # reservation, maxmem, memory, and shadow are all in KiB.
     9.9 -            reservation = self.image.getRequiredInitialReservation(
    9.10 -                self.info['memory'] * 1024)
    9.11 +            # values. maxmem, memory, and shadow are all in KiB.
    9.12              maxmem = self.image.getRequiredAvailableMemory(
    9.13                  self.info['maxmem'] * 1024)
    9.14              memory = self.image.getRequiredAvailableMemory(
    9.15 @@ -1296,12 +1293,6 @@ class XendDomainInfo:
    9.16              shadow_cur = xc.shadow_mem_control(self.domid, shadow / 1024)
    9.17              self.info['shadow_memory'] = shadow_cur
    9.18  
    9.19 -            # Initial memory reservation
    9.20 -            if not (self._infoIsSet('image') and
    9.21 -                    sxp.name(self.info['image']) == "hvm"):
    9.22 -                xc.domain_memory_increase_reservation(
    9.23 -                    self.domid, reservation, 0, 0)
    9.24 -
    9.25              self._createChannels()
    9.26  
    9.27              channel_details = self.image.createImage()
    10.1 --- a/tools/python/xen/xend/image.py	Thu Nov 02 14:26:01 2006 +0000
    10.2 +++ b/tools/python/xen/xend/image.py	Thu Nov 02 14:27:16 2006 +0000
    10.3 @@ -152,13 +152,13 @@ class ImageHandler:
    10.4          necessary."""
    10.5          return mem_kb
    10.6  
    10.7 -    def getRequiredInitialReservation(self, mem_kb):
    10.8 +    def getRequiredInitialReservation(self):
    10.9          """@param mem_kb The configured memory, in KiB.
   10.10          @return The corresponding required amount of memory to be free, also
   10.11          in KiB. This is normally the same as getRequiredAvailableMemory, but
   10.12          architecture- or image-specific code may override this to
   10.13          add headroom where necessary."""
   10.14 -        return self.getRequiredAvailableMemory(mem_kb)
   10.15 +        return self.getRequiredAvailableMemory(self.vm.getMemoryTarget())
   10.16  
   10.17      def getRequiredShadowMemory(self, shadow_mem_kb, maxmem_kb):
   10.18          """@param shadow_mem_kb The configured shadow memory, in KiB.
   10.19 @@ -189,7 +189,10 @@ class LinuxImageHandler(ImageHandler):
   10.20          store_evtchn = self.vm.getStorePort()
   10.21          console_evtchn = self.vm.getConsolePort()
   10.22  
   10.23 +        mem_mb = self.getRequiredInitialReservation() / 1024
   10.24 +
   10.25          log.debug("domid          = %d", self.vm.getDomid())
   10.26 +        log.debug("memsize        = %d", mem_mb)
   10.27          log.debug("image          = %s", self.kernel)
   10.28          log.debug("store_evtchn   = %d", store_evtchn)
   10.29          log.debug("console_evtchn = %d", console_evtchn)
   10.30 @@ -199,6 +202,7 @@ class LinuxImageHandler(ImageHandler):
   10.31          log.debug("features       = %s", self.vm.getFeatures())
   10.32  
   10.33          return xc.linux_build(domid          = self.vm.getDomid(),
   10.34 +                              memsize        = mem_mb,
   10.35                                image          = self.kernel,
   10.36                                store_evtchn   = store_evtchn,
   10.37                                console_evtchn = console_evtchn,
   10.38 @@ -218,7 +222,10 @@ class PPC_LinuxImageHandler(LinuxImageHa
   10.39          store_evtchn = self.vm.getStorePort()
   10.40          console_evtchn = self.vm.getConsolePort()
   10.41  
   10.42 +        mem_mb = self.getRequiredInitialReservation() / 1024
   10.43 +
   10.44          log.debug("domid          = %d", self.vm.getDomid())
   10.45 +        log.debug("memsize        = %d", mem_mb)
   10.46          log.debug("image          = %s", self.kernel)
   10.47          log.debug("store_evtchn   = %d", store_evtchn)
   10.48          log.debug("console_evtchn = %d", console_evtchn)
   10.49 @@ -230,6 +237,7 @@ class PPC_LinuxImageHandler(LinuxImageHa
   10.50          devtree = FlatDeviceTree.build(self)
   10.51  
   10.52          return xc.linux_build(domid          = self.vm.getDomid(),
   10.53 +                              memsize        = mem_mb,
   10.54                                image          = self.kernel,
   10.55                                store_evtchn   = store_evtchn,
   10.56                                console_evtchn = console_evtchn,
   10.57 @@ -272,10 +280,12 @@ class HVMImageHandler(ImageHandler):
   10.58      def buildDomain(self):
   10.59          store_evtchn = self.vm.getStorePort()
   10.60  
   10.61 +        mem_mb = self.getRequiredInitialReservation() / 1024
   10.62 +
   10.63          log.debug("domid          = %d", self.vm.getDomid())
   10.64          log.debug("image          = %s", self.kernel)
   10.65          log.debug("store_evtchn   = %d", store_evtchn)
   10.66 -        log.debug("memsize        = %d", self.vm.getMemoryTarget() / 1024)
   10.67 +        log.debug("memsize        = %d", mem_mb)
   10.68          log.debug("vcpus          = %d", self.vm.getVCpuCount())
   10.69          log.debug("pae            = %d", self.pae)
   10.70          log.debug("acpi           = %d", self.acpi)
   10.71 @@ -286,7 +296,7 @@ class HVMImageHandler(ImageHandler):
   10.72          return xc.hvm_build(domid          = self.vm.getDomid(),
   10.73                              image          = self.kernel,
   10.74                              store_evtchn   = store_evtchn,
   10.75 -                            memsize        = self.vm.getMemoryTarget() / 1024,
   10.76 +                            memsize        = mem_mb,
   10.77                              vcpus          = self.vm.getVCpuCount(),
   10.78                              pae            = self.pae,
   10.79                              acpi           = self.acpi,
   10.80 @@ -401,7 +411,7 @@ class HVMImageHandler(ImageHandler):
   10.81          #todo: Error handling
   10.82          args = [self.device_model]
   10.83          args = args + ([ "-d",  "%d" % self.vm.getDomid(),
   10.84 -                  "-m", "%s" % (self.vm.getMemoryTarget() / 1024)])
   10.85 +                  "-m", "%s" % (self.getRequiredInitialReservation() / 1024)])
   10.86          args = args + self.dmargs
   10.87          env = dict(os.environ)
   10.88          if self.display:
   10.89 @@ -480,8 +490,8 @@ class X86_HVM_ImageHandler(HVMImageHandl
   10.90          # Add 8 MiB overhead for QEMU's video RAM.
   10.91          return mem_kb + 8192
   10.92  
   10.93 -    def getRequiredInitialReservation(self, mem_kb):
   10.94 -        return mem_kb
   10.95 +    def getRequiredInitialReservation(self):
   10.96 +        return self.vm.getMemoryTarget()
   10.97  
   10.98      def getRequiredShadowMemory(self, shadow_mem_kb, maxmem_kb):
   10.99          # 256 pages (1MB) per vcpu,
    11.1 --- a/unmodified_drivers/linux-2.6/compat-include/asm-generic/pgtable-nopud.h	Thu Nov 02 14:26:01 2006 +0000
    11.2 +++ b/unmodified_drivers/linux-2.6/compat-include/asm-generic/pgtable-nopud.h	Thu Nov 02 14:27:16 2006 +0000
    11.3 @@ -9,6 +9,7 @@
    11.4  #define pud_offset(d, va)     d
    11.5  #define pud_none(pud)         0
    11.6  #define pud_present(pud)      1
    11.7 +#define pud_bad(pud)          0
    11.8  #define PTRS_PER_PUD          1
    11.9  
   11.10  #endif /* _PGTABLE_NOPUD_H */
    12.1 --- a/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h	Thu Nov 02 14:26:01 2006 +0000
    12.2 +++ b/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h	Thu Nov 02 14:27:16 2006 +0000
    12.3 @@ -25,6 +25,21 @@
    12.4  #define NET_IP_ALIGN 0
    12.5  #endif
    12.6  
    12.7 +#if defined(_LINUX_ERR_H) && !defined(IS_ERR_VALUE)
    12.8 +#define IS_ERR_VALUE(x) unlikely((x) > (unsigned long)-1000L)
    12.9 +#endif
   12.10 +
   12.11 +#if defined(_ASM_IA64_PGTABLE_H) && !defined(_PGTABLE_NOPUD_H)
   12.12 +#include <asm-generic/pgtable-nopud.h>
   12.13 +#endif
   12.14 +
   12.15 +/* Some kernels have this typedef backported so we cannot reliably
   12.16 + * detect based on version number, hence we forcibly #define it.
   12.17 + */
   12.18 +#if defined(__LINUX_TYPES_H) || defined(__LINUX_GFP_H)
   12.19 +#define gfp_t unsigned
   12.20 +#endif
   12.21 +
   12.22  #if defined(_LINUX_FS_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9)
   12.23  #define nonseekable_open(inode, filp) /* Nothing to do */
   12.24  #endif
    13.1 --- a/unmodified_drivers/linux-2.6/mkbuildtree	Thu Nov 02 14:26:01 2006 +0000
    13.2 +++ b/unmodified_drivers/linux-2.6/mkbuildtree	Thu Nov 02 14:27:16 2006 +0000
    13.3 @@ -31,7 +31,7 @@ mkdir -p include/asm
    13.4  mkdir -p include/asm/xen
    13.5  
    13.6  lndir -silent ${XL}/include/xen include/xen
    13.7 -ln -sf ${XEN}/include/public include/xen/interface
    13.8 +ln -nsf ${XEN}/include/public include/xen/interface
    13.9  
   13.10  # Need to be quite careful here: we don't want the files we link in to
   13.11  # risk overriding the native Linux ones (in particular, system.h must
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/unmodified_drivers/linux-2.6/util/Makefile	Thu Nov 02 14:27:16 2006 +0000
    14.3 @@ -0,0 +1,3 @@
    14.4 +ifneq ($(KERNELRELEASE),)
    14.5 +include $(src)/Kbuild
    14.6 +endif
    15.1 --- a/xen/common/grant_table.c	Thu Nov 02 14:26:01 2006 +0000
    15.2 +++ b/xen/common/grant_table.c	Thu Nov 02 14:27:16 2006 +0000
    15.3 @@ -724,10 +724,6 @@ static void
    15.4  {
    15.5      grant_entry_t *const sha = &rd->grant_table->shared[gref];
    15.6      struct active_grant_entry *const act = &rd->grant_table->active[gref];
    15.7 -    const unsigned long r_frame = act->frame;
    15.8 -
    15.9 -    if ( !readonly )
   15.10 -        gnttab_mark_dirty(rd, r_frame);
   15.11  
   15.12      spin_lock(&rd->grant_table->lock);
   15.13  
   15.14 @@ -750,7 +746,8 @@ static void
   15.15  
   15.16  /* Grab a frame number from a grant entry and update the flags and pin
   15.17     count as appropriate.  Note that this does *not* update the page
   15.18 -   type or reference counts. */
   15.19 +   type or reference counts, and does not check that the mfn is
   15.20 +   actually valid. */
   15.21  static int
   15.22  __acquire_grant_for_copy(
   15.23      struct domain *rd, unsigned long gref, int readonly,
   15.24 @@ -892,6 +889,9 @@ static void
   15.25      {
   15.26          s_frame = gmfn_to_mfn(sd, op->source.u.gmfn);
   15.27      }
   15.28 +    if ( unlikely(!mfn_valid(s_frame)) )
   15.29 +        PIN_FAIL(error_out, GNTST_general_error,
   15.30 +                 "source frame %lx invalid.\n", s_frame);
   15.31      if ( !get_page(mfn_to_page(s_frame), sd) )
   15.32          PIN_FAIL(error_out, GNTST_general_error,
   15.33                   "could not get source frame %lx.\n", s_frame);
   15.34 @@ -906,8 +906,11 @@ static void
   15.35      }
   15.36      else
   15.37      {
   15.38 -        d_frame = gmfn_to_mfn(sd, op->dest.u.gmfn);
   15.39 +        d_frame = gmfn_to_mfn(dd, op->dest.u.gmfn);
   15.40      }
   15.41 +    if ( unlikely(!mfn_valid(d_frame)) )
   15.42 +        PIN_FAIL(error_out, GNTST_general_error,
   15.43 +                 "destination frame %lx invalid.\n", d_frame);
   15.44      if ( !get_page_and_type(mfn_to_page(d_frame), dd, PGT_writable_page) )
   15.45          PIN_FAIL(error_out, GNTST_general_error,
   15.46                   "could not get destination frame %lx.\n", d_frame);
   15.47 @@ -920,6 +923,8 @@ static void
   15.48      unmap_domain_page(dp);
   15.49      unmap_domain_page(sp);
   15.50  
   15.51 +    gnttab_mark_dirty(dd, d_frame);
   15.52 +
   15.53      put_page_and_type(mfn_to_page(d_frame));
   15.54   error_out:
   15.55      if ( have_s_ref )