direct-io.hg

changeset 1426:00e1d3ae9894

bitkeeper revision 1.930 (40bf0f4cD6X2TCNUTUzQPA_qDsagoQ)

Reduce domid to 32 bits only -- more than enough.
author kaf24@scramble.cl.cam.ac.uk
date Thu Jun 03 11:45:16 2004 +0000 (2004-06-03)
parents 46406c62b1d3
children 73eb554453db
files tools/examples/xc_dom_control.py tools/xc/lib/xc.h tools/xc/lib/xc_atropos.c tools/xc/lib/xc_bvtsched.c tools/xc/lib/xc_domain.c tools/xc/lib/xc_evtchn.c tools/xc/lib/xc_linux_build.c tools/xc/lib/xc_linux_restore.c tools/xc/lib/xc_linux_save.c tools/xc/lib/xc_misc.c tools/xc/lib/xc_netbsd_build.c tools/xc/lib/xc_physdev.c tools/xc/lib/xc_private.c tools/xc/lib/xc_vbd.c tools/xc/lib/xc_vif.c tools/xc/py/Xc.c tools/xend/lib/blkif.py tools/xend/lib/netif.py tools/xend/lib/utils.c xen/common/dom0_ops.c xen/common/dom_mem_ops.c xen/common/domain.c xen/common/keyhandler.c xen/common/memory.c xen/common/network.c xen/common/physdev.c xen/common/sched_atropos.c xen/common/sched_bvt.c xen/common/schedule.c xen/drivers/block/xen_block.c xen/drivers/block/xen_vbd.c xen/drivers/char/console.c xen/include/hypervisor-ifs/dom0_ops.h xen/include/hypervisor-ifs/event_channel.h xen/include/hypervisor-ifs/hypervisor-if.h xen/include/hypervisor-ifs/network.h xen/include/hypervisor-ifs/sched_ctl.h xen/include/hypervisor-ifs/vbd.h xen/include/xen/mm.h xen/include/xen/sched.h xen/include/xen/shadow.h xen/net/dev.c xenolinux-2.4.26-sparse/arch/xen/drivers/blkif/backend/interface.c xenolinux-2.4.26-sparse/arch/xen/drivers/blkif/backend/main.c xenolinux-2.4.26-sparse/arch/xen/drivers/blkif/backend/vbd.c xenolinux-2.4.26-sparse/arch/xen/drivers/dom0/core.c xenolinux-2.4.26-sparse/arch/xen/drivers/netif/backend/interface.c xenolinux-2.4.26-sparse/arch/xen/drivers/netif/backend/main.c xenolinux-2.4.26-sparse/arch/xen/mm/ioremap.c xenolinux-2.4.26-sparse/drivers/char/mem.c xenolinux-2.4.26-sparse/include/asm-xen/hypervisor.h
line diff
     1.1 --- a/tools/examples/xc_dom_control.py	Thu Jun 03 09:31:38 2004 +0000
     1.2 +++ b/tools/examples/xc_dom_control.py	Thu Jun 03 11:45:16 2004 +0000
     1.3 @@ -50,7 +50,7 @@ dom = None
     1.4  
     1.5  
     1.6  if len( sys.argv ) > 2 and re.match('\d+$', sys.argv[2]):
     1.7 -    dom = long(sys.argv[2])
     1.8 +    dom = int(sys.argv[2])
     1.9  
    1.10  if cmd == 'stop':
    1.11      rc = xc.domain_stop( dom=dom )
     2.1 --- a/tools/xc/lib/xc.h	Thu Jun 03 09:31:38 2004 +0000
     2.2 +++ b/tools/xc/lib/xc.h	Thu Jun 03 11:45:16 2004 +0000
     2.3 @@ -23,7 +23,7 @@ int xc_interface_open(void);
     2.4  int xc_interface_close(int xc_handle);
     2.5  
     2.6  typedef struct {
     2.7 -    u64           domid;
     2.8 +    u32           domid;
     2.9      unsigned int  cpu;
    2.10      int           has_cpu;
    2.11      int           stopped;
    2.12 @@ -39,24 +39,24 @@ int xc_domain_create(int xc_handle,
    2.13                       unsigned int mem_kb, 
    2.14                       const char *name,
    2.15  		     int cpu,
    2.16 -                     u64 *pdomid);
    2.17 +                     u32 *pdomid);
    2.18  int xc_domain_start(int xc_handle, 
    2.19 -                    u64 domid);
    2.20 +                    u32 domid);
    2.21  int xc_domain_stop(int xc_handle, 
    2.22 -                   u64 domid);
    2.23 +                   u32 domid);
    2.24  int xc_domain_destroy(int xc_handle, 
    2.25 -                      u64 domid, 
    2.26 +                      u32 domid, 
    2.27                        int force);
    2.28  int xc_domain_pincpu(int xc_handle,
    2.29 -                     u64 domid,
    2.30 +                     u32 domid,
    2.31                       int cpu);
    2.32  int xc_domain_getinfo(int xc_handle,
    2.33 -                      u64 first_domid, 
    2.34 +                      u32 first_domid, 
    2.35                        unsigned int max_doms,
    2.36                        xc_dominfo_t *info);
    2.37  
    2.38  int xc_shadow_control(int xc_handle,
    2.39 -                      u64 domid, 
    2.40 +                      u32 domid, 
    2.41                        unsigned int sop,
    2.42  		      unsigned long *dirty_bitmap,
    2.43  		      unsigned long pages,
    2.44 @@ -69,27 +69,27 @@ int xc_shadow_control(int xc_handle,
    2.45  #define XCFLAGS_DEBUG   4
    2.46  
    2.47  int xc_linux_save(int xc_handle,
    2.48 -                  u64 domid, 
    2.49 +                  u32 domid, 
    2.50                    unsigned int flags,
    2.51  		  int (*writerfn)(void *, const void *, size_t),
    2.52  		  void *writerst );
    2.53  
    2.54  int xc_linux_restore(int xc_handle,
    2.55 -                     u64 domid,
    2.56 +                     u32 domid,
    2.57                       unsigned int flags,		     
    2.58  		     int (*readerfn)(void *, void *, size_t),
    2.59  		     void *readerst,
    2.60 -                     u64 *pdomid);
    2.61 +                     u32 *pdomid);
    2.62  
    2.63  int xc_linux_build(int xc_handle,
    2.64 -                   u64 domid,
    2.65 +                   u32 domid,
    2.66                     const char *image_name,
    2.67                     const char *ramdisk_name,
    2.68                     const char *cmdline,
    2.69                     unsigned int control_evtchn);
    2.70  
    2.71  int xc_netbsd_build(int xc_handle,
    2.72 -                    u64 domid,
    2.73 +                    u32 domid,
    2.74                      const char *image_name,
    2.75                      const char *cmdline,
    2.76                      unsigned int control_evtchn);
    2.77 @@ -98,7 +98,7 @@ int xc_bvtsched_global_set(int xc_handle
    2.78                             unsigned long ctx_allow);
    2.79  
    2.80  int xc_bvtsched_domain_set(int xc_handle,
    2.81 -                           u64 domid,
    2.82 +                           u32 domid,
    2.83                             unsigned long mcuadv,
    2.84                             unsigned long warp,
    2.85                             unsigned long warpl,
    2.86 @@ -108,19 +108,19 @@ int xc_bvtsched_global_get(int xc_handle
    2.87                             unsigned long *ctx_allow);
    2.88  
    2.89  int xc_bvtsched_domain_get(int xc_handle,
    2.90 -                           u64 domid,
    2.91 +                           u32 domid,
    2.92                             unsigned long *mcuadv,
    2.93                             unsigned long *warp,
    2.94                             unsigned long *warpl,
    2.95                             unsigned long *warpu);
    2.96  
    2.97  int xc_atropos_domain_set(int xc_handle,
    2.98 -                          u64 domid,
    2.99 +                          u32 domid,
   2.100                            u64 period, u64 slice, u64 latency,
   2.101                            int xtratime);
   2.102  
   2.103  int xc_atropos_domain_get(int xc_handle,
   2.104 -                          u64 domid,
   2.105 +                          u32 domid,
   2.106                            u64* period, u64 *slice, u64 *latency,
   2.107                            int *xtratime);
   2.108  
   2.109 @@ -139,21 +139,21 @@ typedef struct {
   2.110  } xc_vif_stats_t;
   2.111  
   2.112  int xc_vif_scheduler_set(int xc_handle,
   2.113 -                         u64 domid, 
   2.114 +                         u32 domid, 
   2.115                           unsigned int vifid,
   2.116                           xc_vif_sched_params_t *params);
   2.117  int xc_vif_scheduler_get(int xc_handle,
   2.118 -                         u64 domid, 
   2.119 +                         u32 domid, 
   2.120                           unsigned int vifid,
   2.121                           xc_vif_sched_params_t *params);
   2.122  int xc_vif_stats_get(int xc_handle,
   2.123 -                     u64 domid, 
   2.124 +                     u32 domid, 
   2.125                       unsigned int vifid,
   2.126                       xc_vif_stats_t *stats);
   2.127  
   2.128  typedef struct {
   2.129 -#define XC_VBDDOM_PROBE_ALL (~0ULL)
   2.130 -    u64            domid;
   2.131 +#define XC_VBDDOM_PROBE_ALL (0x7FFFFFFFU)
   2.132 +    u32            domid;
   2.133      unsigned short vbdid;
   2.134  #define XC_VBDF_WRITEABLE (1<<0)
   2.135      unsigned long  flags;
   2.136 @@ -175,36 +175,36 @@ typedef struct {
   2.137  } xc_physinfo_t;
   2.138  
   2.139  int xc_vbd_create(int xc_handle,
   2.140 -                  u64 domid, 
   2.141 +                  u32 domid, 
   2.142                    unsigned short vbdid, 
   2.143                    int writeable);
   2.144  int xc_vbd_destroy(int xc_handle,
   2.145 -                   u64 domid, 
   2.146 +                   u32 domid, 
   2.147                     unsigned short vbdid);
   2.148  int xc_vbd_grow(int xc_handle,
   2.149 -                u64 domid, 
   2.150 +                u32 domid, 
   2.151                  unsigned short vbdid,
   2.152                  xc_vbdextent_t *extent);
   2.153  int xc_vbd_shrink(int xc_handle,
   2.154 -                  u64 domid, 
   2.155 +                  u32 domid, 
   2.156                    unsigned short vbdid);
   2.157  int xc_vbd_setextents(int xc_handle,
   2.158 -                      u64 domid, 
   2.159 +                      u32 domid, 
   2.160                        unsigned short vbdid,
   2.161                        unsigned int nr_extents,
   2.162                        xc_vbdextent_t *extents);
   2.163  int xc_vbd_getextents(int xc_handle,
   2.164 -                      u64 domid, 
   2.165 +                      u32 domid, 
   2.166                        unsigned short vbdid,
   2.167                        unsigned int max_extents,
   2.168                        xc_vbdextent_t *extents,
   2.169                        int *writeable);
   2.170  int xc_vbd_probe(int xc_handle,
   2.171 -                 u64 domid,
   2.172 +                 u32 domid,
   2.173                   unsigned int max_vbds,
   2.174                   xc_vbd_t *vbds);
   2.175  
   2.176 -#define DOMID_SELF              (~1ULL)
   2.177 +#define DOMID_SELF              (0x7FFFFFFEU)
   2.178  
   2.179  typedef struct {
   2.180  #define EVTCHNSTAT_closed       0  /* Chennel is not in use.                 */
   2.181 @@ -215,7 +215,7 @@ typedef struct {
   2.182      int status;
   2.183      union {
   2.184          struct {
   2.185 -            u64 dom;
   2.186 +            u32 dom;
   2.187              int port;
   2.188          } interdomain;
   2.189          int pirq;
   2.190 @@ -224,22 +224,22 @@ typedef struct {
   2.191  } xc_evtchn_status_t;
   2.192  
   2.193  int xc_evtchn_bind_interdomain(int xc_handle,
   2.194 -                               u64 dom1,   /* may be DOMID_SELF */
   2.195 -                               u64 dom2,   /* may be DOMID_SELF */
   2.196 +                               u32 dom1,   /* may be DOMID_SELF */
   2.197 +                               u32 dom2,   /* may be DOMID_SELF */
   2.198                                 int *port1,
   2.199                                 int *port2);
   2.200  int xc_evtchn_close(int xc_handle,
   2.201 -                    u64 dom,   /* may be DOMID_SELF */
   2.202 +                    u32 dom,   /* may be DOMID_SELF */
   2.203                      int port);
   2.204  int xc_evtchn_send(int xc_handle,
   2.205                     int local_port);
   2.206  int xc_evtchn_status(int xc_handle,
   2.207 -                     u64 dom, /* may be DOMID_SELF */
   2.208 +                     u32 dom, /* may be DOMID_SELF */
   2.209                       int port,
   2.210                       xc_evtchn_status_t *status);
   2.211  
   2.212  int xc_physdev_pci_access_modify(int xc_handle,
   2.213 -                                 u64 domid,
   2.214 +                                 u32 domid,
   2.215                                   int bus,
   2.216                                   int dev,
   2.217                                   int func,
   2.218 @@ -254,15 +254,15 @@ int xc_physinfo(int xc_handle,
   2.219                  xc_physinfo_t *info);
   2.220  
   2.221  int xc_domain_setname(int xc_handle,
   2.222 -                      u64 domid, 
   2.223 +                      u32 domid, 
   2.224                        char *name);
   2.225  
   2.226  int xc_domain_setinitialmem(int xc_handle,
   2.227 -                            u64 domid, 
   2.228 +                            u32 domid, 
   2.229                              unsigned int initial_memkb);
   2.230  
   2.231  int xc_domain_setmaxmem(int xc_handle,
   2.232 -                            u64 domid, 
   2.233 +                            u32 domid, 
   2.234                              unsigned int max_memkb);
   2.235  
   2.236  
     3.1 --- a/tools/xc/lib/xc_atropos.c	Thu Jun 03 09:31:38 2004 +0000
     3.2 +++ b/tools/xc/lib/xc_atropos.c	Thu Jun 03 11:45:16 2004 +0000
     3.3 @@ -9,7 +9,7 @@
     3.4  #include "xc_private.h"
     3.5  
     3.6  int xc_atropos_domain_set(int xc_handle,
     3.7 -			  u64 domid, u64 period, u64 slice, u64 latency,
     3.8 +                          u32 domid, u64 period, u64 slice, u64 latency,
     3.9                            int xtratime)
    3.10  {
    3.11      dom0_op_t op;
    3.12 @@ -28,7 +28,7 @@ int xc_atropos_domain_set(int xc_handle,
    3.13      return do_dom0_op(xc_handle, &op);
    3.14  }
    3.15  
    3.16 -int xc_atropos_domain_get(int xc_handle, u64 domid, u64 *period,
    3.17 +int xc_atropos_domain_get(int xc_handle, u32 domid, u64 *period,
    3.18                            u64 *slice, u64 *latency, int *xtratime)
    3.19  {
    3.20      dom0_op_t op;
     4.1 --- a/tools/xc/lib/xc_bvtsched.c	Thu Jun 03 09:31:38 2004 +0000
     4.2 +++ b/tools/xc/lib/xc_bvtsched.c	Thu Jun 03 11:45:16 2004 +0000
     4.3 @@ -22,7 +22,7 @@ int xc_bvtsched_global_set(int xc_handle
     4.4  }
     4.5  
     4.6  int xc_bvtsched_global_get(int xc_handle,
     4.7 -			   unsigned long *ctx_allow)
     4.8 +                           unsigned long *ctx_allow)
     4.9  {
    4.10      dom0_op_t op;
    4.11      int ret;
    4.12 @@ -39,7 +39,7 @@ int xc_bvtsched_global_get(int xc_handle
    4.13  }
    4.14  
    4.15  int xc_bvtsched_domain_set(int xc_handle,
    4.16 -                           u64 domid,
    4.17 +                           u32 domid,
    4.18                             unsigned long mcuadv,
    4.19                             unsigned long warp,
    4.20                             unsigned long warpl,
    4.21 @@ -62,9 +62,9 @@ int xc_bvtsched_domain_set(int xc_handle
    4.22  
    4.23  
    4.24  int xc_bvtsched_domain_get(int xc_handle,
    4.25 -			   u64 domid,
    4.26 -			   unsigned long *mcuadv,
    4.27 -			   unsigned long *warp,
    4.28 +                           u32 domid,
    4.29 +                           unsigned long *mcuadv,
    4.30 +                           unsigned long *warp,
    4.31                             unsigned long *warpl,
    4.32                             unsigned long *warpu)
    4.33  {
     5.1 --- a/tools/xc/lib/xc_domain.c	Thu Jun 03 09:31:38 2004 +0000
     5.2 +++ b/tools/xc/lib/xc_domain.c	Thu Jun 03 11:45:16 2004 +0000
     5.3 @@ -11,8 +11,8 @@
     5.4  int xc_domain_create(int xc_handle,
     5.5                       unsigned int mem_kb, 
     5.6                       const char *name,
     5.7 -		     int cpu,
     5.8 -                     u64 *pdomid)
     5.9 +                     int cpu,
    5.10 +                     u32 *pdomid)
    5.11  {
    5.12      int err;
    5.13      dom0_op_t op;
    5.14 @@ -24,14 +24,14 @@ int xc_domain_create(int xc_handle,
    5.15      op.u.createdomain.cpu = cpu;
    5.16  
    5.17      if ( (err = do_dom0_op(xc_handle, &op)) == 0 )
    5.18 -        *pdomid = (u64)op.u.createdomain.domain;
    5.19 +        *pdomid = (u32)op.u.createdomain.domain;
    5.20  
    5.21      return err;
    5.22  }    
    5.23  
    5.24  
    5.25  int xc_domain_start(int xc_handle,
    5.26 -                    u64 domid)
    5.27 +                    u32 domid)
    5.28  {
    5.29      dom0_op_t op;
    5.30      op.cmd = DOM0_STARTDOMAIN;
    5.31 @@ -41,18 +41,18 @@ int xc_domain_start(int xc_handle,
    5.32  
    5.33  
    5.34  int xc_domain_stop(int xc_handle, 
    5.35 -                   u64 domid)
    5.36 +                   u32 domid)
    5.37  {
    5.38      dom0_op_t op;
    5.39      op.cmd = DOM0_STOPDOMAIN;
    5.40      op.u.stopdomain.domain = (domid_t)domid;
    5.41 -    op.u.stopdomain.sync = 0; // async
    5.42 +    op.u.stopdomain.sync = 0; /* async */
    5.43      return do_dom0_op(xc_handle, &op);
    5.44  }    
    5.45  
    5.46  
    5.47  int xc_domain_destroy(int xc_handle,
    5.48 -                      u64 domid, 
    5.49 +                      u32 domid, 
    5.50                        int force)
    5.51  {
    5.52      dom0_op_t op;
    5.53 @@ -63,7 +63,7 @@ int xc_domain_destroy(int xc_handle,
    5.54  }
    5.55  
    5.56  int xc_domain_pincpu(int xc_handle,
    5.57 -                     u64 domid, 
    5.58 +                     u32 domid, 
    5.59                       int cpu)
    5.60  {
    5.61      dom0_op_t op;
    5.62 @@ -75,22 +75,22 @@ int xc_domain_pincpu(int xc_handle,
    5.63  
    5.64  
    5.65  int xc_domain_getinfo(int xc_handle,
    5.66 -                      u64 first_domid,
    5.67 +                      u32 first_domid,
    5.68                        unsigned int max_doms,
    5.69                        xc_dominfo_t *info)
    5.70  {
    5.71      unsigned int nr_doms;
    5.72 -    u64 next_domid = first_domid;
    5.73 +    u32 next_domid = first_domid;
    5.74      dom0_op_t op;
    5.75  
    5.76      for ( nr_doms = 0; nr_doms < max_doms; nr_doms++ )
    5.77      {
    5.78          op.cmd = DOM0_GETDOMAININFO;
    5.79          op.u.getdomaininfo.domain = (domid_t)next_domid;
    5.80 -        op.u.getdomaininfo.ctxt = NULL; // no exec context info, thanks.
    5.81 +        op.u.getdomaininfo.ctxt = NULL; /* no exec context info, thanks. */
    5.82          if ( do_dom0_op(xc_handle, &op) < 0 )
    5.83              break;
    5.84 -        info->domid   = (u64)op.u.getdomaininfo.domain;
    5.85 +        info->domid   = (u32)op.u.getdomaininfo.domain;
    5.86          info->cpu     = op.u.getdomaininfo.processor;
    5.87          info->has_cpu = op.u.getdomaininfo.has_cpu;
    5.88          info->stopped = (op.u.getdomaininfo.state == DOMSTATE_STOPPED);
    5.89 @@ -101,7 +101,7 @@ int xc_domain_getinfo(int xc_handle,
    5.90          strncpy(info->name, op.u.getdomaininfo.name, XC_DOMINFO_MAXNAME);
    5.91          info->name[XC_DOMINFO_MAXNAME-1] = '\0';
    5.92  
    5.93 -        next_domid = (u64)op.u.getdomaininfo.domain + 1;
    5.94 +        next_domid = (u32)op.u.getdomaininfo.domain + 1;
    5.95          info++;
    5.96      }
    5.97  
    5.98 @@ -109,12 +109,12 @@ int xc_domain_getinfo(int xc_handle,
    5.99  }
   5.100  
   5.101  int xc_shadow_control(int xc_handle,
   5.102 -                      u64 domid, 
   5.103 +                      u32 domid, 
   5.104                        unsigned int sop,
   5.105 -		      unsigned long *dirty_bitmap,
   5.106 -		      unsigned long pages,
   5.107 -		      unsigned long *fault_count,
   5.108 -		      unsigned long *dirty_count)
   5.109 +                      unsigned long *dirty_bitmap,
   5.110 +                      unsigned long pages,
   5.111 +                      unsigned long *fault_count,
   5.112 +                      unsigned long *dirty_count)
   5.113  {
   5.114      int rc;
   5.115      dom0_op_t op;
   5.116 @@ -126,18 +126,17 @@ int xc_shadow_control(int xc_handle,
   5.117  
   5.118      rc = do_dom0_op(xc_handle, &op);
   5.119  
   5.120 -    if(fault_count) *fault_count = op.u.shadow_control.fault_count;
   5.121 -    if(dirty_count) *dirty_count = op.u.shadow_control.dirty_count;
   5.122 +    if ( fault_count ) 
   5.123 +        *fault_count = op.u.shadow_control.fault_count;
   5.124 +    if ( dirty_count )
   5.125 +        *dirty_count = op.u.shadow_control.dirty_count;
   5.126  
   5.127 -    if ( rc == 0 )
   5.128 -	return op.u.shadow_control.pages;
   5.129 -    else
   5.130 -	return rc;
   5.131 +    return (rc == 0) ? op.u.shadow_control.pages : rc;
   5.132  }
   5.133  
   5.134  int xc_domain_setname(int xc_handle,
   5.135 -                      u64 domid, 
   5.136 -		      char *name)
   5.137 +                      u32 domid, 
   5.138 +                      char *name)
   5.139  {
   5.140      dom0_op_t op;
   5.141      op.cmd = DOM0_SETDOMAINNAME;
   5.142 @@ -147,8 +146,8 @@ int xc_domain_setname(int xc_handle,
   5.143  }
   5.144  
   5.145  int xc_domain_setinitialmem(int xc_handle,
   5.146 -			    u64 domid, 
   5.147 -			    unsigned int initial_memkb)
   5.148 +                            u32 domid, 
   5.149 +                            unsigned int initial_memkb)
   5.150  {
   5.151      dom0_op_t op;
   5.152      op.cmd = DOM0_SETDOMAININITIALMEM;
   5.153 @@ -158,8 +157,8 @@ int xc_domain_setinitialmem(int xc_handl
   5.154  }
   5.155  
   5.156  int xc_domain_setmaxmem(int xc_handle,
   5.157 -			    u64 domid, 
   5.158 -			    unsigned int max_memkb)
   5.159 +                        u32 domid, 
   5.160 +                        unsigned int max_memkb)
   5.161  {
   5.162      dom0_op_t op;
   5.163      op.cmd = DOM0_SETDOMAINMAXMEM;
     6.1 --- a/tools/xc/lib/xc_evtchn.c	Thu Jun 03 09:31:38 2004 +0000
     6.2 +++ b/tools/xc/lib/xc_evtchn.c	Thu Jun 03 11:45:16 2004 +0000
     6.3 @@ -30,8 +30,8 @@ static int do_evtchn_op(int xc_handle, e
     6.4  }
     6.5  
     6.6  int xc_evtchn_bind_interdomain(int xc_handle,
     6.7 -                               u64 dom1,
     6.8 -                               u64 dom2,
     6.9 +                               u32 dom1,
    6.10 +                               u32 dom2,
    6.11                                 int *port1,
    6.12                                 int *port2)
    6.13  {
    6.14 @@ -55,7 +55,7 @@ int xc_evtchn_bind_interdomain(int xc_ha
    6.15  
    6.16  
    6.17  int xc_evtchn_close(int xc_handle,
    6.18 -                    u64 dom,
    6.19 +                    u32 dom,
    6.20                      int port)
    6.21  {
    6.22      evtchn_op_t op;
    6.23 @@ -77,7 +77,7 @@ int xc_evtchn_send(int xc_handle,
    6.24  
    6.25  
    6.26  int xc_evtchn_status(int xc_handle,
    6.27 -                     u64 dom,
    6.28 +                     u32 dom,
    6.29                       int port,
    6.30                       xc_evtchn_status_t *status)
    6.31  {
    6.32 @@ -93,7 +93,7 @@ int xc_evtchn_status(int xc_handle,
    6.33          switch ( status->status = op.u.status.status )
    6.34          {
    6.35          case EVTCHNSTAT_interdomain:
    6.36 -            status->u.interdomain.dom  = (u64)op.u.status.u.interdomain.dom;
    6.37 +            status->u.interdomain.dom  = (u32)op.u.status.u.interdomain.dom;
    6.38              status->u.interdomain.port = op.u.status.u.interdomain.port;
    6.39              break;
    6.40          case EVTCHNSTAT_pirq:
     7.1 --- a/tools/xc/lib/xc_linux_build.c	Thu Jun 03 09:31:38 2004 +0000
     7.2 +++ b/tools/xc/lib/xc_linux_build.c	Thu Jun 03 11:45:16 2004 +0000
     7.3 @@ -21,7 +21,7 @@ static int readelfimage_base_and_size(ch
     7.4  static int loadelfimage(char *elfbase, int pmh, unsigned long *parray,
     7.5                          unsigned long vstart);
     7.6  
     7.7 -static long get_tot_pages(int xc_handle, u64 domid)
     7.8 +static long get_tot_pages(int xc_handle, u32 domid)
     7.9  {
    7.10      dom0_op_t op;
    7.11      op.cmd = DOM0_GETDOMAININFO;
    7.12 @@ -32,7 +32,7 @@ static long get_tot_pages(int xc_handle,
    7.13  }
    7.14  
    7.15  static int get_pfn_list(int xc_handle,
    7.16 -                        u64 domid, 
    7.17 +                        u32 domid, 
    7.18                          unsigned long *pfn_buf, 
    7.19                          unsigned long max_pfns)
    7.20  {
    7.21 @@ -66,12 +66,12 @@ static int copy_to_domain_page(int pm_ha
    7.22  }
    7.23  
    7.24  static int setup_guestos(int xc_handle,
    7.25 -                         u64 dom,
    7.26 +                         u32 dom,
    7.27                           char *image, unsigned long image_size,
    7.28                           gzFile initrd_gfd, unsigned long initrd_len,
    7.29                           unsigned long nr_pages,
    7.30                           unsigned long *pvsi, unsigned long *pvke,
    7.31 -			 full_execution_context_t *ctxt,
    7.32 +                         full_execution_context_t *ctxt,
    7.33                           const char *cmdline,
    7.34                           unsigned long shared_info_frame,
    7.35                           unsigned int control_evtchn)
    7.36 @@ -377,7 +377,7 @@ static char *read_kernel_image(const cha
    7.37  }
    7.38  
    7.39  int xc_linux_build(int xc_handle,
    7.40 -                   u64 domid,
    7.41 +                   u32 domid,
    7.42                     const char *image_name,
    7.43                     const char *ramdisk_name,
    7.44                     const char *cmdline,
    7.45 @@ -429,7 +429,7 @@ int xc_linux_build(int xc_handle,
    7.46      op.u.getdomaininfo.domain = (domid_t)domid;
    7.47      op.u.getdomaininfo.ctxt = ctxt;
    7.48      if ( (do_dom0_op(xc_handle, &op) < 0) || 
    7.49 -         ((u64)op.u.getdomaininfo.domain != domid) )
    7.50 +         ((u32)op.u.getdomaininfo.domain != domid) )
    7.51      {
    7.52          PERROR("Could not get info on domain");
    7.53          goto error_out;
     8.1 --- a/tools/xc/lib/xc_linux_restore.c	Thu Jun 03 09:31:38 2004 +0000
     8.2 +++ b/tools/xc/lib/xc_linux_restore.c	Thu Jun 03 11:45:16 2004 +0000
     8.3 @@ -30,7 +30,7 @@
     8.4      } while ( 0 )
     8.5  
     8.6  static int get_pfn_list(int xc_handle,
     8.7 -                        u64 domain_id, 
     8.8 +                        u32 domain_id, 
     8.9                          unsigned long *pfn_buf, 
    8.10                          unsigned long max_pfns)
    8.11  {
    8.12 @@ -56,11 +56,11 @@ static int get_pfn_list(int xc_handle,
    8.13  
    8.14  
    8.15  int xc_linux_restore(int xc_handle,
    8.16 -		     u64 dom,
    8.17 +                     u32 dom,
    8.18                       unsigned int flags,
    8.19 -		     int (*readerfn)(void *, void *, size_t),
    8.20 -		     void *readerst,
    8.21 -                     u64 *pdomid)
    8.22 +                     int (*readerfn)(void *, void *, size_t),
    8.23 +                     void *readerst,
    8.24 +                     u32 *pdomid)
    8.25  {
    8.26      dom0_op_t op;
    8.27      int rc = 1, i, j, n, k;
    8.28 @@ -118,7 +118,7 @@ int xc_linux_restore(int xc_handle,
    8.29      if ( mlock(&ctxt, sizeof(ctxt) ) )
    8.30      {   
    8.31          /* needed for when we do the build dom0 op, 
    8.32 -	   but might as well do early */
    8.33 +           but might as well do early */
    8.34          PERROR("Unable to mlock ctxt");
    8.35          return 1;
    8.36      }
    8.37 @@ -162,7 +162,7 @@ int xc_linux_restore(int xc_handle,
    8.38      region_mfn       = calloc(1, 4 * MAX_BATCH_SIZE);    
    8.39  
    8.40      if ( (pfn_to_mfn_table == NULL) || (pfn_type == NULL) || 
    8.41 -	 (region_mfn == NULL) )
    8.42 +         (region_mfn == NULL) )
    8.43      {
    8.44          errno = ENOMEM;
    8.45          goto out;
    8.46 @@ -184,7 +184,8 @@ int xc_linux_restore(int xc_handle,
    8.47      /* Set the domain's initial memory allocation 
    8.48         to that from the restore file */
    8.49  
    8.50 -    if ( xc_domain_setinitialmem( xc_handle, dom, nr_pfns * (PAGE_SIZE / 1024)) )
    8.51 +    if ( xc_domain_setinitialmem(xc_handle, dom, 
    8.52 +                                 nr_pfns * (PAGE_SIZE / 1024)) )
    8.53      {
    8.54          ERROR("Could not set domain initial memory");
    8.55          goto out;
    8.56 @@ -230,8 +231,8 @@ int xc_linux_restore(int xc_handle,
    8.57      n=0;
    8.58      while(1)
    8.59      {
    8.60 -	int j;
    8.61 -	unsigned long region_pfn_type[MAX_BATCH_SIZE];
    8.62 +        int j;
    8.63 +        unsigned long region_pfn_type[MAX_BATCH_SIZE];
    8.64  
    8.65          this_pc = (n * 100) / nr_pfns;
    8.66          if ( (this_pc - prev_pc) >= 5 )
    8.67 @@ -246,168 +247,180 @@ int xc_linux_restore(int xc_handle,
    8.68              goto out;
    8.69          }
    8.70  
    8.71 -	DPRINTF("batch %d\n",j);
    8.72 -	
    8.73 -	if (j == -1)
    8.74 -	{
    8.75 -	    verify = 1;
    8.76 -	    printf("Entering page verify mode\n");
    8.77 -	    continue;
    8.78 -	}
    8.79 +        DPRINTF("batch %d\n",j);
    8.80 + 
    8.81 +        if ( j == -1 )
    8.82 +        {
    8.83 +            verify = 1;
    8.84 +            printf("Entering page verify mode\n");
    8.85 +            continue;
    8.86 +        }
    8.87  
    8.88 -	if (j == 0) 
    8.89 -	{
    8.90 -	    break;  // our work here is done
    8.91 -	}
    8.92 +        if ( j == 0 ) 
    8.93 +            break;  /* our work here is done */
    8.94  
    8.95 -	if( j > MAX_BATCH_SIZE )
    8.96 -	{
    8.97 -	    ERROR("Max batch size exceeded. Giving up.");
    8.98 -	    goto out;
    8.99 -	}
   8.100 -	
   8.101 +        if( j > MAX_BATCH_SIZE )
   8.102 +        {
   8.103 +            ERROR("Max batch size exceeded. Giving up.");
   8.104 +            goto out;
   8.105 +        }
   8.106 + 
   8.107          if ( (*readerfn)(readerst, region_pfn_type, j*sizeof(unsigned long)) )
   8.108          {
   8.109              ERROR("Error when reading from state file");
   8.110              goto out;
   8.111          }
   8.112  
   8.113 -	for(i=0;i<j;i++)
   8.114 -	{
   8.115 +        for(i=0;i<j;i++)
   8.116 +        {
   8.117              if ( (region_pfn_type[i] & LTAB_MASK) == XTAB)
   8.118 -		region_mfn[i] = 0; // we know map will fail, but don't care
   8.119 -	    else
   8.120 -	    {		
   8.121 -		pfn = region_pfn_type[i] & ~LTAB_MASK;
   8.122 -		region_mfn[i] = pfn_to_mfn_table[pfn];
   8.123 -	    }	    	    
   8.124 -	}
   8.125 -	
   8.126 -	if ( (region_base = mfn_mapper_map_batch( xc_handle, dom, 
   8.127 -						  PROT_WRITE,
   8.128 -						  region_mfn,
   8.129 -						  j )) == 0)
   8.130 -	{
   8.131 -	    PERROR("map batch failed");
   8.132 -	    goto out;
   8.133 -	}
   8.134 +            {
   8.135 +                region_mfn[i] = 0; /* we know map will fail, but don't care */
   8.136 +            }
   8.137 +            else
   8.138 +            {  
   8.139 +                pfn = region_pfn_type[i] & ~LTAB_MASK;
   8.140 +                region_mfn[i] = pfn_to_mfn_table[pfn];
   8.141 +            }          
   8.142 +        }
   8.143 + 
   8.144 +        if ( (region_base = mfn_mapper_map_batch( xc_handle, dom, 
   8.145 +                                                  PROT_WRITE,
   8.146 +                                                  region_mfn,
   8.147 +                                                  j )) == 0)
   8.148 +        {
   8.149 +            PERROR("map batch failed");
   8.150 +            goto out;
   8.151 +        }
   8.152  
   8.153 -	for(i=0;i<j;i++)
   8.154 -	{
   8.155 -	    unsigned long *ppage;
   8.156 +        for(i=0;i<j;i++)
   8.157 +        {
   8.158 +            unsigned long *ppage;
   8.159  
   8.160 -	    pfn = region_pfn_type[i] & ~LTAB_MASK;
   8.161 +            pfn = region_pfn_type[i] & ~LTAB_MASK;
   8.162  
   8.163              if ( (region_pfn_type[i] & LTAB_MASK) == XTAB)
   8.164 -		continue;
   8.165 +                continue;
   8.166  
   8.167              if (pfn>nr_pfns)
   8.168 -	    {
   8.169 -		ERROR("pfn out of range");
   8.170 -		goto out;
   8.171 -	    }
   8.172 +            {
   8.173 +                ERROR("pfn out of range");
   8.174 +                goto out;
   8.175 +            }
   8.176  
   8.177 -	    region_pfn_type[i] &= LTAB_MASK;
   8.178 +            region_pfn_type[i] &= LTAB_MASK;
   8.179  
   8.180 -	    pfn_type[pfn] = region_pfn_type[i];
   8.181 +            pfn_type[pfn] = region_pfn_type[i];
   8.182  
   8.183 -	    mfn = pfn_to_mfn_table[pfn];
   8.184 +            mfn = pfn_to_mfn_table[pfn];
   8.185  
   8.186 -	    if ( verify )
   8.187 -		ppage = (unsigned long*) buf;  // debug case
   8.188 -	    else
   8.189 -		ppage = (unsigned long*) (region_base + i*PAGE_SIZE);
   8.190 +            if ( verify )
   8.191 +                ppage = (unsigned long*) buf;  /* debug case */
   8.192 +            else
   8.193 +                ppage = (unsigned long*) (region_base + i*PAGE_SIZE);
   8.194  
   8.195 -	    if ( (*readerfn)(readerst, ppage, PAGE_SIZE) )
   8.196 -	    {
   8.197 -		ERROR("Error when reading from state file");
   8.198 -		goto out;
   8.199 -	    }
   8.200 +            if ( (*readerfn)(readerst, ppage, PAGE_SIZE) )
   8.201 +            {
   8.202 +                ERROR("Error when reading from state file");
   8.203 +                goto out;
   8.204 +            }
   8.205  
   8.206 -	    switch( region_pfn_type[i] )
   8.207 -	    {
   8.208 -	    case 0:
   8.209 -		break;
   8.210 +            switch( region_pfn_type[i] )
   8.211 +            {
   8.212 +            case 0:
   8.213 +                break;
   8.214  
   8.215 -	    case L1TAB:
   8.216 -	    {
   8.217 -		for ( k = 0; k < 1024; k++ )
   8.218 -		{
   8.219 -		    if ( ppage[k] & _PAGE_PRESENT )
   8.220 -		    {
   8.221 -			xpfn = ppage[k] >> PAGE_SHIFT;
   8.222 +            case L1TAB:
   8.223 +            {
   8.224 +                for ( k = 0; k < 1024; k++ )
   8.225 +                {
   8.226 +                    if ( ppage[k] & _PAGE_PRESENT )
   8.227 +                    {
   8.228 +                        xpfn = ppage[k] >> PAGE_SHIFT;
   8.229  
   8.230 -			if ( xpfn >= nr_pfns )
   8.231 -			{
   8.232 -			    ERROR("Frame number in type %d page table is out of range. i=%d k=%d pfn=0x%x nr_pfns=%d",region_pfn_type[i]>>28,i,k,xpfn,nr_pfns);
   8.233 -			    goto out;
   8.234 -			}
   8.235 +                        if ( xpfn >= nr_pfns )
   8.236 +                        {
   8.237 +                            ERROR("Frame number in type %d page table is "
   8.238 +                                  "out of range. i=%d k=%d pfn=0x%x "
   8.239 +                                  "nr_pfns=%d", region_pfn_type[i]>>28, i, 
   8.240 +                                  k, xpfn,nr_pfns);
   8.241 +                            goto out;
   8.242 +                        }
   8.243  
   8.244 -			ppage[k] &= (PAGE_SIZE - 1) & ~(_PAGE_GLOBAL | _PAGE_PAT);
   8.245 -			ppage[k] |= pfn_to_mfn_table[xpfn] << PAGE_SHIFT;
   8.246 -		    }
   8.247 -		}
   8.248 -	    }
   8.249 -	    break;
   8.250 +                        ppage[k] &= (PAGE_SIZE - 1) & 
   8.251 +                            ~(_PAGE_GLOBAL | _PAGE_PAT);
   8.252 +                        ppage[k] |= pfn_to_mfn_table[xpfn] << PAGE_SHIFT;
   8.253 +                    }
   8.254 +                }
   8.255 +            }
   8.256 +            break;
   8.257  
   8.258 -	    case L2TAB:
   8.259 -	    {
   8.260 -		for ( k = 0; k < (HYPERVISOR_VIRT_START>>L2_PAGETABLE_SHIFT); k++ )
   8.261 -		{
   8.262 -		    if ( ppage[k] & _PAGE_PRESENT )
   8.263 -		    {
   8.264 -			xpfn = ppage[k] >> PAGE_SHIFT;
   8.265 +            case L2TAB:
   8.266 +            {
   8.267 +                for ( k = 0; 
   8.268 +                      k < (HYPERVISOR_VIRT_START>>L2_PAGETABLE_SHIFT); 
   8.269 +                      k++ )
   8.270 +                {
   8.271 +                    if ( ppage[k] & _PAGE_PRESENT )
   8.272 +                    {
   8.273 +                        xpfn = ppage[k] >> PAGE_SHIFT;
   8.274  
   8.275 -			if ( xpfn >= nr_pfns )
   8.276 -			{
   8.277 -			    ERROR("Frame number in type %d page table is out of range. i=%d k=%d pfn=%d nr_pfns=%d",region_pfn_type[i]>>28,i,k,xpfn,nr_pfns);
   8.278 +                        if ( xpfn >= nr_pfns )
   8.279 +                        {
   8.280 +                            ERROR("Frame number in type %d page table is "
   8.281 +                                  "out of range. i=%d k=%d pfn=%d nr_pfns=%d",
   8.282 +                                  region_pfn_type[i]>>28, i, k, xpfn, nr_pfns);
   8.283  
   8.284 -			    goto out;
   8.285 -			}
   8.286 +                            goto out;
   8.287 +                        }
   8.288  
   8.289 -			ppage[k] &= (PAGE_SIZE - 1) & ~(_PAGE_GLOBAL | _PAGE_PSE);
   8.290 -			ppage[k] |= pfn_to_mfn_table[xpfn] << PAGE_SHIFT;
   8.291 -		    }
   8.292 -		}
   8.293 -	    }
   8.294 -	    break;
   8.295 +                        ppage[k] &= (PAGE_SIZE - 1) & 
   8.296 +                            ~(_PAGE_GLOBAL | _PAGE_PSE);
   8.297 +                        ppage[k] |= pfn_to_mfn_table[xpfn] << PAGE_SHIFT;
   8.298 +                    }
   8.299 +                }
   8.300 +            }
   8.301 +            break;
   8.302  
   8.303 -	    default:
   8.304 -		ERROR("Bogus page type %x page table is out of range. i=%d nr_pfns=%d",region_pfn_type[i],i,nr_pfns);
   8.305 -		goto out;
   8.306 -
   8.307 -	    } // end of page type switch statement
   8.308 +            default:
   8.309 +                ERROR("Bogus page type %x page table is out of range."
   8.310 +                      " i=%d nr_pfns=%d", region_pfn_type[i], i, nr_pfns);
   8.311 +                goto out;
   8.312  
   8.313 -	    if ( verify )
   8.314 -	    {
   8.315 -		int res = memcmp(buf, (region_base + i*PAGE_SIZE), PAGE_SIZE );
   8.316 -		if (res)
   8.317 -		{
   8.318 -		    int v;
   8.319 -		    printf("************** pfn=%x type=%x gotcs=%08lx actualcs=%08lx\n",pfn,pfn_type[pfn],csum_page(region_base + i*PAGE_SIZE),csum_page(buf));
   8.320 -		    for(v=0;v<4;v++)
   8.321 -		    {
   8.322 -			unsigned long * p = (unsigned long *) (region_base + i*PAGE_SIZE);
   8.323 -			if ( buf[v] != p[v] )
   8.324 -			    printf("    %d: %08lx %08lx\n",
   8.325 -				   v, buf[v], p[v] );
   8.326 -		    }
   8.327 +            } /* end of page type switch statement */
   8.328  
   8.329 -		}
   8.330 -	    }
   8.331 +            if ( verify )
   8.332 +            {
   8.333 +                int res = memcmp(buf, (region_base + i*PAGE_SIZE), PAGE_SIZE );
   8.334 +                if (res)
   8.335 +                {
   8.336 +                    int v;
   8.337 +                    printf("************** pfn=%x type=%x gotcs=%08lx "
   8.338 +                           "actualcs=%08lx\n", pfn, pfn_type[pfn], 
   8.339 +                           csum_page(region_base + i*PAGE_SIZE), 
   8.340 +                           csum_page(buf));
   8.341 +                    for ( v = 0; v < 4; v++ )
   8.342 +                    {
   8.343 +                        unsigned long *p = (unsigned long *)
   8.344 +                            (region_base + i*PAGE_SIZE);
   8.345 +                        if ( buf[v] != p[v] )
   8.346 +                            printf("    %d: %08lx %08lx\n",
   8.347 +                                   v, buf[v], p[v] );
   8.348 +                    }
   8.349 +                }
   8.350 +            }
   8.351  
   8.352 -	    if ( add_mmu_update(xc_handle, mmu,
   8.353 -				(mfn<<PAGE_SHIFT) | MMU_MACHPHYS_UPDATE, pfn) )
   8.354 -	    {
   8.355 -		printf("machpys mfn=%ld pfn=%ld\n",mfn,pfn);
   8.356 -		goto out;
   8.357 -	    }
   8.358 +            if ( add_mmu_update(xc_handle, mmu,
   8.359 +                                (mfn<<PAGE_SHIFT) | MMU_MACHPHYS_UPDATE, pfn) )
   8.360 +            {
   8.361 +                printf("machpys mfn=%ld pfn=%ld\n",mfn,pfn);
   8.362 +                goto out;
   8.363 +            }
   8.364  
   8.365 -	} // end of 'batch' for loop
   8.366 +        } /* end of 'batch' for loop */
   8.367  
   8.368 -	munmap( region_base, j*PAGE_SIZE );
   8.369 -	n+=j; // crude stats
   8.370 -
   8.371 +        munmap( region_base, j*PAGE_SIZE );
   8.372 +        n+=j; /* crude stats */
   8.373      }
   8.374  
   8.375      printf("Received all pages\n");
   8.376 @@ -426,11 +439,11 @@ int xc_linux_restore(int xc_handle,
   8.377                                  (pfn_to_mfn_table[i]<<PAGE_SHIFT) | 
   8.378                                  MMU_EXTENDED_COMMAND,
   8.379                                  MMUEXT_PIN_L1_TABLE) )
   8.380 -	    {
   8.381 -		printf("ERR pin L1 pfn=%lx mfn=%lx\n",
   8.382 -		       i, pfn_to_mfn_table[i]);
   8.383 +            {
   8.384 +                printf("ERR pin L1 pfn=%lx mfn=%lx\n",
   8.385 +                       i, pfn_to_mfn_table[i]);
   8.386                  goto out;
   8.387 -	    }
   8.388 +            }
   8.389          }
   8.390          else if ( pfn_type[i] == L2TAB )
   8.391          {
   8.392 @@ -438,11 +451,11 @@ int xc_linux_restore(int xc_handle,
   8.393                                  (pfn_to_mfn_table[i]<<PAGE_SHIFT) | 
   8.394                                  MMU_EXTENDED_COMMAND,
   8.395                                  MMUEXT_PIN_L2_TABLE) )
   8.396 -	    {
   8.397 -		printf("ERR pin L2 pfn=%lx mfn=%lx\n",
   8.398 -		       i, pfn_to_mfn_table[i]);
   8.399 +            {
   8.400 +                printf("ERR pin L2 pfn=%lx mfn=%lx\n",
   8.401 +                       i, pfn_to_mfn_table[i]);
   8.402                  goto out;
   8.403 -	    }
   8.404 +            }
   8.405          }
   8.406      }
   8.407  
   8.408 @@ -495,7 +508,7 @@ int xc_linux_restore(int xc_handle,
   8.409      if ( (pfn >= nr_pfns) || (pfn_type[pfn] != L2TAB) )
   8.410      {
   8.411          printf("PT base is bad. pfn=%d nr=%d type=%08lx %08lx\n",
   8.412 -	       pfn, nr_pfns, pfn_type[pfn], L2TAB);
   8.413 +               pfn, nr_pfns, pfn_type[pfn], L2TAB);
   8.414          ERROR("PT base is bad.");
   8.415          goto out;
   8.416      }
   8.417 @@ -504,8 +517,8 @@ int xc_linux_restore(int xc_handle,
   8.418  
   8.419      /* clear any pending events and the selector */
   8.420      memset( &(((shared_info_t *)shared_info)->evtchn_pending[0]),
   8.421 -	    0, sizeof (((shared_info_t *)shared_info)->evtchn_pending)+
   8.422 -	    sizeof(((shared_info_t *)shared_info)->evtchn_pending_sel) );
   8.423 +            0, sizeof (((shared_info_t *)shared_info)->evtchn_pending)+
   8.424 +            sizeof(((shared_info_t *)shared_info)->evtchn_pending_sel) );
   8.425  
   8.426      /* Copy saved contents of shared-info page. No checking needed. */
   8.427      ppage = map_pfn_writeable(pm_handle, shared_info_frame);
   8.428 @@ -516,7 +529,7 @@ int xc_linux_restore(int xc_handle,
   8.429      /* Uncanonicalise the pfn-to-mfn table frame-number list. */
   8.430      for ( i = 0; i < (nr_pfns+1023)/1024; i++ )
   8.431      {
   8.432 -	unsigned long pfn, mfn;
   8.433 +        unsigned long pfn, mfn;
   8.434  
   8.435          pfn = pfn_to_mfn_frame_list[i];
   8.436          if ( (pfn >= nr_pfns) || (pfn_type[pfn] != NOTAB) )
   8.437 @@ -524,21 +537,22 @@ int xc_linux_restore(int xc_handle,
   8.438              ERROR("PFN-to-MFN frame number is bad");
   8.439              goto out;
   8.440          }
   8.441 -	mfn = pfn_to_mfn_table[pfn];
   8.442 -	pfn_to_mfn_frame_list[i] = mfn;
   8.443 +        mfn = pfn_to_mfn_table[pfn];
   8.444 +        pfn_to_mfn_frame_list[i] = mfn;
   8.445      }
   8.446      
   8.447 -    if ( (live_pfn_to_mfn_table = mfn_mapper_map_batch( xc_handle, dom, 
   8.448 -				  PROT_WRITE,
   8.449 -				  pfn_to_mfn_frame_list,
   8.450 -				  (nr_pfns+1023)/1024 )) == 0 )
   8.451 +    if ( (live_pfn_to_mfn_table = 
   8.452 +          mfn_mapper_map_batch(xc_handle, dom, 
   8.453 +                               PROT_WRITE,
   8.454 +                               pfn_to_mfn_frame_list,
   8.455 +                               (nr_pfns+1023)/1024 )) == 0 )
   8.456      {
   8.457          ERROR("Couldn't map pfn_to_mfn table");
   8.458          goto out;
   8.459      }
   8.460  
   8.461      memcpy( live_pfn_to_mfn_table, pfn_to_mfn_table, 
   8.462 -	    nr_pfns*sizeof(unsigned long) );
   8.463 +            nr_pfns*sizeof(unsigned long) );
   8.464  
   8.465      munmap( live_pfn_to_mfn_table, ((nr_pfns+1023)/1024)*PAGE_SIZE );
   8.466  
   8.467 @@ -586,18 +600,18 @@ int xc_linux_restore(int xc_handle,
   8.468    
   8.469      if( rc == 0 )
   8.470      {
   8.471 -	/* Success: print the domain id. */
   8.472 -	verbose_printf("DOM=%llu\n", dom);
   8.473 -	return 0;
   8.474 +        /* Success: print the domain id. */
   8.475 +        verbose_printf("DOM=%u\n", dom);
   8.476 +        return 0;
   8.477      }
   8.478  
   8.479  
   8.480   out:
   8.481 -    if ( rc != 0 )  // destroy if something went wrong
   8.482 +    if ( rc != 0 )
   8.483      {
   8.484          if ( dom != 0 )
   8.485          {
   8.486 -	    xc_domain_destroy( xc_handle, dom, 1 );
   8.487 +            xc_domain_destroy( xc_handle, dom, 1 );
   8.488          }
   8.489      }
   8.490  
     9.1 --- a/tools/xc/lib/xc_linux_save.c	Thu Jun 03 09:31:38 2004 +0000
     9.2 +++ b/tools/xc/lib/xc_linux_save.c	Thu Jun 03 11:45:16 2004 +0000
     9.3 @@ -47,8 +47,8 @@
     9.4         (live_pfn_to_mfn_table[live_mfn_to_pfn_table[_mfn]] == (_mfn)) ) || \
     9.5  \
     9.6         (live_mfn_to_pfn_table[_mfn] >= 0x80000000 && \
     9.7 -	live_mfn_to_pfn_table[_mfn] <= 0x80000003 ) || \
     9.8 -	live_pfn_to_mfn_table[live_mfn_to_pfn_table[_mfn]] == 0x80000004 )  )
     9.9 + live_mfn_to_pfn_table[_mfn] <= 0x80000003 ) || \
    9.10 + live_pfn_to_mfn_table[live_mfn_to_pfn_table[_mfn]] == 0x80000004 )  )
    9.11       
    9.12  /* Returns TRUE if MFN is successfully converted to a PFN. */
    9.13  #define translate_mfn_to_pfn(_pmfn)         \
    9.14 @@ -67,19 +67,19 @@
    9.15  static inline int test_bit ( int nr, volatile void * addr)
    9.16  {
    9.17      return ( ((unsigned long*)addr)[nr/(sizeof(unsigned long)*8)] >> 
    9.18 -	     (nr % (sizeof(unsigned long)*8) ) ) & 1;
    9.19 +             (nr % (sizeof(unsigned long)*8) ) ) & 1;
    9.20  }
    9.21  
    9.22  static inline void clear_bit ( int nr, volatile void * addr)
    9.23  {
    9.24      ((unsigned long*)addr)[nr/(sizeof(unsigned long)*8)] &= 
    9.25 -	~(1 << (nr % (sizeof(unsigned long)*8) ) );
    9.26 +        ~(1 << (nr % (sizeof(unsigned long)*8) ) );
    9.27  }
    9.28  
    9.29  static inline void set_bit ( int nr, volatile void * addr)
    9.30  {
    9.31      ((unsigned long*)addr)[nr/(sizeof(unsigned long)*8)] |= 
    9.32 -	(1 << (nr % (sizeof(unsigned long)*8) ) );
    9.33 +        (1 << (nr % (sizeof(unsigned long)*8) ) );
    9.34  }
    9.35  /*
    9.36   * hweightN: returns the hamming weight (i.e. the number
    9.37 @@ -88,20 +88,20 @@ static inline void set_bit ( int nr, vol
    9.38  
    9.39  static inline unsigned int hweight32(unsigned int w)
    9.40  {
    9.41 -        unsigned int res = (w & 0x55555555) + ((w >> 1) & 0x55555555);
    9.42 -        res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
    9.43 -        res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F);
    9.44 -        res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF);
    9.45 -        return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF);
    9.46 +    unsigned int res = (w & 0x55555555) + ((w >> 1) & 0x55555555);
    9.47 +    res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
    9.48 +    res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F);
    9.49 +    res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF);
    9.50 +    return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF);
    9.51  }
    9.52  
    9.53  static inline int count_bits ( int nr, volatile void *addr)
    9.54  {
    9.55      int i, count = 0;
    9.56      unsigned long *p = (unsigned long *)addr;
    9.57 -    // we know the array is padded to unsigned long
    9.58 +    /* we know the array is padded to unsigned long */
    9.59      for(i=0;i<nr/(sizeof(unsigned long)*8);i++,p++)
    9.60 -	count += hweight32( *p );
    9.61 +        count += hweight32( *p );
    9.62      return count;
    9.63  }
    9.64  
    9.65 @@ -131,10 +131,10 @@ static inline int permute( int i, int nr
    9.66  
    9.67      do
    9.68      {
    9.69 -	i = ( ( i>>(order_nr-10))  | ( i<<10 ) ) &
    9.70 -	    ((1<<order_nr)-1);
    9.71 +        i = ( ( i>>(order_nr-10))  | ( i<<10 ) ) &
    9.72 +            ((1<<order_nr)-1);
    9.73      }
    9.74 -    while ( i >= nr ); // this won't ever loop if nr is a power of 2
    9.75 +    while ( i >= nr ); /* this won't ever loop if nr is a power of 2 */
    9.76  
    9.77      return i;
    9.78  }
    9.79 @@ -147,11 +147,11 @@ static long long tv_to_us( struct timeva
    9.80  static long long tvdelta( struct timeval *new, struct timeval *old )
    9.81  {
    9.82      return ((new->tv_sec - old->tv_sec)*1000000 ) + 
    9.83 -	(new->tv_usec - old->tv_usec);
    9.84 +        (new->tv_usec - old->tv_usec);
    9.85  }
    9.86  
    9.87 -static int track_cpu_usage( int xc_handle, u64 domid, int faults,
    9.88 -			    int pages_sent, int pages_dirtied, int print )
    9.89 +static int track_cpu_usage( int xc_handle, u32 domid, int faults,
    9.90 +                            int pages_sent, int pages_dirtied, int print )
    9.91  {
    9.92      static struct timeval wall_last;
    9.93      static long long      d0_cpu_last;
    9.94 @@ -168,9 +168,9 @@ static int track_cpu_usage( int xc_handl
    9.95      d0_cpu_now = xc_domain_get_cpu_usage( xc_handle, 0 )/1000;
    9.96      d1_cpu_now = xc_domain_get_cpu_usage( xc_handle, domid )/1000;
    9.97  
    9.98 -    if ( d0_cpu_now == -1 || d1_cpu_now == -1 )	
    9.99 +    if ( d0_cpu_now == -1 || d1_cpu_now == -1 ) 
   9.100      {
   9.101 -	printf("ARRHHH!!\n");
   9.102 +        printf("ARRHHH!!\n");
   9.103      }
   9.104  
   9.105      wall_delta = tvdelta(&wall_now,&wall_last)/1000;
   9.106 @@ -181,27 +181,28 @@ static int track_cpu_usage( int xc_handl
   9.107      d1_cpu_delta  = (d1_cpu_now - d1_cpu_last)/1000;
   9.108  
   9.109      if(print)
   9.110 -	printf("delta %lldms, dom0 %d%%, target %d%%, sent %dMb/s, dirtied %dMb/s\n",
   9.111 -	       wall_delta, 
   9.112 -	       (int)((d0_cpu_delta*100)/wall_delta),
   9.113 -	       (int)((d1_cpu_delta*100)/wall_delta),
   9.114 -	       (int)((pages_sent*PAGE_SIZE*8)/(wall_delta*1000)),
   9.115 -	       (int)((pages_dirtied*PAGE_SIZE*8)/(wall_delta*1000))
   9.116 -	    );
   9.117 +        printf("delta %lldms, dom0 %d%%, target %d%%, "
   9.118 +               "sent %dMb/s, dirtied %dMb/s\n",
   9.119 +               wall_delta, 
   9.120 +               (int)((d0_cpu_delta*100)/wall_delta),
   9.121 +               (int)((d1_cpu_delta*100)/wall_delta),
   9.122 +               (int)((pages_sent*PAGE_SIZE*8)/(wall_delta*1000)),
   9.123 +               (int)((pages_dirtied*PAGE_SIZE*8)/(wall_delta*1000))
   9.124 +            );
   9.125  
   9.126      d0_cpu_last  = d0_cpu_now;
   9.127      d1_cpu_last  = d1_cpu_now;
   9.128 -    wall_last = wall_now;	
   9.129 +    wall_last = wall_now; 
   9.130  
   9.131      return 0;
   9.132  }
   9.133  
   9.134  
   9.135  int xc_linux_save(int xc_handle,
   9.136 -                  u64 domid, 
   9.137 -		  unsigned int flags,
   9.138 -		  int (*writerfn)(void *, const void *, size_t),
   9.139 -		  void *writerst )
   9.140 +                  u32 domid, 
   9.141 +                  unsigned int flags,
   9.142 +                  int (*writerfn)(void *, const void *, size_t),
   9.143 +                  void *writerst )
   9.144  {
   9.145      dom0_op_t op;
   9.146      int rc = 1, i, j, k, last_iter, iter = 0;
   9.147 @@ -213,8 +214,8 @@ int xc_linux_save(int xc_handle,
   9.148      unsigned long dirtied_this_iter, faults_this_iter;
   9.149  
   9.150      /* Important tuning parameters */
   9.151 -    int max_iters  = 29; // limit us to 30 times round loop
   9.152 -    int max_factor = 3;  // never send more than 3x nr_pfns 
   9.153 +    int max_iters  = 29; /* limit us to 30 times round loop */
   9.154 +    int max_factor = 3;  /* never send more than 3x nr_pfns */
   9.155  
   9.156      /* The new domain's shared-info frame number. */
   9.157      unsigned long shared_info_frame;
   9.158 @@ -275,8 +276,8 @@ int xc_linux_save(int xc_handle,
   9.159  
   9.160      if ( xc_domain_stop_sync( xc_handle, domid, &op, &ctxt ) )
   9.161      {
   9.162 -	PERROR("Could not sync stop domain");
   9.163 -	goto out;
   9.164 +        PERROR("Could not sync stop domain");
   9.165 +        goto out;
   9.166      }
   9.167  
   9.168      memcpy(name, op.u.getdomaininfo.name, sizeof(name));
   9.169 @@ -292,8 +293,8 @@ int xc_linux_save(int xc_handle,
   9.170      /* Map the suspend-record MFN to pin it. The page must be owned by 
   9.171         domid for this to succeed. */
   9.172      p_srec = mfn_mapper_map_single(xc_handle, domid,
   9.173 -				 sizeof(*p_srec), PROT_READ, 
   9.174 -				 ctxt.cpu_ctxt.esi );
   9.175 +                                   sizeof(*p_srec), PROT_READ, 
   9.176 +                                   ctxt.cpu_ctxt.esi );
   9.177  
   9.178      if (!p_srec)
   9.179      {
   9.180 @@ -312,9 +313,9 @@ int xc_linux_save(int xc_handle,
   9.181  
   9.182      /* the pfn_to_mfn_frame_list fits in a single page */
   9.183      live_pfn_to_mfn_frame_list = 
   9.184 -	mfn_mapper_map_single(xc_handle, domid, 
   9.185 -			      PAGE_SIZE, PROT_READ, 
   9.186 -			      p_srec->pfn_to_mfn_frame_list );
   9.187 +        mfn_mapper_map_single(xc_handle, domid, 
   9.188 +                              PAGE_SIZE, PROT_READ, 
   9.189 +                              p_srec->pfn_to_mfn_frame_list );
   9.190  
   9.191      if (!live_pfn_to_mfn_frame_list)
   9.192      {
   9.193 @@ -324,20 +325,20 @@ int xc_linux_save(int xc_handle,
   9.194  
   9.195      /* Track the mfn_to_pfn table down from the domains PT */
   9.196      {
   9.197 -	unsigned long *pgd;
   9.198 -	unsigned long mfn_to_pfn_table_start_mfn;
   9.199 +        unsigned long *pgd;
   9.200 +        unsigned long mfn_to_pfn_table_start_mfn;
   9.201  
   9.202 -	pgd = mfn_mapper_map_single(xc_handle, domid, 
   9.203 -				PAGE_SIZE, PROT_READ, 
   9.204 -				ctxt.pt_base>>PAGE_SHIFT);
   9.205 +        pgd = mfn_mapper_map_single(xc_handle, domid, 
   9.206 +                                    PAGE_SIZE, PROT_READ, 
   9.207 +                                    ctxt.pt_base>>PAGE_SHIFT);
   9.208  
   9.209 -	mfn_to_pfn_table_start_mfn = 
   9.210 -	    pgd[HYPERVISOR_VIRT_START>>L2_PAGETABLE_SHIFT]>>PAGE_SHIFT;
   9.211 +        mfn_to_pfn_table_start_mfn = 
   9.212 +            pgd[HYPERVISOR_VIRT_START>>L2_PAGETABLE_SHIFT]>>PAGE_SHIFT;
   9.213  
   9.214 -	live_mfn_to_pfn_table = 
   9.215 -	    mfn_mapper_map_single(xc_handle, ~0ULL, 
   9.216 -				  PAGE_SIZE*1024, PROT_READ, 
   9.217 -				  mfn_to_pfn_table_start_mfn );
   9.218 +        live_mfn_to_pfn_table = 
   9.219 +            mfn_mapper_map_single(xc_handle, DOMID_SELF, 
   9.220 +                                  PAGE_SIZE*1024, PROT_READ, 
   9.221 +                                  mfn_to_pfn_table_start_mfn );
   9.222      }
   9.223  
   9.224      /* Map all the frames of the pfn->mfn table. For migrate to succeed, 
   9.225 @@ -346,9 +347,9 @@ int xc_linux_save(int xc_handle,
   9.226         from a safety POV anyhow. */
   9.227  
   9.228      live_pfn_to_mfn_table = mfn_mapper_map_batch( xc_handle, domid, 
   9.229 -						  PROT_READ,
   9.230 -						  live_pfn_to_mfn_frame_list,
   9.231 -						  (nr_pfns+1023)/1024 );  
   9.232 +                                                  PROT_READ,
   9.233 +                                                  live_pfn_to_mfn_frame_list,
   9.234 +                                                  (nr_pfns+1023)/1024 );  
   9.235      if( !live_pfn_to_mfn_table )
   9.236      {
   9.237          PERROR("Couldn't map pfn_to_mfn table");
   9.238 @@ -372,64 +373,64 @@ int xc_linux_save(int xc_handle,
   9.239  
   9.240      if( live )
   9.241      { 
   9.242 -	if ( xc_shadow_control( xc_handle, domid, 
   9.243 -			   DOM0_SHADOW_CONTROL_OP_ENABLE_LOGDIRTY,
   9.244 -			   NULL, 0, NULL, NULL ) < 0 )
   9.245 -	{
   9.246 -	    ERROR("Couldn't enable shadow mode");
   9.247 -	    goto out;
   9.248 -	}
   9.249 +        if ( xc_shadow_control( xc_handle, domid, 
   9.250 +                                DOM0_SHADOW_CONTROL_OP_ENABLE_LOGDIRTY,
   9.251 +                                NULL, 0, NULL, NULL ) < 0 )
   9.252 +        {
   9.253 +            ERROR("Couldn't enable shadow mode");
   9.254 +            goto out;
   9.255 +        }
   9.256  
   9.257 -	if ( xc_domain_start( xc_handle, domid ) < 0 )
   9.258 -	{
   9.259 -	    ERROR("Couldn't restart domain");
   9.260 -	    goto out;
   9.261 -	}
   9.262 +        if ( xc_domain_start( xc_handle, domid ) < 0 )
   9.263 +        {
   9.264 +            ERROR("Couldn't restart domain");
   9.265 +            goto out;
   9.266 +        }
   9.267  
   9.268 -	last_iter = 0;
   9.269 -	sent_last_iter = 1<<20; // 4GB's worth of pages
   9.270 +        last_iter = 0;
   9.271 +        sent_last_iter = 1<<20; /* 4GB's worth of pages */
   9.272      }
   9.273      else
   9.274 -	last_iter = 1;
   9.275 +        last_iter = 1;
   9.276  
   9.277  
   9.278      /* Setup to_send bitmap */
   9.279      {
   9.280 -	int sz = (nr_pfns/8) + 8; // includes slop at end of array
   9.281 -	
   9.282 -	to_send = malloc( sz );
   9.283 -	to_fix  = calloc( 1, sz );
   9.284 -	to_skip = malloc( sz );
   9.285 +        int sz = (nr_pfns/8) + 8; /* includes slop at end of array */
   9.286 + 
   9.287 +        to_send = malloc( sz );
   9.288 +        to_fix  = calloc( 1, sz );
   9.289 +        to_skip = malloc( sz );
   9.290  
   9.291 -	if (!to_send || !to_fix || !to_skip)
   9.292 -	{
   9.293 -	    ERROR("Couldn't allocate to_send array");
   9.294 -	    goto out;
   9.295 -	}
   9.296 +        if (!to_send || !to_fix || !to_skip)
   9.297 +        {
   9.298 +            ERROR("Couldn't allocate to_send array");
   9.299 +            goto out;
   9.300 +        }
   9.301  
   9.302 -	memset( to_send, 0xff, sz );
   9.303 +        memset( to_send, 0xff, sz );
   9.304  
   9.305 -	if ( mlock( to_send, sz ) )
   9.306 -	{
   9.307 -	    PERROR("Unable to mlock to_send");
   9.308 -	    return 1;
   9.309 -	}
   9.310 +        if ( mlock( to_send, sz ) )
   9.311 +        {
   9.312 +            PERROR("Unable to mlock to_send");
   9.313 +            return 1;
   9.314 +        }
   9.315  
   9.316 -	/* (to fix is local only) */
   9.317 +        /* (to fix is local only) */
   9.318  
   9.319 -	if ( mlock( to_skip, sz ) )
   9.320 -	{
   9.321 -	    PERROR("Unable to mlock to_skip");
   9.322 -	    return 1;
   9.323 -	}
   9.324 +        if ( mlock( to_skip, sz ) )
   9.325 +        {
   9.326 +            PERROR("Unable to mlock to_skip");
   9.327 +            return 1;
   9.328 +        }
   9.329  
   9.330      }
   9.331  
   9.332      /* calculate the power of 2 order of nr_pfns, e.g.
   9.333 -     15->4 16->4 17->5 */
   9.334 +       15->4 16->4 17->5 */
   9.335      for( i=nr_pfns-1, order_nr=0; i ; i>>=1, order_nr++ );
   9.336  
   9.337 -printf("nr_pfns=%d order_nr=%d\n",nr_pfns, order_nr);
   9.338 +    printf("nr_pfns=%d order_nr=%d\n",nr_pfns, order_nr);
   9.339  
   9.340      /* We want zeroed memory so use calloc rather than malloc. */
   9.341      pfn_type = calloc(BATCH_SIZE, sizeof(unsigned long));
   9.342 @@ -443,8 +444,8 @@ printf("nr_pfns=%d order_nr=%d\n",nr_pfn
   9.343  
   9.344      if ( mlock( pfn_type, BATCH_SIZE * sizeof(unsigned long) ) )
   9.345      {
   9.346 -	ERROR("Unable to mlock");
   9.347 -	goto out;
   9.348 +        ERROR("Unable to mlock");
   9.349 +        goto out;
   9.350      }
   9.351  
   9.352  
   9.353 @@ -456,16 +457,16 @@ printf("nr_pfns=%d order_nr=%d\n",nr_pfn
   9.354      {
   9.355          mfn = live_pfn_to_mfn_table[i];
   9.356  
   9.357 -	if( (live_mfn_to_pfn_table[mfn] != i) && (mfn != 0x80000004) )
   9.358 -	    printf("i=0x%x mfn=%x live_mfn_to_pfn_table=%x\n",
   9.359 -		   i,mfn,live_mfn_to_pfn_table[mfn]);
   9.360 +        if( (live_mfn_to_pfn_table[mfn] != i) && (mfn != 0x80000004) )
   9.361 +            printf("i=0x%x mfn=%x live_mfn_to_pfn_table=%x\n",
   9.362 +                   i,mfn,live_mfn_to_pfn_table[mfn]);
   9.363      }
   9.364  #endif
   9.365  
   9.366      /* Map the shared info frame */
   9.367      live_shinfo = mfn_mapper_map_single(xc_handle, domid,
   9.368 -					PAGE_SIZE, PROT_READ,
   9.369 -					shared_info_frame);
   9.370 +                                        PAGE_SIZE, PROT_READ,
   9.371 +                                        shared_info_frame);
   9.372  
   9.373      if (!live_shinfo)
   9.374      {
   9.375 @@ -490,297 +491,289 @@ printf("nr_pfns=%d order_nr=%d\n",nr_pfn
   9.376      
   9.377      while(1)
   9.378      {
   9.379 -	unsigned int prev_pc, sent_this_iter, N, batch;
   9.380 +        unsigned int prev_pc, sent_this_iter, N, batch;
   9.381  
   9.382 -	iter++;
   9.383 -	sent_this_iter = 0;
   9.384 -	skip_this_iter = 0;
   9.385 -	prev_pc = 0;
   9.386 -	N=0;
   9.387 +        iter++;
   9.388 +        sent_this_iter = 0;
   9.389 +        skip_this_iter = 0;
   9.390 +        prev_pc = 0;
   9.391 +        N=0;
   9.392  
   9.393 -	verbose_printf("Saving memory pages: iter %d   0%%", iter);
   9.394 +        verbose_printf("Saving memory pages: iter %d   0%%", iter);
   9.395  
   9.396 -	while( N < nr_pfns )
   9.397 -	{
   9.398 -	    unsigned int this_pc = (N * 100) / nr_pfns;
   9.399 +        while( N < nr_pfns )
   9.400 +        {
   9.401 +            unsigned int this_pc = (N * 100) / nr_pfns;
   9.402  
   9.403 -	    if ( (this_pc - prev_pc) >= 5 )
   9.404 -	    {
   9.405 -		verbose_printf("\b\b\b\b%3d%%", this_pc);
   9.406 -		prev_pc = this_pc;
   9.407 -	    }
   9.408 +            if ( (this_pc - prev_pc) >= 5 )
   9.409 +            {
   9.410 +                verbose_printf("\b\b\b\b%3d%%", this_pc);
   9.411 +                prev_pc = this_pc;
   9.412 +            }
   9.413  
   9.414 -	    /* slightly wasteful to peek the whole array evey time, 
   9.415 -	       but this is fast enough for the moment. */
   9.416 +            /* slightly wasteful to peek the whole array evey time, 
   9.417 +               but this is fast enough for the moment. */
   9.418  
   9.419 -	    if ( !last_iter && 
   9.420 -		 xc_shadow_control(xc_handle, domid, 
   9.421 -				   DOM0_SHADOW_CONTROL_OP_PEEK,
   9.422 -				   to_skip, nr_pfns, NULL, NULL) != nr_pfns ) 
   9.423 -	    {
   9.424 -		ERROR("Error peeking shadow bitmap");
   9.425 -		goto out;
   9.426 -	    }
   9.427 -	    
   9.428 +            if ( !last_iter && 
   9.429 +                 xc_shadow_control(xc_handle, domid, 
   9.430 +                                   DOM0_SHADOW_CONTROL_OP_PEEK,
   9.431 +                                   to_skip, nr_pfns, NULL, NULL) != nr_pfns ) 
   9.432 +            {
   9.433 +                ERROR("Error peeking shadow bitmap");
   9.434 +                goto out;
   9.435 +            }
   9.436 +     
   9.437  
   9.438 -	    /* load pfn_type[] with the mfn of all the pages we're doing in
   9.439 -	       this batch. */
   9.440 +            /* load pfn_type[] with the mfn of all the pages we're doing in
   9.441 +               this batch. */
   9.442  
   9.443 -	    for( batch = 0; batch < BATCH_SIZE && N < nr_pfns ; N++ )
   9.444 -	    {
   9.445 -		int n = permute(N, nr_pfns, order_nr );
   9.446 +            for( batch = 0; batch < BATCH_SIZE && N < nr_pfns ; N++ )
   9.447 +            {
   9.448 +                int n = permute(N, nr_pfns, order_nr );
   9.449  
   9.450 -		if(0 && debug)
   9.451 -		    fprintf(stderr,"%d pfn= %08lx mfn= %08lx %d   [mfn]= %08lx\n",
   9.452 -			    iter, n, live_pfn_to_mfn_table[n],
   9.453 -			    test_bit(n,to_send),
   9.454 -			    live_mfn_to_pfn_table[live_pfn_to_mfn_table[n]&0xFFFFF]);
   9.455 +                if(0 && debug)
   9.456 +                    fprintf(stderr,"%d pfn= %08lx mfn= %08lx %d   "
   9.457 +                            "[mfn]= %08lx\n",
   9.458 +                            iter, n, live_pfn_to_mfn_table[n],
   9.459 +                            test_bit(n,to_send),
   9.460 +                            live_mfn_to_pfn_table[
   9.461 +                                live_pfn_to_mfn_table[n]&0xFFFFF]);
   9.462  
   9.463 -		if (!last_iter && test_bit(n, to_send) && test_bit(n, to_skip))
   9.464 -		    skip_this_iter++; // stats keeping
   9.465 +                if (!last_iter && test_bit(n, to_send) && test_bit(n, to_skip))
   9.466 +                    skip_this_iter++; /* stats keeping */
   9.467  
   9.468 -		if (! ( (test_bit(n, to_send) && !test_bit(n, to_skip)) ||
   9.469 -			(test_bit(n, to_send) && last_iter) ||
   9.470 -			(test_bit(n, to_fix)  && last_iter) )   )
   9.471 -		    continue;
   9.472 +                if (! ( (test_bit(n, to_send) && !test_bit(n, to_skip)) ||
   9.473 +                        (test_bit(n, to_send) && last_iter) ||
   9.474 +                        (test_bit(n, to_fix)  && last_iter) )   )
   9.475 +                    continue;
   9.476  
   9.477 -		/* we get here if:
   9.478 -		   1. page is marked to_send & hasn't already been re-dirtied
   9.479 -		   2. (ignore to_skip in last iteration)
   9.480 -		   3. add in pages that still need fixup (net bufs)
   9.481 -		 */
   9.482 -		
   9.483 -		pfn_batch[batch] = n;
   9.484 -		pfn_type[batch] = live_pfn_to_mfn_table[n];
   9.485 +                /* we get here if:
   9.486 +                   1. page is marked to_send & hasn't already been re-dirtied
   9.487 +                   2. (ignore to_skip in last iteration)
   9.488 +                   3. add in pages that still need fixup (net bufs)
   9.489 +                */
   9.490 +  
   9.491 +                pfn_batch[batch] = n;
   9.492 +                pfn_type[batch] = live_pfn_to_mfn_table[n];
   9.493  
   9.494 -		if( pfn_type[batch] == 0x80000004 )
   9.495 -		{
   9.496 -		    /* not currently in pusedo-physical map -- set bit
   9.497 -		       in to_fix that we must send this page in last_iter
   9.498 -		       unless its sent sooner anyhow */
   9.499 +                if( pfn_type[batch] == 0x80000004 )
   9.500 +                {
   9.501 +                    /* not currently in pusedo-physical map -- set bit
   9.502 +                       in to_fix that we must send this page in last_iter
   9.503 +                       unless its sent sooner anyhow */
   9.504  
   9.505 -		    set_bit( n, to_fix );
   9.506 -		    if( iter>1 )
   9.507 -			DDPRINTF("Urk! netbuf race: iter %d, pfn %lx. mfn %lx\n",
   9.508 -			       iter,n,pfn_type[batch]);
   9.509 -		    continue;
   9.510 -		}
   9.511 +                    set_bit( n, to_fix );
   9.512 +                    if( iter>1 )
   9.513 +                        DDPRINTF("Urk! netbuf race: iter %d, pfn %lx."
   9.514 +                                 " mfn %lx\n",
   9.515 +                                 iter,n,pfn_type[batch]);
   9.516 +                    continue;
   9.517 +                }
   9.518  
   9.519 -		if ( last_iter && test_bit(n, to_fix ) && !test_bit(n, to_send ))
   9.520 -		{
   9.521 -		    needed_to_fix++;
   9.522 -		    DPRINTF("Fix! iter %d, pfn %lx. mfn %lx\n",
   9.523 -			       iter,n,pfn_type[batch]);
   9.524 -		}
   9.525 +                if ( last_iter && test_bit(n, to_fix) && 
   9.526 +                     !test_bit(n, to_send) )
   9.527 +                {
   9.528 +                    needed_to_fix++;
   9.529 +                    DPRINTF("Fix! iter %d, pfn %lx. mfn %lx\n",
   9.530 +                            iter,n,pfn_type[batch]);
   9.531 +                }
   9.532  
   9.533 -		clear_bit( n, to_fix ); 
   9.534 +                clear_bit( n, to_fix ); 
   9.535  
   9.536 -		batch++;
   9.537 -	    }
   9.538 -	    
   9.539 -	    DDPRINTF("batch %d:%d (n=%d)\n",iter,batch,n);
   9.540 +                batch++;
   9.541 +            }
   9.542 +     
   9.543 +            DDPRINTF("batch %d:%d (n=%d)\n",iter,batch,n);
   9.544  
   9.545 -	    if(batch == 0) goto skip; // vanishingly unlikely...
   9.546 - 	    
   9.547 -	    if ( (region_base = mfn_mapper_map_batch( xc_handle, domid, 
   9.548 -						      PROT_READ,
   9.549 -						      pfn_type,
   9.550 -						      batch )) == 0)
   9.551 -	    {
   9.552 -		PERROR("map batch failed");
   9.553 -		goto out;
   9.554 -	    }
   9.555 -	    
   9.556 -	    if ( get_pfn_type_batch(xc_handle, domid, batch, pfn_type) )
   9.557 -	    {
   9.558 -		ERROR("get_pfn_type_batch failed");
   9.559 -		goto out;
   9.560 -	    }
   9.561 -	    
   9.562 -	    for( j = 0; j < batch; j++ )
   9.563 -	    {
   9.564 -		if( (pfn_type[j] & LTAB_MASK) == XTAB)
   9.565 -		{
   9.566 -		    DDPRINTF("type fail: page %i mfn %08lx\n",j,pfn_type[j]);
   9.567 -		    continue;
   9.568 -		}
   9.569 -		
   9.570 -		if(0 && debug)
   9.571 -		    fprintf(stderr,"%d pfn= %08lx mfn= %08lx [mfn]= %08lx sum= %08lx\n",
   9.572 -			    iter, 
   9.573 -			    (pfn_type[j] & LTAB_MASK) | pfn_batch[j],
   9.574 -			    pfn_type[j],
   9.575 -			    live_mfn_to_pfn_table[pfn_type[j]&(~LTAB_MASK)],
   9.576 -			    csum_page(region_base + (PAGE_SIZE*j))
   9.577 -			);
   9.578 +            if ( batch == 0 ) 
   9.579 +                goto skip; /* very unlikely */
   9.580 +      
   9.581 +            if ( (region_base = mfn_mapper_map_batch(xc_handle, domid, 
   9.582 +                                                     PROT_READ,
   9.583 +                                                     pfn_type,
   9.584 +                                                     batch)) == 0 )
   9.585 +            {
   9.586 +                PERROR("map batch failed");
   9.587 +                goto out;
   9.588 +            }
   9.589 +     
   9.590 +            if ( get_pfn_type_batch(xc_handle, domid, batch, pfn_type) )
   9.591 +            {
   9.592 +                ERROR("get_pfn_type_batch failed");
   9.593 +                goto out;
   9.594 +            }
   9.595 +     
   9.596 +            for ( j = 0; j < batch; j++ )
   9.597 +            {
   9.598 +                if ( (pfn_type[j] & LTAB_MASK) == XTAB )
   9.599 +                {
   9.600 +                    DDPRINTF("type fail: page %i mfn %08lx\n",j,pfn_type[j]);
   9.601 +                    continue;
   9.602 +                }
   9.603 +  
   9.604 +                if ( 0 && debug )
   9.605 +                    fprintf(stderr,"%d pfn= %08lx mfn= %08lx "
   9.606 +                            "[mfn]= %08lx sum= %08lx\n",
   9.607 +                            iter, 
   9.608 +                            (pfn_type[j] & LTAB_MASK) | pfn_batch[j],
   9.609 +                            pfn_type[j],
   9.610 +                            live_mfn_to_pfn_table[pfn_type[j]&(~LTAB_MASK)],
   9.611 +                            csum_page(region_base + (PAGE_SIZE*j))
   9.612 +                        );
   9.613  
   9.614 -		/* canonicalise mfn->pfn */
   9.615 -		pfn_type[j] = (pfn_type[j] & LTAB_MASK) |
   9.616 -		    pfn_batch[j];
   9.617 -		//live_mfn_to_pfn_table[pfn_type[j]&~LTAB_MASK];
   9.618 -
   9.619 -	    }
   9.620 +                /* canonicalise mfn->pfn */
   9.621 +                pfn_type[j] = (pfn_type[j] & LTAB_MASK) |
   9.622 +                    pfn_batch[j];
   9.623 +            }
   9.624  
   9.625 -	    
   9.626 -	    if ( (*writerfn)(writerst, &batch, sizeof(int) ) )
   9.627 -	    {
   9.628 -		ERROR("Error when writing to state file (2)");
   9.629 -		goto out;
   9.630 -	    }
   9.631 +     
   9.632 +            if ( (*writerfn)(writerst, &batch, sizeof(int) ) )
   9.633 +            {
   9.634 +                ERROR("Error when writing to state file (2)");
   9.635 +                goto out;
   9.636 +            }
   9.637  
   9.638 -	    if ( (*writerfn)(writerst, pfn_type, sizeof(unsigned long)*j ) )
   9.639 -	    {
   9.640 -		ERROR("Error when writing to state file (3)");
   9.641 -		goto out;
   9.642 -	    }
   9.643 -	    
   9.644 -	    /* entering this loop, pfn_type is now in pfns (Not mfns) */
   9.645 -	    for( j = 0; j < batch; j++ )
   9.646 -	    {
   9.647 -		/* write out pages in batch */
   9.648 -		
   9.649 -		if( (pfn_type[j] & LTAB_MASK) == XTAB)
   9.650 -		{
   9.651 -		    DDPRINTF("SKIP BOGUS page %i mfn %08lx\n",j,pfn_type[j]);
   9.652 -		    continue;
   9.653 -		}
   9.654 -		
   9.655 -		if ( ((pfn_type[j] & LTAB_MASK) == L1TAB) || 
   9.656 -		     ((pfn_type[j] & LTAB_MASK) == L2TAB) )
   9.657 -		{
   9.658 -		    
   9.659 -		    memcpy(page, region_base + (PAGE_SIZE*j), PAGE_SIZE);
   9.660 -		    
   9.661 -		    for ( k = 0; 
   9.662 -			  k < (((pfn_type[j] & LTAB_MASK) == L2TAB) ? 
   9.663 -		       (HYPERVISOR_VIRT_START >> L2_PAGETABLE_SHIFT) : 1024); 
   9.664 -			  k++ )
   9.665 -		    {
   9.666 -			unsigned long pfn;
   9.667 +            if ( (*writerfn)(writerst, pfn_type, sizeof(unsigned long)*j ) )
   9.668 +            {
   9.669 +                ERROR("Error when writing to state file (3)");
   9.670 +                goto out;
   9.671 +            }
   9.672 +     
   9.673 +            /* entering this loop, pfn_type is now in pfns (Not mfns) */
   9.674 +            for( j = 0; j < batch; j++ )
   9.675 +            {
   9.676 +                /* write out pages in batch */
   9.677 +  
   9.678 +                if( (pfn_type[j] & LTAB_MASK) == XTAB)
   9.679 +                {
   9.680 +                    DDPRINTF("SKIP BOGUS page %i mfn %08lx\n",j,pfn_type[j]);
   9.681 +                    continue;
   9.682 +                }
   9.683 +  
   9.684 +                if ( ((pfn_type[j] & LTAB_MASK) == L1TAB) || 
   9.685 +                     ((pfn_type[j] & LTAB_MASK) == L2TAB) )
   9.686 +                {
   9.687 +      
   9.688 +                    memcpy(page, region_base + (PAGE_SIZE*j), PAGE_SIZE);
   9.689 +      
   9.690 +                    for ( k = 0; 
   9.691 +                          k < (((pfn_type[j] & LTAB_MASK) == L2TAB) ? 
   9.692 +                               (HYPERVISOR_VIRT_START >> L2_PAGETABLE_SHIFT) : 
   9.693 +                               1024); 
   9.694 +                          k++ )
   9.695 +                    {
   9.696 +                        unsigned long pfn;
   9.697  
   9.698 -			if ( !(page[k] & _PAGE_PRESENT) ) continue;
   9.699 -			mfn = page[k] >> PAGE_SHIFT;		    
   9.700 -			pfn = live_mfn_to_pfn_table[mfn];
   9.701 -
   9.702 -			if ( !MFN_IS_IN_PSEUDOPHYS_MAP(mfn) )
   9.703 -			{
   9.704 -			    // I don't think this should ever happen
   9.705 +                        if ( !(page[k] & _PAGE_PRESENT) ) continue;
   9.706 +                        mfn = page[k] >> PAGE_SHIFT;      
   9.707 +                        pfn = live_mfn_to_pfn_table[mfn];
   9.708  
   9.709 -			    printf("FNI %d : [%08lx,%d] pte=%08lx, mfn=%08lx, pfn=%08lx [mfn]=%08lx\n",
   9.710 -				   j, pfn_type[j], k,
   9.711 -				   page[k], mfn, live_mfn_to_pfn_table[mfn],
   9.712 -				   (live_mfn_to_pfn_table[mfn]<nr_pfns)? 
   9.713 -				   live_pfn_to_mfn_table[live_mfn_to_pfn_table[mfn]]: 0xdeadbeef);
   9.714 -
   9.715 -			    pfn = 0; // be suspicious, very suspicious
   9.716 -			    
   9.717 -			    //goto out;  // let's try our luck
   9.718 -
   9.719 +                        if ( !MFN_IS_IN_PSEUDOPHYS_MAP(mfn) )
   9.720 +                        {
   9.721 +                            /* I don't think this should ever happen */
   9.722 +                            printf("FNI %d : [%08lx,%d] pte=%08lx, "
   9.723 +                                   "mfn=%08lx, pfn=%08lx [mfn]=%08lx\n",
   9.724 +                                   j, pfn_type[j], k,
   9.725 +                                   page[k], mfn, live_mfn_to_pfn_table[mfn],
   9.726 +                                   (live_mfn_to_pfn_table[mfn]<nr_pfns)? 
   9.727 +                                   live_pfn_to_mfn_table[
   9.728 +                                       live_mfn_to_pfn_table[mfn]]:0xdeadbeef);
   9.729 +                            pfn = 0; /* be suspicious, very suspicious */
   9.730 +                        }
   9.731 +                        page[k] &= PAGE_SIZE - 1;
   9.732 +                        page[k] |= pfn << PAGE_SHIFT;
   9.733 +                    } /* end of page table rewrite for loop */
   9.734 +      
   9.735 +                    if ( (*writerfn)(writerst, page, PAGE_SIZE) )
   9.736 +                    {
   9.737 +                        ERROR("Error when writing to state file (4)");
   9.738 +                        goto out;
   9.739 +                    }
   9.740 +      
   9.741 +                }  /* end of it's a PT page */
   9.742 +                else
   9.743 +                {  /* normal page */
   9.744  
   9.745 -			}
   9.746 -			page[k] &= PAGE_SIZE - 1;
   9.747 -			page[k] |= pfn << PAGE_SHIFT;
   9.748 -			
   9.749 -#if 0
   9.750 -			printf("L%d i=%d pfn=%d mfn=%d k=%d pte=%08lx xpfn=%d\n",
   9.751 -			       pfn_type[j]>>28,
   9.752 -			       j,i,mfn,k,page[k],page[k]>>PAGE_SHIFT);
   9.753 -#endif			  
   9.754 -			
   9.755 -		    } /* end of page table rewrite for loop */
   9.756 -		    
   9.757 -		    if ( (*writerfn)(writerst, page, PAGE_SIZE) )
   9.758 -		    {
   9.759 -			ERROR("Error when writing to state file (4)");
   9.760 -			goto out;
   9.761 -		    }
   9.762 -		    
   9.763 -		}  /* end of it's a PT page */
   9.764 -		else
   9.765 -		{  /* normal page */
   9.766 +                    if ( (*writerfn)(writerst, region_base + (PAGE_SIZE*j), 
   9.767 +                                     PAGE_SIZE) )
   9.768 +                    {
   9.769 +                        ERROR("Error when writing to state file (5)");
   9.770 +                        goto out;
   9.771 +                    }
   9.772 +                }
   9.773 +            } /* end of the write out for this batch */
   9.774 +     
   9.775 +            sent_this_iter += batch;
   9.776  
   9.777 -		    if ( (*writerfn)(writerst, region_base + (PAGE_SIZE*j), PAGE_SIZE) )
   9.778 -		    {
   9.779 -			ERROR("Error when writing to state file (5)");
   9.780 -			goto out;
   9.781 -		    }
   9.782 -		}
   9.783 -	    } /* end of the write out for this batch */
   9.784 -	    
   9.785 -	    sent_this_iter += batch;
   9.786 +        } /* end of this while loop for this iteration */
   9.787  
   9.788 -	} /* end of this while loop for this iteration */
   9.789 -
   9.790 -	munmap(region_base, batch*PAGE_SIZE);
   9.791 +        munmap(region_base, batch*PAGE_SIZE);
   9.792  
   9.793      skip: 
   9.794  
   9.795 -	total_sent += sent_this_iter;
   9.796 +        total_sent += sent_this_iter;
   9.797  
   9.798 -	verbose_printf("\r %d: sent %d, skipped %d, ", 
   9.799 -		       iter, sent_this_iter, skip_this_iter );
   9.800 +        verbose_printf("\r %d: sent %d, skipped %d, ", 
   9.801 +                       iter, sent_this_iter, skip_this_iter );
   9.802  
   9.803 -	if ( last_iter )
   9.804 -	{
   9.805 -	    track_cpu_usage( xc_handle, domid, 0, sent_this_iter, 0, 1);
   9.806 +        if ( last_iter )
   9.807 +        {
   9.808 +            track_cpu_usage( xc_handle, domid, 0, sent_this_iter, 0, 1);
   9.809  
   9.810 -	    verbose_printf("Total pages sent= %d (%.2fx)\n", 
   9.811 -			   total_sent, ((float)total_sent)/nr_pfns );
   9.812 -	    verbose_printf("(of which %d were fixups)\n", needed_to_fix  );
   9.813 -	}       
   9.814 +            verbose_printf("Total pages sent= %d (%.2fx)\n", 
   9.815 +                           total_sent, ((float)total_sent)/nr_pfns );
   9.816 +            verbose_printf("(of which %d were fixups)\n", needed_to_fix  );
   9.817 +        }       
   9.818  
   9.819 -	if ( debug && last_iter )
   9.820 -	{
   9.821 -	    int minusone = -1;
   9.822 -	    memset( to_send, 0xff, nr_pfns/8 );
   9.823 -	    debug = 0;
   9.824 -	    printf("Entering debug resend-all mode\n");
   9.825 +        if ( debug && last_iter )
   9.826 +        {
   9.827 +            int minusone = -1;
   9.828 +            memset( to_send, 0xff, nr_pfns/8 );
   9.829 +            debug = 0;
   9.830 +            printf("Entering debug resend-all mode\n");
   9.831      
   9.832 -	    /* send "-1" to put receiver into debug mode */
   9.833 -	    if ( (*writerfn)(writerst, &minusone, sizeof(int)) )
   9.834 -	    {
   9.835 -		ERROR("Error when writing to state file (6)");
   9.836 -		goto out;
   9.837 -	    }
   9.838 +            /* send "-1" to put receiver into debug mode */
   9.839 +            if ( (*writerfn)(writerst, &minusone, sizeof(int)) )
   9.840 +            {
   9.841 +                ERROR("Error when writing to state file (6)");
   9.842 +                goto out;
   9.843 +            }
   9.844  
   9.845 -	    continue;
   9.846 -	}
   9.847 +            continue;
   9.848 +        }
   9.849  
   9.850 -	if ( last_iter )
   9.851 -	    break;
   9.852 +        if ( last_iter )
   9.853 +            break;
   9.854  
   9.855 -	if ( live )
   9.856 -	{
   9.857 -	    if ( 
   9.858 -		 // ( sent_this_iter > (sent_last_iter * 0.95) ) ||		 
   9.859 -		 (iter >= max_iters) || 
   9.860 -		 (sent_this_iter+skip_this_iter < 50) || 
   9.861 -		 (total_sent > nr_pfns*max_factor) )
   9.862 -	    {
   9.863 -		DPRINTF("Start last iteration\n");
   9.864 -		last_iter = 1;
   9.865 +        if ( live )
   9.866 +        {
   9.867 +            if ( (iter >= max_iters) || 
   9.868 +                 (sent_this_iter+skip_this_iter < 50) || 
   9.869 +                 (total_sent > nr_pfns*max_factor) )
   9.870 +            {
   9.871 +                DPRINTF("Start last iteration\n");
   9.872 +                last_iter = 1;
   9.873  
   9.874 -		xc_domain_stop_sync( xc_handle, domid, &op, NULL );
   9.875 +                xc_domain_stop_sync( xc_handle, domid, &op, NULL );
   9.876  
   9.877 -	    } 
   9.878 +            } 
   9.879  
   9.880 -	    if ( xc_shadow_control( xc_handle, domid, 
   9.881 -				    DOM0_SHADOW_CONTROL_OP_CLEAN2,
   9.882 -				    to_send, nr_pfns, &faults_this_iter,
   9.883 -				    &dirtied_this_iter) != nr_pfns ) 
   9.884 -	    {
   9.885 -		ERROR("Error flushing shadow PT");
   9.886 -		goto out;
   9.887 -	    }
   9.888 +            if ( xc_shadow_control( xc_handle, domid, 
   9.889 +                                    DOM0_SHADOW_CONTROL_OP_CLEAN2,
   9.890 +                                    to_send, nr_pfns, &faults_this_iter,
   9.891 +                                    &dirtied_this_iter) != nr_pfns ) 
   9.892 +            {
   9.893 +                ERROR("Error flushing shadow PT");
   9.894 +                goto out;
   9.895 +            }
   9.896  
   9.897 -	    sent_last_iter = sent_this_iter;
   9.898 +            sent_last_iter = sent_this_iter;
   9.899  
   9.900 -	    //dirtied_this_iter = count_bits( nr_pfns, to_send ); 
   9.901 -	    track_cpu_usage( xc_handle, domid, faults_this_iter,
   9.902 -			     sent_this_iter, dirtied_this_iter, 1);
   9.903 -	    
   9.904 -	}
   9.905 -
   9.906 +            /* dirtied_this_iter = count_bits( nr_pfns, to_send ); */
   9.907 +            track_cpu_usage( xc_handle, domid, faults_this_iter,
   9.908 +                             sent_this_iter, dirtied_this_iter, 1);
   9.909 +     
   9.910 +        }
   9.911  
   9.912      } /* end of while 1 */
   9.913  
   9.914 @@ -792,8 +785,8 @@ printf("nr_pfns=%d order_nr=%d\n",nr_pfn
   9.915      /* Zero terminate */
   9.916      if ( (*writerfn)(writerst, &rc, sizeof(int)) )
   9.917      {
   9.918 -	ERROR("Error when writing to state file (6)");
   9.919 -	goto out;
   9.920 +        ERROR("Error when writing to state file (6)");
   9.921 +        goto out;
   9.922      }
   9.923  
   9.924      /* Get the final execution context */
   9.925 @@ -801,10 +794,10 @@ printf("nr_pfns=%d order_nr=%d\n",nr_pfn
   9.926      op.u.getdomaininfo.domain = (domid_t)domid;
   9.927      op.u.getdomaininfo.ctxt = &ctxt;
   9.928      if ( (do_dom0_op(xc_handle, &op) < 0) || 
   9.929 -	 ((u64)op.u.getdomaininfo.domain != domid) )
   9.930 +         ((u32)op.u.getdomaininfo.domain != domid) )
   9.931      {
   9.932 -	PERROR("Could not get info on domain");
   9.933 -	goto out;
   9.934 +        PERROR("Could not get info on domain");
   9.935 +        goto out;
   9.936      }
   9.937  
   9.938      /* Canonicalise the suspend-record frame number. */
   9.939 @@ -830,18 +823,18 @@ printf("nr_pfns=%d order_nr=%d\n",nr_pfn
   9.940          ERROR("PT base is not in range of pseudophys map");
   9.941          goto out;
   9.942      }
   9.943 -    ctxt.pt_base = live_mfn_to_pfn_table[ctxt.pt_base >> PAGE_SHIFT] << PAGE_SHIFT;
   9.944 +    ctxt.pt_base = live_mfn_to_pfn_table[ctxt.pt_base >> PAGE_SHIFT] << 
   9.945 +        PAGE_SHIFT;
   9.946  
   9.947 -    if ( (*writerfn)(writerst, &ctxt,                 sizeof(ctxt)) ||
   9.948 -         (*writerfn)(writerst, live_shinfo,           PAGE_SIZE) )
   9.949 +    if ( (*writerfn)(writerst, &ctxt,       sizeof(ctxt)) ||
   9.950 +         (*writerfn)(writerst, live_shinfo, PAGE_SIZE) )
   9.951      {
   9.952          ERROR("Error when writing to state file (1)");
   9.953          goto out;
   9.954      }
   9.955      munmap(live_shinfo, PAGE_SIZE);
   9.956  
   9.957 -out:
   9.958 -
   9.959 + out:
   9.960      if ( pfn_type != NULL )
   9.961          free(pfn_type);
   9.962  
    10.1 --- a/tools/xc/lib/xc_misc.c	Thu Jun 03 09:31:38 2004 +0000
    10.2 +++ b/tools/xc/lib/xc_misc.c	Thu Jun 03 11:45:16 2004 +0000
    10.3 @@ -20,7 +20,7 @@ int xc_interface_close(int xc_handle)
    10.4  }
    10.5  
    10.6  
    10.7 -#define CONSOLE_RING_CLEAR	1
    10.8 +#define CONSOLE_RING_CLEAR 1
    10.9  
   10.10  int xc_readconsolering(int xc_handle,
   10.11                         char *str, 
   10.12 @@ -48,7 +48,7 @@ int xc_readconsolering(int xc_handle,
   10.13  
   10.14  
   10.15  int xc_physinfo(int xc_handle,
   10.16 -		xc_physinfo_t *put_info)
   10.17 +                xc_physinfo_t *put_info)
   10.18  {
   10.19      int ret;
   10.20      dom0_op_t op;
    11.1 --- a/tools/xc/lib/xc_netbsd_build.c	Thu Jun 03 09:31:38 2004 +0000
    11.2 +++ b/tools/xc/lib/xc_netbsd_build.c	Thu Jun 03 11:45:16 2004 +0000
    11.3 @@ -22,7 +22,7 @@ static int loadelfimage(gzFile, int, uns
    11.4  #define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED)
    11.5  #define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
    11.6  
    11.7 -static long get_tot_pages(int xc_handle, u64 domid)
    11.8 +static long get_tot_pages(int xc_handle, u32 domid)
    11.9  {
   11.10      dom0_op_t op;
   11.11      op.cmd = DOM0_GETDOMAININFO;
   11.12 @@ -33,7 +33,7 @@ static long get_tot_pages(int xc_handle,
   11.13  }
   11.14  
   11.15  static int get_pfn_list(int xc_handle,
   11.16 -                        u64 domid, 
   11.17 +                        u32 domid, 
   11.18                          unsigned long *pfn_buf, 
   11.19                          unsigned long max_pfns)
   11.20  {
   11.21 @@ -55,12 +55,12 @@ static int get_pfn_list(int xc_handle,
   11.22  }
   11.23  
   11.24  static int setup_guestos(int xc_handle,
   11.25 -                         u64 dom, 
   11.26 +                         u32 dom, 
   11.27                           gzFile kernel_gfd, 
   11.28                           unsigned long tot_pages,
   11.29                           unsigned long *virt_startinfo_addr, 
   11.30                           unsigned long *virt_load_addr, 
   11.31 -			 full_execution_context_t *ctxt,
   11.32 +                         full_execution_context_t *ctxt,
   11.33                           const char *cmdline,
   11.34                           unsigned long shared_info_frame,
   11.35                           unsigned int control_evtchn)
   11.36 @@ -209,7 +209,7 @@ static int setup_guestos(int xc_handle,
   11.37  }
   11.38  
   11.39  int xc_netbsd_build(int xc_handle,
   11.40 -                    u64 domid,
   11.41 +                    u32 domid,
   11.42                      const char *image_name,
   11.43                      const char *cmdline,
   11.44                      unsigned int control_evtchn)
   11.45 @@ -253,7 +253,7 @@ int xc_netbsd_build(int xc_handle,
   11.46      op.u.getdomaininfo.domain = (domid_t)domid;
   11.47      op.u.getdomaininfo.ctxt = ctxt;
   11.48      if ( (do_dom0_op(xc_handle, &op) < 0) || 
   11.49 -         ((u64)op.u.getdomaininfo.domain != domid) )
   11.50 +         ((u32)op.u.getdomaininfo.domain != domid) )
   11.51      {
   11.52          PERROR("Could not get info on domain");
   11.53          goto error_out;
    12.1 --- a/tools/xc/lib/xc_physdev.c	Thu Jun 03 09:31:38 2004 +0000
    12.2 +++ b/tools/xc/lib/xc_physdev.c	Thu Jun 03 11:45:16 2004 +0000
    12.3 @@ -10,7 +10,7 @@
    12.4  #include "xc_private.h"
    12.5  
    12.6  int xc_physdev_pci_access_modify(int xc_handle,
    12.7 -                                 u64 domid,
    12.8 +                                 u32 domid,
    12.9                                   int bus,
   12.10                                   int dev,
   12.11                                   int func,
    13.1 --- a/tools/xc/lib/xc_private.c	Thu Jun 03 09:31:38 2004 +0000
    13.2 +++ b/tools/xc/lib/xc_private.c	Thu Jun 03 11:45:16 2004 +0000
    13.3 @@ -10,10 +10,7 @@ int init_pfn_mapper(domid_t domid)
    13.4  {
    13.5      int fd = open("/dev/mem", O_RDWR);
    13.6      if ( fd >= 0 )
    13.7 -    {
    13.8 -        (void)ioctl(fd, _IO('M', 1), (unsigned long)(domid>> 0)); /* low  */
    13.9 -        (void)ioctl(fd, _IO('M', 2), (unsigned long)(domid>>32)); /* high */
   13.10 -    }
   13.11 +        (void)ioctl(fd, _IO('M', 1), (unsigned long)domid);
   13.12      return fd;
   13.13  }
   13.14  
   13.15 @@ -48,23 +45,23 @@ void unmap_pfn(int pm_handle, void *vadd
   13.16  /*******************/
   13.17  
   13.18  void * mfn_mapper_map_batch(int xc_handle, domid_t dom, int prot,
   13.19 -			    unsigned long *arr, int num )
   13.20 +                            unsigned long *arr, int num )
   13.21  {
   13.22      privcmd_mmapbatch_t ioctlx; 
   13.23      void *addr;
   13.24      addr = mmap( NULL, num*PAGE_SIZE, prot, MAP_SHARED, xc_handle, 0 );
   13.25      if (addr)
   13.26      {
   13.27 -	ioctlx.num=num;
   13.28 -	ioctlx.dom=dom;
   13.29 -	ioctlx.addr=(unsigned long)addr;
   13.30 -	ioctlx.arr=arr;
   13.31 -	if ( ioctl( xc_handle, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx ) <0 )
   13.32 -	{
   13.33 -	    perror("XXXXXXXX");
   13.34 -	    munmap(addr, num*PAGE_SIZE);
   13.35 -	    return 0;
   13.36 -	}
   13.37 +        ioctlx.num=num;
   13.38 +        ioctlx.dom=dom;
   13.39 +        ioctlx.addr=(unsigned long)addr;
   13.40 +        ioctlx.arr=arr;
   13.41 +        if ( ioctl( xc_handle, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx ) < 0 )
   13.42 +        {
   13.43 +            perror("XXXXXXXX");
   13.44 +            munmap(addr, num*PAGE_SIZE);
   13.45 +            return 0;
   13.46 +        }
   13.47      }
   13.48      return addr;
   13.49  
   13.50 @@ -73,8 +70,8 @@ void * mfn_mapper_map_batch(int xc_handl
   13.51  /*******************/
   13.52  
   13.53  void * mfn_mapper_map_single(int xc_handle, domid_t dom,
   13.54 -			     int size, int prot,
   13.55 -			     unsigned long mfn )
   13.56 +                             int size, int prot,
   13.57 +                             unsigned long mfn )
   13.58  {
   13.59      privcmd_mmap_t ioctlx; 
   13.60      privcmd_mmap_entry_t entry; 
   13.61 @@ -82,17 +79,17 @@ void * mfn_mapper_map_single(int xc_hand
   13.62      addr = mmap( NULL, size, prot, MAP_SHARED, xc_handle, 0 );
   13.63      if (addr)
   13.64      {
   13.65 -	ioctlx.num=1;
   13.66 -	ioctlx.dom=dom;
   13.67 -	ioctlx.entry=&entry;
   13.68 -	entry.va=(unsigned long) addr;
   13.69 -	entry.mfn=mfn;
   13.70 -	entry.npages=(size+PAGE_SIZE-1)>>PAGE_SHIFT;
   13.71 -	if ( ioctl( xc_handle, IOCTL_PRIVCMD_MMAP, &ioctlx ) <0 )
   13.72 -	{
   13.73 -	    munmap(addr, size);
   13.74 -	    return 0;
   13.75 -	}
   13.76 +        ioctlx.num=1;
   13.77 +        ioctlx.dom=dom;
   13.78 +        ioctlx.entry=&entry;
   13.79 +        entry.va=(unsigned long) addr;
   13.80 +        entry.mfn=mfn;
   13.81 +        entry.npages=(size+PAGE_SIZE-1)>>PAGE_SHIFT;
   13.82 +        if ( ioctl( xc_handle, IOCTL_PRIVCMD_MMAP, &ioctlx ) <0 )
   13.83 +        {
   13.84 +            munmap(addr, size);
   13.85 +            return 0;
   13.86 +        }
   13.87      }
   13.88      return addr;
   13.89  }
   13.90 @@ -101,7 +98,7 @@ void * mfn_mapper_map_single(int xc_hand
   13.91  
   13.92  /* NB: arr must be mlock'ed */
   13.93  int get_pfn_type_batch(int xc_handle, 
   13.94 -		       u64 dom, int num, unsigned long *arr)
   13.95 +                       u32 dom, int num, unsigned long *arr)
   13.96  {
   13.97      dom0_op_t op;
   13.98      op.cmd = DOM0_GETPAGEFRAMEINFO2;
   13.99 @@ -113,8 +110,8 @@ int get_pfn_type_batch(int xc_handle,
  13.100  
  13.101  #define GETPFN_ERR (~0U)
  13.102  unsigned int get_pfn_type(int xc_handle, 
  13.103 -			  unsigned long mfn, 
  13.104 -			  u64 dom)
  13.105 +                          unsigned long mfn, 
  13.106 +                          u32 dom)
  13.107  {
  13.108      dom0_op_t op;
  13.109      op.cmd = DOM0_GETPAGEFRAMEINFO;
  13.110 @@ -132,7 +129,7 @@ unsigned int get_pfn_type(int xc_handle,
  13.111  
  13.112  /*******************/
  13.113  
  13.114 -#define FIRST_MMU_UPDATE 2
  13.115 +#define FIRST_MMU_UPDATE 1
  13.116  
  13.117  static int flush_mmu_updates(int xc_handle, mmu_t *mmu)
  13.118  {
  13.119 @@ -145,12 +142,8 @@ static int flush_mmu_updates(int xc_hand
  13.120      /* The first two requests set the correct subject domain (PTS and GPS). */
  13.121      mmu->updates[0].val  = (unsigned long)(mmu->subject<<16) & ~0xFFFFUL;
  13.122      mmu->updates[0].ptr  = (unsigned long)(mmu->subject<< 0) & ~0xFFFFUL;
  13.123 -    mmu->updates[1].val  = (unsigned long)(mmu->subject>>16) & ~0xFFFFUL;
  13.124 -    mmu->updates[1].ptr  = (unsigned long)(mmu->subject>>32) & ~0xFFFFUL;
  13.125      mmu->updates[0].ptr |= MMU_EXTENDED_COMMAND;
  13.126 -    mmu->updates[0].val |= MMUEXT_SET_SUBJECTDOM_L;
  13.127 -    mmu->updates[1].ptr |= MMU_EXTENDED_COMMAND;
  13.128 -    mmu->updates[1].val |= MMUEXT_SET_SUBJECTDOM_H | SET_PAGETABLE_SUBJECTDOM;
  13.129 +    mmu->updates[0].val |= MMUEXT_SET_SUBJECTDOM | SET_PAGETABLE_SUBJECTDOM;
  13.130  
  13.131      hypercall.op     = __HYPERVISOR_mmu_update;
  13.132      hypercall.arg[0] = (unsigned long)mmu->updates;
  13.133 @@ -211,46 +204,43 @@ int finish_mmu_updates(int xc_handle, mm
  13.134  /* this function is a hack until we get proper synchronous domain stop */
  13.135  
  13.136  int xc_domain_stop_sync( int xc_handle, domid_t domid,
  13.137 -			 dom0_op_t *op, full_execution_context_t *ctxt)
  13.138 +                         dom0_op_t *op, full_execution_context_t *ctxt)
  13.139  {
  13.140      int i;
  13.141  
  13.142      printf("Sleep:");
  13.143  
  13.144 -    for(i=0;;i++)
  13.145 +    for( i = 0; ; i++ )
  13.146      {    
  13.147  
  13.148 -	op->cmd = DOM0_STOPDOMAIN;
  13.149 -	op->u.stopdomain.domain = (domid_t)domid;
  13.150 -	op->u.stopdomain.sync = 1;
  13.151 -	do_dom0_op(xc_handle, op);
  13.152 -	/* can't trust return code due to sync stop hack :-(( */
  13.153 +        op->cmd = DOM0_STOPDOMAIN;
  13.154 +        op->u.stopdomain.domain = (domid_t)domid;
  13.155 +        op->u.stopdomain.sync = 1;
  13.156 +        do_dom0_op(xc_handle, op);
  13.157 +        /* can't trust return code due to sync stop hack :-(( */
  13.158  
  13.159 -       
  13.160          op->cmd = DOM0_GETDOMAININFO;
  13.161          op->u.getdomaininfo.domain = (domid_t)domid;
  13.162          op->u.getdomaininfo.ctxt = ctxt;
  13.163          if ( (do_dom0_op(xc_handle, op) < 0) || 
  13.164 -             ((u64)op->u.getdomaininfo.domain != domid) )
  13.165 +             ((u32)op->u.getdomaininfo.domain != domid) )
  13.166          {
  13.167              PERROR("Could not get info on domain");
  13.168              goto out;
  13.169          }
  13.170  
  13.171          if ( op->u.getdomaininfo.state == DOMSTATE_STOPPED )
  13.172 -	{
  13.173 -	    printf("Domain %lld stopped\n",domid);
  13.174 +        {
  13.175 +            printf("Domain %u stopped\n",domid);
  13.176              return 0;
  13.177 -	}
  13.178 -	
  13.179 -	printf(".");
  13.180 -
  13.181 -	//usleep(1000);
  13.182 +        }
  13.183 + 
  13.184 +        printf(".");
  13.185      }
  13.186  
  13.187      printf("\n");
  13.188  
  13.189 -out:
  13.190 + out:
  13.191      return -1;    
  13.192  }
  13.193  
  13.194 @@ -262,10 +252,10 @@ long long  xc_domain_get_cpu_usage( int 
  13.195      op.u.getdomaininfo.domain = (domid_t)domid;
  13.196      op.u.getdomaininfo.ctxt = NULL;
  13.197      if ( (do_dom0_op(xc_handle, &op) < 0) || 
  13.198 -	 ((u64)op.u.getdomaininfo.domain != domid) )
  13.199 +         ((u32)op.u.getdomaininfo.domain != domid) )
  13.200      {
  13.201 -	PERROR("Could not get info on domain");
  13.202 -	return -1;
  13.203 +        PERROR("Could not get info on domain");
  13.204 +        return -1;
  13.205      }
  13.206      return op.u.getdomaininfo.cpu_time;
  13.207  }
  13.208 @@ -273,18 +263,15 @@ long long  xc_domain_get_cpu_usage( int 
  13.209  
  13.210  /**********************************************************************/
  13.211  
  13.212 -// this is shared between save and restore, and may be useful.
  13.213 -
  13.214 -unsigned long csum_page ( void * page )
  13.215 +/* This is shared between save and restore, and may generally be useful. */
  13.216 +unsigned long csum_page (void * page)
  13.217  {
  13.218      int i;
  13.219      unsigned long *p = page;
  13.220      unsigned long long sum=0;
  13.221  
  13.222 -    for (i=0;i<PAGE_SIZE/sizeof(unsigned long);i++)
  13.223 -    {
  13.224 -	sum += p[i];
  13.225 -    }
  13.226 +    for ( i = 0; i < (PAGE_SIZE/sizeof(unsigned long)); i++ )
  13.227 +        sum += p[i];
  13.228  
  13.229      return sum ^ (sum>>32);
  13.230  }
    14.1 --- a/tools/xc/lib/xc_vbd.c	Thu Jun 03 09:31:38 2004 +0000
    14.2 +++ b/tools/xc/lib/xc_vbd.c	Thu Jun 03 11:45:16 2004 +0000
    14.3 @@ -10,7 +10,7 @@
    14.4  #include "xc_private.h"
    14.5  
    14.6  int xc_vbd_create(int xc_handle,
    14.7 -                  u64 domid, 
    14.8 +                  u32 domid, 
    14.9                    unsigned short vbdid, 
   14.10                    int writeable)
   14.11  {
   14.12 @@ -24,7 +24,7 @@ int xc_vbd_create(int xc_handle,
   14.13  
   14.14  
   14.15  int xc_vbd_destroy(int xc_handle,
   14.16 -                   u64 domid, 
   14.17 +                   u32 domid, 
   14.18                     unsigned short vbdid)
   14.19  {
   14.20      block_io_op_t op; 
   14.21 @@ -36,7 +36,7 @@ int xc_vbd_destroy(int xc_handle,
   14.22  
   14.23  
   14.24  int xc_vbd_grow(int xc_handle,
   14.25 -                u64 domid, 
   14.26 +                u32 domid, 
   14.27                  unsigned short vbdid,
   14.28                  xc_vbdextent_t *extent)
   14.29  {
   14.30 @@ -52,7 +52,7 @@ int xc_vbd_grow(int xc_handle,
   14.31  
   14.32  
   14.33  int xc_vbd_shrink(int xc_handle,
   14.34 -                  u64 domid, 
   14.35 +                  u32 domid, 
   14.36                    unsigned short vbdid)
   14.37  {
   14.38      block_io_op_t op; 
   14.39 @@ -64,7 +64,7 @@ int xc_vbd_shrink(int xc_handle,
   14.40  
   14.41  
   14.42  int xc_vbd_setextents(int xc_handle,
   14.43 -                      u64 domid, 
   14.44 +                      u32 domid, 
   14.45                        unsigned short vbdid,
   14.46                        unsigned int nr_extents,
   14.47                        xc_vbdextent_t *extents)
   14.48 @@ -112,7 +112,7 @@ int xc_vbd_setextents(int xc_handle,
   14.49  
   14.50  
   14.51  int xc_vbd_getextents(int xc_handle,
   14.52 -                      u64 domid, 
   14.53 +                      u32 domid, 
   14.54                        unsigned short vbdid,
   14.55                        unsigned int max_extents,
   14.56                        xc_vbdextent_t *extents,
   14.57 @@ -161,7 +161,7 @@ int xc_vbd_getextents(int xc_handle,
   14.58  
   14.59  
   14.60  int xc_vbd_probe(int xc_handle,
   14.61 -                 u64 domid,
   14.62 +                 u32 domid,
   14.63                   unsigned int max_vbds,
   14.64                   xc_vbd_t *vbds)
   14.65  {
   14.66 @@ -194,7 +194,7 @@ int xc_vbd_probe(int xc_handle,
   14.67              if ( !(xdi->disks[i].info & XD_FLAG_VIRT) )
   14.68                  continue;
   14.69              
   14.70 -            vbds[j].domid = (u64)xdi->disks[i].domain;
   14.71 +            vbds[j].domid = (u32)xdi->disks[i].domain;
   14.72              vbds[j].vbdid = xdi->disks[i].device;
   14.73              vbds[j].flags = (xdi->disks[i].info & XD_FLAG_RO) ? 
   14.74                  0 : XC_VBDF_WRITEABLE;
    15.1 --- a/tools/xc/lib/xc_vif.c	Thu Jun 03 09:31:38 2004 +0000
    15.2 +++ b/tools/xc/lib/xc_vif.c	Thu Jun 03 11:45:16 2004 +0000
    15.3 @@ -9,7 +9,7 @@
    15.4  #include "xc_private.h"
    15.5  
    15.6  int xc_vif_scheduler_set(int xc_handle,
    15.7 -                         u64 domid, 
    15.8 +                         u32 domid, 
    15.9                           unsigned int vifid, 
   15.10                           xc_vif_sched_params_t *params)
   15.11  {
   15.12 @@ -24,7 +24,7 @@ int xc_vif_scheduler_set(int xc_handle,
   15.13  
   15.14  
   15.15  int xc_vif_scheduler_get(int xc_handle,
   15.16 -                         u64 domid, 
   15.17 +                         u32 domid, 
   15.18                           unsigned int vifid, 
   15.19                           xc_vif_sched_params_t *params)
   15.20  {
   15.21 @@ -46,7 +46,7 @@ int xc_vif_scheduler_get(int xc_handle,
   15.22  
   15.23  
   15.24  int xc_vif_stats_get(int xc_handle,
   15.25 -                     u64 domid, 
   15.26 +                     u32 domid, 
   15.27                       unsigned int vifid, 
   15.28                       xc_vif_stats_t *stats)
   15.29  {
    16.1 --- a/tools/xc/py/Xc.c	Thu Jun 03 09:31:38 2004 +0000
    16.2 +++ b/tools/xc/py/Xc.c	Thu Jun 03 11:45:16 2004 +0000
    16.3 @@ -40,7 +40,7 @@ static PyObject *pyxc_domain_create(PyOb
    16.4      unsigned int mem_kb = 0;
    16.5      char        *name   = "(anon)";
    16.6      int          cpu = -1;
    16.7 -    u64          dom;
    16.8 +    u32          dom;
    16.9      int          ret;
   16.10  
   16.11      static char *kwd_list[] = { "mem_kb", "name", "cpu", NULL };
   16.12 @@ -52,7 +52,7 @@ static PyObject *pyxc_domain_create(PyOb
   16.13      if ( (ret = xc_domain_create(xc->xc_handle, mem_kb, name, cpu, &dom)) < 0 )
   16.14          return PyErr_SetFromErrno(xc_error);
   16.15  
   16.16 -    return PyLong_FromUnsignedLongLong(dom);
   16.17 +    return PyInt_FromLong(dom);
   16.18  }
   16.19  
   16.20  static PyObject *pyxc_domain_start(PyObject *self,
   16.21 @@ -61,11 +61,11 @@ static PyObject *pyxc_domain_start(PyObj
   16.22  {
   16.23      XcObject *xc = (XcObject *)self;
   16.24  
   16.25 -    u64 dom;
   16.26 +    u32 dom;
   16.27  
   16.28      static char *kwd_list[] = { "dom", NULL };
   16.29  
   16.30 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "L", kwd_list, &dom) )
   16.31 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) )
   16.32          return NULL;
   16.33  
   16.34      if ( xc_domain_start(xc->xc_handle, dom) != 0 )
   16.35 @@ -81,11 +81,11 @@ static PyObject *pyxc_domain_stop(PyObje
   16.36  {
   16.37      XcObject *xc = (XcObject *)self;
   16.38  
   16.39 -    u64 dom;
   16.40 +    u32 dom;
   16.41  
   16.42      static char *kwd_list[] = { "dom", NULL };
   16.43  
   16.44 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "L", kwd_list, &dom) )
   16.45 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) )
   16.46          return NULL;
   16.47  
   16.48      if ( xc_domain_stop(xc->xc_handle, dom) != 0 )
   16.49 @@ -101,12 +101,12 @@ static PyObject *pyxc_domain_destroy(PyO
   16.50  {
   16.51      XcObject *xc = (XcObject *)self;
   16.52  
   16.53 -    u64 dom;
   16.54 +    u32 dom;
   16.55      int force = 0;
   16.56  
   16.57      static char *kwd_list[] = { "dom", "force", NULL };
   16.58  
   16.59 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "L|i", kwd_list, 
   16.60 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list, 
   16.61                                        &dom, &force) )
   16.62          return NULL;
   16.63  
   16.64 @@ -118,17 +118,17 @@ static PyObject *pyxc_domain_destroy(PyO
   16.65  }
   16.66  
   16.67  static PyObject *pyxc_domain_pincpu(PyObject *self,
   16.68 -                                     PyObject *args,
   16.69 -                                     PyObject *kwds)
   16.70 +                                    PyObject *args,
   16.71 +                                    PyObject *kwds)
   16.72  {
   16.73      XcObject *xc = (XcObject *)self;
   16.74  
   16.75 -    u64 dom;
   16.76 +    u32 dom;
   16.77      int cpu = -1;
   16.78  
   16.79      static char *kwd_list[] = { "dom", "cpu", NULL };
   16.80  
   16.81 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "L|i", kwd_list, 
   16.82 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list, 
   16.83                                        &dom, &cpu) )
   16.84          return NULL;
   16.85  
   16.86 @@ -146,13 +146,13 @@ static PyObject *pyxc_domain_getinfo(PyO
   16.87      XcObject *xc = (XcObject *)self;
   16.88      PyObject *list;
   16.89  
   16.90 -    u64 first_dom = 0;
   16.91 +    u32 first_dom = 0;
   16.92      int max_doms = 1024, nr_doms, i;
   16.93      xc_dominfo_t *info;
   16.94  
   16.95      static char *kwd_list[] = { "first_dom", "max_doms", NULL };
   16.96      
   16.97 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|Li", kwd_list,
   16.98 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|ii", kwd_list,
   16.99                                        &first_dom, &max_doms) )
  16.100          return NULL;
  16.101  
  16.102 @@ -166,7 +166,7 @@ static PyObject *pyxc_domain_getinfo(PyO
  16.103      {
  16.104          PyList_SetItem(
  16.105              list, i, 
  16.106 -            Py_BuildValue("{s:L,s:i,s:i,s:i,s:l,s:L,s:s,s:l}",
  16.107 +            Py_BuildValue("{s:i,s:i,s:i,s:i,s:l,s:L,s:s,s:l}",
  16.108                            "dom",      info[i].domid,
  16.109                            "cpu",      info[i].cpu,
  16.110                            "running",  info[i].has_cpu,
  16.111 @@ -175,7 +175,7 @@ static PyObject *pyxc_domain_getinfo(PyO
  16.112                            "cpu_time", info[i].cpu_time,
  16.113                            "name",     info[i].name,
  16.114                            "maxmem_kb",info[i].max_memkb
  16.115 -		));
  16.116 +                ));
  16.117      }
  16.118  
  16.119      free(info);
  16.120 @@ -189,15 +189,17 @@ static PyObject *pyxc_linux_save(PyObjec
  16.121  {
  16.122      XcObject *xc = (XcObject *)self;
  16.123  
  16.124 -    u64   dom;
  16.125 +    u32   dom;
  16.126      char *state_file;
  16.127      int   progress = 1, live = -1, debug = 0;
  16.128      unsigned int flags = 0;
  16.129  
  16.130 -    static char *kwd_list[] = { "dom", "state_file", "progress", "live", "debug", NULL };
  16.131 +    static char *kwd_list[] = { "dom", "state_file", "progress", 
  16.132 +                                "live", "debug", NULL };
  16.133  
  16.134 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Ls|iii", kwd_list, 
  16.135 -                                      &dom, &state_file, &progress, &live, &debug) )
  16.136 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is|iii", kwd_list, 
  16.137 +                                      &dom, &state_file, &progress, 
  16.138 +                                      &live, &debug) )
  16.139          return NULL;
  16.140  
  16.141      if (progress)  flags |= XCFLAGS_VERBOSE;
  16.142 @@ -207,136 +209,136 @@ static PyObject *pyxc_linux_save(PyObjec
  16.143      if ( strncmp(state_file,"tcp:", strlen("tcp:")) == 0 )
  16.144      {
  16.145  #define max_namelen 64
  16.146 -	char server[max_namelen];
  16.147 -	char *port_s;
  16.148 -	int port=777;
  16.149 -	int sd = -1;
  16.150 -	struct hostent *h;
  16.151 -	struct sockaddr_in s;
  16.152 -	int sockbufsize;
  16.153 -	int rc = -1;
  16.154 +        char server[max_namelen];
  16.155 +        char *port_s;
  16.156 +        int port=777;
  16.157 +        int sd = -1;
  16.158 +        struct hostent *h;
  16.159 +        struct sockaddr_in s;
  16.160 +        int sockbufsize;
  16.161 +        int rc = -1;
  16.162  
  16.163 -	int writerfn(void *fd, const void *buf, size_t count)
  16.164 -	{
  16.165 -	    int tot = 0, rc;
  16.166 -	    do {
  16.167 -		rc = write( (int) fd, ((char*)buf)+tot, count-tot );
  16.168 -		if ( rc < 0 ) { perror("WRITE"); return rc; };
  16.169 -		tot += rc;
  16.170 -	    }
  16.171 -	    while ( tot < count );
  16.172 -	    return 0;
  16.173 -	}
  16.174 +        int writerfn(void *fd, const void *buf, size_t count)
  16.175 +        {
  16.176 +            int tot = 0, rc;
  16.177 +            do {
  16.178 +                rc = write( (int) fd, ((char*)buf)+tot, count-tot );
  16.179 +                if ( rc < 0 ) { perror("WRITE"); return rc; };
  16.180 +                tot += rc;
  16.181 +            }
  16.182 +            while ( tot < count );
  16.183 +            return 0;
  16.184 +        }
  16.185  
  16.186 -	if (live == -1) flags |= XCFLAGS_LIVE; // default to live for tcp
  16.187 +        if (live == -1) flags |= XCFLAGS_LIVE; /* default to live for tcp */
  16.188  
  16.189 -	strncpy( server, state_file+strlen("tcp://"), max_namelen);
  16.190 -	server[max_namelen-1]='\0';
  16.191 -	if ( (port_s = strchr(server,':')) != NULL )
  16.192 -	{
  16.193 -	    *port_s = '\0';
  16.194 -	    port = atoi(port_s+1);
  16.195 -	}
  16.196 +        strncpy( server, state_file+strlen("tcp://"), max_namelen);
  16.197 +        server[max_namelen-1]='\0';
  16.198 +        if ( (port_s = strchr(server,':')) != NULL )
  16.199 +        {
  16.200 +            *port_s = '\0';
  16.201 +            port = atoi(port_s+1);
  16.202 +        }
  16.203  
  16.204 -	printf("X server=%s port=%d\n",server,port);
  16.205 -	
  16.206 -	h = gethostbyname(server);
  16.207 -	sd = socket (AF_INET,SOCK_STREAM,0);
  16.208 -	if ( sd < 0 )
  16.209 +        printf("X server=%s port=%d\n",server,port);
  16.210 + 
  16.211 +        h = gethostbyname(server);
  16.212 +        sd = socket (AF_INET,SOCK_STREAM,0);
  16.213 +        if ( sd < 0 )
  16.214              goto serr;
  16.215 -	s.sin_family = AF_INET;
  16.216 -	bcopy ( h->h_addr, &(s.sin_addr.s_addr), h->h_length);
  16.217 -	s.sin_port = htons(port);
  16.218 -	if ( connect(sd, (struct sockaddr *) &s, sizeof(s)) ) 
  16.219 -	    goto serr;
  16.220 +        s.sin_family = AF_INET;
  16.221 +        bcopy ( h->h_addr, &(s.sin_addr.s_addr), h->h_length);
  16.222 +        s.sin_port = htons(port);
  16.223 +        if ( connect(sd, (struct sockaddr *) &s, sizeof(s)) ) 
  16.224 +            goto serr;
  16.225  
  16.226 -	sockbufsize=128*1024;
  16.227 -	if ( setsockopt(sd, SOL_SOCKET, SO_SNDBUF, 
  16.228 +        sockbufsize=128*1024;
  16.229 +        if ( setsockopt(sd, SOL_SOCKET, SO_SNDBUF, 
  16.230                          &sockbufsize, sizeof sockbufsize) < 0 ) 
  16.231 -	    goto serr;
  16.232 +            goto serr;
  16.233  
  16.234 -	if ( xc_linux_save(xc->xc_handle, dom, flags, 
  16.235 +        if ( xc_linux_save(xc->xc_handle, dom, flags, 
  16.236                             writerfn, (void*)sd) == 0 )
  16.237 -	{
  16.238 -	    if ( read( sd, &rc, sizeof(int) ) != sizeof(int) )
  16.239 -		goto serr;
  16.240 -		
  16.241 -	    if ( rc == 0 )
  16.242 -	    {
  16.243 -		printf("Migration succesful -- destroy local copy\n");
  16.244 -		xc_domain_destroy( xc->xc_handle, dom, 1 );
  16.245 -		close(sd);
  16.246 -		Py_INCREF(zero);
  16.247 -		return zero;
  16.248 -	    }
  16.249 -	    else
  16.250 -		errno = rc;
  16.251 -	}
  16.252 +        {
  16.253 +            if ( read( sd, &rc, sizeof(int) ) != sizeof(int) )
  16.254 +                goto serr;
  16.255 +  
  16.256 +            if ( rc == 0 )
  16.257 +            {
  16.258 +                printf("Migration succesful -- destroy local copy\n");
  16.259 +                xc_domain_destroy( xc->xc_handle, dom, 1 );
  16.260 +                close(sd);
  16.261 +                Py_INCREF(zero);
  16.262 +                return zero;
  16.263 +            }
  16.264 +            else
  16.265 +                errno = rc;
  16.266 +        }
  16.267  
  16.268      serr:
  16.269 -	printf("Migration failed -- restart local copy\n");
  16.270 -	xc_domain_start( xc->xc_handle, dom );
  16.271 -	PyErr_SetFromErrno(xc_error);
  16.272 -	if ( sd >= 0 ) close(sd);
  16.273 -	return NULL;
  16.274 +        printf("Migration failed -- restart local copy\n");
  16.275 +        xc_domain_start( xc->xc_handle, dom );
  16.276 +        PyErr_SetFromErrno(xc_error);
  16.277 +        if ( sd >= 0 ) close(sd);
  16.278 +        return NULL;
  16.279      }    
  16.280      else
  16.281      {
  16.282 -	int fd = -1;
  16.283 -	gzFile gfd = NULL;
  16.284 +        int fd = -1;
  16.285 +        gzFile gfd = NULL;
  16.286  
  16.287 -	int writerfn(void *fd, const void *buf, size_t count)
  16.288 -	{
  16.289 -	    int rc;
  16.290 -	    while ( ((rc = gzwrite( (gzFile*)fd, (void*)buf, count)) == -1) && 
  16.291 -		    (errno = EINTR) )
  16.292 -		continue;
  16.293 -	    return ! (rc == count);
  16.294 -	}
  16.295 +        int writerfn(void *fd, const void *buf, size_t count)
  16.296 +        {
  16.297 +            int rc;
  16.298 +            while ( ((rc = gzwrite( (gzFile*)fd, (void*)buf, count)) == -1) && 
  16.299 +                    (errno = EINTR) )
  16.300 +                continue;
  16.301 +            return ! (rc == count);
  16.302 +        }
  16.303  
  16.304 -	if (strncmp(state_file,"file:",strlen("file:")) == 0)
  16.305 -	    state_file += strlen("file:");
  16.306 +        if (strncmp(state_file,"file:",strlen("file:")) == 0)
  16.307 +            state_file += strlen("file:");
  16.308  
  16.309 -	if ( (fd = open(state_file, O_CREAT|O_EXCL|O_WRONLY, 0644)) == -1 )
  16.310 -	{
  16.311 -	    perror("Could not open file for writing");
  16.312 -	    goto err;
  16.313 -	}
  16.314 +        if ( (fd = open(state_file, O_CREAT|O_EXCL|O_WRONLY, 0644)) == -1 )
  16.315 +        {
  16.316 +            perror("Could not open file for writing");
  16.317 +            goto err;
  16.318 +        }
  16.319  
  16.320 -	/*
  16.321 -	 * Compression rate 1: we want speed over compression. 
  16.322 -	 * We're mainly going for those zero pages, after all.
  16.323 -	 */
  16.324 +        /*
  16.325 +         * Compression rate 1: we want speed over compression. 
  16.326 +         * We're mainly going for those zero pages, after all.
  16.327 +         */
  16.328  
  16.329 -	if ( (gfd = gzdopen(fd, "wb1")) == NULL )
  16.330 -	{
  16.331 -	    perror("Could not allocate compression state for state file");
  16.332 -	    close(fd);
  16.333 -	    goto err;
  16.334 -	}
  16.335 +        if ( (gfd = gzdopen(fd, "wb1")) == NULL )
  16.336 +        {
  16.337 +            perror("Could not allocate compression state for state file");
  16.338 +            close(fd);
  16.339 +            goto err;
  16.340 +        }
  16.341  
  16.342  
  16.343 -	if ( xc_linux_save(xc->xc_handle, dom, flags, writerfn, gfd) == 0 )
  16.344 -	{
  16.345 -	    /* kill domain. We don't want to do this for checkpointing, but
  16.346 -	       if we don't do it here I think people will hurt themselves
  16.347 -	       by accident... */
  16.348 -	    xc_domain_destroy( xc->xc_handle, dom, 1 );
  16.349 -	    gzclose(gfd);
  16.350 -	    close(fd);
  16.351 +        if ( xc_linux_save(xc->xc_handle, dom, flags, writerfn, gfd) == 0 )
  16.352 +        {
  16.353 +            /* kill domain. We don't want to do this for checkpointing, but
  16.354 +               if we don't do it here I think people will hurt themselves
  16.355 +               by accident... */
  16.356 +            xc_domain_destroy( xc->xc_handle, dom, 1 );
  16.357 +            gzclose(gfd);
  16.358 +            close(fd);
  16.359  
  16.360 -	    Py_INCREF(zero);
  16.361 -	    return zero;
  16.362 -	}
  16.363 +            Py_INCREF(zero);
  16.364 +            return zero;
  16.365 +        }
  16.366  
  16.367      err:
  16.368 -	PyErr_SetFromErrno(xc_error);
  16.369 -	if ( gfd != NULL )
  16.370 +        PyErr_SetFromErrno(xc_error);
  16.371 +        if ( gfd != NULL )
  16.372              gzclose(gfd);
  16.373 -	if ( fd >= 0 )
  16.374 +        if ( fd >= 0 )
  16.375              close(fd);
  16.376 -	unlink(state_file);
  16.377 -	return NULL;
  16.378 +        unlink(state_file);
  16.379 +        return NULL;
  16.380      }
  16.381  
  16.382  }
  16.383 @@ -349,12 +351,12 @@ static PyObject *pyxc_linux_restore(PyOb
  16.384  
  16.385      char        *state_file;
  16.386      int          progress = 1;
  16.387 -    u64          dom;
  16.388 +    u32          dom;
  16.389      unsigned int flags = 0;
  16.390  
  16.391      static char *kwd_list[] = { "dom", "state_file", "progress", NULL };
  16.392  
  16.393 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Ls|i", kwd_list, 
  16.394 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is|i", kwd_list, 
  16.395                                        &dom, &state_file, &progress) )
  16.396          return NULL;
  16.397  
  16.398 @@ -364,142 +366,141 @@ static PyObject *pyxc_linux_restore(PyOb
  16.399      if ( strncmp(state_file,"tcp:", strlen("tcp:")) == 0 )
  16.400      {
  16.401  #define max_namelen 64
  16.402 -	char server[max_namelen];
  16.403 -	char *port_s;
  16.404 -	int port=777;
  16.405 -	int ld = -1, sd = -1;
  16.406 -	struct hostent *h;
  16.407 -	struct sockaddr_in s, d, p;
  16.408 -	socklen_t dlen, plen;
  16.409 -	int sockbufsize;
  16.410 -	int on = 1, rc = -1;
  16.411 +        char server[max_namelen];
  16.412 +        char *port_s;
  16.413 +        int port=777;
  16.414 +        int ld = -1, sd = -1;
  16.415 +        struct hostent *h;
  16.416 +        struct sockaddr_in s, d, p;
  16.417 +        socklen_t dlen, plen;
  16.418 +        int sockbufsize;
  16.419 +        int on = 1, rc = -1;
  16.420  
  16.421 -	int readerfn(void *fd, void *buf, size_t count)
  16.422 -	{
  16.423 -	    int rc, tot = 0;
  16.424 -	    do { 
  16.425 -		rc = read( (int) fd, ((char*)buf)+tot, count-tot ); 
  16.426 -		if ( rc < 0 ) { perror("READ"); return rc; }
  16.427 -		if ( rc == 0 ) { printf("read: need %d, tot=%d got zero\n",count-tot,tot); return -1; }
  16.428 -		tot += rc;
  16.429 -	    } 
  16.430 +        int readerfn(void *fd, void *buf, size_t count)
  16.431 +        {
  16.432 +            int rc, tot = 0;
  16.433 +            do { 
  16.434 +                rc = read( (int) fd, ((char*)buf)+tot, count-tot ); 
  16.435 +                if ( rc < 0 ) { perror("READ"); return rc; }
  16.436 +                if ( rc == 0 ) { printf("read: need %d, tot=%d got zero\n",
  16.437 +                                        count-tot, tot); return -1; }
  16.438 +                tot += rc;
  16.439 +            } 
  16.440              while ( tot < count );
  16.441 -	    return 0;
  16.442 -	}
  16.443 +            return 0;
  16.444 +        }
  16.445  
  16.446 -	strncpy( server, state_file+strlen("tcp://"), max_namelen);
  16.447 -	server[max_namelen-1]='\0';
  16.448 -	if ( (port_s = strchr(server,':')) != NULL )
  16.449 -	{
  16.450 -	    *port_s = '\0';
  16.451 -	    port = atoi(port_s+1);
  16.452 -	}
  16.453 +        strncpy( server, state_file+strlen("tcp://"), max_namelen);
  16.454 +        server[max_namelen-1]='\0';
  16.455 +        if ( (port_s = strchr(server,':')) != NULL )
  16.456 +        {
  16.457 +            *port_s = '\0';
  16.458 +            port = atoi(port_s+1);
  16.459 +        }
  16.460  
  16.461 -	printf("X server=%s port=%d\n",server,port);
  16.462 -	
  16.463 -	h = gethostbyname(server);
  16.464 -	ld = socket (AF_INET,SOCK_STREAM,0);
  16.465 -	if ( ld < 0 ) goto serr;
  16.466 -	s.sin_family = AF_INET;
  16.467 -	//bcopy ( h->h_addr, &(s.sin_addr.s_addr), h->h_length);
  16.468 -	s.sin_addr.s_addr = htonl(INADDR_ANY);
  16.469 -	s.sin_port = htons(port);
  16.470 +        printf("X server=%s port=%d\n",server,port);
  16.471 + 
  16.472 +        h = gethostbyname(server);
  16.473 +        ld = socket (AF_INET,SOCK_STREAM,0);
  16.474 +        if ( ld < 0 ) goto serr;
  16.475 +        s.sin_family = AF_INET;
  16.476 +        s.sin_addr.s_addr = htonl(INADDR_ANY);
  16.477 +        s.sin_port = htons(port);
  16.478  
  16.479 -	if ( setsockopt(ld, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0 )
  16.480 -	    goto serr;
  16.481 +        if ( setsockopt(ld, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0 )
  16.482 +            goto serr;
  16.483  
  16.484 -	if ( bind(ld, (struct sockaddr *) &s, sizeof(s)) ) 
  16.485 -	    goto serr;
  16.486 +        if ( bind(ld, (struct sockaddr *) &s, sizeof(s)) ) 
  16.487 +            goto serr;
  16.488  
  16.489 -	if ( listen(ld, 1) )
  16.490 -	    goto serr;
  16.491 +        if ( listen(ld, 1) )
  16.492 +            goto serr;
  16.493  
  16.494 -	dlen=sizeof(struct sockaddr);
  16.495 -	if ( (sd = accept(ld, (struct sockaddr *) &d, &dlen )) < 0 )
  16.496 -	    goto serr;
  16.497 +        dlen=sizeof(struct sockaddr);
  16.498 +        if ( (sd = accept(ld, (struct sockaddr *) &d, &dlen )) < 0 )
  16.499 +            goto serr;
  16.500  
  16.501          plen = sizeof(p);
  16.502 -	if ( getpeername(sd, (struct sockaddr_in *) &p, 
  16.503 +        if ( getpeername(sd, (struct sockaddr_in *) &p, 
  16.504                           &plen) < 0 )
  16.505 -	    goto serr;
  16.506 +            goto serr;
  16.507  
  16.508 -	printf("Accepted connection from %s\n", inet_ntoa(p.sin_addr));
  16.509 -	
  16.510 -	sockbufsize=128*1024;
  16.511 -	if ( setsockopt(sd, SOL_SOCKET, SO_SNDBUF, &sockbufsize, 
  16.512 +        printf("Accepted connection from %s\n", inet_ntoa(p.sin_addr));
  16.513 + 
  16.514 +        sockbufsize=128*1024;
  16.515 +        if ( setsockopt(sd, SOL_SOCKET, SO_SNDBUF, &sockbufsize, 
  16.516                          sizeof sockbufsize) < 0 ) 
  16.517 -	    goto serr;
  16.518 +            goto serr;
  16.519  
  16.520 -	rc = xc_linux_restore(xc->xc_handle, dom, flags, 
  16.521 +        rc = xc_linux_restore(xc->xc_handle, dom, flags, 
  16.522                                readerfn, (void*)sd, &dom);
  16.523  
  16.524 -	write( sd, &rc, sizeof(int) ); 
  16.525 +        write( sd, &rc, sizeof(int) ); 
  16.526  
  16.527 -	if (rc == 0)
  16.528 -	{
  16.529 -	    close(sd);
  16.530 -	    Py_INCREF(zero);
  16.531 -	    return zero;
  16.532 -	}
  16.533 -	errno = rc;
  16.534 +        if (rc == 0)
  16.535 +        {
  16.536 +            close(sd);
  16.537 +            Py_INCREF(zero);
  16.538 +            return zero;
  16.539 +        }
  16.540 +        errno = rc;
  16.541  
  16.542      serr:
  16.543 -	PyErr_SetFromErrno(xc_error);
  16.544 -	if ( ld >= 0 ) close(ld);
  16.545 -	if ( sd >= 0 ) close(sd);
  16.546 -	return NULL;
  16.547 +        PyErr_SetFromErrno(xc_error);
  16.548 +        if ( ld >= 0 ) close(ld);
  16.549 +        if ( sd >= 0 ) close(sd);
  16.550 +        return NULL;
  16.551      }    
  16.552      else
  16.553      {
  16.554 -	int fd = -1;
  16.555 -	gzFile gfd = NULL;
  16.556 +        int fd = -1;
  16.557 +        gzFile gfd = NULL;
  16.558  
  16.559 -	int readerfn(void *fd, void *buf, size_t count)
  16.560 -	{
  16.561 -	    int rc;
  16.562 -	    while ( ((rc = gzread( (gzFile*)fd, (void*)buf, count)) == -1) && 
  16.563 -		    (errno = EINTR) )
  16.564 -		continue;
  16.565 -	    return ! (rc == count);
  16.566 -	}
  16.567 +        int readerfn(void *fd, void *buf, size_t count)
  16.568 +        {
  16.569 +            int rc;
  16.570 +            while ( ((rc = gzread( (gzFile*)fd, (void*)buf, count)) == -1) && 
  16.571 +                    (errno = EINTR) )
  16.572 +                continue;
  16.573 +            return ! (rc == count);
  16.574 +        }
  16.575  
  16.576 -	if ( strncmp(state_file,"file:",strlen("file:")) == 0 )
  16.577 -	    state_file += strlen("file:");
  16.578 +        if ( strncmp(state_file,"file:",strlen("file:")) == 0 )
  16.579 +            state_file += strlen("file:");
  16.580  
  16.581 -	if ( (fd = open(state_file, O_RDONLY)) == -1 )
  16.582 -	{
  16.583 -	    perror("Could not open file for writing");
  16.584 -	    goto err;
  16.585 -	}
  16.586 +        if ( (fd = open(state_file, O_RDONLY)) == -1 )
  16.587 +        {
  16.588 +            perror("Could not open file for writing");
  16.589 +            goto err;
  16.590 +        }
  16.591  
  16.592 -	/*
  16.593 -	 * Compression rate 1: we want speed over compression. 
  16.594 -	 * We're mainly going for those zero pages, after all.
  16.595 -	 */
  16.596 -
  16.597 -	if ( (gfd = gzdopen(fd, "rb")) == NULL )
  16.598 -	{
  16.599 -	    perror("Could not allocate compression state for state file");
  16.600 -	    close(fd);
  16.601 -	    goto err;
  16.602 -	}
  16.603 +        /*
  16.604 +         * Compression rate 1: we want speed over compression. 
  16.605 +         * We're mainly going for those zero pages, after all.
  16.606 +         */
  16.607 +        if ( (gfd = gzdopen(fd, "rb")) == NULL )
  16.608 +        {
  16.609 +            perror("Could not allocate compression state for state file");
  16.610 +            close(fd);
  16.611 +            goto err;
  16.612 +        }
  16.613  
  16.614  
  16.615 -	if ( xc_linux_restore(xc->xc_handle, dom, flags, 
  16.616 +        if ( xc_linux_restore(xc->xc_handle, dom, flags, 
  16.617                                readerfn, gfd, &dom) == 0 )
  16.618 -	{
  16.619 -	    gzclose(gfd);
  16.620 -	    close(fd);
  16.621 +        {
  16.622 +            gzclose(gfd);
  16.623 +            close(fd);
  16.624  
  16.625 -	    Py_INCREF(zero);
  16.626 -	    return zero;
  16.627 -	}
  16.628 +            Py_INCREF(zero);
  16.629 +            return zero;
  16.630 +        }
  16.631  
  16.632      err:
  16.633 -	PyErr_SetFromErrno(xc_error);
  16.634 -	if ( gfd != NULL ) gzclose(gfd);
  16.635 -	if ( fd >= 0 ) close(fd);
  16.636 -	return NULL;
  16.637 +        PyErr_SetFromErrno(xc_error);
  16.638 +        if ( gfd != NULL ) gzclose(gfd);
  16.639 +        if ( fd >= 0 ) close(fd);
  16.640 +        return NULL;
  16.641      }
  16.642  
  16.643  }
  16.644 @@ -510,14 +511,14 @@ static PyObject *pyxc_linux_build(PyObje
  16.645  {
  16.646      XcObject *xc = (XcObject *)self;
  16.647  
  16.648 -    u64   dom;
  16.649 +    u32   dom;
  16.650      char *image, *ramdisk = NULL, *cmdline = "";
  16.651      int   control_evtchn;
  16.652  
  16.653      static char *kwd_list[] = { "dom", "control_evtchn", 
  16.654                                  "image", "ramdisk", "cmdline", NULL };
  16.655  
  16.656 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Lis|ss", kwd_list, 
  16.657 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|ss", kwd_list, 
  16.658                                        &dom, &control_evtchn, 
  16.659                                        &image, &ramdisk, &cmdline) )
  16.660          return NULL;
  16.661 @@ -536,14 +537,14 @@ static PyObject *pyxc_netbsd_build(PyObj
  16.662  {
  16.663      XcObject *xc = (XcObject *)self;
  16.664  
  16.665 -    u64   dom;
  16.666 +    u32   dom;
  16.667      char *image, *ramdisk = NULL, *cmdline = "";
  16.668      int   control_evtchn;
  16.669  
  16.670      static char *kwd_list[] = { "dom", "control_evtchn",
  16.671                                  "image", "ramdisk", "cmdline", NULL };
  16.672  
  16.673 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Lis|ssi", kwd_list, 
  16.674 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|ssi", kwd_list, 
  16.675                                        &dom, &control_evtchn,
  16.676                                        &image, &ramdisk, &cmdline) )
  16.677          return NULL;
  16.678 @@ -577,8 +578,8 @@ static PyObject *pyxc_bvtsched_global_se
  16.679  }
  16.680  
  16.681  static PyObject *pyxc_bvtsched_global_get(PyObject *self,
  16.682 -					  PyObject *args,
  16.683 -					  PyObject *kwds)
  16.684 +                                          PyObject *args,
  16.685 +                                          PyObject *kwds)
  16.686  {
  16.687      XcObject *xc = (XcObject *)self;
  16.688      
  16.689 @@ -599,13 +600,13 @@ static PyObject *pyxc_bvtsched_domain_se
  16.690  {
  16.691      XcObject *xc = (XcObject *)self;
  16.692  
  16.693 -    u64           dom;
  16.694 +    u32           dom;
  16.695      unsigned long mcuadv, warp, warpl, warpu;
  16.696  
  16.697      static char *kwd_list[] = { "dom", "mcuadv", "warp", "warpl",
  16.698                                  "warpu", NULL };
  16.699  
  16.700 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Lllll", kwd_list,
  16.701 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "illll", kwd_list,
  16.702                                        &dom, &mcuadv, &warp, &warpl, &warpu) )
  16.703          return NULL;
  16.704  
  16.705 @@ -622,19 +623,19 @@ static PyObject *pyxc_bvtsched_domain_ge
  16.706                                            PyObject *kwds)
  16.707  {
  16.708      XcObject *xc = (XcObject *)self;
  16.709 -    u64 dom;
  16.710 +    u32 dom;
  16.711      unsigned long mcuadv, warp, warpl, warpu;
  16.712      
  16.713      static char *kwd_list[] = { "dom", NULL };
  16.714  
  16.715 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "L", kwd_list, &dom) )
  16.716 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) )
  16.717          return NULL;
  16.718      
  16.719      if ( xc_bvtsched_domain_get(xc->xc_handle, dom, &mcuadv, &warp,
  16.720                                  &warpl, &warpu) != 0 )
  16.721          return PyErr_SetFromErrno(xc_error);
  16.722  
  16.723 -    return Py_BuildValue("{s:L,s:l,s:l,s:l,s:l}",
  16.724 +    return Py_BuildValue("{s:i,s:l,s:l,s:l,s:l}",
  16.725                           "domain", dom,
  16.726                           "mcuadv", mcuadv,
  16.727                           "warp",   warp,
  16.728 @@ -648,14 +649,14 @@ static PyObject *pyxc_vif_scheduler_set(
  16.729  {
  16.730      XcObject *xc = (XcObject *)self;
  16.731  
  16.732 -    u64           dom;
  16.733 +    u32           dom;
  16.734      unsigned int  vif;
  16.735      xc_vif_sched_params_t sched = { 0, 0 };
  16.736  
  16.737      static char *kwd_list[] = { "dom", "vif", "credit_bytes", 
  16.738                                  "credit_usecs", NULL };
  16.739  
  16.740 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Li|ll", kwd_list, 
  16.741 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii|ll", kwd_list, 
  16.742                                        &dom, &vif, 
  16.743                                        &sched.credit_bytes, 
  16.744                                        &sched.credit_usec) )
  16.745 @@ -674,13 +675,13 @@ static PyObject *pyxc_vif_scheduler_get(
  16.746  {
  16.747      XcObject *xc = (XcObject *)self;
  16.748  
  16.749 -    u64           dom;
  16.750 +    u32           dom;
  16.751      unsigned int  vif;
  16.752      xc_vif_sched_params_t sched;
  16.753  
  16.754      static char *kwd_list[] = { "dom", "vif", NULL };
  16.755  
  16.756 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Li", kwd_list, 
  16.757 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list, 
  16.758                                        &dom, &vif) )
  16.759          return NULL;
  16.760  
  16.761 @@ -698,13 +699,13 @@ static PyObject *pyxc_vif_stats_get(PyOb
  16.762  {
  16.763      XcObject *xc = (XcObject *)self;
  16.764  
  16.765 -    u64            dom;
  16.766 +    u32            dom;
  16.767      unsigned int   vif;
  16.768      xc_vif_stats_t stats;
  16.769  
  16.770      static char *kwd_list[] = { "dom", "vif", NULL };
  16.771  
  16.772 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Li", kwd_list, 
  16.773 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list, 
  16.774                                        &dom, &vif) )
  16.775          return NULL;
  16.776  
  16.777 @@ -724,13 +725,13 @@ static PyObject *pyxc_vbd_create(PyObjec
  16.778  {
  16.779      XcObject *xc = (XcObject *)self;
  16.780  
  16.781 -    u64          dom;
  16.782 +    u32          dom;
  16.783      unsigned int vbd;
  16.784      int          writeable;
  16.785  
  16.786      static char *kwd_list[] = { "dom", "vbd", "writeable", NULL };
  16.787  
  16.788 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Lii", kwd_list, 
  16.789 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iii", kwd_list, 
  16.790                                        &dom, &vbd, &writeable) )
  16.791          return NULL;
  16.792  
  16.793 @@ -747,12 +748,12 @@ static PyObject *pyxc_vbd_destroy(PyObje
  16.794  {
  16.795      XcObject *xc = (XcObject *)self;
  16.796  
  16.797 -    u64          dom;
  16.798 +    u32          dom;
  16.799      unsigned int vbd;
  16.800  
  16.801      static char *kwd_list[] = { "dom", "vbd", NULL };
  16.802  
  16.803 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Li", kwd_list, 
  16.804 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list, 
  16.805                                        &dom, &vbd) )
  16.806          return NULL;
  16.807  
  16.808 @@ -769,14 +770,14 @@ static PyObject *pyxc_vbd_grow(PyObject 
  16.809  {
  16.810      XcObject *xc = (XcObject *)self;
  16.811  
  16.812 -    u64            dom;
  16.813 +    u32            dom;
  16.814      unsigned int   vbd;
  16.815      xc_vbdextent_t extent;
  16.816  
  16.817      static char *kwd_list[] = { "dom", "vbd", "device", 
  16.818                                  "start_sector", "nr_sectors", NULL };
  16.819  
  16.820 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "LiiLL", kwd_list, 
  16.821 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiLL", kwd_list, 
  16.822                                        &dom, &vbd, 
  16.823                                        &extent.real_device, 
  16.824                                        &extent.start_sector, 
  16.825 @@ -796,12 +797,12 @@ static PyObject *pyxc_vbd_shrink(PyObjec
  16.826  {
  16.827      XcObject *xc = (XcObject *)self;
  16.828  
  16.829 -    u64          dom;
  16.830 +    u32          dom;
  16.831      unsigned int vbd;
  16.832  
  16.833      static char *kwd_list[] = { "dom", "vbd", NULL };
  16.834  
  16.835 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Li", kwd_list, 
  16.836 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list, 
  16.837                                        &dom, &vbd) )
  16.838          return NULL;
  16.839  
  16.840 @@ -819,14 +820,14 @@ static PyObject *pyxc_vbd_setextents(PyO
  16.841      XcObject *xc = (XcObject *)self;
  16.842      PyObject *list, *dict, *obj;
  16.843  
  16.844 -    u64             dom;
  16.845 +    u32             dom;
  16.846      unsigned int    vbd;
  16.847      xc_vbdextent_t *extents = NULL;
  16.848      int             i, nr_extents;
  16.849  
  16.850      static char *kwd_list[] = { "dom", "vbd", "extents", NULL };
  16.851  
  16.852 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "LiO", kwd_list, 
  16.853 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiO", kwd_list, 
  16.854                                        &dom, &vbd, &list) )
  16.855          return NULL;
  16.856  
  16.857 @@ -941,14 +942,14 @@ static PyObject *pyxc_vbd_getextents(PyO
  16.858      XcObject *xc = (XcObject *)self;
  16.859      PyObject *list;
  16.860  
  16.861 -    u64             dom;
  16.862 +    u32             dom;
  16.863      unsigned int    vbd;
  16.864      xc_vbdextent_t *extents;
  16.865      int             i, nr_extents;
  16.866  
  16.867      static char *kwd_list[] = { "dom", "vbd", NULL };
  16.868  
  16.869 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Li", kwd_list, 
  16.870 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list, 
  16.871                                        &dom, &vbd) )
  16.872          return NULL;
  16.873  
  16.874 @@ -987,14 +988,14 @@ static PyObject *pyxc_vbd_probe(PyObject
  16.875      XcObject *xc = (XcObject *)self;
  16.876      PyObject *list;
  16.877  
  16.878 -    u64          dom = XC_VBDDOM_PROBE_ALL;
  16.879 +    u32          dom = XC_VBDDOM_PROBE_ALL;
  16.880      unsigned int max_vbds = 1024;
  16.881      xc_vbd_t    *info;
  16.882      int          nr_vbds, i;
  16.883  
  16.884      static char *kwd_list[] = { "dom", "max_vbds", NULL };
  16.885  
  16.886 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|Li", kwd_list, 
  16.887 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|ii", kwd_list, 
  16.888                                        &dom, &max_vbds) )
  16.889          return NULL;
  16.890  
  16.891 @@ -1012,7 +1013,7 @@ static PyObject *pyxc_vbd_probe(PyObject
  16.892      {
  16.893          PyList_SetItem(
  16.894              list, i, 
  16.895 -            Py_BuildValue("{s:L,s:i,s:i,s:L}",
  16.896 +            Py_BuildValue("{s:i,s:i,s:i,s:L}",
  16.897                            "dom",        info[i].domid,
  16.898                            "vbd",        info[i].vbdid,
  16.899                            "writeable",  !!(info[i].flags & XC_VBDF_WRITEABLE),
  16.900 @@ -1030,12 +1031,12 @@ static PyObject *pyxc_evtchn_bind_interd
  16.901  {
  16.902      XcObject *xc = (XcObject *)self;
  16.903  
  16.904 -    u64 dom1 = DOMID_SELF, dom2 = DOMID_SELF;
  16.905 +    u32 dom1 = DOMID_SELF, dom2 = DOMID_SELF;
  16.906      int port1, port2;
  16.907  
  16.908      static char *kwd_list[] = { "dom1", "dom2", NULL };
  16.909  
  16.910 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|LL", kwd_list, 
  16.911 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|ii", kwd_list, 
  16.912                                        &dom1, &dom2) )
  16.913          return NULL;
  16.914  
  16.915 @@ -1054,12 +1055,12 @@ static PyObject *pyxc_evtchn_close(PyObj
  16.916  {
  16.917      XcObject *xc = (XcObject *)self;
  16.918  
  16.919 -    u64 dom = DOMID_SELF;
  16.920 +    u32 dom = DOMID_SELF;
  16.921      int port;
  16.922  
  16.923      static char *kwd_list[] = { "port", "dom", NULL };
  16.924  
  16.925 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|L", kwd_list, 
  16.926 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list, 
  16.927                                        &port, &dom) )
  16.928          return NULL;
  16.929  
  16.930 @@ -1097,13 +1098,13 @@ static PyObject *pyxc_evtchn_status(PyOb
  16.931      XcObject *xc = (XcObject *)self;
  16.932      PyObject *dict;
  16.933  
  16.934 -    u64 dom = DOMID_SELF;
  16.935 +    u32 dom = DOMID_SELF;
  16.936      int port, ret;
  16.937      xc_evtchn_status_t status;
  16.938  
  16.939      static char *kwd_list[] = { "port", "dom", NULL };
  16.940  
  16.941 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|L", kwd_list, 
  16.942 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list, 
  16.943                                        &port, &dom) )
  16.944          return NULL;
  16.945  
  16.946 @@ -1122,7 +1123,7 @@ static PyObject *pyxc_evtchn_status(PyOb
  16.947                               "status", "unbound");
  16.948          break;
  16.949      case EVTCHNSTAT_interdomain:
  16.950 -        dict = Py_BuildValue("{s:s,s:L,s:i}", 
  16.951 +        dict = Py_BuildValue("{s:s,s:i,s:i}", 
  16.952                               "status", "interdomain",
  16.953                               "dom", status.u.interdomain.dom,
  16.954                               "port", status.u.interdomain.port);
  16.955 @@ -1150,12 +1151,12 @@ static PyObject *pyxc_physdev_pci_access
  16.956                                                  PyObject *kwds)
  16.957  {
  16.958      XcObject *xc = (XcObject *)self;
  16.959 -    u64 dom;
  16.960 +    u32 dom;
  16.961      int bus, dev, func, enable, ret;
  16.962  
  16.963      static char *kwd_list[] = { "dom", "bus", "dev", "func", "enable", NULL };
  16.964  
  16.965 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Liiii", kwd_list, 
  16.966 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiii", kwd_list, 
  16.967                                        &dom, &bus, &dev, &func, &enable) )
  16.968          return NULL;
  16.969  
  16.970 @@ -1191,8 +1192,8 @@ static PyObject *pyxc_readconsolering(Py
  16.971  }
  16.972  
  16.973  static PyObject *pyxc_physinfo(PyObject *self,
  16.974 -			       PyObject *args,
  16.975 -			       PyObject *kwds)
  16.976 +                               PyObject *args,
  16.977 +                               PyObject *kwds)
  16.978  {
  16.979      XcObject *xc = (XcObject *)self;
  16.980      xc_physinfo_t info;
  16.981 @@ -1216,19 +1217,19 @@ static PyObject *pyxc_atropos_domain_set
  16.982                                           PyObject *kwds)
  16.983  {
  16.984      XcObject *xc = (XcObject *)self;
  16.985 -    u64 domid;
  16.986 +    u32 domid;
  16.987      u64 period, slice, latency;
  16.988      int xtratime;
  16.989  
  16.990      static char *kwd_list[] = { "dom", "period", "slice", "latency",
  16.991 -				"xtratime", NULL };
  16.992 +                                "xtratime", NULL };
  16.993      
  16.994 -    if( !PyArg_ParseTupleAndKeywords(args, kwds, "LLLLi", kwd_list, &domid,
  16.995 +    if( !PyArg_ParseTupleAndKeywords(args, kwds, "iLLLi", kwd_list, &domid,
  16.996                                       &period, &slice, &latency, &xtratime) )
  16.997          return NULL;
  16.998     
  16.999      if ( xc_atropos_domain_set(xc->xc_handle, domid, period, slice,
 16.1000 -			       latency, xtratime) != 0 )
 16.1001 +                               latency, xtratime) != 0 )
 16.1002          return PyErr_SetFromErrno(xc_error);
 16.1003  
 16.1004      Py_INCREF(zero);
 16.1005 @@ -1240,20 +1241,20 @@ static PyObject *pyxc_atropos_domain_get
 16.1006                                           PyObject *kwds)
 16.1007  {
 16.1008      XcObject *xc = (XcObject *)self;
 16.1009 -    u64 domid;
 16.1010 +    u32 domid;
 16.1011      u64 period, slice, latency;
 16.1012      int xtratime;
 16.1013      
 16.1014      static char *kwd_list[] = { "dom", NULL };
 16.1015  
 16.1016 -    if( !PyArg_ParseTupleAndKeywords(args, kwds, "L", kwd_list, &domid) )
 16.1017 +    if( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &domid) )
 16.1018          return NULL;
 16.1019      
 16.1020      if ( xc_atropos_domain_get( xc->xc_handle, domid, &period,
 16.1021                                  &slice, &latency, &xtratime ) )
 16.1022          return PyErr_SetFromErrno(xc_error);
 16.1023  
 16.1024 -    return Py_BuildValue("{s:L,s:L,s:L,s:L,s:i}",
 16.1025 +    return Py_BuildValue("{s:i,s:L,s:L,s:L,s:i}",
 16.1026                           "domain",  domid,
 16.1027                           "period",  period,
 16.1028                           "slice",   slice,
 16.1029 @@ -1287,12 +1288,12 @@ static PyObject *pyxc_shadow_control(PyO
 16.1030  {
 16.1031      XcObject *xc = (XcObject *)self;
 16.1032  
 16.1033 -    u64 dom;
 16.1034 +    u32 dom;
 16.1035      int op=0;
 16.1036  
 16.1037      static char *kwd_list[] = { "dom", "op", NULL };
 16.1038  
 16.1039 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "L|i", kwd_list, 
 16.1040 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list, 
 16.1041                                        &dom, &op) )
 16.1042          return NULL;
 16.1043  
 16.1044 @@ -1324,12 +1325,12 @@ static PyObject *pyxc_domain_setname(PyO
 16.1045                                       PyObject *kwds)
 16.1046  {
 16.1047      XcObject *xc = (XcObject *)self;
 16.1048 -    u64 dom;
 16.1049 +    u32 dom;
 16.1050      char *name;
 16.1051  
 16.1052      static char *kwd_list[] = { "dom", "name", NULL };
 16.1053  
 16.1054 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Ls", kwd_list, 
 16.1055 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is", kwd_list, 
 16.1056                                        &dom, &name) )
 16.1057          return NULL;
 16.1058  
 16.1059 @@ -1341,17 +1342,17 @@ static PyObject *pyxc_domain_setname(PyO
 16.1060  }
 16.1061  
 16.1062  static PyObject *pyxc_domain_setmaxmem(PyObject *self,
 16.1063 -				       PyObject *args,
 16.1064 -				       PyObject *kwds)
 16.1065 +                                       PyObject *args,
 16.1066 +                                       PyObject *kwds)
 16.1067  {
 16.1068      XcObject *xc = (XcObject *)self;
 16.1069  
 16.1070 -    u64 dom;
 16.1071 +    u32 dom;
 16.1072      unsigned long max_memkb;
 16.1073  
 16.1074      static char *kwd_list[] = { "dom", "max_memkb", NULL };
 16.1075  
 16.1076 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Li", kwd_list, 
 16.1077 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list, 
 16.1078                                        &dom, &max_memkb) )
 16.1079          return NULL;
 16.1080  
 16.1081 @@ -1370,27 +1371,27 @@ static PyMethodDef pyxc_methods[] = {
 16.1082        "Create a new domain.\n"
 16.1083        " mem_kb [int, 65536]:    Memory allocation, in kilobytes.\n"
 16.1084        " name   [str, '(anon)']: Informative textual name.\n\n"
 16.1085 -      "Returns: [long] new domain identifier; -1 on error.\n" },
 16.1086 +      "Returns: [int] new domain identifier; -1 on error.\n" },
 16.1087  
 16.1088      { "domain_start", 
 16.1089        (PyCFunction)pyxc_domain_start, 
 16.1090        METH_VARARGS | METH_KEYWORDS, "\n"
 16.1091        "Start execution of a domain.\n"
 16.1092 -      " dom [long]: Identifier of domain to be started.\n\n"
 16.1093 +      " dom [int]: Identifier of domain to be started.\n\n"
 16.1094        "Returns: [int] 0 on success; -1 on error.\n" },
 16.1095  
 16.1096      { "domain_stop", 
 16.1097        (PyCFunction)pyxc_domain_stop, 
 16.1098        METH_VARARGS | METH_KEYWORDS, "\n"
 16.1099        "Stop execution of a domain.\n"
 16.1100 -      " dom [long]: Identifier of domain to be stopped.\n\n"
 16.1101 +      " dom [int]: Identifier of domain to be stopped.\n\n"
 16.1102        "Returns: [int] 0 on success; -1 on error.\n" },
 16.1103  
 16.1104      { "domain_destroy", 
 16.1105        (PyCFunction)pyxc_domain_destroy, 
 16.1106        METH_VARARGS | METH_KEYWORDS, "\n"
 16.1107        "Destroy a domain.\n"
 16.1108 -      " dom   [long]:   Identifier of domain to be destroyed.\n"
 16.1109 +      " dom   [int]:    Identifier of domain to be destroyed.\n"
 16.1110        " force [int, 0]: Bool - force immediate destruction?\n\n"
 16.1111        "Returns: [int] 0 on success; -1 on error.\n" },
 16.1112  
 16.1113 @@ -1398,7 +1399,7 @@ static PyMethodDef pyxc_methods[] = {
 16.1114        (PyCFunction)pyxc_domain_pincpu, 
 16.1115        METH_VARARGS | METH_KEYWORDS, "\n"
 16.1116        "Pin a domain to a specified CPU.\n"
 16.1117 -      " dom [long]:    Identifier of domain to be pinned.\n"
 16.1118 +      " dom [int]:     Identifier of domain to be pinned.\n"
 16.1119        " cpu [int, -1]: CPU to pin to, or -1 to unpin\n\n"
 16.1120        "Returns: [int] 0 on success; -1 on error.\n" },
 16.1121  
 16.1122 @@ -1406,13 +1407,13 @@ static PyMethodDef pyxc_methods[] = {
 16.1123        (PyCFunction)pyxc_domain_getinfo, 
 16.1124        METH_VARARGS | METH_KEYWORDS, "\n"
 16.1125        "Get information regarding a set of domains, in increasing id order.\n"
 16.1126 -      " first_dom [long, 0]:   First domain to retrieve info about.\n"
 16.1127 +      " first_dom [int, 0]:    First domain to retrieve info about.\n"
 16.1128        " max_doms  [int, 1024]: Maximum number of domains to retrieve info"
 16.1129        " about.\n\n"
 16.1130        "Returns: [list of dicts] if list length is less than 'max_doms'\n"
 16.1131        "         parameter then there was an error, or the end of the\n"
 16.1132        "         domain-id space was reached.\n"
 16.1133 -      " dom      [long]: Identifier of domain to which this info pertains\n"
 16.1134 +      " dom      [int]: Identifier of domain to which this info pertains\n"
 16.1135        " cpu      [int]:  CPU to which this domain is bound\n"
 16.1136        " running  [int]:  Bool - is the domain currently running?\n"
 16.1137        " stopped  [int]:  Bool - is the domain suspended?\n"
 16.1138 @@ -1424,7 +1425,7 @@ static PyMethodDef pyxc_methods[] = {
 16.1139        (PyCFunction)pyxc_linux_save, 
 16.1140        METH_VARARGS | METH_KEYWORDS, "\n"
 16.1141        "Save the CPU and memory state of a Linux guest OS.\n"
 16.1142 -      " dom        [long]:   Identifier of domain to be saved.\n"
 16.1143 +      " dom        [int]:    Identifier of domain to be saved.\n"
 16.1144        " state_file [str]:    Name of state file. Must not currently exist.\n"
 16.1145        " progress   [int, 1]: Bool - display a running progress indication?\n\n"
 16.1146        "Returns: [int] 0 on success; -1 on error.\n" },
 16.1147 @@ -1435,13 +1436,13 @@ static PyMethodDef pyxc_methods[] = {
 16.1148        "Restore the CPU and memory state of a Linux guest OS.\n"
 16.1149        " state_file [str]:    Name of state file. Must not currently exist.\n"
 16.1150        " progress   [int, 1]: Bool - display a running progress indication?\n\n"
 16.1151 -      "Returns: [long] new domain identifier on success; -1 on error.\n" },
 16.1152 +      "Returns: [int] new domain identifier on success; -1 on error.\n" },
 16.1153  
 16.1154      { "linux_build", 
 16.1155        (PyCFunction)pyxc_linux_build, 
 16.1156        METH_VARARGS | METH_KEYWORDS, "\n"
 16.1157        "Build a new Linux guest OS.\n"
 16.1158 -      " dom     [long]:     Identifier of domain to build into.\n"
 16.1159 +      " dom     [int]:      Identifier of domain to build into.\n"
 16.1160        " image   [str]:      Name of kernel image file. May be gzipped.\n"
 16.1161        " ramdisk [str, n/a]: Name of ramdisk file, if any.\n"
 16.1162        " cmdline [str, n/a]: Kernel parameters, if any.\n\n"
 16.1163 @@ -1451,7 +1452,7 @@ static PyMethodDef pyxc_methods[] = {
 16.1164        (PyCFunction)pyxc_netbsd_build, 
 16.1165        METH_VARARGS | METH_KEYWORDS, "\n"
 16.1166        "Build a new NetBSD guest OS.\n"
 16.1167 -      " dom     [long]:     Identifier of domain to build into.\n"
 16.1168 +      " dom     [int]:     Identifier of domain to build into.\n"
 16.1169        " image   [str]:      Name of kernel image file. May be gzipped.\n"
 16.1170        " cmdline [str, n/a]: Kernel parameters, if any.\n\n"
 16.1171        "Returns: [int] 0 on success; -1 on error.\n" },
 16.1172 @@ -1474,20 +1475,20 @@ static PyMethodDef pyxc_methods[] = {
 16.1173        (PyCFunction)pyxc_bvtsched_domain_set,
 16.1174        METH_VARARGS | METH_KEYWORDS, "\n"
 16.1175        "Set per-domain tuning parameters for Borrowed Virtual Time scheduler.\n"
 16.1176 -      " dom    [long]: Identifier of domain to be tuned.\n"
 16.1177 -      " mcuadv [int]:  Proportional to the inverse of the domain's weight.\n"
 16.1178 -      " warp   [int]:  How far to warp domain's EVT on unblock.\n"
 16.1179 -      " warpl  [int]:  How long the domain can run warped.\n"
 16.1180 -      " warpu  [int]:  How long before the domain can warp again.\n\n"
 16.1181 +      " dom    [int]: Identifier of domain to be tuned.\n"
 16.1182 +      " mcuadv [int]: Proportional to the inverse of the domain's weight.\n"
 16.1183 +      " warp   [int]: How far to warp domain's EVT on unblock.\n"
 16.1184 +      " warpl  [int]: How long the domain can run warped.\n"
 16.1185 +      " warpu  [int]: How long before the domain can warp again.\n\n"
 16.1186        "Returns: [int] 0 on success; -1 on error.\n" },
 16.1187  
 16.1188      { "bvtsched_domain_get",
 16.1189        (PyCFunction)pyxc_bvtsched_domain_get,
 16.1190        METH_KEYWORDS, "\n"
 16.1191        "Get per-domain tuning parameters under the BVT scheduler.\n"
 16.1192 -      " dom [long]: Identifier of domain to be queried.\n"
 16.1193 +      " dom [int]: Identifier of domain to be queried.\n"
 16.1194        "Returns [dict]:\n"
 16.1195 -      " domain [long]: Domain ID.\n"
 16.1196 +      " domain [int]:  Domain ID.\n"
 16.1197        " mcuadv [long]: MCU Advance.\n"
 16.1198        " warp   [long]: Warp.\n"
 16.1199        " warpu  [long]: Unwarp requirement.\n"
 16.1200 @@ -1498,7 +1499,7 @@ static PyMethodDef pyxc_methods[] = {
 16.1201        (PyCFunction)pyxc_atropos_domain_set,
 16.1202        METH_KEYWORDS, "\n"
 16.1203        "Set the scheduling parameters for a domain when running with Atropos.\n"
 16.1204 -      " dom      [long]: domain to set\n"
 16.1205 +      " dom      [int]:  domain to set\n"
 16.1206        " period   [long]: domain's scheduling period\n"
 16.1207        " slice    [long]: domain's slice per period\n"
 16.1208        " latency  [long]: wakeup latency hint\n"
 16.1209 @@ -1510,9 +1511,9 @@ static PyMethodDef pyxc_methods[] = {
 16.1210        METH_KEYWORDS, "\n"
 16.1211        "Get the current scheduling parameters for a domain when running with\n"
 16.1212        "the Atropos scheduler."
 16.1213 -      " dom      [long]: domain to query\n"
 16.1214 +      " dom      [int]: domain to query\n"
 16.1215        "Returns:  [dict]\n"
 16.1216 -      " domain   [long]: domain ID\n"
 16.1217 +      " domain   [int]: domain ID\n"
 16.1218        " period   [long]: scheduler period\n"
 16.1219        " slice    [long]: CPU reservation per period\n"
 16.1220        " latency  [long]: unblocking latency hint\n"
 16.1221 @@ -1536,7 +1537,7 @@ static PyMethodDef pyxc_methods[] = {
 16.1222        (PyCFunction)pyxc_vif_scheduler_set, 
 16.1223        METH_VARARGS | METH_KEYWORDS, "\n"
 16.1224        "Set per-network-interface scheduling parameters.\n"
 16.1225 -      " dom          [long]:   Identifier of domain to be adjusted.\n"
 16.1226 +      " dom          [int]:    Identifier of domain to be adjusted.\n"
 16.1227        " vif          [int]:    Identifier of VIF to be adjusted.\n"
 16.1228        " credit_bytes [int, 0]: Tx bytes permitted each interval.\n"
 16.1229        " credit_usecs [int, 0]: Interval, in usecs. 0 == no scheduling.\n\n"
 16.1230 @@ -1546,8 +1547,8 @@ static PyMethodDef pyxc_methods[] = {
 16.1231        (PyCFunction)pyxc_vif_scheduler_get, 
 16.1232        METH_VARARGS | METH_KEYWORDS, "\n"
 16.1233        "Query the per-network-interface scheduling parameters.\n"
 16.1234 -      " dom          [long]:   Identifier of domain to be queried.\n"
 16.1235 -      " vif          [int]:    Identifier of VIF to be queried.\n\n"
 16.1236 +      " dom          [int]: Identifier of domain to be queried.\n"
 16.1237 +      " vif          [int]: Identifier of VIF to be queried.\n\n"
 16.1238        "Returns: [dict] dictionary is empty on failure.\n"
 16.1239        " credit_bytes [int]: Tx bytes permitted each interval.\n"
 16.1240        " credit_usecs [int]: Interval, in usecs. 0 == no scheduling.\n" },
 16.1241 @@ -1556,7 +1557,7 @@ static PyMethodDef pyxc_methods[] = {
 16.1242        (PyCFunction)pyxc_vif_stats_get, 
 16.1243        METH_VARARGS | METH_KEYWORDS, "\n"
 16.1244        "Query the per-network-interface statistics.\n"
 16.1245 -      " dom          [long]: Identifier of domain to be queried.\n"
 16.1246 +      " dom          [int]:  Identifier of domain to be queried.\n"
 16.1247        " vif          [int]:  Identifier of VIF to be queried.\n\n"
 16.1248        "Returns: [dict] dictionary is empty on failure.\n"
 16.1249        " tx_bytes   [long]: Bytes transmitted.\n"
 16.1250 @@ -1568,7 +1569,7 @@ static PyMethodDef pyxc_methods[] = {
 16.1251        (PyCFunction)pyxc_vbd_create, 
 16.1252        METH_VARARGS | METH_KEYWORDS, "\n"
 16.1253        "Create a new virtual block device associated with a given domain.\n"
 16.1254 -      " dom       [long]: Identifier of domain to get a new VBD.\n"
 16.1255 +      " dom       [int]:  Identifier of domain to get a new VBD.\n"
 16.1256        " vbd       [int]:  Identifier for new VBD.\n"
 16.1257        " writeable [int]:  Bool - is the new VBD writeable?\n\n"
 16.1258        "Returns: [int] 0 on success; -1 on error.\n" },
 16.1259 @@ -1577,7 +1578,7 @@ static PyMethodDef pyxc_methods[] = {
 16.1260        (PyCFunction)pyxc_vbd_destroy, 
 16.1261        METH_VARARGS | METH_KEYWORDS, "\n"
 16.1262        "Destroy a virtual block device.\n"
 16.1263 -      " dom       [long]: Identifier of domain containing the VBD.\n"
 16.1264 +      " dom       [int]:  Identifier of domain containing the VBD.\n"
 16.1265        " vbd       [int]:  Identifier of the VBD.\n\n"
 16.1266        "Returns: [int] 0 on success; -1 on error.\n" },
 16.1267  
 16.1268 @@ -1585,7 +1586,7 @@ static PyMethodDef pyxc_methods[] = {
 16.1269        (PyCFunction)pyxc_vbd_grow, 
 16.1270        METH_VARARGS | METH_KEYWORDS, "\n"
 16.1271        "Grow a virtual block device by appending a new extent.\n"
 16.1272 -      " dom          [long]: Identifier of domain containing the VBD.\n"
 16.1273 +      " dom          [int]:  Identifier of domain containing the VBD.\n"
 16.1274        " vbd          [int]:  Identifier of the VBD.\n"
 16.1275        " device       [int]:  Identifier of the real underlying block device.\n"
 16.1276        " start_sector [long]: Real start sector of this extent.\n"
 16.1277 @@ -1596,7 +1597,7 @@ static PyMethodDef pyxc_methods[] = {
 16.1278        (PyCFunction)pyxc_vbd_shrink, 
 16.1279        METH_VARARGS | METH_KEYWORDS, "\n"
 16.1280        "Shrink a virtual block device by deleting its final extent.\n"
 16.1281 -      " dom          [long]: Identifier of domain containing the VBD.\n"
 16.1282 +      " dom          [int]:  Identifier of domain containing the VBD.\n"
 16.1283        " vbd          [int]:  Identifier of the VBD.\n\n"
 16.1284        "Returns: [int] 0 on success; -1 on error.\n" },
 16.1285  
 16.1286 @@ -1604,7 +1605,7 @@ static PyMethodDef pyxc_methods[] = {
 16.1287        (PyCFunction)pyxc_vbd_setextents, 
 16.1288        METH_VARARGS | METH_KEYWORDS, "\n"
 16.1289        "Set all the extent information for a virtual block device.\n"
 16.1290 -      " dom          [long]: Identifier of domain containing the VBD.\n"
 16.1291 +      " dom          [int]:  Identifier of domain containing the VBD.\n"
 16.1292        " vbd          [int]:  Identifier of the VBD.\n"
 16.1293        " extents      [list of dicts]: Per-extent information.\n"
 16.1294        "  device       [int]:  Id of the real underlying block device.\n"
 16.1295 @@ -1616,7 +1617,7 @@ static PyMethodDef pyxc_methods[] = {
 16.1296        (PyCFunction)pyxc_vbd_getextents, 
 16.1297        METH_VARARGS | METH_KEYWORDS, "\n"
 16.1298        "Get info on all the extents in a virtual block device.\n"
 16.1299 -      " dom          [long]: Identifier of domain containing the VBD.\n"
 16.1300 +      " dom          [int]:  Identifier of domain containing the VBD.\n"
 16.1301        " vbd          [int]:  Identifier of the VBD.\n\n"
 16.1302        "Returns: [list of dicts] per-extent information; empty on error.\n"
 16.1303        " device       [int]:  Identifier of the real underlying block device.\n"
 16.1304 @@ -1627,11 +1628,11 @@ static PyMethodDef pyxc_methods[] = {
 16.1305        (PyCFunction)pyxc_vbd_probe, 
 16.1306        METH_VARARGS | METH_KEYWORDS, "\n"
 16.1307        "Get information regarding extant virtual block devices.\n"
 16.1308 -      " dom          [long, ALL]: Domain to query (default is to query all).\n"
 16.1309 +      " dom          [int, ALL]: Domain to query (default is to query all).\n"
 16.1310        " max_vbds     [int, 1024]: Maximum VBDs to query.\n\n"
 16.1311        "Returns: [list of dicts] if list length is less than 'max_vbds'\n"
 16.1312        "         parameter then there was an error, or there were fewer vbds.\n"
 16.1313 -      " dom        [long]: Domain containing this VBD.\n"
 16.1314 +      " dom        [int]:  Domain containing this VBD.\n"
 16.1315        " vbd        [int]:  Domain-specific identifier of this VBD.\n"
 16.1316        " writeable  [int]:  Bool - is this VBD writeable?\n"
 16.1317        " nr_sectors [long]: Size of this VBD, in 512-byte sectors.\n" },
 16.1318 @@ -1640,8 +1641,8 @@ static PyMethodDef pyxc_methods[] = {
 16.1319        (PyCFunction)pyxc_evtchn_bind_interdomain, 
 16.1320        METH_VARARGS | METH_KEYWORDS, "\n"
 16.1321        "Open an event channel between two domains.\n"
 16.1322 -      " dom1 [long, SELF]: First domain to be connected.\n"
 16.1323 -      " dom2 [long, SELF]: Second domain to be connected.\n\n"
 16.1324 +      " dom1 [int, SELF]: First domain to be connected.\n"
 16.1325 +      " dom2 [int, SELF]: Second domain to be connected.\n\n"
 16.1326        "Returns: [dict] dictionary is empty on failure.\n"
 16.1327        " port1 [int]: Port-id for endpoint at dom1.\n"
 16.1328        " port2 [int]: Port-id for endpoint at dom2.\n" },
 16.1329 @@ -1650,8 +1651,8 @@ static PyMethodDef pyxc_methods[] = {
 16.1330        (PyCFunction)pyxc_evtchn_close, 
 16.1331        METH_VARARGS | METH_KEYWORDS, "\n"
 16.1332        "Close an event channel.\n"
 16.1333 -      " dom  [long, SELF]: Dom-id of one endpoint of the channel.\n"
 16.1334 -      " port [int]:        Port-id of one endpoint of the channel.\n\n"
 16.1335 +      " dom  [int, SELF]: Dom-id of one endpoint of the channel.\n"
 16.1336 +      " port [int]:       Port-id of one endpoint of the channel.\n\n"
 16.1337        "Returns: [int] 0 on success; -1 on error.\n" },
 16.1338  
 16.1339      { "evtchn_send", 
 16.1340 @@ -1665,26 +1666,26 @@ static PyMethodDef pyxc_methods[] = {
 16.1341        (PyCFunction)pyxc_evtchn_status, 
 16.1342        METH_VARARGS | METH_KEYWORDS, "\n"
 16.1343        "Query the status of an event channel.\n"
 16.1344 -      " dom  [long, SELF]: Dom-id of one endpoint of the channel.\n"
 16.1345 -      " port [int]:        Port-id of one endpoint of the channel.\n\n"
 16.1346 +      " dom  [int, SELF]: Dom-id of one endpoint of the channel.\n"
 16.1347 +      " port [int]:       Port-id of one endpoint of the channel.\n\n"
 16.1348        "Returns: [dict] dictionary is empty on failure.\n"
 16.1349        " status [str]:  'closed', 'unbound', 'interdomain', 'pirq',"
 16.1350        " or 'virq'.\n"
 16.1351        "The following are returned if 'status' is 'interdomain':\n"
 16.1352 -      " dom  [long]: Dom-id of remote endpoint.\n"
 16.1353 -      " port [int]:  Port-id of remote endpoint.\n"
 16.1354 +      " dom  [int]: Dom-id of remote endpoint.\n"
 16.1355 +      " port [int]: Port-id of remote endpoint.\n"
 16.1356        "The following are returned if 'status' is 'pirq' or 'virq':\n"
 16.1357 -      " irq  [int]:  IRQ number.\n" },
 16.1358 +      " irq  [int]: IRQ number.\n" },
 16.1359  
 16.1360      { "physdev_pci_access_modify",
 16.1361        (PyCFunction)pyxc_physdev_pci_access_modify,
 16.1362        METH_VARARGS | METH_KEYWORDS, "\n"
 16.1363        "Allow a domain access to a PCI device\n"
 16.1364 -      " dom    [long]: Identifier of domain to be allowed access.\n"
 16.1365 -      " bus    [int]:  PCI bus\n"
 16.1366 -      " dev    [int]:  PCI slot\n"
 16.1367 -      " func   [int]:  PCI function\n"
 16.1368 -      " enable [int]:  Non-zero means enable access; else disable access\n\n"
 16.1369 +      " dom    [int]: Identifier of domain to be allowed access.\n"
 16.1370 +      " bus    [int]: PCI bus\n"
 16.1371 +      " dev    [int]: PCI slot\n"
 16.1372 +      " func   [int]: PCI function\n"
 16.1373 +      " enable [int]: Non-zero means enable access; else disable access\n\n"
 16.1374        "Returns: [int] 0 on success; -1 on error.\n" },
 16.1375   
 16.1376      { "readconsolering", 
 16.1377 @@ -1705,7 +1706,7 @@ static PyMethodDef pyxc_methods[] = {
 16.1378        (PyCFunction)pyxc_shadow_control, 
 16.1379        METH_VARARGS | METH_KEYWORDS, "\n"
 16.1380        "Set parameter for shadow pagetable interface\n"
 16.1381 -      " dom [long]:    Identifier of domain.\n"
 16.1382 +      " dom [int]:   Identifier of domain.\n"
 16.1383        " op [int, 0]: operation\n\n"
 16.1384        "Returns: [int] 0 on success; -1 on error.\n" },
 16.1385  
 16.1386 @@ -1713,7 +1714,7 @@ static PyMethodDef pyxc_methods[] = {
 16.1387        (PyCFunction)pyxc_domain_setname, 
 16.1388        METH_VARARGS | METH_KEYWORDS, "\n"
 16.1389        "Set domain informative textual name\n"
 16.1390 -      " dom [long]: Identifier of domain.\n"
 16.1391 +      " dom [int]:  Identifier of domain.\n"
 16.1392        " name [str]: Text string.\n\n"
 16.1393        "Returns: [int] 0 on success; -1 on error.\n" },
 16.1394  
 16.1395 @@ -1721,7 +1722,7 @@ static PyMethodDef pyxc_methods[] = {
 16.1396        (PyCFunction)pyxc_domain_setname, 
 16.1397        METH_VARARGS | METH_KEYWORDS, "\n"
 16.1398        "Set a domain's memory limit\n"
 16.1399 -      " dom [long]: Identifier of domain.\n"
 16.1400 +      " dom [int]: Identifier of domain.\n"
 16.1401        " max_memkb [long]: .\n"
 16.1402        "Returns: [int] 0 on success; -1 on error.\n" },
 16.1403  
 16.1404 @@ -1747,7 +1748,7 @@ static PyObject *PyXc_new(PyObject *self
 16.1405      if ( (xc->xc_handle = xc_interface_open()) == -1 )
 16.1406      {
 16.1407          PyObject_Del((PyObject *)xc);
 16.1408 -	return PyErr_SetFromErrno(xc_error);
 16.1409 +        return PyErr_SetFromErrno(xc_error);
 16.1410      }
 16.1411  
 16.1412      return (PyObject *)xc;
    17.1 --- a/tools/xend/lib/blkif.py	Thu Jun 03 09:31:38 2004 +0000
    17.2 +++ b/tools/xend/lib/blkif.py	Thu Jun 03 11:45:16 2004 +0000
    17.3 @@ -43,18 +43,18 @@ def backend_rx_rsp(port, msg):
    17.4          rsp = { 'success': True }
    17.5          xend.main.send_management_response(rsp, xend.blkif.pendaddr)
    17.6      elif subtype == CMSG_BLKIF_BE_CONNECT:
    17.7 -        (dom,hnd,evtchn,frame,st) = struct.unpack("QIILI", msg.get_payload())
    17.8 +        (dom,hnd,evtchn,frame,st) = struct.unpack("IIILI", msg.get_payload())
    17.9          blkif = interface.list[xend.main.port_from_dom(dom).local_port]
   17.10          msg = xend.utils.message(CMSG_BLKIF_FE, \
   17.11                                   CMSG_BLKIF_FE_INTERFACE_STATUS_CHANGED, 0)
   17.12          msg.append_payload(struct.pack("III",0,2,blkif.evtchn['port2']))
   17.13          blkif.ctrlif_tx_req(xend.main.port_list[blkif.key], msg)
   17.14      elif subtype == CMSG_BLKIF_BE_VBD_CREATE:
   17.15 -        (dom,hnd,vdev,ro,st) = struct.unpack("QIHII", msg.get_payload())
   17.16 +        (dom,hnd,vdev,ro,st) = struct.unpack("IIHII", msg.get_payload())
   17.17          blkif = interface.list[xend.main.port_from_dom(dom).local_port]
   17.18          (pdev, start_sect, nr_sect, readonly) = blkif.devices[vdev]
   17.19          msg = xend.utils.message(CMSG_BLKIF_BE, CMSG_BLKIF_BE_VBD_GROW, 0)
   17.20 -        msg.append_payload(struct.pack("QIHHHQQI",dom,0,vdev,0, \
   17.21 +        msg.append_payload(struct.pack("IIHHHQQI",dom,0,vdev,0, \
   17.22                                         pdev,start_sect,nr_sect,0))
   17.23          backend_tx_req(msg)
   17.24      elif subtype == CMSG_BLKIF_BE_VBD_GROW:
   17.25 @@ -84,7 +84,7 @@ class interface:
   17.26          self.pendmsg = None
   17.27          interface.list[key] = self
   17.28          msg = xend.utils.message(CMSG_BLKIF_BE, CMSG_BLKIF_BE_CREATE, 0)
   17.29 -        msg.append_payload(struct.pack("QII",dom,0,0))
   17.30 +        msg.append_payload(struct.pack("III",dom,0,0))
   17.31          xend.blkif.pendaddr = xend.main.mgmt_req_addr
   17.32          backend_tx_req(msg)
   17.33  
   17.34 @@ -94,7 +94,7 @@ class interface:
   17.35              return False
   17.36          self.devices[vdev] = (pdev, start_sect, nr_sect, readonly)
   17.37          msg = xend.utils.message(CMSG_BLKIF_BE, CMSG_BLKIF_BE_VBD_CREATE, 0)
   17.38 -        msg.append_payload(struct.pack("QIHII",self.dom,0,vdev,readonly,0))
   17.39 +        msg.append_payload(struct.pack("IIHII",self.dom,0,vdev,readonly,0))
   17.40          xend.blkif.pendaddr = xend.main.mgmt_req_addr
   17.41          backend_tx_req(msg)
   17.42          return True
   17.43 @@ -104,7 +104,7 @@ class interface:
   17.44      def destroy(self):
   17.45          del interface.list[self.key]
   17.46          msg = xend.utils.message(CMSG_BLKIF_BE, CMSG_BLKIF_BE_DESTROY, 0)
   17.47 -        msg.append_payload(struct.pack("QII",self.dom,0,0))
   17.48 +        msg.append_payload(struct.pack("III",self.dom,0,0))
   17.49          backend_tx_req(msg)        
   17.50  
   17.51  
   17.52 @@ -138,6 +138,6 @@ class interface:
   17.53              self.evtchn = xc.evtchn_bind_interdomain(dom1=0,dom2=self.dom)
   17.54              msg = xend.utils.message(CMSG_BLKIF_BE, \
   17.55                                       CMSG_BLKIF_BE_CONNECT, 0)
   17.56 -            msg.append_payload(struct.pack("QIILI",self.dom,0, \
   17.57 +            msg.append_payload(struct.pack("IIILI",self.dom,0, \
   17.58                                             self.evtchn['port1'],frame,0))
   17.59              backend_tx_req(msg)
    18.1 --- a/tools/xend/lib/netif.py	Thu Jun 03 09:31:38 2004 +0000
    18.2 +++ b/tools/xend/lib/netif.py	Thu Jun 03 11:45:16 2004 +0000
    18.3 @@ -40,7 +40,7 @@ def backend_rx_rsp(port, msg):
    18.4          xend.main.send_management_response(rsp, xend.netif.pendaddr)
    18.5      elif subtype == CMSG_NETIF_BE_CONNECT:
    18.6          (dom,hnd,evtchn,tx_frame,rx_frame,st) = \
    18.7 -           struct.unpack("QIILLI", msg.get_payload())
    18.8 +           struct.unpack("IIILLI", msg.get_payload())
    18.9          netif = interface.list[xend.main.port_from_dom(dom).local_port]
   18.10          msg = xend.utils.message(CMSG_NETIF_FE, \
   18.11                                   CMSG_NETIF_FE_INTERFACE_STATUS_CHANGED, 0)
   18.12 @@ -88,7 +88,7 @@ class interface:
   18.13                  
   18.14          interface.list[key] = self
   18.15          msg = xend.utils.message(CMSG_NETIF_BE, CMSG_NETIF_BE_CREATE, 0)
   18.16 -        msg.append_payload(struct.pack("QIBBBBBBBBI",dom,0, \
   18.17 +        msg.append_payload(struct.pack("IIBBBBBBBBI",dom,0, \
   18.18                                         self.mac[0],self.mac[1], \
   18.19                                         self.mac[2],self.mac[3], \
   18.20                                         self.mac[4],self.mac[5], \
   18.21 @@ -101,7 +101,7 @@ class interface:
   18.22      def destroy(self):
   18.23          del interface.list[self.key]
   18.24          msg = xend.utils.message(CMSG_NETIF_BE, CMSG_NETIF_BE_DESTROY, 0)
   18.25 -        msg.append_payload(struct.pack("QII",self.dom,0,0))
   18.26 +        msg.append_payload(struct.pack("III",self.dom,0,0))
   18.27          backend_tx_req(msg)        
   18.28  
   18.29  
   18.30 @@ -138,7 +138,7 @@ class interface:
   18.31              self.evtchn = xc.evtchn_bind_interdomain(dom1=0,dom2=self.dom)
   18.32              msg = xend.utils.message(CMSG_NETIF_BE, \
   18.33                                       CMSG_NETIF_BE_CONNECT, 0)
   18.34 -            msg.append_payload(struct.pack("QIILLI",self.dom,0, \
   18.35 +            msg.append_payload(struct.pack("IIILLI",self.dom,0, \
   18.36                                             self.evtchn['port1'],tx_frame, \
   18.37                                             rx_frame,0))
   18.38              backend_tx_req(msg)
    19.1 --- a/tools/xend/lib/utils.c	Thu Jun 03 09:31:38 2004 +0000
    19.2 +++ b/tools/xend/lib/utils.c	Thu Jun 03 11:45:16 2004 +0000
    19.3 @@ -408,7 +408,7 @@ typedef struct {
    19.4      PyObject_HEAD;
    19.5      int mem_fd;
    19.6      int xc_handle;
    19.7 -    u64 remote_dom;
    19.8 +    u32 remote_dom;
    19.9      int local_port, remote_port;
   19.10      control_if_t    *interface;
   19.11      CONTROL_RING_IDX tx_req_cons, tx_resp_prod;
   19.12 @@ -661,11 +661,11 @@ staticforward PyTypeObject xu_port_type;
   19.13  static PyObject *xu_port_new(PyObject *self, PyObject *args)
   19.14  {
   19.15      xu_port_object *xup;
   19.16 -    u64 dom;
   19.17 +    u32 dom;
   19.18      int port1, port2;
   19.19      xc_dominfo_t info;
   19.20  
   19.21 -    if ( !PyArg_ParseTuple(args, "L", &dom) )
   19.22 +    if ( !PyArg_ParseTuple(args, "i", &dom) )
   19.23          return NULL;
   19.24  
   19.25      xup = PyObject_New(xu_port_object, &xu_port_type);
   19.26 @@ -677,8 +677,7 @@ static PyObject *xu_port_new(PyObject *s
   19.27      }
   19.28  
   19.29      /* Set the General-Purpose Subject whose page frame will be mapped. */
   19.30 -    (void)ioctl(xup->mem_fd, _IO('M', 1), (unsigned long)(dom>> 0)); /* low  */
   19.31 -    (void)ioctl(xup->mem_fd, _IO('M', 2), (unsigned long)(dom>>32)); /* high */
   19.32 +    (void)ioctl(xup->mem_fd, _IO('M', 1), (unsigned long)dom);
   19.33  
   19.34      if ( (xup->xc_handle = xc_interface_open()) == -1 )
   19.35      {
   19.36 @@ -686,7 +685,7 @@ static PyObject *xu_port_new(PyObject *s
   19.37          goto fail2;
   19.38      }
   19.39  
   19.40 -    if ( dom == 0ULL )
   19.41 +    if ( dom == 0 )
   19.42      {
   19.43          /*
   19.44           * The control-interface event channel for DOM0 is already set up.
   19.45 @@ -758,7 +757,7 @@ static PyObject *xu_port_getattr(PyObjec
   19.46      if ( strcmp(name, "remote_port") == 0 )
   19.47          return PyInt_FromLong(xup->remote_port);
   19.48      if ( strcmp(name, "remote_dom") == 0 )
   19.49 -        return PyLong_FromUnsignedLongLong(xup->remote_dom);
   19.50 +        return PyInt_FromLong(xup->remote_dom);
   19.51      return Py_FindMethod(xu_port_methods, obj, name);
   19.52  }
   19.53  
   19.54 @@ -766,7 +765,7 @@ static void xu_port_dealloc(PyObject *se
   19.55  {
   19.56      xu_port_object *xup = (xu_port_object *)self;
   19.57      unmap_control_interface(xup->mem_fd, xup->interface);
   19.58 -    if ( xup->remote_dom != 0ULL )
   19.59 +    if ( xup->remote_dom != 0 )
   19.60          (void)xc_evtchn_close(xup->xc_handle, DOMID_SELF, xup->local_port);
   19.61      (void)xc_interface_close(xup->xc_handle);
   19.62      (void)close(xup->mem_fd);
    20.1 --- a/xen/common/dom0_ops.c	Thu Jun 03 09:31:38 2004 +0000
    20.2 +++ b/xen/common/dom0_ops.c	Thu Jun 03 11:45:16 2004 +0000
    20.3 @@ -42,7 +42,7 @@ static void write_msr_for(void *unused)
    20.4  static void read_msr_for(void *unused)
    20.5  {
    20.6      if (((1 << current->processor) & msr_cpu_mask))
    20.7 -	rdmsr(msr_addr, msr_lo, msr_hi);
    20.8 +        rdmsr(msr_addr, msr_lo, msr_hi);
    20.9  }
   20.10  
   20.11      
   20.12 @@ -64,8 +64,9 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
   20.13          return -EACCES;
   20.14      }
   20.15  
   20.16 -    TRACE_5D( TRC_DOM0OP_ENTER_BASE + op->cmd, 
   20.17 -	 0, op->u.dummy[0], op->u.dummy[1], op->u.dummy[2], op->u.dummy[3] );
   20.18 +    TRACE_5D(TRC_DOM0OP_ENTER_BASE + op->cmd, 
   20.19 +             0, op->u.dummy[0], op->u.dummy[1], 
   20.20 +             op->u.dummy[2], op->u.dummy[3] );
   20.21  
   20.22      switch ( op->cmd )
   20.23      {
   20.24 @@ -102,19 +103,20 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
   20.25      case DOM0_STOPDOMAIN:
   20.26      {
   20.27          ret = stop_other_domain(op->u.stopdomain.domain);
   20.28 -	
   20.29 -	/* This is grim, but helps for live migrate. It's also unsafe
   20.30 -	   in the strict sense as we're not explicitly setting a
   20.31 -	   timeout, but dom0 is bound to have other timers going off to
   20.32 -	   wake us back up. 
   20.33 -	   We go to sleep so that the other domain can stop quicker, hence
   20.34 -	   we have less total down time in a migrate.
   20.35 -	 */
   20.36 -	if( ret == 0 && op->u.stopdomain.sync == 1 )
   20.37 -	{
   20.38 -	    extern long do_block( void );
   20.39 -	    do_block(); // Yuk...
   20.40 -	}
   20.41 + 
   20.42 +        /*
   20.43 +         * This is grim, but helps for live migrate. It's also unsafe
   20.44 +         * in the strict sense as we're not explicitly setting a
   20.45 +         * timeout, but dom0 is bound to have other timers going off to
   20.46 +         * wake us back up. 
   20.47 +         * We go to sleep so that the other domain can stop quicker, hence
   20.48 +         * we have less total down time in a migrate.
   20.49 +         */
   20.50 +        if( ret == 0 && op->u.stopdomain.sync == 1 )
   20.51 +        {
   20.52 +            extern long do_block( void );
   20.53 +            do_block(); /* Yuk... */
   20.54 +        }
   20.55      }
   20.56      break;
   20.57  
   20.58 @@ -127,24 +129,34 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
   20.59          domid_t dom;
   20.60          ret = -ENOMEM;
   20.61  
   20.62 -        spin_lock(&domnr_lock);
   20.63 -        dom = ++domnr;
   20.64 -        spin_unlock(&domnr_lock);
   20.65 +        /* Search for an unused domain identifier. */
   20.66 +        for ( ; ; )
   20.67 +        {
   20.68 +            spin_lock(&domnr_lock);
   20.69 +            /* Wrap the roving counter when we reach first special value. */
   20.70 +            if ( (dom = ++domnr) == DOMID_SELF )
   20.71 +                dom = domnr = 1;
   20.72 +            spin_unlock(&domnr_lock);
   20.73  
   20.74 -	if (op->u.createdomain.cpu == -1 )
   20.75 -	    pro = (unsigned int)dom % smp_num_cpus;
   20.76 -	else
   20.77 -	    pro = op->u.createdomain.cpu % smp_num_cpus;
   20.78 +            if ( (p = find_domain_by_id(dom)) == NULL )
   20.79 +                break;
   20.80 +            put_task_struct(p);
   20.81 +        }
   20.82 +
   20.83 +        if (op->u.createdomain.cpu == -1 )
   20.84 +            pro = (unsigned int)dom % smp_num_cpus;
   20.85 +        else
   20.86 +            pro = op->u.createdomain.cpu % smp_num_cpus;
   20.87  
   20.88          p = do_createdomain(dom, pro);
   20.89          if ( p == NULL ) 
   20.90              break;
   20.91  
   20.92 -	if ( op->u.createdomain.name[0] )
   20.93 +        if ( op->u.createdomain.name[0] )
   20.94          {
   20.95              strncpy(p->name, op->u.createdomain.name, MAX_DOMAIN_NAME);
   20.96              p->name[MAX_DOMAIN_NAME - 1] = '\0';
   20.97 -	}
   20.98 +        }
   20.99  
  20.100          ret = alloc_new_dom_mem(p, op->u.createdomain.memory_kb);
  20.101          if ( ret != 0 ) 
  20.102 @@ -192,7 +204,8 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
  20.103                  else
  20.104                  {
  20.105                      /* Pause domain if necessary. */
  20.106 -                    if( !(p->state & TASK_STOPPED) && !(p->state & TASK_PAUSED) )
  20.107 +                    if( !(p->state & TASK_STOPPED) && 
  20.108 +                        !(p->state & TASK_PAUSED) )
  20.109                      {
  20.110                          sched_pause_sync(p);
  20.111                          we_paused = 1;
  20.112 @@ -210,7 +223,7 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
  20.113                      ret = 0;
  20.114                  }
  20.115                  put_task_struct(p);
  20.116 -            }     	
  20.117 +            }      
  20.118          }
  20.119      }
  20.120      break;
  20.121 @@ -278,13 +291,13 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
  20.122          for_each_domain ( p )
  20.123          {
  20.124              if ( p->domain >= op->u.getdomaininfo.domain )
  20.125 -		break;
  20.126 +                break;
  20.127          }
  20.128  
  20.129          if ( p == NULL )
  20.130          {
  20.131              ret = -ESRCH;
  20.132 -	    goto gdi_out;
  20.133 +            goto gdi_out;
  20.134          }
  20.135          else
  20.136          {
  20.137 @@ -304,13 +317,13 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
  20.138  
  20.139              if ( p->state == TASK_STOPPED && op->u.getdomaininfo.ctxt )
  20.140              {
  20.141 -		full_execution_context_t *c=NULL;
  20.142 +                full_execution_context_t *c=NULL;
  20.143  
  20.144 -		if ( (c = kmalloc(sizeof(*c), GFP_KERNEL)) == NULL )
  20.145 -		{
  20.146 -		    ret= -ENOMEM;
  20.147 -		    goto gdi_out;
  20.148 -		}
  20.149 +                if ( (c = kmalloc(sizeof(*c), GFP_KERNEL)) == NULL )
  20.150 +                {
  20.151 +                    ret= -ENOMEM;
  20.152 +                    goto gdi_out;
  20.153 +                }
  20.154  
  20.155                  rmb(); /* Ensure that we see saved register state. */
  20.156                  c->flags = 0;
  20.157 @@ -360,17 +373,17 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
  20.158                  c->failsafe_callback_eip = 
  20.159                      p->failsafe_address;
  20.160  
  20.161 -		if( copy_to_user(op->u.getdomaininfo.ctxt, c, sizeof(*c)) )
  20.162 -		{
  20.163 -		    ret = -EINVAL;
  20.164 -		}
  20.165 +                if( copy_to_user(op->u.getdomaininfo.ctxt, c, sizeof(*c)) )
  20.166 +                {
  20.167 +                    ret = -EINVAL;
  20.168 +                }
  20.169  
  20.170 -		if (c) kfree(c);
  20.171 +                if (c) kfree(c);
  20.172              }
  20.173          }
  20.174  
  20.175 -        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )	    
  20.176 -	    ret = -EINVAL;
  20.177 +        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )     
  20.178 +            ret = -EINVAL;
  20.179  
  20.180      gdi_out:
  20.181          read_unlock_irqrestore(&tasklist_lock, flags);
  20.182 @@ -437,16 +450,16 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
  20.183      case DOM0_MSR:
  20.184      {
  20.185          if ( op->u.msr.write )
  20.186 -	{
  20.187 +        {
  20.188              msr_cpu_mask = op->u.msr.cpu_mask;
  20.189              msr_addr = op->u.msr.msr;
  20.190              msr_lo = op->u.msr.in1;
  20.191              msr_hi = op->u.msr.in2;
  20.192              smp_call_function(write_msr_for, NULL, 1, 1);
  20.193              write_msr_for(NULL);
  20.194 -	}
  20.195 +        }
  20.196          else
  20.197 -	{
  20.198 +        {
  20.199              msr_cpu_mask = op->u.msr.cpu_mask;
  20.200              msr_addr = op->u.msr.msr;
  20.201              smp_call_function(read_msr_for, NULL, 1, 1);
  20.202 @@ -455,7 +468,7 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
  20.203              op->u.msr.out1 = msr_lo;
  20.204              op->u.msr.out2 = msr_hi;
  20.205              copy_to_user(u_dom0_op, op, sizeof(*op));
  20.206 -	}
  20.207 +        }
  20.208          ret = 0;
  20.209      }
  20.210      break;
  20.211 @@ -481,7 +494,7 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
  20.212      case DOM0_GETTBUFS:
  20.213      {
  20.214          ret = get_tb_info(&op->u.gettbufs);
  20.215 -	copy_to_user(u_dom0_op, op, sizeof(*op));
  20.216 +        copy_to_user(u_dom0_op, op, sizeof(*op));
  20.217      }
  20.218      break;
  20.219  #endif
  20.220 @@ -489,8 +502,8 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
  20.221      case DOM0_READCONSOLE:
  20.222      {
  20.223          ret = read_console_ring(op->u.readconsole.str, 
  20.224 -                         	op->u.readconsole.count,
  20.225 -				op->u.readconsole.cmd); 
  20.226 +                                op->u.readconsole.count,
  20.227 +                                op->u.readconsole.cmd); 
  20.228      }
  20.229      break;
  20.230  
  20.231 @@ -530,15 +543,15 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
  20.232  
  20.233      case DOM0_SHADOW_CONTROL:
  20.234      {
  20.235 -	struct task_struct *p; 
  20.236 -	ret = -ESRCH;
  20.237 -	p = find_domain_by_id( op->u.shadow_control.domain );
  20.238 -	if ( p )
  20.239 -	{
  20.240 +        struct task_struct *p; 
  20.241 +        ret = -ESRCH;
  20.242 +        p = find_domain_by_id( op->u.shadow_control.domain );
  20.243 +        if ( p )
  20.244 +        {
  20.245              ret = shadow_mode_control(p, &op->u.shadow_control );
  20.246 -	    put_task_struct(p);
  20.247 -	    copy_to_user(u_dom0_op, op, sizeof(*op));
  20.248 -        }	
  20.249 +            put_task_struct(p);
  20.250 +            copy_to_user(u_dom0_op, op, sizeof(*op));
  20.251 +        } 
  20.252      }
  20.253      break;
  20.254  
  20.255 @@ -553,131 +566,131 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
  20.256  
  20.257      case DOM0_SETDOMAINNAME:
  20.258      {
  20.259 -	struct task_struct *p; 
  20.260 -	p = find_domain_by_id( op->u.setdomainname.domain );
  20.261 -	if ( p )
  20.262 -	{
  20.263 -	    strncpy(p->name, op->u.setdomainname.name, MAX_DOMAIN_NAME);
  20.264 -	    put_task_struct(p);
  20.265 -	}
  20.266 -	else 
  20.267 -	    ret = -ESRCH;
  20.268 +        struct task_struct *p; 
  20.269 +        p = find_domain_by_id( op->u.setdomainname.domain );
  20.270 +        if ( p )
  20.271 +        {
  20.272 +            strncpy(p->name, op->u.setdomainname.name, MAX_DOMAIN_NAME);
  20.273 +            put_task_struct(p);
  20.274 +        }
  20.275 +        else 
  20.276 +            ret = -ESRCH;
  20.277      }
  20.278      break;
  20.279  
  20.280      case DOM0_SETDOMAININITIALMEM:
  20.281      {
  20.282 -	struct task_struct *p; 
  20.283 -	ret = -ESRCH;
  20.284 -	p = find_domain_by_id( op->u.setdomaininitialmem.domain );
  20.285 -	if ( p )
  20.286 -	{	
  20.287 -	    /* should only be used *before* domain is built. */
  20.288 +        struct task_struct *p; 
  20.289 +        ret = -ESRCH;
  20.290 +        p = find_domain_by_id( op->u.setdomaininitialmem.domain );
  20.291 +        if ( p )
  20.292 +        { 
  20.293 +            /* should only be used *before* domain is built. */
  20.294              if ( ! test_bit(PF_CONSTRUCTED, &p->flags) )
  20.295 -		ret = alloc_new_dom_mem( 
  20.296 -		    p, op->u.setdomaininitialmem.initial_memkb );
  20.297 -	    else
  20.298 -		ret = -EINVAL;
  20.299 -	    put_task_struct(p);
  20.300 -	}
  20.301 +                ret = alloc_new_dom_mem( 
  20.302 +                    p, op->u.setdomaininitialmem.initial_memkb );
  20.303 +            else
  20.304 +                ret = -EINVAL;
  20.305 +            put_task_struct(p);
  20.306 +        }
  20.307      }
  20.308      break;
  20.309  
  20.310      case DOM0_SETDOMAINMAXMEM:
  20.311      {
  20.312 -	struct task_struct *p; 
  20.313 -	p = find_domain_by_id( op->u.setdomainmaxmem.domain );
  20.314 -	if ( p )
  20.315 -	{
  20.316 -	    p->max_pages = 
  20.317 -		(op->u.setdomainmaxmem.max_memkb+PAGE_SIZE-1)>> PAGE_SHIFT;
  20.318 -	    put_task_struct(p);
  20.319 -	}
  20.320 -	else 
  20.321 -	    ret = -ESRCH;
  20.322 +        struct task_struct *p; 
  20.323 +        p = find_domain_by_id( op->u.setdomainmaxmem.domain );
  20.324 +        if ( p )
  20.325 +        {
  20.326 +            p->max_pages = 
  20.327 +                (op->u.setdomainmaxmem.max_memkb+PAGE_SIZE-1)>> PAGE_SHIFT;
  20.328 +            put_task_struct(p);
  20.329 +        }
  20.330 +        else 
  20.331 +            ret = -ESRCH;
  20.332      }
  20.333      break;
  20.334  
  20.335      case DOM0_GETPAGEFRAMEINFO2:
  20.336      {
  20.337  #define GPF2_BATCH 128
  20.338 -	int n,j;
  20.339 +        int n,j;
  20.340          int num = op->u.getpageframeinfo2.num;
  20.341          domid_t dom = op->u.getpageframeinfo2.domain;
  20.342 -	unsigned long *s_ptr = (unsigned long*) op->u.getpageframeinfo2.array;
  20.343 +        unsigned long *s_ptr = (unsigned long*) op->u.getpageframeinfo2.array;
  20.344          struct task_struct *p;
  20.345 -	unsigned long l_arr[GPF2_BATCH];
  20.346 +        unsigned long l_arr[GPF2_BATCH];
  20.347          ret = -ESRCH;
  20.348  
  20.349 -	if ( unlikely((p = find_domain_by_id(dom)) == NULL) )
  20.350 -	    break;
  20.351 +        if ( unlikely((p = find_domain_by_id(dom)) == NULL) )
  20.352 +            break;
  20.353  
  20.354 -	if ( unlikely(num>1024) )
  20.355 -	{
  20.356 -	    ret = -E2BIG;
  20.357 -	    break;
  20.358 -	}
  20.359 -	
  20.360 -	ret = 0;    
  20.361 -	for(n=0;n<num;)
  20.362 -	{
  20.363 -	    int k = ((num-n)>GPF2_BATCH)?GPF2_BATCH:(num-n);
  20.364 +        if ( unlikely(num>1024) )
  20.365 +        {
  20.366 +            ret = -E2BIG;
  20.367 +            break;
  20.368 +        }
  20.369 + 
  20.370 +        ret = 0;    
  20.371 +        for(n=0;n<num;)
  20.372 +        {
  20.373 +            int k = ((num-n)>GPF2_BATCH)?GPF2_BATCH:(num-n);
  20.374  
  20.375 -	    if( copy_from_user( l_arr, &s_ptr[n], k*sizeof(unsigned long) ) )
  20.376 -	    {
  20.377 -		ret = -EINVAL;
  20.378 -		break;
  20.379 -	    }
  20.380 -	    
  20.381 -	    for(j=0;j<k;j++)
  20.382 -	    {		    
  20.383 -		struct pfn_info *page;
  20.384 -		unsigned long mfn = l_arr[j];
  20.385 +            if( copy_from_user( l_arr, &s_ptr[n], k*sizeof(unsigned long) ) )
  20.386 +            {
  20.387 +                ret = -EINVAL;
  20.388 +                break;
  20.389 +            }
  20.390 +     
  20.391 +            for(j=0;j<k;j++)
  20.392 +            {      
  20.393 +                struct pfn_info *page;
  20.394 +                unsigned long mfn = l_arr[j];
  20.395  
  20.396 -		if ( unlikely(mfn >= max_page) )
  20.397 -		    goto e2_err;
  20.398 +                if ( unlikely(mfn >= max_page) )
  20.399 +                    goto e2_err;
  20.400  
  20.401 -		page = &frame_table[mfn];
  20.402 -		
  20.403 -		if ( likely(get_page(page, p)) )
  20.404 -		{
  20.405 -		    unsigned long type = 0;
  20.406 -		    switch( page->type_and_flags & PGT_type_mask )
  20.407 -		    {
  20.408 -		    case PGT_l1_page_table:
  20.409 -			type = L1TAB;
  20.410 -			break;
  20.411 -		    case PGT_l2_page_table:
  20.412 -			type = L2TAB;
  20.413 -			break;
  20.414 -		    case PGT_l3_page_table:
  20.415 -			type = L3TAB;
  20.416 -			break;
  20.417 -		    case PGT_l4_page_table:
  20.418 -			type = L4TAB;
  20.419 -			break;
  20.420 -		    }
  20.421 -		    l_arr[j] |= type;
  20.422 -		    put_page(page);
  20.423 -		}
  20.424 -		else
  20.425 -		{
  20.426 -		e2_err:
  20.427 -		    l_arr[j] |= XTAB;
  20.428 -		}
  20.429 +                page = &frame_table[mfn];
  20.430 +  
  20.431 +                if ( likely(get_page(page, p)) )
  20.432 +                {
  20.433 +                    unsigned long type = 0;
  20.434 +                    switch( page->type_and_flags & PGT_type_mask )
  20.435 +                    {
  20.436 +                    case PGT_l1_page_table:
  20.437 +                        type = L1TAB;
  20.438 +                        break;
  20.439 +                    case PGT_l2_page_table:
  20.440 +                        type = L2TAB;
  20.441 +                        break;
  20.442 +                    case PGT_l3_page_table:
  20.443 +                        type = L3TAB;
  20.444 +                        break;
  20.445 +                    case PGT_l4_page_table:
  20.446 +                        type = L4TAB;
  20.447 +                        break;
  20.448 +                    }
  20.449 +                    l_arr[j] |= type;
  20.450 +                    put_page(page);
  20.451 +                }
  20.452 +                else
  20.453 +                {
  20.454 +                e2_err:
  20.455 +                    l_arr[j] |= XTAB;
  20.456 +                }
  20.457  
  20.458 -	    }
  20.459 +            }
  20.460  
  20.461 -	    if( copy_to_user( &s_ptr[n], l_arr, k*sizeof(unsigned long) ) )
  20.462 -	    {
  20.463 -		ret = -EINVAL;
  20.464 -		break;
  20.465 -	    }
  20.466 +            if( copy_to_user( &s_ptr[n], l_arr, k*sizeof(unsigned long) ) )
  20.467 +            {
  20.468 +                ret = -EINVAL;
  20.469 +                break;
  20.470 +            }
  20.471  
  20.472 -	    n+=j;	    
  20.473 -	}
  20.474 +            n+=j;     
  20.475 +        }
  20.476  
  20.477 -	put_task_struct(p);
  20.478 +        put_task_struct(p);
  20.479  
  20.480      }
  20.481      break;
  20.482 @@ -687,8 +700,8 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
  20.483  
  20.484      }
  20.485  
  20.486 -    TRACE_5D( TRC_DOM0OP_LEAVE_BASE + op->cmd, ret,
  20.487 -	 op->u.dummy[0], op->u.dummy[1], op->u.dummy[2], op->u.dummy[3]  );
  20.488 +    TRACE_5D(TRC_DOM0OP_LEAVE_BASE + op->cmd, ret,
  20.489 +             op->u.dummy[0], op->u.dummy[1], op->u.dummy[2], op->u.dummy[3]);
  20.490  
  20.491  
  20.492      return ret;
    21.1 --- a/xen/common/dom_mem_ops.c	Thu Jun 03 09:31:38 2004 +0000
    21.2 +++ b/xen/common/dom_mem_ops.c	Thu Jun 03 11:45:16 2004 +0000
    21.3 @@ -64,7 +64,7 @@ static long free_dom_mem(struct task_str
    21.4  
    21.5          if ( unlikely(mpfn >= max_page) )
    21.6          {
    21.7 -            DPRINTK("Domain %llu page number out of range (%08lx>=%08lx)\n", 
    21.8 +            DPRINTK("Domain %u page number out of range (%08lx>=%08lx)\n", 
    21.9                      p->domain, mpfn, max_page);
   21.10              rc = -EINVAL;
   21.11              break;
   21.12 @@ -73,7 +73,7 @@ static long free_dom_mem(struct task_str
   21.13          page = &frame_table[mpfn];
   21.14          if ( unlikely(!get_page(page, p)) )
   21.15          {
   21.16 -            DPRINTK("Bad page free for domain %llu\n", p->domain);
   21.17 +            DPRINTK("Bad page free for domain %u\n", p->domain);
   21.18              rc = -EINVAL;
   21.19              break;
   21.20          }
    22.1 --- a/xen/common/domain.c	Thu Jun 03 09:31:38 2004 +0000
    22.2 +++ b/xen/common/domain.c	Thu Jun 03 11:45:16 2004 +0000
    22.3 @@ -75,7 +75,7 @@ struct task_struct *do_createdomain(domi
    22.4          }
    22.5          
    22.6          /* We use a large intermediate to avoid overflow in sprintf. */
    22.7 -        sprintf(buf, "Domain-%llu", dom_id);
    22.8 +        sprintf(buf, "Domain-%u", dom_id);
    22.9          strncpy(p->name, buf, MAX_DOMAIN_NAME);
   22.10          p->name[MAX_DOMAIN_NAME-1] = '\0';
   22.11  
   22.12 @@ -90,15 +90,13 @@ struct task_struct *do_createdomain(domi
   22.13          p->shared_info = (void *)get_free_page(GFP_KERNEL);
   22.14          memset(p->shared_info, 0, PAGE_SIZE);
   22.15          SHARE_PFN_WITH_DOMAIN(virt_to_page(p->shared_info), p);
   22.16 -        
   22.17 -	machine_to_phys_mapping[virt_to_phys(p->shared_info) >> PAGE_SHIFT] =
   22.18 -	    0x80000000UL;  // set m2p table to magic marker (helps debug)
   22.19 +        machine_to_phys_mapping[virt_to_phys(p->shared_info) >> 
   22.20 +                               PAGE_SHIFT] = 0x80000000UL;  /* debug */
   22.21  
   22.22          p->mm.perdomain_pt = (l1_pgentry_t *)get_free_page(GFP_KERNEL);
   22.23          memset(p->mm.perdomain_pt, 0, PAGE_SIZE);
   22.24 -        
   22.25 -	machine_to_phys_mapping[virt_to_phys(p->mm.perdomain_pt) >> PAGE_SHIFT] =
   22.26 -	    0x0fffdeadUL;  // set m2p table to magic marker (helps debug)
   22.27 +        machine_to_phys_mapping[virt_to_phys(p->mm.perdomain_pt) >> 
   22.28 +                               PAGE_SHIFT] = 0x0fffdeadUL;  /* debug */
   22.29  
   22.30          init_blkdev_info(p);
   22.31          
   22.32 @@ -161,8 +159,8 @@ struct task_struct *find_last_domain(voi
   22.33      p = plast->next_list;
   22.34      while ( p != NULL )
   22.35      {
   22.36 -	if ( p->create_time > plast->create_time )
   22.37 -	    plast = p;
   22.38 +        if ( p->create_time > plast->create_time )
   22.39 +            plast = p;
   22.40          p = p->next_list;
   22.41      }
   22.42      get_task_struct(plast);
   22.43 @@ -174,7 +172,7 @@ struct task_struct *find_last_domain(voi
   22.44  
   22.45  void kill_domain_with_errmsg(const char *err)
   22.46  {
   22.47 -    printk("DOM%llu FATAL ERROR: %s\n", current->domain, err);
   22.48 +    printk("DOM%u FATAL ERROR: %s\n", current->domain, err);
   22.49      kill_domain();
   22.50  }
   22.51  
   22.52 @@ -196,7 +194,7 @@ void __kill_domain(struct task_struct *p
   22.53      if ( !sched_rem_domain(p) )
   22.54          return;
   22.55  
   22.56 -    DPRINTK("Killing domain %llu\n", p->domain);
   22.57 +    DPRINTK("Killing domain %u\n", p->domain);
   22.58  
   22.59      unlink_blkdev_info(p);
   22.60  
   22.61 @@ -270,9 +268,9 @@ void stop_domain(void)
   22.62      /* OK, this is grim, but helps speed up live migrate. When a domain stops,
   22.63         kick Dom0 */
   22.64      {
   22.65 -	struct task_struct *p;
   22.66 -	guest_schedule_to_run( p = find_domain_by_id(0ULL) );
   22.67 -	put_task_struct(p);
   22.68 +        struct task_struct *p;
   22.69 +        guest_schedule_to_run( p = find_domain_by_id(0ULL) );
   22.70 +        put_task_struct(p);
   22.71      }
   22.72  
   22.73      __enter_scheduler();
   22.74 @@ -355,7 +353,7 @@ struct pfn_info *alloc_domain_page(struc
   22.75          spin_lock(&p->page_list_lock);
   22.76          if ( unlikely(p->tot_pages >= p->max_pages) )
   22.77          {
   22.78 -            DPRINTK("Over-allocation for domain %llu: %u >= %u\n",
   22.79 +            DPRINTK("Over-allocation for domain %u: %u >= %u\n",
   22.80                      p->domain, p->tot_pages, p->max_pages);
   22.81              spin_unlock(&p->page_list_lock);
   22.82              goto free_and_exit;
   22.83 @@ -393,14 +391,14 @@ void free_domain_page(struct pfn_info *p
   22.84          if ( !(page->count_and_flags & PGC_zombie) )
   22.85          {
   22.86              page->tlbflush_timestamp = tlbflush_clock;
   22.87 -	    if ( likely(p != NULL) )
   22.88 -	    {
   22.89 +            if ( likely(p != NULL) )
   22.90 +            {
   22.91                  page->u.cpu_mask = 1 << p->processor;
   22.92                  spin_lock(&p->page_list_lock);
   22.93 -		list_del(&page->list);
   22.94 -		p->tot_pages--;
   22.95 -		spin_unlock(&p->page_list_lock);
   22.96 -	    }
   22.97 +                list_del(&page->list);
   22.98 +                p->tot_pages--;
   22.99 +                spin_unlock(&p->page_list_lock);
  22.100 +            }
  22.101          }
  22.102  
  22.103          page->count_and_flags = 0;
  22.104 @@ -533,16 +531,16 @@ unsigned int alloc_new_dom_mem(struct ta
  22.105              return -ENOMEM;
  22.106          }
  22.107  
  22.108 -	/* initialise to machine_to_phys_mapping table to likely pfn */
  22.109 -	machine_to_phys_mapping[page-frame_table] = alloc_pfns;
  22.110 +        /* initialise to machine_to_phys_mapping table to likely pfn */
  22.111 +        machine_to_phys_mapping[page-frame_table] = alloc_pfns;
  22.112  
  22.113  #ifndef NDEBUG
  22.114 -	{
  22.115 -	    // initialise with magic marker if in DEBUG mode
  22.116 -	    void * a = map_domain_mem( (page-frame_table)<<PAGE_SHIFT );
  22.117 -	    memset( a, 0x80 | (char) p->domain, PAGE_SIZE );
  22.118 -	    unmap_domain_mem( a );
  22.119 -	}
  22.120 +        {
  22.121 +            /* Initialise with magic marker if in DEBUG mode. */
  22.122 +            void * a = map_domain_mem( (page-frame_table)<<PAGE_SHIFT );
  22.123 +            memset( a, 0x80 | (char) p->domain, PAGE_SIZE );
  22.124 +            unmap_domain_mem( a );
  22.125 +        }
  22.126  #endif
  22.127  
  22.128      }
  22.129 @@ -559,7 +557,7 @@ void release_task(struct task_struct *p)
  22.130      ASSERT(p->state == TASK_DYING);
  22.131      ASSERT(!p->has_cpu);
  22.132  
  22.133 -    DPRINTK("Releasing task %llu\n", p->domain);
  22.134 +    DPRINTK("Releasing task %u\n", p->domain);
  22.135  
  22.136      /*
  22.137       * This frees up blkdev rings and vbd-access lists. Totally safe since
  22.138 @@ -588,12 +586,12 @@ int final_setup_guestos(struct task_stru
  22.139      full_execution_context_t *c;
  22.140  
  22.141      if ( (c = kmalloc(sizeof(*c), GFP_KERNEL)) == NULL )
  22.142 -	return -ENOMEM;
  22.143 +        return -ENOMEM;
  22.144  
  22.145      if ( test_bit(PF_CONSTRUCTED, &p->flags) )
  22.146      {
  22.147          rc = -EINVAL;
  22.148 -	goto out;
  22.149 +        goto out;
  22.150      }
  22.151  
  22.152      if ( copy_from_user(c, builddomain->ctxt, sizeof(*c)) )
  22.153 @@ -649,7 +647,7 @@ int final_setup_guestos(struct task_stru
  22.154  
  22.155      set_bit(PF_CONSTRUCTED, &p->flags);
  22.156  
  22.157 -out:    
  22.158 + out:    
  22.159      if (c) kfree(c);
  22.160      
  22.161      return rc;
  22.162 @@ -682,13 +680,13 @@ static int readelfimage_base_and_size(ch
  22.163  
  22.164      if ( (ehdr->e_phoff + (ehdr->e_phnum * ehdr->e_phentsize)) > elfsize )
  22.165      {
  22.166 -	printk("ELF program headers extend beyond end of image.\n");
  22.167 +        printk("ELF program headers extend beyond end of image.\n");
  22.168          return -EINVAL;
  22.169      }
  22.170  
  22.171      if ( (ehdr->e_shoff + (ehdr->e_shnum * ehdr->e_shentsize)) > elfsize )
  22.172      {
  22.173 -	printk("ELF section headers extend beyond end of image.\n");
  22.174 +        printk("ELF section headers extend beyond end of image.\n");
  22.175          return -EINVAL;
  22.176      }
  22.177  
  22.178 @@ -760,7 +758,7 @@ static int loadelfimage(char *elfbase)
  22.179      {
  22.180          phdr = (Elf_Phdr *)(elfbase + ehdr->e_phoff + (h*ehdr->e_phentsize));
  22.181          if ( !is_loadable_phdr(phdr) )
  22.182 -	    continue;
  22.183 +            continue;
  22.184          if ( phdr->p_filesz != 0 )
  22.185              memcpy((char *)phdr->p_vaddr, elfbase + phdr->p_offset, 
  22.186                     phdr->p_filesz);
  22.187 @@ -1045,10 +1043,10 @@ int construct_dom0(struct task_struct *p
  22.188  
  22.189      if ( initrd_len != 0 )
  22.190      {
  22.191 -	si->mod_start = vinitrd_start;
  22.192 -	si->mod_len   = initrd_len;
  22.193 -	printk("Initrd len 0x%lx, start at 0x%08lx\n",
  22.194 -	       si->mod_len, si->mod_start);
  22.195 +        si->mod_start = vinitrd_start;
  22.196 +        si->mod_len   = initrd_len;
  22.197 +        printk("Initrd len 0x%lx, start at 0x%08lx\n",
  22.198 +               si->mod_len, si->mod_start);
  22.199      }
  22.200  
  22.201      dst = si->cmd_line;
    23.1 --- a/xen/common/keyhandler.c	Thu Jun 03 09:31:38 2004 +0000
    23.2 +++ b/xen/common/keyhandler.c	Thu Jun 03 11:45:16 2004 +0000
    23.3 @@ -22,20 +22,20 @@ void add_key_handler(u_char key, key_han
    23.4      char *str; 
    23.5  
    23.6      if ( key_table[key].handler != NULL ) 
    23.7 -	printk("Warning: overwriting handler for key 0x%x\n", key); 
    23.8 +        printk("Warning: overwriting handler for key 0x%x\n", key); 
    23.9  
   23.10      key_table[key].handler = handler; 
   23.11  
   23.12      str = key_table[key].desc; 
   23.13      for ( i = 0; i < STR_MAX; i++ )
   23.14      {
   23.15 -	if ( *desc != '\0' ) 
   23.16 -	    *str++ = *desc++; 
   23.17 -	else
   23.18 +        if ( *desc != '\0' ) 
   23.19 +            *str++ = *desc++; 
   23.20 +        else
   23.21              break; 
   23.22      }
   23.23      if ( i == STR_MAX ) 
   23.24 -	key_table[key].desc[STR_MAX-1] = '\0'; 
   23.25 +        key_table[key].desc[STR_MAX-1] = '\0'; 
   23.26  }
   23.27  
   23.28  key_handler *get_key_handler(u_char key)
   23.29 @@ -49,10 +49,10 @@ static void show_handlers(u_char key, vo
   23.30  
   23.31      printk("'%c' pressed -> showing installed handlers\n", key); 
   23.32      for ( i = 0; i < KEY_MAX; i++ ) 
   23.33 -	if ( key_table[i].handler != NULL ) 
   23.34 -	    printk(" key '%c' (ascii '%02x') => %s\n", 
   23.35 -			(i<33 || i>126)?(' '):(i),i,
   23.36 -			key_table[i].desc);
   23.37 +        if ( key_table[i].handler != NULL ) 
   23.38 +            printk(" key '%c' (ascii '%02x') => %s\n", 
   23.39 +                   (i<33 || i>126)?(' '):(i),i,
   23.40 +                   key_table[i].desc);
   23.41  }
   23.42  
   23.43  
   23.44 @@ -89,10 +89,10 @@ void do_task_queues(u_char key, void *de
   23.45  
   23.46      for_each_domain ( p )
   23.47      {
   23.48 -        printk("Xen: DOM %llu, CPU %d [has=%c], state = ",
   23.49 +        printk("Xen: DOM %u, CPU %d [has=%c], state = ",
   23.50                 p->domain, p->processor, p->has_cpu ? 'T':'F'); 
   23.51          sched_prn_state(p ->state);
   23.52 -	printk(", hyp_events = %08x\n", p->hyp_events);
   23.53 +        printk(", hyp_events = %08x\n", p->hyp_events);
   23.54          s = p->shared_info; 
   23.55          printk("Guest: upcall_pend = %02x, upcall_mask = %02x\n", 
   23.56                 s->vcpu_data[0].evtchn_upcall_pending, 
   23.57 @@ -123,8 +123,8 @@ void initialize_keytable(void)
   23.58  
   23.59      /* first initialize key handler table */
   23.60      for ( i = 0; i < KEY_MAX; i++ ) 
   23.61 -	key_table[i].handler = (key_handler *)NULL; 
   23.62 -	
   23.63 +        key_table[i].handler = (key_handler *)NULL; 
   23.64 +
   23.65      /* setup own handlers */
   23.66      add_key_handler('d', dump_registers, "dump registers"); 
   23.67      add_key_handler('h', show_handlers, "show this message");
    24.1 --- a/xen/common/memory.c	Thu Jun 03 09:31:38 2004 +0000
    24.2 +++ b/xen/common/memory.c	Thu Jun 03 11:45:16 2004 +0000
    24.3 @@ -142,8 +142,8 @@
    24.4  #include <asm/ldt.h>
    24.5  
    24.6  #ifndef NDEBUG
    24.7 -#define MEM_LOG(_f, _a...)                             \
    24.8 -  printk("DOM%llu: (file=memory.c, line=%d) " _f "\n", \
    24.9 +#define MEM_LOG(_f, _a...)                           \
   24.10 +  printk("DOM%u: (file=memory.c, line=%d) " _f "\n", \
   24.11           current->domain , __LINE__ , ## _a )
   24.12  #else
   24.13  #define MEM_LOG(_f, _a...) ((void)0)
   24.14 @@ -177,7 +177,6 @@ static struct {
   24.15  #define DOP_RELOAD_LDT  (1<<1) /* Reload the LDT shadow mapping. */
   24.16      unsigned long       deferred_ops;
   24.17      unsigned long       cr0;
   24.18 -    domid_t             subject_id;
   24.19      /* General-Purpose Subject, Page-Table Subject */
   24.20      struct task_struct *gps, *pts;
   24.21  } percpu_info[NR_CPUS] __cacheline_aligned;
   24.22 @@ -219,9 +218,9 @@ void __init init_frametable(unsigned lon
   24.23            mfn < virt_to_phys((void *)RDWR_MPT_VIRT_END)>>PAGE_SHIFT;
   24.24            mfn++ )
   24.25      {
   24.26 -	frame_table[mfn].count_and_flags = 1 | PGC_allocated;
   24.27 -	frame_table[mfn].type_and_flags = 1 | PGT_gdt_page; /* non-RW type */
   24.28 -	frame_table[mfn].u.domain = &idle0_task;
   24.29 +        frame_table[mfn].count_and_flags = 1 | PGC_allocated;
   24.30 +        frame_table[mfn].type_and_flags = 1 | PGT_gdt_page; /* non-RW type */
   24.31 +        frame_table[mfn].u.domain = &idle0_task;
   24.32      }
   24.33  }
   24.34  
   24.35 @@ -427,9 +426,9 @@ static int get_page_from_l1e(l1_pgentry_
   24.36      if ( unlikely(!pfn_is_ram(pfn)) )
   24.37      {
   24.38          if ( IS_PRIV(current) )
   24.39 -            return 1;	
   24.40 +            return 1;
   24.41  
   24.42 -	if ( IS_CAPABLE_PHYSDEV(current) )
   24.43 +        if ( IS_CAPABLE_PHYSDEV(current) )
   24.44              return domain_iomem_in_pfn(current, pfn);
   24.45  
   24.46          MEM_LOG("Non-privileged attempt to map I/O space %08lx", pfn);
   24.47 @@ -805,6 +804,7 @@ static int do_extended_command(unsigned 
   24.48      unsigned long old_base_pfn;
   24.49      struct pfn_info *page = &frame_table[pfn];
   24.50      struct task_struct *p = current, *q;
   24.51 +    domid_t domid;
   24.52  
   24.53      switch ( cmd )
   24.54      {
   24.55 @@ -914,17 +914,12 @@ static int do_extended_command(unsigned 
   24.56          break;
   24.57      }
   24.58  
   24.59 -    case MMUEXT_SET_SUBJECTDOM_L:
   24.60 -        percpu_info[cpu].subject_id = (domid_t)((ptr&~0xFFFF)|(val>>16));
   24.61 -        break;
   24.62 -
   24.63 -    case MMUEXT_SET_SUBJECTDOM_H:
   24.64 -        percpu_info[cpu].subject_id |= 
   24.65 -            ((domid_t)((ptr&~0xFFFF)|(val>>16)))<<32;
   24.66 +    case MMUEXT_SET_SUBJECTDOM:
   24.67 +        domid = ((domid_t)((ptr&~0xFFFF)|(val>>16)));
   24.68  
   24.69          if ( !IS_PRIV(p) )
   24.70          {
   24.71 -            MEM_LOG("Dom %llu has no privilege to set subject domain",
   24.72 +            MEM_LOG("Dom %u has no privilege to set subject domain",
   24.73                      p->domain);
   24.74              okay = 0;
   24.75          }
   24.76 @@ -932,13 +927,12 @@ static int do_extended_command(unsigned 
   24.77          {
   24.78              if ( percpu_info[cpu].gps != NULL )
   24.79                  put_task_struct(percpu_info[cpu].gps);
   24.80 -            percpu_info[cpu].gps = find_domain_by_id(
   24.81 -                percpu_info[cpu].subject_id);
   24.82 +            percpu_info[cpu].gps = find_domain_by_id(domid);
   24.83              percpu_info[cpu].pts = (val & SET_PAGETABLE_SUBJECTDOM) ? 
   24.84                  percpu_info[cpu].gps : NULL;
   24.85              if ( percpu_info[cpu].gps == NULL )
   24.86              {
   24.87 -                MEM_LOG("Unknown domain '%llu'", percpu_info[cpu].subject_id);
   24.88 +                MEM_LOG("Unknown domain '%u'", domid);
   24.89                  okay = 0;
   24.90              }
   24.91          }
   24.92 @@ -947,7 +941,7 @@ static int do_extended_command(unsigned 
   24.93      case MMUEXT_REASSIGN_PAGE:
   24.94          if ( unlikely(!IS_PRIV(p)) )
   24.95          {
   24.96 -            MEM_LOG("Dom %llu has no privilege to reassign page ownership",
   24.97 +            MEM_LOG("Dom %u has no privilege to reassign page ownership",
   24.98                      p->domain);
   24.99              okay = 0;
  24.100          }
  24.101 @@ -1102,10 +1096,12 @@ int do_mmu_update(mmu_update_t *ureqs, i
  24.102              machine_to_phys_mapping[pfn] = req.val;
  24.103              okay = 1;
  24.104  
  24.105 -	    /*  if in log dirty shadow mode, mark the corresponding 
  24.106 -		psuedo-physical page as dirty */
  24.107 -	    if( unlikely(current->mm.shadow_mode == SHM_logdirty) )
  24.108 -		mark_dirty( &current->mm, pfn );
  24.109 +            /*
  24.110 +             * If in log-dirty mode, mark the corresponding pseudo-physical
  24.111 +             * page as dirty.
  24.112 +             */
  24.113 +            if( unlikely(current->mm.shadow_mode == SHM_logdirty) )
  24.114 +                mark_dirty( &current->mm, pfn );
  24.115  
  24.116              put_page(&frame_table[pfn]);
  24.117              break;
  24.118 @@ -1155,7 +1151,7 @@ int do_mmu_update(mmu_update_t *ureqs, i
  24.119      }
  24.120  
  24.121      if ( unlikely(success_count != NULL) )
  24.122 -	put_user(count, success_count);
  24.123 +        put_user(count, success_count);
  24.124  
  24.125      return rc;
  24.126  }
  24.127 @@ -1241,7 +1237,7 @@ int do_update_va_mapping_otherdomain(uns
  24.128      percpu_info[cpu].gps = p = find_domain_by_id(domid);
  24.129      if ( unlikely(p == NULL) )
  24.130      {
  24.131 -        MEM_LOG("Unknown domain '%llu'", domid);
  24.132 +        MEM_LOG("Unknown domain '%u'", domid);
  24.133          return -ESRCH;
  24.134      }
  24.135  
    25.1 --- a/xen/common/network.c	Thu Jun 03 09:31:38 2004 +0000
    25.2 +++ b/xen/common/network.c	Thu Jun 03 11:45:16 2004 +0000
    25.3 @@ -370,12 +370,12 @@ void print_net_rule(net_rule_t *r)
    25.4      if ( r->src_dom == VIF_SPECIAL )
    25.5          printk("=] src_dom/idx      : %s\n", idx_to_name(r->src_idx));
    25.6      else
    25.7 -        printk("=] src_dom/idx      : %llu/%u\n", r->src_dom, r->src_idx);
    25.8 +        printk("=] src_dom/idx      : %u/%u\n", r->src_dom, r->src_idx);
    25.9  
   25.10      if ( r->dst_dom == VIF_SPECIAL )
   25.11          printk("=] dst_dom/idx      : %s\n", idx_to_name(r->dst_idx));
   25.12      else
   25.13 -        printk("=] dst_dom/idx      : %llu/%u\n", r->dst_dom, r->dst_idx);
   25.14 +        printk("=] dst_dom/idx      : %u/%u\n", r->dst_dom, r->dst_idx);
   25.15  
   25.16      printk("=] action           : %u\n", r->action);
   25.17  }
   25.18 @@ -530,8 +530,7 @@ net_vif_t *net_get_target_vif(u8 *data, 
   25.19      return target;
   25.20      
   25.21   drop:
   25.22 -    printk("VIF%llu/%u: pkt to drop!\n", 
   25.23 -           src_dom, src_idx);
   25.24 +    DPRINTK("VIF%u/%u: pkt to drop!\n", src_dom, src_idx);
   25.25      return VIF_DROP;
   25.26  }
   25.27  
    26.1 --- a/xen/common/physdev.c	Thu Jun 03 09:31:38 2004 +0000
    26.2 +++ b/xen/common/physdev.c	Thu Jun 03 11:45:16 2004 +0000
    26.3 @@ -189,7 +189,7 @@ int physdev_pci_access_modify(
    26.4               * this will allow all processes in that domain access to those
    26.5               * ports as well.  This will do for now, since driver domains don't
    26.6               * run untrusted processes! */
    26.7 -            INFO("Giving domain %llu IO resources (%lx - %lx) "
    26.8 +            INFO("Giving domain %u IO resources (%lx - %lx) "
    26.9                   "for device %s\n", dom, r->start, r->end, pdev->slot_name);
   26.10              for ( j = r->start; j < r->end + 1; j++ )
   26.11              {
   26.12 @@ -204,7 +204,7 @@ int physdev_pci_access_modify(
   26.13          }
   26.14  
   26.15          /* rights to IO memory regions are checked when the domain maps them */
   26.16 -	}
   26.17 +    }
   26.18   out:
   26.19      put_task_struct(p);
   26.20      return rc;
   26.21 @@ -217,7 +217,7 @@ int domain_iomem_in_pfn(struct task_stru
   26.22      int ret = 0;
   26.23      struct list_head *l;
   26.24  
   26.25 -    VERBOSE_INFO("Checking if physdev-capable domain %llu needs access to "
   26.26 +    VERBOSE_INFO("Checking if physdev-capable domain %u needs access to "
   26.27                   "pfn %08lx\n", p->domain, pfn);
   26.28      
   26.29      spin_lock(&p->pcidev_lock);
   26.30 @@ -245,7 +245,7 @@ int domain_iomem_in_pfn(struct task_stru
   26.31      
   26.32      spin_unlock(&p->pcidev_lock);
   26.33  
   26.34 -    VERBOSE_INFO("Domain %llu %s mapping of pfn %08lx\n",
   26.35 +    VERBOSE_INFO("Domain %u %s mapping of pfn %08lx\n",
   26.36                   p->domain, ret ? "allowed" : "disallowed", pfn);
   26.37  
   26.38      return ret;
   26.39 @@ -300,8 +300,8 @@ inline static int check_dev_acc (struct 
   26.40   * to work out the length of the io region a device probe typically does:
   26.41   * 1) a = read_base_addr_reg()
   26.42   * 2) write_base_addr_reg(0xffffffff)
   26.43 - * 3) b = read_base_addr_reg() // device zeros lower bits
   26.44 - * 4) write_base_addr_reg(a) // restore original value
   26.45 + * 3) b = read_base_addr_reg()  [device zeros lower bits]
   26.46 + * 4) write_base_addr_reg(a)    [restore original value]
   26.47   * this function fakes out step 2-4. *no* writes are made to the device.
   26.48   * 
   26.49   * phys_dev_t contains a bit field (a bit for each base address register).
   26.50 @@ -328,7 +328,7 @@ static int do_base_address_access(phys_d
   26.51          /* We could set *val to some value but the guest may well be in trouble
   26.52           * anyway if this write fails.  Hopefully the printk will give us a
   26.53           * clue what went wrong. */
   26.54 -        printk("Guest %llu attempting sub-dword %s to BASE_ADDRESS %d\n",
   26.55 +        printk("Guest %u attempting sub-dword %s to BASE_ADDRESS %d\n",
   26.56                 pdev->owner->domain, (acc == ACC_READ) ? "read" : "write", idx);
   26.57          
   26.58          return -EPERM;
    27.1 --- a/xen/common/sched_atropos.c	Thu Jun 03 09:31:38 2004 +0000
    27.2 +++ b/xen/common/sched_atropos.c	Thu Jun 03 11:45:16 2004 +0000
    27.3 @@ -513,7 +513,7 @@ task_slice_t ksched_scheduler(s_time_t t
    27.4      cur_sdom->min_slice = newtime - time;
    27.5      DOM_INFO(cur_sdom)->reason = reason;
    27.6  
    27.7 -    TRACE_2D(0, (cur_sdom->domain >> 32), ((u32)cur_sdom->domain));
    27.8 +    TRACE_1D(0, cur_sdom->domain);
    27.9   
   27.10      return ret;
   27.11  }
    28.1 --- a/xen/common/sched_bvt.c	Thu Jun 03 09:31:38 2004 +0000
    28.2 +++ b/xen/common/sched_bvt.c	Thu Jun 03 11:45:16 2004 +0000
    28.3 @@ -205,10 +205,10 @@ int bvt_adjdom(struct task_struct *p,
    28.4          
    28.5          struct bvt_dom_info *inf = BVT_INFO(p);
    28.6          
    28.7 -
    28.8 -		printk("Get domain %lld bvt mcu_adv=%ld, warp=%ld, warpl=%ld, warpu=%ld\n",
    28.9 -			   p->domain, inf->mcu_advance, inf->warp,
   28.10 -			   inf->warpl, inf->warpu );
   28.11 +        DPRINTK("Get domain %u bvt mcu_adv=%ld, warp=%ld, "
   28.12 +                "warpl=%ld, warpu=%ld\n",
   28.13 +                p->domain, inf->mcu_advance, inf->warp,
   28.14 +                inf->warpl, inf->warpu );
   28.15  
   28.16          /* Sanity -- this can avoid divide-by-zero. */
   28.17          if ( mcu_adv == 0 )
   28.18 @@ -220,9 +220,10 @@ int bvt_adjdom(struct task_struct *p,
   28.19          inf->warpl = warpl;
   28.20          inf->warpu = warpu;
   28.21  
   28.22 -		printk("Set domain %lld bvt mcu_adv=%ld, warp=%ld, warpl=%ld, warpu=%ld\n",
   28.23 -			   p->domain, inf->mcu_advance, inf->warp,
   28.24 -			   inf->warpl, inf->warpu );
   28.25 +        DPRINTK("Set domain %u bvt mcu_adv=%ld, warp=%ld, "
   28.26 +                "warpl=%ld, warpu=%ld\n",
   28.27 +                p->domain, inf->mcu_advance, inf->warp,
   28.28 +                inf->warpl, inf->warpu );
   28.29  
   28.30          spin_unlock_irqrestore(&schedule_lock[p->processor], flags);
   28.31      }
    29.1 --- a/xen/common/schedule.c	Thu Jun 03 09:31:38 2004 +0000
    29.2 +++ b/xen/common/schedule.c	Thu Jun 03 11:45:16 2004 +0000
    29.3 @@ -264,7 +264,7 @@ long do_sched_op(unsigned long op)
    29.4  
    29.5      case SCHEDOP_exit:
    29.6      {
    29.7 -        DPRINTK("DOM%llu killed itself!\n", current->domain);
    29.8 +        DPRINTK("DOM%u killed itself!\n", current->domain);
    29.9          DPRINTK(" EIP == %08lx\n", get_execution_context()->eip);
   29.10          kill_domain();
   29.11          break;
   29.12 @@ -272,7 +272,7 @@ long do_sched_op(unsigned long op)
   29.13  
   29.14      case SCHEDOP_stop:
   29.15      {
   29.16 -        DPRINTK("DOM%llu stopped itself!\n", current->domain);
   29.17 +        DPRINTK("DOM%u stopped itself!\n", current->domain);
   29.18          DPRINTK(" EIP == %08lx\n", get_execution_context()->eip);
   29.19          stop_domain();
   29.20          break;
   29.21 @@ -673,7 +673,7 @@ static void dump_rqueue(struct list_head
   29.22              (unsigned long) queue->next, (unsigned long) queue->prev);
   29.23      list_for_each (list, queue) {
   29.24          p = list_entry(list, struct task_struct, run_list);
   29.25 -        printk("%3d: %llu has=%c ", loop++, p->domain, p->has_cpu ? 'T':'F');
   29.26 +        printk("%3d: %u has=%c ", loop++, p->domain, p->has_cpu ? 'T':'F');
   29.27          SCHED_OP(dump_runq_el, p);
   29.28          printk("c=0x%X%08X\n", (u32)(p->cpu_time>>32), (u32)p->cpu_time);
   29.29          printk("         l: %lx n: %lx  p: %lx\n",
    30.1 --- a/xen/drivers/block/xen_block.c	Thu Jun 03 09:31:38 2004 +0000
    30.2 +++ b/xen/drivers/block/xen_block.c	Thu Jun 03 11:45:16 2004 +0000
    30.3 @@ -579,7 +579,7 @@ static void dump_blockq(u_char key, void
    30.4      read_lock_irqsave(&tasklist_lock, flags);
    30.5      for_each_domain ( p )
    30.6      {
    30.7 -        printk("Domain: %llu\n", p->domain);
    30.8 +        printk("Domain: %u\n", p->domain);
    30.9          blk_ring = p->blk_ring_base;
   30.10          printk("  req_prod:0x%08x, req_cons:0x%08x resp_prod:0x%08x/"
   30.11                 "0x%08x on_list=%d\n",
    31.1 --- a/xen/drivers/block/xen_vbd.c	Thu Jun 03 09:31:38 2004 +0000
    31.2 +++ b/xen/drivers/block/xen_vbd.c	Thu Jun 03 11:45:16 2004 +0000
    31.3 @@ -86,7 +86,7 @@ long vbd_create(vbd_create_t *create)
    31.4  
    31.5      if ( unlikely((p = find_domain_by_id(create->domain)) == NULL) )
    31.6      {
    31.7 -        DPRINTK("vbd_create attempted for non-existent domain %llu\n", 
    31.8 +        DPRINTK("vbd_create attempted for non-existent domain %u\n", 
    31.9                  create->domain); 
   31.10          return -EINVAL; 
   31.11      }
   31.12 @@ -166,7 +166,7 @@ long vbd_grow(vbd_grow_t *grow)
   31.13  
   31.14      if ( unlikely((p = find_domain_by_id(grow->domain)) == NULL) )
   31.15      {
   31.16 -        DPRINTK("vbd_grow: attempted for non-existent domain %llu\n", 
   31.17 +        DPRINTK("vbd_grow: attempted for non-existent domain %u\n", 
   31.18                  grow->domain); 
   31.19          return -EINVAL; 
   31.20      }
   31.21 @@ -192,7 +192,7 @@ long vbd_shrink(vbd_shrink_t *shrink)
   31.22  
   31.23      if ( (p = find_domain_by_id(shrink->domain)) == NULL )
   31.24      {
   31.25 -        DPRINTK("vbd_shrink attempted for non-existent domain %llu\n", 
   31.26 +        DPRINTK("vbd_shrink attempted for non-existent domain %u\n", 
   31.27                  shrink->domain); 
   31.28          return -EINVAL; 
   31.29      }
   31.30 @@ -252,7 +252,7 @@ long vbd_setextents(vbd_setextents_t *se
   31.31  
   31.32      if ( (p = find_domain_by_id(setextents->domain)) == NULL )
   31.33      {
   31.34 -        DPRINTK("vbd_setextents attempted for non-existent domain %llu\n", 
   31.35 +        DPRINTK("vbd_setextents attempted for non-existent domain %u\n", 
   31.36                  setextents->domain); 
   31.37          return -EINVAL; 
   31.38      }
   31.39 @@ -346,7 +346,7 @@ long vbd_delete(vbd_delete_t *delete)
   31.40  
   31.41      if ( (p = find_domain_by_id(delete->domain)) == NULL )
   31.42      {
   31.43 -        DPRINTK("vbd_delete attempted for non-existent domain %llu\n", 
   31.44 +        DPRINTK("vbd_delete attempted for non-existent domain %u\n", 
   31.45                  delete->domain); 
   31.46          return -EINVAL; 
   31.47      }
   31.48 @@ -530,7 +530,7 @@ long vbd_probe(vbd_probe_t *probe)
   31.49          if ( (probe->domain != VBD_PROBE_ALL) &&
   31.50               ((p = find_domain_by_id(probe->domain)) == NULL) )
   31.51          {
   31.52 -            DPRINTK("vbd_probe attempted for non-existent domain %llu\n", 
   31.53 +            DPRINTK("vbd_probe attempted for non-existent domain %u\n", 
   31.54                      probe->domain); 
   31.55              return -EINVAL; 
   31.56          }
   31.57 @@ -581,7 +581,7 @@ long vbd_info(vbd_info_t *info)
   31.58  
   31.59      if ( (p = find_domain_by_id(info->domain)) == NULL )
   31.60      {
   31.61 -        DPRINTK("vbd_info attempted for non-existent domain %llu\n", 
   31.62 +        DPRINTK("vbd_info attempted for non-existent domain %u\n", 
   31.63                  info->domain); 
   31.64          return -EINVAL; 
   31.65      }
   31.66 @@ -654,7 +654,7 @@ int vbd_translate(phys_seg_t *pseg, stru
   31.67              goto found;
   31.68      }
   31.69  
   31.70 -    DPRINTK("vbd_translate; domain %llu attempted to access "
   31.71 +    DPRINTK("vbd_translate; domain %u attempted to access "
   31.72              "non-existent VBD.\n", p->domain); 
   31.73  
   31.74      spin_unlock(&p->vbd_lock);
    32.1 --- a/xen/drivers/char/console.c	Thu Jun 03 09:31:38 2004 +0000
    32.2 +++ b/xen/drivers/char/console.c	Thu Jun 03 11:45:16 2004 +0000
    32.3 @@ -43,8 +43,8 @@ spinlock_t console_lock = SPIN_LOCK_UNLO
    32.4   */
    32.5  
    32.6  /* VGA text (mode 3) definitions. */
    32.7 -#define COLUMNS	    80
    32.8 -#define LINES	    25
    32.9 +#define COLUMNS     80
   32.10 +#define LINES       25
   32.11  #define ATTRIBUTE    7
   32.12  
   32.13  /* Clear the screen and initialize VIDEO, XPOS and YPOS.  */
   32.14 @@ -209,7 +209,7 @@ long read_console_ring(unsigned long str
   32.15          return -EFAULT;
   32.16  
   32.17      if ( cmd & CONSOLE_RING_CLEAR )
   32.18 -	console_ring.len = 0;
   32.19 +        console_ring.len = 0;
   32.20      
   32.21      return len;
   32.22  }
   32.23 @@ -418,7 +418,7 @@ long do_console_write(char *str, unsigne
   32.24          return -EFAULT;
   32.25      safe_str[count] = '\0';
   32.26      
   32.27 -    sprintf(line_header, "DOM%llu: ", current->domain);
   32.28 +    sprintf(line_header, "DOM%u: ", current->domain);
   32.29      
   32.30      p = safe_str;
   32.31      while ( *p != '\0' )
   32.32 @@ -447,7 +447,7 @@ long do_console_write(char *str, unsigne
   32.33  #else
   32.34      if ( !test_and_set_bit(PF_CONSOLEWRITEBUG, &current->flags) )
   32.35      {
   32.36 -        printk("DOM%llu is attempting to use the deprecated "
   32.37 +        printk("DOM%u is attempting to use the deprecated "
   32.38                 "HYPERVISOR_console_write() interface.\n", current->domain);
   32.39          printk(" - For testing, create a debug build of Xen\n");
   32.40          printk(" - For production, your OS must use the new console model\n");
    33.1 --- a/xen/include/hypervisor-ifs/dom0_ops.h	Thu Jun 03 09:31:38 2004 +0000
    33.2 +++ b/xen/include/hypervisor-ifs/dom0_ops.h	Thu Jun 03 11:45:16 2004 +0000
    33.3 @@ -19,7 +19,7 @@
    33.4   * This makes sure that old versions of dom0 tools will stop working in a
    33.5   * well-defined way (rather than crashing the machine, for instance).
    33.6   */
    33.7 -#define DOM0_INTERFACE_VERSION   0xAAAA000D
    33.8 +#define DOM0_INTERFACE_VERSION   0xAAAA000E
    33.9  
   33.10  #define MAX_DOMAIN_NAME    16
   33.11  
   33.12 @@ -29,6 +29,7 @@
   33.13  typedef struct {
   33.14      /* IN variables. */
   33.15      domid_t       domain;             /*  0 */
   33.16 +    u32           __pad;
   33.17      memory_t      max_pfns;           /*  8 */
   33.18      MEMORY_PADDING;
   33.19      void         *buffer;             /* 16 */
   33.20 @@ -56,20 +57,20 @@ typedef struct {
   33.21      u32          __pad;               /* 28 */
   33.22      /* OUT parameters. */
   33.23      domid_t      domain;              /* 32 */
   33.24 -} PACKED dom0_createdomain_t; /* 40 bytes */
   33.25 +} PACKED dom0_createdomain_t; /* 36 bytes */
   33.26  
   33.27  #define DOM0_DESTROYDOMAIN     9
   33.28  typedef struct {
   33.29      /* IN variables. */
   33.30      domid_t      domain;              /*  0 */
   33.31 -    u32          force;               /*  8 */
   33.32 -} PACKED dom0_destroydomain_t; /* 12 bytes */
   33.33 +    u32          force;               /*  4 */
   33.34 +} PACKED dom0_destroydomain_t; /* 8 bytes */
   33.35  
   33.36  #define DOM0_STARTDOMAIN      10
   33.37  typedef struct {
   33.38      /* IN parameters. */
   33.39      domid_t domain;                   /*  0 */
   33.40 -} PACKED dom0_startdomain_t; /* 8 bytes */
   33.41 +} PACKED dom0_startdomain_t; /* 4 bytes */
   33.42  
   33.43  #define DOM0_STOPDOMAIN       11
   33.44  typedef struct {
   33.45 @@ -77,26 +78,27 @@ typedef struct {
   33.46      domid_t domain;                   /*  0 */
   33.47      /* hack to indicate that you want to wait for other domain -- replace
   33.48         with proper sychronous stop soon! */
   33.49 -    u32     sync;                     /*  8 */
   33.50 -} PACKED dom0_stopdomain_t; /* 12 bytes */
   33.51 +    u32     sync;                     /*  4 */
   33.52 +} PACKED dom0_stopdomain_t; /* 8 bytes */
   33.53  
   33.54  #define DOM0_GETDOMAININFO    12
   33.55  typedef struct {
   33.56      /* IN variables. */
   33.57      domid_t domain;                   /*  0 */
   33.58 +    u32     __pad;
   33.59      full_execution_context_t *ctxt;   /*  8 */
   33.60      MEMORY_PADDING;
   33.61      /* OUT variables. */
   33.62 -    char name[MAX_DOMAIN_NAME];       /* 16 */
   33.63 -    u32 processor;                    /* 32 */
   33.64 -    u32 has_cpu;                      /* 36 */
   33.65 +    u8      name[MAX_DOMAIN_NAME];    /* 16 */
   33.66 +    u32     processor;                /* 32 */
   33.67 +    u32     has_cpu;                  /* 36 */
   33.68  #define DOMSTATE_ACTIVE              0
   33.69  #define DOMSTATE_STOPPED             1
   33.70 -    u32 state;                        /* 40 */
   33.71 -    u32 hyp_events;                   /* 44 */
   33.72 -    u32 tot_pages;                    /* 48 */
   33.73 -    u32 max_pages;                    /* 52 */
   33.74 -    u64 cpu_time;                     /* 56 */
   33.75 +    u32     state;                    /* 40 */
   33.76 +    u32     hyp_events;               /* 44 */
   33.77 +    u32     tot_pages;                /* 48 */
   33.78 +    u32     max_pages;                /* 52 */
   33.79 +    u64     cpu_time;                 /* 56 */
   33.80      memory_t shared_info_frame;       /* 64: MFN of shared_info struct */
   33.81      MEMORY_PADDING;
   33.82  } PACKED dom0_getdomaininfo_t; /* 72 bytes */
   33.83 @@ -104,19 +106,18 @@ typedef struct {
   33.84  #define DOM0_BUILDDOMAIN      13
   33.85  typedef struct {
   33.86      /* IN variables. */
   33.87 -    domid_t                  domain;  /*  0 */
   33.88 -    u32                      num_vifs;/*  8 */
   33.89 -    u32                      __pad;   /* 12 */
   33.90 +    domid_t                 domain;   /*  0 */
   33.91 +    u32                     num_vifs; /*  4 */
   33.92      /* IN/OUT parameters */
   33.93 -    full_execution_context_t *ctxt;   /* 16 */
   33.94 +    full_execution_context_t *ctxt;   /*  8 */
   33.95      MEMORY_PADDING;
   33.96 -} PACKED dom0_builddomain_t; /* 24 bytes */
   33.97 +} PACKED dom0_builddomain_t; /* 16 bytes */
   33.98  
   33.99  #define DOM0_IOPL             14
  33.100  typedef struct {
  33.101      domid_t domain;                   /*  0 */
  33.102 -    u32     iopl;                     /*  8 */
  33.103 -} PACKED dom0_iopl_t; /* 12 bytes */
  33.104 +    u32     iopl;                     /*  4 */
  33.105 +} PACKED dom0_iopl_t; /* 8 bytes */
  33.106  
  33.107  #define DOM0_MSR              15
  33.108  typedef struct {
  33.109 @@ -135,17 +136,17 @@ typedef struct {
  33.110  typedef struct {
  33.111      /* IN variables. */
  33.112      domid_t domain;                   /*  0 */
  33.113 -    u8  opcode;                       /*  8 */
  33.114 +    u8  opcode;                       /*  4 */
  33.115      u8  __pad0, __pad1, __pad2;
  33.116 -    u32 in1;                          /* 12 */
  33.117 -    u32 in2;                          /* 16 */
  33.118 -    u32 in3;                          /* 20 */
  33.119 -    u32 in4;                          /* 24 */
  33.120 +    u32 in1;                          /*  8 */
  33.121 +    u32 in2;                          /* 12 */
  33.122 +    u32 in3;                          /* 16 */
  33.123 +    u32 in4;                          /* 20 */
  33.124      /* OUT variables. */
  33.125 -    u32 status;                       /* 28 */
  33.126 -    u32 out1;                         /* 32 */
  33.127 -    u32 out2;                         /* 36 */
  33.128 -} PACKED dom0_debug_t; /* 40 bytes */
  33.129 +    u32 status;                       /* 24 */
  33.130 +    u32 out1;                         /* 28 */
  33.131 +    u32 out2;                         /* 32 */
  33.132 +} PACKED dom0_debug_t; /* 36 bytes */
  33.133  
  33.134  /*
  33.135   * Set clock such that it would read <secs,usecs> after 00:00:00 UTC,
  33.136 @@ -174,8 +175,8 @@ typedef struct {
  33.137      domid_t domain;        /*  8: To which domain does the frame belong?    */
  33.138      /* OUT variables. */
  33.139      /* Is the page PINNED to a type? */
  33.140 -    u32 type;              /* 16: see above type defs */
  33.141 -} PACKED dom0_getpageframeinfo_t; /* 20 bytes */
  33.142 +    u32 type;              /* 12: see above type defs */
  33.143 +} PACKED dom0_getpageframeinfo_t; /* 16 bytes */
  33.144  
  33.145  /*
  33.146   * Read console content from Xen buffer ring.
  33.147 @@ -195,8 +196,8 @@ typedef struct {
  33.148  typedef struct {
  33.149      /* IN variables. */
  33.150      domid_t      domain;              /*  0 */
  33.151 -    s32          cpu;                 /*  8: -1 implies unpin */
  33.152 -} PACKED dom0_pincpudomain_t; /* 12 bytes */
  33.153 +    s32          cpu;                 /*  4: -1 implies unpin */
  33.154 +} PACKED dom0_pincpudomain_t; /* 8 bytes */
  33.155  
  33.156  /* Get trace buffers physical base pointer */
  33.157  #define DOM0_GETTBUFS         21
  33.158 @@ -229,11 +230,11 @@ typedef struct {
  33.159  typedef struct {
  33.160      /* IN variables. */
  33.161      domid_t      domain;              /*  0 */
  33.162 -    u32          bus;                 /*  8 */
  33.163 -    u32          dev;                 /* 12 */
  33.164 -    u32          func;                /* 16 */
  33.165 -    u32          enable;              /* 20 */
  33.166 -} PACKED dom0_pcidev_access_t; /* 24 bytes */
  33.167 +    u32          bus;                 /*  4 */
  33.168 +    u32          dev;                 /*  8 */
  33.169 +    u32          func;                /* 12 */
  33.170 +    u32          enable;              /* 16 */
  33.171 +} PACKED dom0_pcidev_access_t; /* 20 bytes */
  33.172  
  33.173  /*
  33.174   * Get the ID of the current scheduler.
  33.175 @@ -259,31 +260,31 @@ typedef struct {
  33.176  typedef struct {
  33.177      /* IN variables. */
  33.178      domid_t        domain;            /*  0 */
  33.179 -    u32            op;                /*  8 */
  33.180 -    u32            __pad;             /* 12 */
  33.181 -    unsigned long *dirty_bitmap;      /* 16: pointer to locked buffer */
  33.182 +    u32            op;                /*  4 */
  33.183 +    unsigned long *dirty_bitmap;      /*  8: pointer to locked buffer */
  33.184      MEMORY_PADDING;
  33.185      /* IN/OUT variables. */
  33.186 -    memory_t       pages;  /* 24: size of buffer, updated with actual size */
  33.187 +    memory_t       pages;  /* 16: size of buffer, updated with actual size */
  33.188      MEMORY_PADDING;
  33.189      /* OUT variables. */
  33.190 -    memory_t       fault_count;       /* 32 */
  33.191 +    memory_t       fault_count;       /* 24 */
  33.192      MEMORY_PADDING;
  33.193 -    memory_t       dirty_count;       /* 40 */
  33.194 +    memory_t       dirty_count;       /* 32 */
  33.195      MEMORY_PADDING;
  33.196 -} PACKED dom0_shadow_control_t; /* 48 bytes */
  33.197 +} PACKED dom0_shadow_control_t; /* 40 bytes */
  33.198  
  33.199  #define DOM0_SETDOMAINNAME     26
  33.200  typedef struct {
  33.201      /* IN variables. */
  33.202      domid_t  domain;                  /*  0 */
  33.203 -    char     name[MAX_DOMAIN_NAME];   /*  8 */
  33.204 -} PACKED dom0_setdomainname_t; /* 24 bytes */
  33.205 +    u8       name[MAX_DOMAIN_NAME];   /*  4 */
  33.206 +} PACKED dom0_setdomainname_t; /* 20 bytes */
  33.207  
  33.208  #define DOM0_SETDOMAININITIALMEM   27
  33.209  typedef struct {
  33.210      /* IN variables. */
  33.211      domid_t     domain;               /*  0 */
  33.212 +    u32         __pad;
  33.213      memory_t    initial_memkb;        /*  8 */
  33.214      MEMORY_PADDING;
  33.215  } PACKED dom0_setdomaininitialmem_t; /* 16 bytes */
  33.216 @@ -292,6 +293,7 @@ typedef struct {
  33.217  typedef struct {
  33.218      /* IN variables. */
  33.219      domid_t     domain;               /*  0 */
  33.220 +    u32         __pad;
  33.221      memory_t    max_memkb;            /*  8 */
  33.222      MEMORY_PADDING;
  33.223  } PACKED dom0_setdomainmaxmem_t; /* 16 bytes */
  33.224 @@ -300,6 +302,7 @@ typedef struct {
  33.225  typedef struct {
  33.226      /* IN variables. */
  33.227      domid_t  domain;                  /*  0 */
  33.228 +    u32         __pad;
  33.229      memory_t num;                     /*  8 */
  33.230      MEMORY_PADDING;
  33.231      /* IN/OUT variables. */
    34.1 --- a/xen/include/hypervisor-ifs/event_channel.h	Thu Jun 03 09:31:38 2004 +0000
    34.2 +++ b/xen/include/hypervisor-ifs/event_channel.h	Thu Jun 03 11:45:16 2004 +0000
    34.3 @@ -19,10 +19,10 @@
    34.4  #define EVTCHNOP_bind_interdomain 0
    34.5  typedef struct {
    34.6      /* IN parameters. */
    34.7 -    domid_t dom1, dom2;               /*  0,  8 */
    34.8 +    domid_t dom1, dom2;               /*  0,  4 */
    34.9      /* OUT parameters. */
   34.10 -    u32     port1, port2;             /* 16, 20 */
   34.11 -} PACKED evtchn_bind_interdomain_t; /* 24 bytes */
   34.12 +    u32     port1, port2;             /*  8, 12 */
   34.13 +} PACKED evtchn_bind_interdomain_t; /* 16 bytes */
   34.14  
   34.15  /*
   34.16   * EVTCHNOP_bind_virq: Bind a local event channel to IRQ <irq>.
   34.17 @@ -65,9 +65,9 @@ typedef struct {
   34.18  typedef struct {
   34.19      /* IN parameters. */
   34.20      domid_t dom;                      /*  0 */
   34.21 -    u32     port;                     /*  8 */
   34.22 +    u32     port;                     /*  4 */
   34.23      /* No OUT parameters. */
   34.24 -} PACKED evtchn_close_t; /* 12 bytes */
   34.25 +} PACKED evtchn_close_t; /* 8 bytes */
   34.26  
   34.27  /*
   34.28   * EVTCHNOP_send: Send an event to the remote end of the channel whose local
   34.29 @@ -92,23 +92,23 @@ typedef struct {
   34.30  typedef struct {
   34.31      /* IN parameters */
   34.32      domid_t dom;                      /*  0 */
   34.33 -    u32     port;                     /*  8 */
   34.34 +    u32     port;                     /*  4 */
   34.35      /* OUT parameters */
   34.36  #define EVTCHNSTAT_closed       0  /* Chennel is not in use.                 */
   34.37  #define EVTCHNSTAT_unbound      1  /* Channel is not bound to a source.      */
   34.38  #define EVTCHNSTAT_interdomain  2  /* Channel is connected to remote domain. */
   34.39  #define EVTCHNSTAT_pirq         3  /* Channel is bound to a phys IRQ line.   */
   34.40  #define EVTCHNSTAT_virq         4  /* Channel is bound to a virtual IRQ line */
   34.41 -    u32     status;                   /* 12 */
   34.42 -    union {
   34.43 +    u32     status;                   /*  8 */
   34.44 +    union {                           /* 12 */
   34.45          struct {
   34.46 -            domid_t dom;                              /* 16 */
   34.47 -            u32     port;                             /* 24 */
   34.48 +            domid_t dom;                              /* 12 */
   34.49 +            u32     port;                             /* 16 */
   34.50          } PACKED interdomain; /* EVTCHNSTAT_interdomain */
   34.51 -        u32 pirq;      /* EVTCHNSTAT_pirq        */   /* 16 */
   34.52 -        u32 virq;      /* EVTCHNSTAT_virq        */   /* 16 */
   34.53 +        u32 pirq;      /* EVTCHNSTAT_pirq        */   /* 12 */
   34.54 +        u32 virq;      /* EVTCHNSTAT_virq        */   /* 12 */
   34.55      } PACKED u;
   34.56 -} PACKED evtchn_status_t; /* 28 bytes */
   34.57 +} PACKED evtchn_status_t; /* 20 bytes */
   34.58  
   34.59  typedef struct {
   34.60      u32 cmd; /* EVTCHNOP_* */         /*  0 */
   34.61 @@ -120,8 +120,8 @@ typedef struct {
   34.62          evtchn_close_t            close;
   34.63          evtchn_send_t             send;
   34.64          evtchn_status_t           status;
   34.65 -        u8                        __dummy[32];
   34.66 +        u8                        __dummy[24];
   34.67      } PACKED u;
   34.68 -} PACKED evtchn_op_t; /* 40 bytes */
   34.69 +} PACKED evtchn_op_t; /* 32 bytes */
   34.70  
   34.71  #endif /* __HYPERVISOR_IFS__EVENT_CHANNEL_H__ */
    35.1 --- a/xen/include/hypervisor-ifs/hypervisor-if.h	Thu Jun 03 09:31:38 2004 +0000
    35.2 +++ b/xen/include/hypervisor-ifs/hypervisor-if.h	Thu Jun 03 11:45:16 2004 +0000
    35.3 @@ -84,14 +84,14 @@
    35.4   *  This domain that must own all non-page-table pages that are involved in
    35.5   *  MMU updates. By default it is the domain that executes mmu_update(). If the
    35.6   *  caller has sufficient privilege then it can be changed by executing
    35.7 - *  MMUEXT_SET_SUBJECTDOM_{L,H}.
    35.8 + *  MMUEXT_SET_SUBJECTDOM.
    35.9   * 
   35.10   * PTS (Page-Table Subject)
   35.11   * ------------------------
   35.12   *  This domain must own all the page-table pages that are subject to MMU
   35.13   *  updates. By default it is the domain that executes mmu_update(). If the
   35.14   *  caller has sufficient privilege then it can be changed by executing
   35.15 - *  MMUEXT_SET_SUBJECTDOM_H with val[14] (SET_PAGETABLE_SUBJECTDOM) set.
   35.16 + *  MMUEXT_SET_SUBJECTDOM with val[14] (SET_PAGETABLE_SUBJECTDOM) set.
   35.17   * 
   35.18   * ptr[1:0] == MMU_NORMAL_PT_UPDATE:
   35.19   * Updates an entry in a page table.
   35.20 @@ -122,14 +122,10 @@
   35.21   *   ptr[:2]  -- linear address of LDT base (NB. must be page-aligned)
   35.22   *   val[:8]  -- number of entries in LDT
   35.23   * 
   35.24 - *   val[7:0] == MMUEXT_SET_SUBJECTDOM_L:
   35.25 + *   val[7:0] == MMUEXT_SET_SUBJECTDOM:
   35.26 + *   val[14]  -- if TRUE then sets the PTS in addition to the GPS.
   35.27   *   (ptr[31:15],val[31:15]) -- dom[31:0]
   35.28   * 
   35.29 - *   val[7:0] == MMUEXT_SET_SUBJECTDOM_H:
   35.30 - *   val[14]  -- if TRUE then sets the PTS in addition to the GPS.
   35.31 - *   (ptr[31:15],val[31:15]) -- dom[63:32]
   35.32 - *   NB. This command must be immediately preceded by SET_SUBJECTDOM_L.
   35.33 - * 
   35.34   *   val[7:0] == MMUEXT_REASSIGN_PAGE:
   35.35   *   ptr[:2]  -- machine address within page to be reassigned to the GPS.
   35.36   * 
   35.37 @@ -156,12 +152,10 @@
   35.38  #define MMUEXT_TLB_FLUSH         6 /* ptr = NULL                             */
   35.39  #define MMUEXT_INVLPG            7 /* ptr = VA to invalidate                 */
   35.40  #define MMUEXT_SET_LDT           8 /* ptr = VA of table; val = # entries     */
   35.41 -/* NB. MMUEXT_SET_SUBJECTDOM must consist of *_L followed immediately by *_H */
   35.42 -#define MMUEXT_SET_SUBJECTDOM_L  9 /* (ptr[31:15],val[31:15]) = dom[31:0]    */
   35.43 -#define MMUEXT_SET_SUBJECTDOM_H 10 /* (ptr[31:15],val[31:15]) = dom[63:32]   */
   35.44 -#define SET_PAGETABLE_SUBJECTDOM (1<<14) /* OR into 'val' arg of SUBJECTDOM_H*/
   35.45 -#define MMUEXT_REASSIGN_PAGE    11
   35.46 -#define MMUEXT_RESET_SUBJECTDOM 12
   35.47 +#define MMUEXT_SET_SUBJECTDOM    9 /* (ptr[31:15],val[31:15]) = dom[31:0]    */
   35.48 +#define SET_PAGETABLE_SUBJECTDOM (1<<14) /* OR into 'val' arg of SUBJECTDOM  */
   35.49 +#define MMUEXT_REASSIGN_PAGE    10
   35.50 +#define MMUEXT_RESET_SUBJECTDOM 11
   35.51  #define MMUEXT_CMD_MASK        255
   35.52  #define MMUEXT_CMD_SHIFT         8
   35.53  
   35.54 @@ -192,9 +186,9 @@
   35.55  
   35.56  #ifndef __ASSEMBLY__
   35.57  
   35.58 -typedef u64 domid_t;
   35.59 +typedef u32 domid_t;
   35.60  /* DOMID_SELF is used in certain contexts to refer to oneself. */
   35.61 -#define DOMID_SELF (~1ULL)
   35.62 +#define DOMID_SELF (0x7FFFFFFEU)
   35.63  
   35.64  #include "network.h"
   35.65  #include "block.h"
    36.1 --- a/xen/include/hypervisor-ifs/network.h	Thu Jun 03 09:31:38 2004 +0000
    36.2 +++ b/xen/include/hypervisor-ifs/network.h	Thu Jun 03 11:45:16 2004 +0000
    36.3 @@ -141,7 +141,7 @@ typedef struct net_rule_st
    36.4  } net_rule_t;
    36.5  
    36.6  /* These are specified in the 'idx' if the 'dom' is SPECIAL. */
    36.7 -#define VIF_SPECIAL             (~0ULL)
    36.8 +#define VIF_SPECIAL             (0x7FFFFFFFU)
    36.9  #define VIF_UNKNOWN_INTERFACE   0
   36.10  #define VIF_PHYSICAL_INTERFACE  1
   36.11  #define VIF_ANY_INTERFACE       2
    37.1 --- a/xen/include/hypervisor-ifs/sched_ctl.h	Thu Jun 03 09:31:38 2004 +0000
    37.2 +++ b/xen/include/hypervisor-ifs/sched_ctl.h	Thu Jun 03 11:45:16 2004 +0000
    37.3 @@ -42,9 +42,10 @@ struct sched_ctl_cmd
    37.4  
    37.5  struct sched_adjdom_cmd
    37.6  {
    37.7 -    u32 sched_id;                     /*  0 */
    37.8 -    u32 direction;                    /*  4 */
    37.9 +    u32     sched_id;                 /*  0 */
   37.10 +    u32     direction;                /*  4 */
   37.11      domid_t domain;                   /*  8 */
   37.12 +    u32     __pad;
   37.13      union {                           /* 16 */
   37.14          struct bvt_adjdom
   37.15          {
    38.1 --- a/xen/include/hypervisor-ifs/vbd.h	Thu Jun 03 09:31:38 2004 +0000
    38.2 +++ b/xen/include/hypervisor-ifs/vbd.h	Thu Jun 03 11:45:16 2004 +0000
    38.3 @@ -60,7 +60,7 @@ typedef struct _vbd_delete {
    38.4      u16          vdevice;             /* 16 bit id domain refers to VBD as */
    38.5  } vbd_delete_t; 
    38.6  
    38.7 -#define VBD_PROBE_ALL (~0ULL)
    38.8 +#define VBD_PROBE_ALL (0x7FFFFFFFU)
    38.9  typedef struct _vbd_probe { 
   38.10      domid_t          domain;          /* domain in question or VBD_PROBE_ALL */
   38.11      xen_disk_info_t  xdi;             /* where's our space for VBD/disk info */
    39.1 --- a/xen/include/xen/mm.h	Thu Jun 03 09:31:38 2004 +0000
    39.2 +++ b/xen/include/xen/mm.h	Thu Jun 03 11:45:16 2004 +0000
    39.3 @@ -164,8 +164,11 @@ static inline int get_page(struct pfn_in
    39.4               unlikely(x & PGC_zombie) ||             /* Zombie? */
    39.5               unlikely(p != domain) )                 /* Wrong owner? */
    39.6          {
    39.7 -            DPRINTK("Error pfn %08lx: ed=%p(%lld), sd=%p(%lld), caf=%08x, taf=%08x\n",
    39.8 -                    page_to_pfn(page), domain, (domain)?domain->domain:999, p, (p && !((x & PGC_count_mask) == 0))?p->domain:999, x, page->type_and_flags);
    39.9 +            DPRINTK("Error pfn %08lx: ed=%p(%u), sd=%p(%u),"
   39.10 +                    " caf=%08x, taf=%08x\n",
   39.11 +                    page_to_pfn(page), domain, (domain)?domain->domain:999, 
   39.12 +                    p, (p && !((x & PGC_count_mask) == 0))?p->domain:999, 
   39.13 +                    x, page->type_and_flags);
   39.14              return 0;
   39.15          }
   39.16          __asm__ __volatile__(
    40.1 --- a/xen/include/xen/sched.h	Thu Jun 03 09:31:38 2004 +0000
    40.2 +++ b/xen/include/xen/sched.h	Thu Jun 03 11:45:16 2004 +0000
    40.3 @@ -226,7 +226,7 @@ struct task_struct
    40.4  extern struct task_struct idle0_task;
    40.5  
    40.6  extern struct task_struct *idle_task[NR_CPUS];
    40.7 -#define IDLE_DOMAIN_ID   (~0ULL)
    40.8 +#define IDLE_DOMAIN_ID   (0x7FFFFFFFU)
    40.9  #define is_idle_task(_p) (test_bit(PF_IDLETASK, &(_p)->flags))
   40.10  
   40.11  #include <xen/slab.h>
    41.1 --- a/xen/include/xen/shadow.h	Thu Jun 03 09:31:38 2004 +0000
    41.2 +++ b/xen/include/xen/shadow.h	Thu Jun 03 11:45:16 2004 +0000
    41.3 @@ -10,9 +10,9 @@
    41.4  
    41.5  
    41.6  /* Shadow PT flag bits in pfn_info */
    41.7 -#define PSH_shadowed	(1<<31) /* page has a shadow. PFN points to shadow */
    41.8 -#define PSH_pending	    (1<<29) /* page is in the process of being shadowed */
    41.9 -#define PSH_pfn_mask	((1<<21)-1)
   41.10 +#define PSH_shadowed    (1<<31) /* page has a shadow. PFN points to shadow */
   41.11 +#define PSH_pending     (1<<29) /* page is in the process of being shadowed */
   41.12 +#define PSH_pfn_mask    ((1<<21)-1)
   41.13  
   41.14  /* Shadow PT operation mode : shadowmode variable in mm_struct */
   41.15  #define SHM_test        (1) /* just run domain on shadow PTs */
   41.16 @@ -27,8 +27,8 @@ extern void shadow_mode_init(void);
   41.17  extern int shadow_mode_control( struct task_struct *p, dom0_shadow_control_t *sc );
   41.18  extern int shadow_fault( unsigned long va, long error_code );
   41.19  extern void shadow_l1_normal_pt_update( unsigned long pa, unsigned long gpte, 
   41.20 -					unsigned long *prev_spfn_ptr,
   41.21 -					l1_pgentry_t **prev_spl1e_ptr  );
   41.22 +                                        unsigned long *prev_spfn_ptr,
   41.23 +                                        l1_pgentry_t **prev_spl1e_ptr  );
   41.24  extern void shadow_l2_normal_pt_update( unsigned long pa, unsigned long gpte );
   41.25  extern void unshadow_table( unsigned long gpfn, unsigned int type );
   41.26  extern int shadow_mode_enable( struct task_struct *p, unsigned int mode );
   41.27 @@ -51,7 +51,7 @@ struct shadow_status {
   41.28  
   41.29  #ifndef NDEBUG
   41.30  #define SH_LOG(_f, _a...)                             \
   41.31 -printk("DOM%lld: (file=shadow.c, line=%d) " _f "\n", \
   41.32 +printk("DOM%u: (file=shadow.c, line=%d) " _f "\n",    \
   41.33         current->domain , __LINE__ , ## _a )
   41.34  #else
   41.35  #define SH_LOG(_f, _a...) 
   41.36 @@ -59,16 +59,16 @@ printk("DOM%lld: (file=shadow.c, line=%d
   41.37  
   41.38  #if SHADOW_DEBUG
   41.39  #define SH_VLOG(_f, _a...)                             \
   41.40 -    printk("DOM%lld: (file=shadow.c, line=%d) " _f "\n", \
   41.41 -	   current->domain , __LINE__ , ## _a )
   41.42 +    printk("DOM%u: (file=shadow.c, line=%d) " _f "\n", \
   41.43 +           current->domain , __LINE__ , ## _a )
   41.44  #else
   41.45  #define SH_VLOG(_f, _a...) 
   41.46  #endif
   41.47  
   41.48  #if 0
   41.49  #define SH_VVLOG(_f, _a...)                             \
   41.50 -    printk("DOM%lld: (file=shadow.c, line=%d) " _f "\n", \
   41.51 -	   current->domain , __LINE__ , ## _a )
   41.52 +    printk("DOM%u: (file=shadow.c, line=%d) " _f "\n",  \
   41.53 +           current->domain , __LINE__ , ## _a )
   41.54  #else
   41.55  #define SH_VVLOG(_f, _a...) 
   41.56  #endif
   41.57 @@ -76,49 +76,44 @@ printk("DOM%lld: (file=shadow.c, line=%d
   41.58  
   41.59  /************************************************************************/
   41.60  
   41.61 -    static inline void __mark_dirty( struct mm_struct *m, unsigned int mfn )
   41.62 +static inline void __mark_dirty( struct mm_struct *m, unsigned int mfn )
   41.63  {
   41.64      unsigned int pfn;
   41.65  
   41.66      ASSERT(spin_is_locked(&m->shadow_lock));
   41.67 -	
   41.68 -    //printk("%08x %08lx\n", mfn, machine_to_phys_mapping[mfn] );
   41.69  
   41.70      pfn = machine_to_phys_mapping[mfn];
   41.71  
   41.72      /* We use values with the top bit set to mark MFNs that aren't
   41.73         really part of the domain's psuedo-physical memory map e.g.
   41.74         the shared info frame. Nothing to do here...
   41.75 -       */
   41.76 +    */
   41.77      if ( unlikely(pfn & 0x80000000U) ) return; 
   41.78  
   41.79      ASSERT(m->shadow_dirty_bitmap);
   41.80      if( likely(pfn<m->shadow_dirty_bitmap_size) )
   41.81      {
   41.82 -		/* These updates occur with mm.shadow_lock held, so use 
   41.83 -		   (__) version of test_and_set */
   41.84 -		if( ! __test_and_set_bit( pfn, m->shadow_dirty_bitmap ) )
   41.85 -		{
   41.86 -			m->shadow_dirty_count++;
   41.87 -		}
   41.88 +        /* These updates occur with mm.shadow_lock held, so use 
   41.89 +           (__) version of test_and_set */
   41.90 +        if( !__test_and_set_bit( pfn, m->shadow_dirty_bitmap) )
   41.91 +            m->shadow_dirty_count++;
   41.92      }
   41.93      else
   41.94      {
   41.95 -	extern void show_traceX(void);
   41.96 -	SH_LOG("mark_dirty OOR! mfn=%x pfn=%x max=%x (mm %p)",
   41.97 -	       mfn, pfn, m->shadow_dirty_bitmap_size, m );
   41.98 -	SH_LOG("dom=%lld caf=%08x taf=%08x\n", 
   41.99 -	       frame_table[mfn].u.domain->domain,
  41.100 -	       frame_table[mfn].count_and_flags, 
  41.101 -	       frame_table[mfn].type_and_flags );
  41.102 -	//show_traceX();
  41.103 +        extern void show_traceX(void);
  41.104 +        SH_LOG("mark_dirty OOR! mfn=%x pfn=%x max=%x (mm %p)",
  41.105 +               mfn, pfn, m->shadow_dirty_bitmap_size, m );
  41.106 +        SH_LOG("dom=%u caf=%08x taf=%08x\n", 
  41.107 +               frame_table[mfn].u.domain->domain,
  41.108 +               frame_table[mfn].count_and_flags, 
  41.109 +               frame_table[mfn].type_and_flags );
  41.110      }
  41.111  
  41.112  }
  41.113  
  41.114  
  41.115  static inline void mark_dirty( struct mm_struct *m, unsigned int mfn )
  41.116 -{	
  41.117 +{
  41.118      ASSERT(local_irq_is_enabled());
  41.119      //if(spin_is_locked(&m->shadow_lock)) printk("+");
  41.120      spin_lock(&m->shadow_lock);
  41.121 @@ -130,7 +125,7 @@ static inline void mark_dirty( struct mm
  41.122  /************************************************************************/
  41.123  
  41.124  static inline void l1pte_write_fault( struct mm_struct *m, 
  41.125 -				      unsigned long *gpte_p, unsigned long *spte_p )
  41.126 +                                      unsigned long *gpte_p, unsigned long *spte_p )
  41.127  { 
  41.128      unsigned long gpte = *gpte_p;
  41.129      unsigned long spte = *spte_p;
  41.130 @@ -138,17 +133,17 @@ static inline void l1pte_write_fault( st
  41.131      switch( m->shadow_mode )
  41.132      {
  41.133      case SHM_test:
  41.134 -	spte = gpte;
  41.135 -	gpte |= _PAGE_DIRTY | _PAGE_ACCESSED;
  41.136 -	spte |= _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED; 			
  41.137 -	break;
  41.138 +        spte = gpte;
  41.139 +        gpte |= _PAGE_DIRTY | _PAGE_ACCESSED;
  41.140 +        spte |= _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED;
  41.141 +        break;
  41.142  
  41.143      case SHM_logdirty:
  41.144 -	spte = gpte;
  41.145 -	gpte |= _PAGE_DIRTY | _PAGE_ACCESSED;
  41.146 -	spte |= _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED; 			
  41.147 -	__mark_dirty( m, (gpte >> PAGE_SHIFT) );
  41.148 -	break;
  41.149 +        spte = gpte;
  41.150 +        gpte |= _PAGE_DIRTY | _PAGE_ACCESSED;
  41.151 +        spte |= _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED;
  41.152 +        __mark_dirty( m, (gpte >> PAGE_SHIFT) );
  41.153 +        break;
  41.154      }
  41.155  
  41.156      *gpte_p = gpte;
  41.157 @@ -156,7 +151,7 @@ static inline void l1pte_write_fault( st
  41.158  }
  41.159  
  41.160  static inline void l1pte_read_fault( struct mm_struct *m, 
  41.161 -				     unsigned long *gpte_p, unsigned long *spte_p )
  41.162 +                                     unsigned long *gpte_p, unsigned long *spte_p )
  41.163  { 
  41.164      unsigned long gpte = *gpte_p;
  41.165      unsigned long spte = *spte_p;
  41.166 @@ -164,19 +159,19 @@ static inline void l1pte_read_fault( str
  41.167      switch( m->shadow_mode )
  41.168      {
  41.169      case SHM_test:
  41.170 -	spte = gpte;
  41.171 -	gpte |= _PAGE_ACCESSED;
  41.172 -	spte |= _PAGE_ACCESSED; 			
  41.173 -	if ( ! (gpte & _PAGE_DIRTY ) )
  41.174 -	    spte &= ~ _PAGE_RW;
  41.175 -	break;
  41.176 +        spte = gpte;
  41.177 +        gpte |= _PAGE_ACCESSED;
  41.178 +        spte |= _PAGE_ACCESSED;
  41.179 +        if ( ! (gpte & _PAGE_DIRTY ) )
  41.180 +            spte &= ~ _PAGE_RW;
  41.181 +        break;
  41.182  
  41.183      case SHM_logdirty:
  41.184 -	spte = gpte;
  41.185 -	gpte |= _PAGE_ACCESSED;
  41.186 -	spte |= _PAGE_ACCESSED; 			
  41.187 -	spte &= ~ _PAGE_RW;
  41.188 -	break;
  41.189 +        spte = gpte;
  41.190 +        gpte |= _PAGE_ACCESSED;
  41.191 +        spte |= _PAGE_ACCESSED;
  41.192 +        spte &= ~ _PAGE_RW;
  41.193 +        break;
  41.194      }
  41.195  
  41.196      *gpte_p = gpte;
  41.197 @@ -184,7 +179,7 @@ static inline void l1pte_read_fault( str
  41.198  }
  41.199  
  41.200  static inline void l1pte_no_fault( struct mm_struct *m, 
  41.201 -				   unsigned long *gpte_p, unsigned long *spte_p )
  41.202 +                                   unsigned long *gpte_p, unsigned long *spte_p )
  41.203  { 
  41.204      unsigned long gpte = *gpte_p;
  41.205      unsigned long spte = *spte_p;
  41.206 @@ -192,26 +187,26 @@ static inline void l1pte_no_fault( struc
  41.207      switch( m->shadow_mode )
  41.208      {
  41.209      case SHM_test:
  41.210 -	spte = 0;
  41.211 -	if ( (gpte & (_PAGE_PRESENT|_PAGE_ACCESSED) ) == 
  41.212 -	     (_PAGE_PRESENT|_PAGE_ACCESSED) )
  41.213 -	{
  41.214 -	    spte = gpte;
  41.215 -	    if ( ! (gpte & _PAGE_DIRTY ) )
  41.216 -		spte &= ~ _PAGE_RW;
  41.217 -	}
  41.218 -	break;
  41.219 +        spte = 0;
  41.220 +        if ( (gpte & (_PAGE_PRESENT|_PAGE_ACCESSED) ) == 
  41.221 +             (_PAGE_PRESENT|_PAGE_ACCESSED) )
  41.222 +        {
  41.223 +            spte = gpte;
  41.224 +            if ( ! (gpte & _PAGE_DIRTY ) )
  41.225 +                spte &= ~ _PAGE_RW;
  41.226 +        }
  41.227 +        break;
  41.228  
  41.229      case SHM_logdirty:
  41.230 -	spte = 0;
  41.231 -	if ( (gpte & (_PAGE_PRESENT|_PAGE_ACCESSED) ) == 
  41.232 -	     (_PAGE_PRESENT|_PAGE_ACCESSED) )
  41.233 -	{
  41.234 -	    spte = gpte;
  41.235 -	    spte &= ~ _PAGE_RW;
  41.236 -	}
  41.237 +        spte = 0;
  41.238 +        if ( (gpte & (_PAGE_PRESENT|_PAGE_ACCESSED) ) == 
  41.239 +             (_PAGE_PRESENT|_PAGE_ACCESSED) )
  41.240 +        {
  41.241 +            spte = gpte;
  41.242 +            spte &= ~ _PAGE_RW;
  41.243 +        }
  41.244  
  41.245 -	break;
  41.246 +        break;
  41.247      }
  41.248  
  41.249      *gpte_p = gpte;
  41.250 @@ -219,8 +214,8 @@ static inline void l1pte_no_fault( struc
  41.251  }
  41.252  
  41.253  static inline void l2pde_general( struct mm_struct *m, 
  41.254 -				  unsigned long *gpde_p, unsigned long *spde_p,
  41.255 -				  unsigned long sl1pfn)
  41.256 +                                  unsigned long *gpde_p, unsigned long *spde_p,
  41.257 +                                  unsigned long sl1pfn)
  41.258  {
  41.259      unsigned long gpde = *gpde_p;
  41.260      unsigned long spde = *spde_p;
  41.261 @@ -229,16 +224,16 @@ static inline void l2pde_general( struct
  41.262  
  41.263      if ( sl1pfn )
  41.264      {
  41.265 -	spde = (gpde & ~PAGE_MASK) | (sl1pfn<<PAGE_SHIFT) | 
  41.266 -	    _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY;
  41.267 -	gpde = gpde | _PAGE_ACCESSED | _PAGE_DIRTY;
  41.268 +        spde = (gpde & ~PAGE_MASK) | (sl1pfn<<PAGE_SHIFT) | 
  41.269 +            _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY;
  41.270 +        gpde = gpde | _PAGE_ACCESSED | _PAGE_DIRTY;
  41.271  
  41.272 -	if ( unlikely( (sl1pfn<<PAGE_SHIFT) == (gpde & PAGE_MASK)  ) )
  41.273 -	{   
  41.274 -	    // detect linear map, and keep pointing at guest
  41.275 -	    SH_VLOG("4c: linear mapping ( %08lx )",sl1pfn);
  41.276 -	    spde = gpde & ~_PAGE_RW;
  41.277 -	}
  41.278 +        if ( unlikely( (sl1pfn<<PAGE_SHIFT) == (gpde & PAGE_MASK)  ) )
  41.279 +        {   
  41.280 +            // detect linear map, and keep pointing at guest
  41.281 +            SH_VLOG("4c: linear mapping ( %08lx )",sl1pfn);
  41.282 +            spde = gpde & ~_PAGE_RW;
  41.283 +        }
  41.284      }
  41.285  
  41.286      *gpde_p = gpde;
  41.287 @@ -254,30 +249,30 @@ static void shadow_audit(struct mm_struc
  41.288  {
  41.289      int live=0, free=0, j=0, abs;
  41.290      struct shadow_status *a;
  41.291 -	
  41.292 -    for(j=0;j<shadow_ht_buckets;j++)
  41.293 +
  41.294 +    for( j = 0; j < shadow_ht_buckets; j++ )
  41.295      {
  41.296          a = &m->shadow_ht[j];        
  41.297 -	if(a->pfn){live++; ASSERT(a->spfn_and_flags&PSH_pfn_mask);}
  41.298 -	ASSERT((a->pfn&0xf0000000)==0);
  41.299 -	ASSERT(a->pfn<0x00100000);
  41.300 -	a=a->next;
  41.301 +        if(a->pfn){live++; ASSERT(a->spfn_and_flags&PSH_pfn_mask);}
  41.302 +        ASSERT((a->pfn&0xf0000000)==0);
  41.303 +        ASSERT(a->pfn<0x00100000);
  41.304 +        a=a->next;
  41.305          while(a && live<9999)
  41.306 -	{ 
  41.307 -	    live++; 
  41.308 -	    if(a->pfn == 0 || a->spfn_and_flags == 0)
  41.309 -	    {
  41.310 -		printk("XXX live=%d pfn=%08lx sp=%08lx next=%p\n",
  41.311 -		       live, a->pfn, a->spfn_and_flags, a->next);
  41.312 -		BUG();
  41.313 -	    }
  41.314 -	    ASSERT(a->pfn);
  41.315 -	    ASSERT((a->pfn&0xf0000000)==0);
  41.316 -	    ASSERT(a->pfn<0x00100000);
  41.317 -	    ASSERT(a->spfn_and_flags&PSH_pfn_mask);
  41.318 -	    a=a->next; 
  41.319 -	}
  41.320 -	ASSERT(live<9999);
  41.321 +        { 
  41.322 +            live++; 
  41.323 +            if(a->pfn == 0 || a->spfn_and_flags == 0)
  41.324 +            {
  41.325 +                printk("XXX live=%d pfn=%08lx sp=%08lx next=%p\n",
  41.326 +                       live, a->pfn, a->spfn_and_flags, a->next);
  41.327 +                BUG();
  41.328 +            }
  41.329 +            ASSERT(a->pfn);
  41.330 +            ASSERT((a->pfn&0xf0000000)==0);
  41.331 +            ASSERT(a->pfn<0x00100000);
  41.332 +            ASSERT(a->spfn_and_flags&PSH_pfn_mask);
  41.333 +            a=a->next; 
  41.334 +        }
  41.335 +        ASSERT(live<9999);
  41.336      }
  41.337  
  41.338      a = m->shadow_ht_free;
  41.339 @@ -288,9 +283,9 @@ static void shadow_audit(struct mm_struc
  41.340      abs=(perfc_value(shadow_l1_pages)+perfc_value(shadow_l2_pages))-live;
  41.341      if( abs < -1 || abs > 1 )
  41.342      {
  41.343 -	printk("live=%d free=%d l1=%d l2=%d\n",live,free,
  41.344 -	       perfc_value(shadow_l1_pages), perfc_value(shadow_l2_pages) );
  41.345 -	BUG();
  41.346 +        printk("live=%d free=%d l1=%d l2=%d\n",live,free,
  41.347 +               perfc_value(shadow_l1_pages), perfc_value(shadow_l2_pages) );
  41.348 +        BUG();
  41.349      }
  41.350  
  41.351  }
  41.352 @@ -302,14 +297,14 @@ static void shadow_audit(struct mm_struc
  41.353  
  41.354  
  41.355  static inline struct shadow_status* hash_bucket( struct mm_struct *m,
  41.356 -						 unsigned int gpfn )
  41.357 +                                                 unsigned int gpfn )
  41.358  {
  41.359      return &(m->shadow_ht[gpfn % shadow_ht_buckets]);
  41.360  }
  41.361  
  41.362  
  41.363  static inline unsigned long __shadow_status( struct mm_struct *m,
  41.364 -					     unsigned int gpfn )
  41.365 +                                             unsigned int gpfn )
  41.366  {
  41.367      struct shadow_status **ob, *b, *B = hash_bucket( m, gpfn );
  41.368  
  41.369 @@ -321,33 +316,33 @@ static inline unsigned long __shadow_sta
  41.370  
  41.371      do
  41.372      {
  41.373 -	if ( b->pfn == gpfn )
  41.374 -	{
  41.375 -	    unsigned long t;
  41.376 -	    struct shadow_status *x;
  41.377 +        if ( b->pfn == gpfn )
  41.378 +        {
  41.379 +            unsigned long t;
  41.380 +            struct shadow_status *x;
  41.381  
  41.382 -	    // swap with head
  41.383 -	    t=B->pfn; B->pfn=b->pfn; b->pfn=t;
  41.384 -	    t=B->spfn_and_flags; B->spfn_and_flags=b->spfn_and_flags; 
  41.385 -	    b->spfn_and_flags=t;
  41.386 +            // swap with head
  41.387 +            t=B->pfn; B->pfn=b->pfn; b->pfn=t;
  41.388 +            t=B->spfn_and_flags; B->spfn_and_flags=b->spfn_and_flags; 
  41.389 +            b->spfn_and_flags=t;
  41.390  
  41.391 -	    if(ob)
  41.392 -	    {   // pull to front
  41.393 -		*ob=b->next;
  41.394 -		x=B->next;
  41.395 -		B->next=b;	
  41.396 -		b->next=x;
  41.397 -	    }			
  41.398 -	    return B->spfn_and_flags;
  41.399 -	}
  41.400 +            if( ob )
  41.401 +            {   // pull to front
  41.402 +                *ob=b->next;
  41.403 +                x=B->next;
  41.404 +                B->next=b;
  41.405 +                b->next=x;
  41.406 +            }
  41.407 +            return B->spfn_and_flags;
  41.408 +        }
  41.409  #if SHADOW_HASH_DEBUG
  41.410 -	else
  41.411 -	{
  41.412 -	    if(b!=B)ASSERT(b->pfn);
  41.413 -	}
  41.414 +        else
  41.415 +        {
  41.416 +            if(b!=B)ASSERT(b->pfn);
  41.417 +        }
  41.418  #endif
  41.419 -	ob=&b->next;
  41.420 -	b=b->next;
  41.421 +        ob=&b->next;
  41.422 +        b=b->next;
  41.423      }
  41.424      while (b);
  41.425  
  41.426 @@ -359,7 +354,7 @@ ever becomes a problem, but since we nee
  41.427  anyway its probably not worth being too clever. */
  41.428  
  41.429  static inline unsigned long get_shadow_status( struct mm_struct *m,
  41.430 -					       unsigned int gpfn )
  41.431 +                                               unsigned int gpfn )
  41.432  {
  41.433      unsigned long res;
  41.434  
  41.435 @@ -370,15 +365,15 @@ static inline unsigned long get_shadow_s
  41.436         bit in the dirty bitmap.
  41.437         NB: the VA update path doesn't use this so needs to be handled 
  41.438         independnetly. 
  41.439 -       */
  41.440 +    */
  41.441  
  41.442      ASSERT(local_irq_is_enabled());
  41.443      //if(spin_is_locked(&m->shadow_lock)) printk("*");
  41.444      spin_lock(&m->shadow_lock);
  41.445  
  41.446      if( m->shadow_mode == SHM_logdirty )
  41.447 -	__mark_dirty( m, gpfn );
  41.448 -	
  41.449 +        __mark_dirty( m, gpfn );
  41.450 +
  41.451      res = __shadow_status( m, gpfn );
  41.452      if (!res) spin_unlock(&m->shadow_lock);
  41.453      return res;
  41.454 @@ -392,7 +387,7 @@ static inline void put_shadow_status( st
  41.455  
  41.456  
  41.457  static inline void delete_shadow_status( struct mm_struct *m,
  41.458 -					 unsigned int gpfn )
  41.459 +                                         unsigned int gpfn )
  41.460  {
  41.461      struct shadow_status *b, *B, **ob;
  41.462  
  41.463 @@ -406,29 +401,29 @@ static inline void delete_shadow_status(
  41.464  
  41.465      if( b->pfn == gpfn )
  41.466      {
  41.467 -	if (b->next)
  41.468 -	{
  41.469 -	    struct shadow_status *D=b->next;
  41.470 -	    b->spfn_and_flags = b->next->spfn_and_flags;
  41.471 -	    b->pfn = b->next->pfn;
  41.472 +        if (b->next)
  41.473 +        {
  41.474 +            struct shadow_status *D=b->next;
  41.475 +            b->spfn_and_flags = b->next->spfn_and_flags;
  41.476 +            b->pfn = b->next->pfn;
  41.477  
  41.478 -	    b->next = b->next->next;
  41.479 -	    D->next = m->shadow_ht_free;
  41.480 -	    D->pfn = 0;
  41.481 -	    D->spfn_and_flags = 0;
  41.482 -	    m->shadow_ht_free = D;
  41.483 -	}
  41.484 -	else
  41.485 -	{
  41.486 -	    b->pfn = 0;
  41.487 -	    b->spfn_and_flags = 0;
  41.488 -	}
  41.489 +            b->next = b->next->next;
  41.490 +            D->next = m->shadow_ht_free;
  41.491 +            D->pfn = 0;
  41.492 +            D->spfn_and_flags = 0;
  41.493 +            m->shadow_ht_free = D;
  41.494 +        }
  41.495 +        else
  41.496 +        {
  41.497 +            b->pfn = 0;
  41.498 +            b->spfn_and_flags = 0;
  41.499 +        }
  41.500  
  41.501  #if SHADOW_HASH_DEBUG
  41.502 -	if( __shadow_status(m,gpfn) ) BUG();  
  41.503 -	shadow_audit(m,0);
  41.504 +        if( __shadow_status(m,gpfn) ) BUG();  
  41.505 +        shadow_audit(m,0);
  41.506  #endif
  41.507 -	return;
  41.508 +        return;
  41.509      }
  41.510  
  41.511      ob = &b->next;
  41.512 @@ -436,25 +431,25 @@ static inline void delete_shadow_status(
  41.513  
  41.514      do
  41.515      {
  41.516 -	if ( b->pfn == gpfn )			
  41.517 -	{
  41.518 -	    b->pfn = 0;
  41.519 -	    b->spfn_and_flags = 0;
  41.520 +        if ( b->pfn == gpfn )
  41.521 +        {
  41.522 +            b->pfn = 0;
  41.523 +            b->spfn_and_flags = 0;
  41.524  
  41.525 -	    // b is in the list
  41.526 -	    *ob=b->next;
  41.527 -	    b->next = m->shadow_ht_free;
  41.528 -	    m->shadow_ht_free = b;
  41.529 +            // b is in the list
  41.530 +            *ob=b->next;
  41.531 +            b->next = m->shadow_ht_free;
  41.532 +            m->shadow_ht_free = b;
  41.533  
  41.534  #if SHADOW_HASH_DEBUG
  41.535 -	    if( __shadow_status(m,gpfn) ) BUG();
  41.536 +            if( __shadow_status(m,gpfn) ) BUG();
  41.537  #endif
  41.538 -	    shadow_audit(m,0);
  41.539 -	    return;
  41.540 -	}
  41.541 +            shadow_audit(m,0);
  41.542 +            return;
  41.543 +        }
  41.544  
  41.545 -	ob = &b->next;
  41.546 -	b=b->next;
  41.547 +        ob = &b->next;
  41.548 +        b=b->next;
  41.549      }
  41.550      while (b);
  41.551  
  41.552 @@ -464,7 +459,7 @@ static inline void delete_shadow_status(
  41.553  
  41.554  
  41.555  static inline void set_shadow_status( struct mm_struct *m,
  41.556 -				      unsigned int gpfn, unsigned long s )
  41.557 +                                      unsigned int gpfn, unsigned long s )
  41.558  {
  41.559      struct shadow_status *b, *B, *extra, **fptr;
  41.560      int i;
  41.561 @@ -474,22 +469,20 @@ static inline void set_shadow_status( st
  41.562      B = b = hash_bucket( m, gpfn );
  41.563     
  41.564      ASSERT(gpfn);
  41.565 -    //ASSERT(s);
  41.566 -    //ASSERT(s&PSH_pfn_mask);
  41.567      SH_VVLOG("set gpfn=%08x s=%08lx bucket=%p(%p)", gpfn, s, b, b->next );
  41.568  
  41.569      shadow_audit(m,0);
  41.570  
  41.571      do
  41.572      {
  41.573 -	if ( b->pfn == gpfn )			
  41.574 -	{
  41.575 -	    b->spfn_and_flags = s;
  41.576 -	    shadow_audit(m,0);
  41.577 -	    return;
  41.578 -	}
  41.579 +        if ( b->pfn == gpfn )
  41.580 +        {
  41.581 +            b->spfn_and_flags = s;
  41.582 +            shadow_audit(m,0);
  41.583 +            return;
  41.584 +        }
  41.585  
  41.586 -	b=b->next;
  41.587 +        b=b->next;
  41.588      }
  41.589      while (b);
  41.590  
  41.591 @@ -499,41 +492,41 @@ static inline void set_shadow_status( st
  41.592  
  41.593      if ( B->pfn == 0 )
  41.594      {
  41.595 -	// we can use this head
  41.596 -	ASSERT( B->next == 0 );
  41.597 -	B->pfn = gpfn;
  41.598 -	B->spfn_and_flags = s;
  41.599 -	shadow_audit(m,0);
  41.600 -	return;
  41.601 +        // we can use this head
  41.602 +        ASSERT( B->next == 0 );
  41.603 +        B->pfn = gpfn;
  41.604 +        B->spfn_and_flags = s;
  41.605 +        shadow_audit(m,0);
  41.606 +        return;
  41.607      }
  41.608  
  41.609      if( unlikely(m->shadow_ht_free == NULL) )
  41.610      {
  41.611 -	SH_LOG("allocate more shadow hashtable blocks");
  41.612 +        SH_LOG("allocate more shadow hashtable blocks");
  41.613 +
  41.614 +        // we need to allocate more space
  41.615 +        extra = kmalloc( sizeof(void*) + (shadow_ht_extra_size * 
  41.616 +                                          sizeof(struct shadow_status)), GFP_KERNEL );
  41.617  
  41.618 -	// we need to allocate more space
  41.619 -	extra = kmalloc( sizeof(void*) + (shadow_ht_extra_size * 
  41.620 -					  sizeof(struct shadow_status)), GFP_KERNEL );
  41.621 +        if( ! extra ) BUG(); // should be more graceful here....
  41.622  
  41.623 -	if( ! extra ) BUG(); // should be more graceful here....
  41.624 +        memset( extra, 0, sizeof(void*) + (shadow_ht_extra_size * 
  41.625 +                                           sizeof(struct shadow_status)) );
  41.626  
  41.627 -	memset( extra, 0, sizeof(void*) + (shadow_ht_extra_size * 
  41.628 -					   sizeof(struct shadow_status)) );
  41.629 +        m->shadow_extras_count++;
  41.630  
  41.631 -	m->shadow_extras_count++;
  41.632 -	
  41.633 -	// add extras to free list
  41.634 -	fptr = &m->shadow_ht_free;
  41.635 -	for ( i=0; i<shadow_ht_extra_size; i++ )
  41.636 -	{
  41.637 -	    *fptr = &extra[i];
  41.638 -	    fptr = &(extra[i].next);
  41.639 -	}
  41.640 -	*fptr = NULL;
  41.641 +        // add extras to free list
  41.642 +        fptr = &m->shadow_ht_free;
  41.643 +        for ( i=0; i<shadow_ht_extra_size; i++ )
  41.644 +        {
  41.645 +            *fptr = &extra[i];
  41.646 +            fptr = &(extra[i].next);
  41.647 +        }
  41.648 +        *fptr = NULL;
  41.649  
  41.650 -	*((struct shadow_status ** ) &extra[shadow_ht_extra_size]) = 
  41.651 -	    m->shadow_ht_extras;
  41.652 -	m->shadow_ht_extras = extra;
  41.653 +        *((struct shadow_status ** ) &extra[shadow_ht_extra_size]) = 
  41.654 +            m->shadow_ht_extras;
  41.655 +        m->shadow_ht_extras = extra;
  41.656  
  41.657      }
  41.658  
  41.659 @@ -555,10 +548,10 @@ static inline void __shadow_mk_pagetable
  41.660      unsigned long gpfn, spfn=0;
  41.661  
  41.662      gpfn =  pagetable_val(mm->pagetable) >> PAGE_SHIFT;
  41.663 -		
  41.664 +
  41.665      if ( unlikely((spfn=__shadow_status(mm, gpfn)) == 0 ) )
  41.666      {
  41.667 -	spfn = shadow_l2_table(mm, gpfn );
  41.668 +        spfn = shadow_l2_table(mm, gpfn );
  41.669      }      
  41.670      mm->shadow_table = mk_pagetable(spfn<<PAGE_SHIFT);
  41.671  }
  41.672 @@ -566,21 +559,21 @@ static inline void __shadow_mk_pagetable
  41.673  static inline void shadow_mk_pagetable( struct mm_struct *mm )
  41.674  {
  41.675      SH_VVLOG("shadow_mk_pagetable( gptbase=%08lx, mode=%d )",
  41.676 -	     pagetable_val(mm->pagetable), mm->shadow_mode );
  41.677 +             pagetable_val(mm->pagetable), mm->shadow_mode );
  41.678  
  41.679      if ( unlikely(mm->shadow_mode) )
  41.680      {
  41.681 -	ASSERT(local_irq_is_enabled());
  41.682 +        ASSERT(local_irq_is_enabled());
  41.683          spin_lock(&mm->shadow_lock);
  41.684  
  41.685 -	__shadow_mk_pagetable( mm );
  41.686 +        __shadow_mk_pagetable( mm );
  41.687  
  41.688 -        spin_unlock(&mm->shadow_lock);		
  41.689 +        spin_unlock(&mm->shadow_lock);
  41.690      }
  41.691  
  41.692      SH_VVLOG("leaving shadow_mk_pagetable( gptbase=%08lx, mode=%d ) sh=%08lx",
  41.693 -	     pagetable_val(mm->pagetable), mm->shadow_mode, 
  41.694 -	     pagetable_val(mm->shadow_table) );
  41.695 +             pagetable_val(mm->pagetable), mm->shadow_mode, 
  41.696 +             pagetable_val(mm->shadow_table) );
  41.697  
  41.698  }
  41.699  
    42.1 --- a/xen/net/dev.c	Thu Jun 03 09:31:38 2004 +0000
    42.2 +++ b/xen/net/dev.c	Thu Jun 03 11:45:16 2004 +0000
    42.3 @@ -2094,7 +2094,7 @@ static void get_rx_bufs(net_vif_t *vif)
    42.4          if ( unlikely(pte_pfn >= max_page) ||
    42.5               unlikely(!get_page_and_type(pte_page, p, PGT_l1_page_table)) )
    42.6          {
    42.7 -            DPRINTK("Bad page frame for ppte %llu,%08lx,%08lx,%08x\n",
    42.8 +            DPRINTK("Bad page frame for ppte %u,%08lx,%08lx,%08x\n",
    42.9                      p->domain, pte_pfn, max_page, pte_page->type_and_flags);
   42.10              make_rx_response(vif, rx.id, 0, RING_STATUS_BAD_PAGE, 0);
   42.11              continue;
   42.12 @@ -2265,24 +2265,13 @@ long flush_bufs_for_vif(net_vif_t *vif)
   42.13  
   42.14          put_page_and_type(&frame_table[rx->pte_ptr >> PAGE_SHIFT]);
   42.15  
   42.16 -	/* if in shadow mode, mark the PTE as dirty */
   42.17 -	if( p->mm.shadow_mode == SHM_logdirty )
   42.18 -	{
   42.19 -	    mark_dirty( &p->mm, rx->pte_ptr>>PAGE_SHIFT );
   42.20 -#if 0
   42.21 -	    mark_dirty( &p->mm, rx->buf_pfn ); // XXXXXXX debug
   42.22 -
   42.23 -	    {
   42.24 -		unsigned long * p = map_domain_mem( rx->buf_pfn<<PAGE_SHIFT );
   42.25 -		p[2] = 0xdeadc001;
   42.26 -		unmap_domain_mem(p);
   42.27 -	    }
   42.28 -#endif
   42.29 -
   42.30 -	}
   42.31 -	/* assume the shadow page table is about to be blown away,
   42.32 -	   and that its not worth marking the buffer as dirty */
   42.33 -
   42.34 +	/*
   42.35 +         * If in shadow mode, mark the PTE as dirty.
   42.36 +         * (We assume the shadow page table is about to be blown away,
   42.37 +         * and so it's not worth marking the buffer as dirty.)
   42.38 +         */
   42.39 +	if ( p->mm.shadow_mode == SHM_logdirty )
   42.40 +	    mark_dirty(&p->mm, rx->pte_ptr>>PAGE_SHIFT);
   42.41  
   42.42          make_rx_response(vif, rx->id, 0, RING_STATUS_DROPPED, 0);
   42.43      }
    43.1 --- a/xenolinux-2.4.26-sparse/arch/xen/drivers/blkif/backend/interface.c	Thu Jun 03 09:31:38 2004 +0000
    43.2 +++ b/xenolinux-2.4.26-sparse/arch/xen/drivers/blkif/backend/interface.c	Thu Jun 03 11:45:16 2004 +0000
    43.3 @@ -9,8 +9,7 @@
    43.4  #include "common.h"
    43.5  
    43.6  #define BLKIF_HASHSZ 1024
    43.7 -#define BLKIF_HASH(_d,_h) \
    43.8 -    (((int)(_d)^(int)((_d)>>32)^(int)(_h))&(BLKIF_HASHSZ-1))
    43.9 +#define BLKIF_HASH(_d,_h) (((int)(_d)^(int)(_h))&(BLKIF_HASHSZ-1))
   43.10  
   43.11  static kmem_cache_t *blkif_cachep;
   43.12  static blkif_t      *blkif_hash[BLKIF_HASHSZ];
   43.13 @@ -151,7 +150,7 @@ void blkif_connect(blkif_be_connect_t *c
   43.14      blkif = blkif_find_by_handle(domid, handle);
   43.15      if ( unlikely(blkif == NULL) )
   43.16      {
   43.17 -        DPRINTK("blkif_connect attempted for non-existent blkif (%llu,%u)\n", 
   43.18 +        DPRINTK("blkif_connect attempted for non-existent blkif (%u,%u)\n", 
   43.19                  connect->domid, connect->blkif_handle); 
   43.20          connect->status = BLKIF_BE_STATUS_INTERFACE_NOT_FOUND;
   43.21          return;
   43.22 @@ -208,7 +207,7 @@ int blkif_disconnect(blkif_be_disconnect
   43.23      if ( unlikely(blkif == NULL) )
   43.24      {
   43.25          DPRINTK("blkif_disconnect attempted for non-existent blkif"
   43.26 -                " (%llu,%u)\n", disconnect->domid, disconnect->blkif_handle); 
   43.27 +                " (%u,%u)\n", disconnect->domid, disconnect->blkif_handle); 
   43.28          disconnect->status = BLKIF_BE_STATUS_INTERFACE_NOT_FOUND;
   43.29          return 1; /* Caller will send response error message. */
   43.30      }
    44.1 --- a/xenolinux-2.4.26-sparse/arch/xen/drivers/blkif/backend/main.c	Thu Jun 03 09:31:38 2004 +0000
    44.2 +++ b/xenolinux-2.4.26-sparse/arch/xen/drivers/blkif/backend/main.c	Thu Jun 03 11:45:16 2004 +0000
    44.3 @@ -382,8 +382,7 @@ static void dispatch_rw_block_io(blkif_t
    44.4          mcl[i].args[0] = MMAP_VADDR(pending_idx, i) >> PAGE_SHIFT;
    44.5          mcl[i].args[1] = (phys_seg[i].buffer & PAGE_MASK) | remap_prot;
    44.6          mcl[i].args[2] = 0;
    44.7 -        mcl[i].args[3] = (unsigned long)blkif->domid;
    44.8 -        mcl[i].args[4] = (unsigned long)(blkif->domid>>32);
    44.9 +        mcl[i].args[3] = blkif->domid;
   44.10  
   44.11          phys_to_machine_mapping[__pa(MMAP_VADDR(pending_idx, i))>>PAGE_SHIFT] =
   44.12              phys_seg[i].buffer >> PAGE_SHIFT;
    45.1 --- a/xenolinux-2.4.26-sparse/arch/xen/drivers/blkif/backend/vbd.c	Thu Jun 03 09:31:38 2004 +0000
    45.2 +++ b/xenolinux-2.4.26-sparse/arch/xen/drivers/blkif/backend/vbd.c	Thu Jun 03 11:45:16 2004 +0000
    45.3 @@ -18,7 +18,7 @@ void vbd_create(blkif_be_vbd_create_t *c
    45.4      blkif = blkif_find_by_handle(create->domid, create->blkif_handle);
    45.5      if ( unlikely(blkif == NULL) )
    45.6      {
    45.7 -        DPRINTK("vbd_create attempted for non-existent blkif (%llu,%u)\n", 
    45.8 +        DPRINTK("vbd_create attempted for non-existent blkif (%u,%u)\n", 
    45.9                  create->domid, create->blkif_handle); 
   45.10          create->status = BLKIF_BE_STATUS_INTERFACE_NOT_FOUND;
   45.11          return;
   45.12 @@ -62,7 +62,7 @@ void vbd_create(blkif_be_vbd_create_t *c
   45.13      rb_link_node(&vbd->rb, rb_parent, rb_p);
   45.14      rb_insert_color(&vbd->rb, &blkif->vbd_rb);
   45.15  
   45.16 -    DPRINTK("Successful creation of vdev=%04x (dom=%llu)\n",
   45.17 +    DPRINTK("Successful creation of vdev=%04x (dom=%u)\n",
   45.18              vdevice, create->domid);
   45.19      create->status = BLKIF_BE_STATUS_OKAY;
   45.20  
   45.21 @@ -83,7 +83,7 @@ void vbd_grow(blkif_be_vbd_grow_t *grow)
   45.22      blkif = blkif_find_by_handle(grow->domid, grow->blkif_handle);
   45.23      if ( unlikely(blkif == NULL) )
   45.24      {
   45.25 -        DPRINTK("vbd_grow attempted for non-existent blkif (%llu,%u)\n", 
   45.26 +        DPRINTK("vbd_grow attempted for non-existent blkif (%u,%u)\n", 
   45.27                  grow->domid, grow->blkif_handle); 
   45.28          grow->status = BLKIF_BE_STATUS_INTERFACE_NOT_FOUND;
   45.29          return;
   45.30 @@ -128,7 +128,7 @@ void vbd_grow(blkif_be_vbd_grow_t *grow)
   45.31  
   45.32      *px = x;
   45.33  
   45.34 -    DPRINTK("Successful grow of vdev=%04x (dom=%llu)\n",
   45.35 +    DPRINTK("Successful grow of vdev=%04x (dom=%u)\n",
   45.36              vdevice, grow->domid);
   45.37      grow->status = BLKIF_BE_STATUS_OKAY;
   45.38  
   45.39 @@ -148,7 +148,7 @@ void vbd_shrink(blkif_be_vbd_shrink_t *s
   45.40      blkif = blkif_find_by_handle(shrink->domid, shrink->blkif_handle);
   45.41      if ( unlikely(blkif == NULL) )
   45.42      {
   45.43 -        DPRINTK("vbd_shrink attempted for non-existent blkif (%llu,%u)\n", 
   45.44 +        DPRINTK("vbd_shrink attempted for non-existent blkif (%u,%u)\n", 
   45.45                  shrink->domid, shrink->blkif_handle); 
   45.46          shrink->status = BLKIF_BE_STATUS_INTERFACE_NOT_FOUND;
   45.47          return;
   45.48 @@ -206,7 +206,7 @@ void vbd_destroy(blkif_be_vbd_destroy_t 
   45.49      blkif = blkif_find_by_handle(destroy->domid, destroy->blkif_handle);
   45.50      if ( unlikely(blkif == NULL) )
   45.51      {
   45.52 -        DPRINTK("vbd_destroy attempted for non-existent blkif (%llu,%u)\n", 
   45.53 +        DPRINTK("vbd_destroy attempted for non-existent blkif (%u,%u)\n", 
   45.54                  destroy->domid, destroy->blkif_handle); 
   45.55          destroy->status = BLKIF_BE_STATUS_INTERFACE_NOT_FOUND;
   45.56          return;
   45.57 @@ -365,7 +365,7 @@ int vbd_translate(phys_seg_t *pseg, blki
   45.58              goto found;
   45.59      }
   45.60  
   45.61 -    DPRINTK("vbd_translate; domain %llu attempted to access "
   45.62 +    DPRINTK("vbd_translate; domain %u attempted to access "
   45.63              "non-existent VBD.\n", blkif->domid);
   45.64  
   45.65      spin_unlock(&blkif->vbd_lock);
    46.1 --- a/xenolinux-2.4.26-sparse/arch/xen/drivers/dom0/core.c	Thu Jun 03 09:31:38 2004 +0000
    46.2 +++ b/xenolinux-2.4.26-sparse/arch/xen/drivers/dom0/core.c	Thu Jun 03 11:45:16 2004 +0000
    46.3 @@ -73,139 +73,133 @@ static int privcmd_ioctl(struct inode *i
    46.4      case IOCTL_PRIVCMD_MMAP:
    46.5      {
    46.6  #define PRIVCMD_MMAP_SZ 32
    46.7 -	privcmd_mmap_t mmapcmd;
    46.8 -	privcmd_mmap_entry_t msg[PRIVCMD_MMAP_SZ], *p;
    46.9 -	int i, rc;
   46.10 +        privcmd_mmap_t mmapcmd;
   46.11 +        privcmd_mmap_entry_t msg[PRIVCMD_MMAP_SZ], *p;
   46.12 +        int i, rc;
   46.13  
   46.14          if ( copy_from_user(&mmapcmd, (void *)data, sizeof(mmapcmd)) )
   46.15              return -EFAULT;
   46.16  
   46.17 -	p = mmapcmd.entry;
   46.18 +        p = mmapcmd.entry;
   46.19  
   46.20 -	for (i=0; i<mmapcmd.num; i+=PRIVCMD_MMAP_SZ, p+=PRIVCMD_MMAP_SZ)
   46.21 -	{
   46.22 -	    int j, n = ((mmapcmd.num-i)>PRIVCMD_MMAP_SZ)?
   46.23 -		PRIVCMD_MMAP_SZ:(mmapcmd.num-i);
   46.24 -	    if ( copy_from_user(&msg, p, n*sizeof(privcmd_mmap_entry_t)) )
   46.25 -		return -EFAULT;
   46.26 -	    
   46.27 -	    for ( j = 0; j < n; j++ )
   46.28 -	    {
   46.29 -		struct vm_area_struct *vma = 
   46.30 -		    find_vma( current->mm, msg[j].va );
   46.31 +        for (i=0; i<mmapcmd.num; i+=PRIVCMD_MMAP_SZ, p+=PRIVCMD_MMAP_SZ)
   46.32 +        {
   46.33 +            int j, n = ((mmapcmd.num-i)>PRIVCMD_MMAP_SZ)?
   46.34 +                PRIVCMD_MMAP_SZ:(mmapcmd.num-i);
   46.35 +            if ( copy_from_user(&msg, p, n*sizeof(privcmd_mmap_entry_t)) )
   46.36 +                return -EFAULT;
   46.37 +     
   46.38 +            for ( j = 0; j < n; j++ )
   46.39 +            {
   46.40 +                struct vm_area_struct *vma = 
   46.41 +                    find_vma( current->mm, msg[j].va );
   46.42  
   46.43 -		if ( !vma )
   46.44 -		    return -EINVAL;
   46.45 +                if ( !vma )
   46.46 +                    return -EINVAL;
   46.47  
   46.48 -		if ( msg[j].va > PAGE_OFFSET )
   46.49 -		    return -EINVAL;
   46.50 +                if ( msg[j].va > PAGE_OFFSET )
   46.51 +                    return -EINVAL;
   46.52  
   46.53 -		if ( (msg[j].va + (msg[j].npages<<PAGE_SHIFT)) > vma->vm_end )
   46.54 -		    return -EINVAL;
   46.55 +                if ( (msg[j].va + (msg[j].npages<<PAGE_SHIFT)) > vma->vm_end )
   46.56 +                    return -EINVAL;
   46.57  
   46.58 -		if ( (rc = direct_remap_area_pages(vma->vm_mm, 
   46.59 -					    msg[j].va&PAGE_MASK, 
   46.60 -					    msg[j].mfn<<PAGE_SHIFT, 
   46.61 -					    msg[j].npages<<PAGE_SHIFT, 
   46.62 -					    vma->vm_page_prot,
   46.63 -					    mmapcmd.dom)) < 0 )
   46.64 -		    return rc;
   46.65 -	    }
   46.66 -	}
   46.67 -	ret = 0;
   46.68 +                if ( (rc = direct_remap_area_pages(vma->vm_mm, 
   46.69 +                                                   msg[j].va&PAGE_MASK, 
   46.70 +                                                   msg[j].mfn<<PAGE_SHIFT, 
   46.71 +                                                   msg[j].npages<<PAGE_SHIFT, 
   46.72 +                                                   vma->vm_page_prot,
   46.73 +                                                   mmapcmd.dom)) < 0 )
   46.74 +                    return rc;
   46.75 +            }
   46.76 +        }
   46.77 +        ret = 0;
   46.78      }
   46.79      break;
   46.80  
   46.81      case IOCTL_PRIVCMD_MMAPBATCH:
   46.82      {
   46.83  #define MAX_DIRECTMAP_MMU_QUEUE 130
   46.84 -	mmu_update_t u[MAX_DIRECTMAP_MMU_QUEUE], *w, *v;
   46.85 -	privcmd_mmapbatch_t m;
   46.86 -	struct vm_area_struct *vma = NULL;
   46.87 -	unsigned long *p, addr;
   46.88 -	unsigned long mfn;
   46.89 -	int i;
   46.90 +        mmu_update_t u[MAX_DIRECTMAP_MMU_QUEUE], *w, *v;
   46.91 +        privcmd_mmapbatch_t m;
   46.92 +        struct vm_area_struct *vma = NULL;
   46.93 +        unsigned long *p, addr;
   46.94 +        unsigned long mfn;
   46.95 +        int i;
   46.96  
   46.97          if ( copy_from_user(&m, (void *)data, sizeof(m)) )
   46.98 -	{ ret = -EFAULT; goto batch_err; }
   46.99 +        { ret = -EFAULT; goto batch_err; }
  46.100  
  46.101 -	vma = find_vma( current->mm, m.addr );
  46.102 +        vma = find_vma( current->mm, m.addr );
  46.103  
  46.104 -	if ( !vma )
  46.105 -	{ ret = -EINVAL; goto batch_err; }
  46.106 +        if ( !vma )
  46.107 +        { ret = -EINVAL; goto batch_err; }
  46.108  
  46.109 -	if ( m.addr > PAGE_OFFSET )
  46.110 -	{ ret = -EFAULT; goto batch_err; }
  46.111 +        if ( m.addr > PAGE_OFFSET )
  46.112 +        { ret = -EFAULT; goto batch_err; }
  46.113  
  46.114 -	if ( (m.addr + (m.num<<PAGE_SHIFT)) > vma->vm_end )
  46.115 -	{ ret = -EFAULT; goto batch_err; }
  46.116 +        if ( (m.addr + (m.num<<PAGE_SHIFT)) > vma->vm_end )
  46.117 +        { ret = -EFAULT; goto batch_err; }
  46.118  
  46.119 -	if ( m.dom != 0 )
  46.120 -	{
  46.121 -	    u[0].val  = (unsigned long)(m.dom<<16) & ~0xFFFFUL;
  46.122 -	    u[0].ptr  = (unsigned long)(m.dom<< 0) & ~0xFFFFUL;
  46.123 -	    u[1].val  = (unsigned long)(m.dom>>16) & ~0xFFFFUL;
  46.124 -	    u[1].ptr  = (unsigned long)(m.dom>>32) & ~0xFFFFUL;
  46.125 -	    u[0].ptr |= MMU_EXTENDED_COMMAND;
  46.126 -	    u[0].val |= MMUEXT_SET_SUBJECTDOM_L;
  46.127 -	    u[1].ptr |= MMU_EXTENDED_COMMAND;
  46.128 -	    u[1].val |= MMUEXT_SET_SUBJECTDOM_H;
  46.129 -	    v = w = &u[2];
  46.130 -	}
  46.131 -	else
  46.132 -	{
  46.133 -	    v = w = &u[0];
  46.134 -	}
  46.135 +        if ( m.dom != 0 )
  46.136 +        {
  46.137 +            u[0].val  = (unsigned long)(m.dom<<16) & ~0xFFFFUL;
  46.138 +            u[0].ptr  = (unsigned long)(m.dom<< 0) & ~0xFFFFUL;
  46.139 +            u[0].ptr |= MMU_EXTENDED_COMMAND;
  46.140 +            u[0].val |= MMUEXT_SET_SUBJECTDOM;
  46.141 +            v = w = &u[1];
  46.142 +        }
  46.143 +        else
  46.144 +        {
  46.145 +            v = w = &u[0];
  46.146 +        }
  46.147  
  46.148 -	p = m.arr;
  46.149 -	addr = m.addr;
  46.150 -	for ( i = 0; i < m.num; i++, addr += PAGE_SIZE, p++ )
  46.151 -	{
  46.152 -	    if ( get_user(mfn, p) ) return -EFAULT;
  46.153 +        p = m.arr;
  46.154 +        addr = m.addr;
  46.155 +        for ( i = 0; i < m.num; i++, addr += PAGE_SIZE, p++ )
  46.156 +        {
  46.157 +            if ( get_user(mfn, p) ) return -EFAULT;
  46.158  
  46.159 -	    v->val = (mfn << PAGE_SHIFT) | pgprot_val(vma->vm_page_prot) |
  46.160 -		_PAGE_IO;
  46.161 +            v->val = (mfn << PAGE_SHIFT) | pgprot_val(vma->vm_page_prot) |
  46.162 +                _PAGE_IO;
  46.163  
  46.164 -	    __direct_remap_area_pages(vma->vm_mm,
  46.165 +            __direct_remap_area_pages(vma->vm_mm,
  46.166                                        addr, 
  46.167                                        PAGE_SIZE, 
  46.168                                        v);
  46.169  
  46.170 -	    if ( unlikely(HYPERVISOR_mmu_update(u, v - u + 1, NULL) < 0) )
  46.171 -		put_user( 0xF0000000 | mfn, p );
  46.172 +            if ( unlikely(HYPERVISOR_mmu_update(u, v - u + 1, NULL) < 0) )
  46.173 +                put_user( 0xF0000000 | mfn, p );
  46.174  
  46.175 -	    v = w;
  46.176 -	}
  46.177 -	ret = 0;
  46.178 -	break;
  46.179 +            v = w;
  46.180 +        }
  46.181 +        ret = 0;
  46.182 +        break;
  46.183  
  46.184      batch_err:
  46.185 -	printk("batch_err ret=%d vma=%p addr=%lx num=%d arr=%p %lx-%lx\n", 
  46.186 -	       ret, vma, m.addr, m.num, m.arr, vma->vm_start, vma->vm_end);
  46.187 -	break;
  46.188 +        printk("batch_err ret=%d vma=%p addr=%lx num=%d arr=%p %lx-%lx\n", 
  46.189 +               ret, vma, m.addr, m.num, m.arr, vma->vm_start, vma->vm_end);
  46.190 +        break;
  46.191      }
  46.192      break;
  46.193  
  46.194 -
  46.195 -
  46.196      default:
  46.197          ret = -EINVAL;
  46.198 -    	break;
  46.199 +        break;
  46.200      }
  46.201      return ret;
  46.202  }
  46.203  
  46.204  static int privcmd_mmap(struct file * file, struct vm_area_struct * vma)
  46.205  {
  46.206 -	/* DONTCOPY is essential for Xen as copy_page_range is broken. */
  46.207 -	vma->vm_flags |= VM_RESERVED | VM_IO | VM_DONTCOPY;
  46.208 +    /* DONTCOPY is essential for Xen as copy_page_range is broken. */
  46.209 +    vma->vm_flags |= VM_RESERVED | VM_IO | VM_DONTCOPY;
  46.210  
  46.211 -	return 0;
  46.212 +    return 0;
  46.213  }
  46.214  
  46.215  static struct file_operations privcmd_file_ops = {
  46.216 -  ioctl : privcmd_ioctl,
  46.217 -  mmap:   privcmd_mmap
  46.218 +    ioctl : privcmd_ioctl,
  46.219 +    mmap:   privcmd_mmap
  46.220  };
  46.221  
  46.222  
  46.223 @@ -236,3 +230,4 @@ static void __exit cleanup_module(void)
  46.224  
  46.225  module_init(init_module);
  46.226  module_exit(cleanup_module);
  46.227 +#
    47.1 --- a/xenolinux-2.4.26-sparse/arch/xen/drivers/netif/backend/interface.c	Thu Jun 03 09:31:38 2004 +0000
    47.2 +++ b/xenolinux-2.4.26-sparse/arch/xen/drivers/netif/backend/interface.c	Thu Jun 03 11:45:16 2004 +0000
    47.3 @@ -10,8 +10,7 @@
    47.4  #include <linux/rtnetlink.h>
    47.5  
    47.6  #define NETIF_HASHSZ 1024
    47.7 -#define NETIF_HASH(_d,_h) \
    47.8 -    (((int)(_d)^(int)((_d)>>32)^(int)(_h))&(NETIF_HASHSZ-1))
    47.9 +#define NETIF_HASH(_d,_h) (((int)(_d)^(int)(_h))&(NETIF_HASHSZ-1))
   47.10  
   47.11  static netif_t *netif_hash[NETIF_HASHSZ];
   47.12  static struct net_device *bridge_dev;
   47.13 @@ -185,7 +184,7 @@ void netif_connect(netif_be_connect_t *c
   47.14      netif = netif_find_by_handle(domid, handle);
   47.15      if ( unlikely(netif == NULL) )
   47.16      {
   47.17 -        DPRINTK("netif_connect attempted for non-existent netif (%llu,%u)\n", 
   47.18 +        DPRINTK("netif_connect attempted for non-existent netif (%u,%u)\n", 
   47.19                  connect->domid, connect->netif_handle); 
   47.20          connect->status = NETIF_BE_STATUS_INTERFACE_NOT_FOUND;
   47.21          return;
   47.22 @@ -271,7 +270,7 @@ int netif_disconnect(netif_be_disconnect
   47.23      if ( unlikely(netif == NULL) )
   47.24      {
   47.25          DPRINTK("netif_disconnect attempted for non-existent netif"
   47.26 -                " (%llu,%u)\n", disconnect->domid, disconnect->netif_handle); 
   47.27 +                " (%u,%u)\n", disconnect->domid, disconnect->netif_handle); 
   47.28          disconnect->status = NETIF_BE_STATUS_INTERFACE_NOT_FOUND;
   47.29          return 1; /* Caller will send response error message. */
   47.30      }
    48.1 --- a/xenolinux-2.4.26-sparse/arch/xen/drivers/netif/backend/main.c	Thu Jun 03 09:31:38 2004 +0000
    48.2 +++ b/xenolinux-2.4.26-sparse/arch/xen/drivers/netif/backend/main.c	Thu Jun 03 11:45:16 2004 +0000
    48.3 @@ -36,7 +36,7 @@ typedef struct {
    48.4  } rx_info_t;
    48.5  static struct sk_buff_head rx_queue;
    48.6  static multicall_entry_t rx_mcl[NETIF_RX_RING_SIZE*2];
    48.7 -static mmu_update_t rx_mmu[NETIF_RX_RING_SIZE*4];
    48.8 +static mmu_update_t rx_mmu[NETIF_RX_RING_SIZE*3];
    48.9  static unsigned char rx_notify[NR_EVENT_CHANNELS];
   48.10  
   48.11  /* Don't currently gate addition of an interface to the tx scheduling list. */
   48.12 @@ -217,14 +217,10 @@ static void net_rx_action(unsigned long 
   48.13          mmu[0].val  = __pa(vdata) >> PAGE_SHIFT;        
   48.14          mmu[1].val  = (unsigned long)(netif->domid<<16) & ~0xFFFFUL;
   48.15          mmu[1].ptr  = (unsigned long)(netif->domid<< 0) & ~0xFFFFUL;
   48.16 -        mmu[2].val  = (unsigned long)(netif->domid>>16) & ~0xFFFFUL;
   48.17 -        mmu[2].ptr  = (unsigned long)(netif->domid>>32) & ~0xFFFFUL;
   48.18          mmu[1].ptr |= MMU_EXTENDED_COMMAND;
   48.19 -        mmu[1].val |= MMUEXT_SET_SUBJECTDOM_L;
   48.20 -        mmu[2].ptr |= MMU_EXTENDED_COMMAND;
   48.21 -        mmu[2].val |= MMUEXT_SET_SUBJECTDOM_H;
   48.22 -        mmu[3].ptr  = (mdata & PAGE_MASK) | MMU_EXTENDED_COMMAND;
   48.23 -        mmu[3].val  = MMUEXT_REASSIGN_PAGE;
   48.24 +        mmu[1].val |= MMUEXT_SET_SUBJECTDOM;
   48.25 +        mmu[2].ptr  = (mdata & PAGE_MASK) | MMU_EXTENDED_COMMAND;
   48.26 +        mmu[2].val  = MMUEXT_REASSIGN_PAGE;
   48.27  
   48.28          mcl[0].op = __HYPERVISOR_update_va_mapping;
   48.29          mcl[0].args[0] = vdata >> PAGE_SHIFT;
   48.30 @@ -232,10 +228,10 @@ static void net_rx_action(unsigned long 
   48.31          mcl[0].args[2] = 0;
   48.32          mcl[1].op = __HYPERVISOR_mmu_update;
   48.33          mcl[1].args[0] = (unsigned long)mmu;
   48.34 -        mcl[1].args[1] = 4;
   48.35 +        mcl[1].args[1] = 3;
   48.36          mcl[1].args[2] = 0;
   48.37  
   48.38 -        mmu += 4;
   48.39 +        mmu += 3;
   48.40          mcl += 2;
   48.41  
   48.42          ((rx_info_t *)&skb->cb[0])->old_mach_ptr = mdata;
   48.43 @@ -265,7 +261,7 @@ static void net_rx_action(unsigned long 
   48.44          /* Check the reassignment error code. */
   48.45          if ( unlikely(mcl[1].args[5] != 0) )
   48.46          {
   48.47 -            DPRINTK("Failed MMU update transferring to DOM%llu\n",
   48.48 +            DPRINTK("Failed MMU update transferring to DOM%u\n",
   48.49                      netif->domid);
   48.50              (void)HYPERVISOR_update_va_mapping(
   48.51                  (unsigned long)skb->head >> PAGE_SHIFT,
   48.52 @@ -514,8 +510,7 @@ static void net_tx_action(unsigned long 
   48.53          mcl[0].args[0] = MMAP_VADDR(pending_idx) >> PAGE_SHIFT;
   48.54          mcl[0].args[1] = (txreq.addr & PAGE_MASK) | __PAGE_KERNEL;
   48.55          mcl[0].args[2] = 0;
   48.56 -        mcl[0].args[3] = (unsigned long)netif->domid;
   48.57 -        mcl[0].args[4] = (unsigned long)(netif->domid>>32);
   48.58 +        mcl[0].args[3] = netif->domid;
   48.59          mcl++;
   48.60          
   48.61          ((tx_info_t *)&skb->cb[0])->idx = pending_idx;
   48.62 @@ -760,7 +755,7 @@ static int __init init_module(void)
   48.63  
   48.64      (void)request_irq(bind_virq_to_irq(VIRQ_DEBUG),
   48.65                        netif_be_dbg, SA_SHIRQ, 
   48.66 -                      "net-be-dbg", NULL);
   48.67 +                      "net-be-dbg", &netif_be_dbg);
   48.68  
   48.69      return 0;
   48.70  }
    49.1 --- a/xenolinux-2.4.26-sparse/arch/xen/mm/ioremap.c	Thu Jun 03 09:31:38 2004 +0000
    49.2 +++ b/xenolinux-2.4.26-sparse/arch/xen/mm/ioremap.c	Thu Jun 03 11:45:16 2004 +0000
    49.3 @@ -119,13 +119,9 @@ int direct_remap_area_pages(struct mm_st
    49.4      {
    49.5          u[0].val  = (unsigned long)(domid<<16) & ~0xFFFFUL;
    49.6          u[0].ptr  = (unsigned long)(domid<< 0) & ~0xFFFFUL;
    49.7 -        u[1].val  = (unsigned long)(domid>>16) & ~0xFFFFUL;
    49.8 -        u[1].ptr  = (unsigned long)(domid>>32) & ~0xFFFFUL;
    49.9          u[0].ptr |= MMU_EXTENDED_COMMAND;
   49.10 -        u[0].val |= MMUEXT_SET_SUBJECTDOM_L;
   49.11 -        u[1].ptr |= MMU_EXTENDED_COMMAND;
   49.12 -        u[1].val |= MMUEXT_SET_SUBJECTDOM_H;
   49.13 -        v = w = &u[2];
   49.14 +        u[0].val |= MMUEXT_SET_SUBJECTDOM;
   49.15 +        v = w = &u[1];
   49.16      }
   49.17      else
   49.18      {
    50.1 --- a/xenolinux-2.4.26-sparse/drivers/char/mem.c	Thu Jun 03 09:31:38 2004 +0000
    50.2 +++ b/xenolinux-2.4.26-sparse/drivers/char/mem.c	Thu Jun 03 11:45:16 2004 +0000
    50.3 @@ -233,39 +233,27 @@ static int mmap_mem(struct file * file, 
    50.4  static int mmap_mem(struct file * file, struct vm_area_struct * vma)
    50.5  {
    50.6  	unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
    50.7 -	domid_t domid;
    50.8  
    50.9  	if (!(start_info.flags & SIF_PRIVILEGED))
   50.10  		return -ENXIO;
   50.11  
   50.12 -	domid = file->private_data ? *(domid_t *)file->private_data : 0;
   50.13 -
   50.14  	/* DONTCOPY is essential for Xen as copy_page_range is broken. */
   50.15  	vma->vm_flags |= VM_RESERVED | VM_IO | VM_DONTCOPY;
   50.16  	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
   50.17  	if (direct_remap_area_pages(vma->vm_mm, vma->vm_start, offset, 
   50.18  				vma->vm_end-vma->vm_start, vma->vm_page_prot,
   50.19 -				domid))
   50.20 +				(domid_t)file->private_data))
   50.21  		return -EAGAIN;
   50.22  	return 0;
   50.23  }
   50.24  static int ioctl_mem(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg)
   50.25  {
   50.26 -	if (file->private_data == NULL)
   50.27 -		file->private_data = kmalloc(sizeof(domid_t), GFP_KERNEL);
   50.28  	switch (cmd) {
   50.29 -	case _IO('M', 1): ((unsigned long *)file->private_data)[0]=arg; break;
   50.30 -	case _IO('M', 2): ((unsigned long *)file->private_data)[1]=arg; break;
   50.31 +	case _IO('M', 1): file->private_data = (void *)arg; break;
   50.32  	default: return -ENOSYS;
   50.33  	}
   50.34  	return 0;
   50.35  }
   50.36 -static int release_mem(struct inode * inode, struct file * file)
   50.37 -{
   50.38 -	if (file->private_data != NULL)
   50.39 -		kfree(file->private_data);
   50.40 -	return 0;
   50.41 -}
   50.42  #endif /* CONFIG_XEN */
   50.43  
   50.44  /*
   50.45 @@ -685,7 +673,6 @@ static struct file_operations mem_fops =
   50.46  	mmap:		mmap_mem,
   50.47  	open:		open_mem,
   50.48  #if defined(CONFIG_XEN_PRIVILEGED_GUEST)
   50.49 -	release:	release_mem,
   50.50  	ioctl:		ioctl_mem,
   50.51  #endif
   50.52  };
    51.1 --- a/xenolinux-2.4.26-sparse/include/asm-xen/hypervisor.h	Thu Jun 03 09:31:38 2004 +0000
    51.2 +++ b/xenolinux-2.4.26-sparse/include/asm-xen/hypervisor.h	Thu Jun 03 11:45:16 2004 +0000
    51.3 @@ -470,8 +470,7 @@ static inline int HYPERVISOR_update_va_m
    51.4      __asm__ __volatile__ (
    51.5          TRAP_INSTR
    51.6          : "=a" (ret) : "0" (__HYPERVISOR_update_va_mapping_otherdomain), 
    51.7 -        "b" (page_nr), "c" ((new_val).pte_low), "d" (flags),
    51.8 -        "S" ((unsigned long)domid), "D" ((unsigned long)(domid>>32)) : 
    51.9 +        "b" (page_nr), "c" ((new_val).pte_low), "d" (flags), "S" (domid) :
   51.10          "memory" );
   51.11      
   51.12      return ret;