ia64/xen-unstable

changeset 9730:74ee53209cca

Fix whitespace in libxc. Tabs are manually fixed.
Trailing whitespace removed with:
perl -p -i -e 's/\s+$/\n/g' tools/libxc/*.[ch]

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author kaf24@firebug.cl.cam.ac.uk
date Sat Apr 15 10:07:31 2006 +0100 (2006-04-15)
parents 1d8b3c85121d
children 1dce0d05c763
files tools/libxc/xc_bvtsched.c tools/libxc/xc_core.c tools/libxc/xc_domain.c tools/libxc/xc_elf.h tools/libxc/xc_evtchn.c tools/libxc/xc_ia64_stubs.c tools/libxc/xc_linux_build.c tools/libxc/xc_linux_restore.c tools/libxc/xc_linux_save.c tools/libxc/xc_load_aout9.c tools/libxc/xc_load_bin.c tools/libxc/xc_load_elf.c tools/libxc/xc_misc.c tools/libxc/xc_physdev.c tools/libxc/xc_private.c tools/libxc/xc_private.h tools/libxc/xc_ptrace.c tools/libxc/xc_ptrace.h tools/libxc/xc_ptrace_core.c tools/libxc/xc_sedf.c tools/libxc/xc_tbuf.c tools/libxc/xenctrl.h tools/libxc/xenguest.h tools/libxc/xg_private.c tools/libxc/xg_private.h tools/libxc/xg_save_restore.h
line diff
     1.1 --- a/tools/libxc/xc_bvtsched.c	Sat Apr 15 09:52:32 2006 +0100
     1.2 +++ b/tools/libxc/xc_bvtsched.c	Sat Apr 15 10:07:31 2006 +0100
     1.3 @@ -1,8 +1,8 @@
     1.4  /******************************************************************************
     1.5   * xc_bvtsched.c
     1.6 - * 
     1.7 + *
     1.8   * API for manipulating parameters of the Borrowed Virtual Time scheduler.
     1.9 - * 
    1.10 + *
    1.11   * Copyright (c) 2003, K A Fraser.
    1.12   */
    1.13  
    1.14 @@ -26,7 +26,7 @@ int xc_bvtsched_global_get(int xc_handle
    1.15  {
    1.16      DECLARE_DOM0_OP;
    1.17      int ret;
    1.18 -    
    1.19 +
    1.20      op.cmd = DOM0_SCHEDCTL;
    1.21      op.u.schedctl.sched_id = SCHED_BVT;
    1.22      op.u.schedctl.direction = SCHED_INFO_GET;
    1.23 @@ -71,7 +71,7 @@ int xc_bvtsched_domain_get(int xc_handle
    1.24                             long long *warpl,
    1.25                             long long *warpu)
    1.26  {
    1.27 -    
    1.28 +
    1.29      DECLARE_DOM0_OP;
    1.30      int ret;
    1.31      struct bvt_adjdom *adjptr = &op.u.adjustdom.u.bvt;
     2.1 --- a/tools/libxc/xc_core.c	Sat Apr 15 09:52:32 2006 +0100
     2.2 +++ b/tools/libxc/xc_core.c	Sat Apr 15 10:07:31 2006 +0100
     2.3 @@ -23,7 +23,7 @@ copy_from_domain_page(int xc_handle,
     2.4      return 0;
     2.5  }
     2.6  
     2.7 -int 
     2.8 +int
     2.9  xc_domain_dumpcore_via_callback(int xc_handle,
    2.10                                  uint32_t domid,
    2.11                                  void *args,
    2.12 @@ -45,13 +45,13 @@ xc_domain_dumpcore_via_callback(int xc_h
    2.13          PERROR("Could not allocate dump_mem");
    2.14          goto error_out;
    2.15      }
    2.16 - 
    2.17 +
    2.18      if ( xc_domain_getinfo(xc_handle, domid, 1, &info) != 1 )
    2.19      {
    2.20          PERROR("Could not get info for domain");
    2.21          goto error_out;
    2.22      }
    2.23 - 
    2.24 +
    2.25      if ( domid != info.domid )
    2.26      {
    2.27          PERROR("Domain %d does not exist", domid);
    2.28 @@ -61,10 +61,10 @@ xc_domain_dumpcore_via_callback(int xc_h
    2.29      for ( i = 0; i <= info.max_vcpu_id; i++ )
    2.30          if ( xc_vcpu_getcontext(xc_handle, domid, i, &ctxt[nr_vcpus]) == 0)
    2.31              nr_vcpus++;
    2.32 - 
    2.33 +
    2.34      nr_pages = info.nr_pages;
    2.35  
    2.36 -    header.xch_magic = XC_CORE_MAGIC; 
    2.37 +    header.xch_magic = XC_CORE_MAGIC;
    2.38      header.xch_nr_vcpus = nr_vcpus;
    2.39      header.xch_nr_pages = nr_pages;
    2.40      header.xch_ctxt_offset = sizeof(struct xc_core_header);
    2.41 @@ -74,7 +74,7 @@ xc_domain_dumpcore_via_callback(int xc_h
    2.42                   (sizeof(vcpu_guest_context_t) * nr_vcpus) +
    2.43                   (nr_pages * sizeof(unsigned long)));
    2.44      header.xch_pages_offset = round_pgup(dummy_len);
    2.45 -    
    2.46 +
    2.47      sts = dump_rtn(args, (char *)&header, sizeof(struct xc_core_header));
    2.48      if ( sts != 0 )
    2.49          goto error_out;
    2.50 @@ -150,7 +150,7 @@ static int local_file_dump(void *args, c
    2.51      return 0;
    2.52  }
    2.53  
    2.54 -int 
    2.55 +int
    2.56  xc_domain_dumpcore(int xc_handle,
    2.57                     uint32_t domid,
    2.58                     const char *corename)
    2.59 @@ -163,7 +163,7 @@ xc_domain_dumpcore(int xc_handle,
    2.60          PERROR("Could not open corefile %s: %s", corename, strerror(errno));
    2.61          return -errno;
    2.62      }
    2.63 - 
    2.64 +
    2.65      sts = xc_domain_dumpcore_via_callback(
    2.66          xc_handle, domid, &da, &local_file_dump);
    2.67  
     3.1 --- a/tools/libxc/xc_domain.c	Sat Apr 15 09:52:32 2006 +0100
     3.2 +++ b/tools/libxc/xc_domain.c	Sat Apr 15 10:07:31 2006 +0100
     3.3 @@ -1,8 +1,8 @@
     3.4  /******************************************************************************
     3.5   * xc_domain.c
     3.6 - * 
     3.7 + *
     3.8   * API for manipulating and obtaining information on domains.
     3.9 - * 
    3.10 + *
    3.11   * Copyright (c) 2003, K A Fraser.
    3.12   */
    3.13  
    3.14 @@ -26,17 +26,17 @@ int xc_domain_create(int xc_handle,
    3.15  
    3.16      *pdomid = (uint16_t)op.u.createdomain.domain;
    3.17      return 0;
    3.18 -}    
    3.19 +}
    3.20  
    3.21  
    3.22 -int xc_domain_pause(int xc_handle, 
    3.23 +int xc_domain_pause(int xc_handle,
    3.24                      uint32_t domid)
    3.25  {
    3.26      DECLARE_DOM0_OP;
    3.27      op.cmd = DOM0_PAUSEDOMAIN;
    3.28      op.u.pausedomain.domain = (domid_t)domid;
    3.29      return do_dom0_op(xc_handle, &op);
    3.30 -}    
    3.31 +}
    3.32  
    3.33  
    3.34  int xc_domain_unpause(int xc_handle,
    3.35 @@ -46,7 +46,7 @@ int xc_domain_unpause(int xc_handle,
    3.36      op.cmd = DOM0_UNPAUSEDOMAIN;
    3.37      op.u.unpausedomain.domain = (domid_t)domid;
    3.38      return do_dom0_op(xc_handle, &op);
    3.39 -}    
    3.40 +}
    3.41  
    3.42  
    3.43  int xc_domain_destroy(int xc_handle,
    3.44 @@ -88,7 +88,7 @@ int xc_domain_shutdown(int xc_handle,
    3.45  
    3.46  
    3.47  int xc_vcpu_setaffinity(int xc_handle,
    3.48 -                        uint32_t domid, 
    3.49 +                        uint32_t domid,
    3.50                          int vcpu,
    3.51                          cpumap_t cpumap)
    3.52  {
    3.53 @@ -109,7 +109,7 @@ int xc_domain_getinfo(int xc_handle,
    3.54      unsigned int nr_doms;
    3.55      uint32_t next_domid = first_domid;
    3.56      DECLARE_DOM0_OP;
    3.57 -    int rc = 0; 
    3.58 +    int rc = 0;
    3.59  
    3.60      memset(info, 0, max_doms*sizeof(xc_dominfo_t));
    3.61  
    3.62 @@ -127,8 +127,8 @@ int xc_domain_getinfo(int xc_handle,
    3.63          info->blocked  = !!(op.u.getdomaininfo.flags & DOMFLAGS_BLOCKED);
    3.64          info->running  = !!(op.u.getdomaininfo.flags & DOMFLAGS_RUNNING);
    3.65  
    3.66 -        info->shutdown_reason = 
    3.67 -            (op.u.getdomaininfo.flags>>DOMFLAGS_SHUTDOWNSHIFT) & 
    3.68 +        info->shutdown_reason =
    3.69 +            (op.u.getdomaininfo.flags>>DOMFLAGS_SHUTDOWNSHIFT) &
    3.70              DOMFLAGS_SHUTDOWNMASK;
    3.71  
    3.72          if ( info->shutdown && (info->shutdown_reason == SHUTDOWN_crash) )
    3.73 @@ -152,7 +152,7 @@ int xc_domain_getinfo(int xc_handle,
    3.74          info++;
    3.75      }
    3.76  
    3.77 -    if( !nr_doms ) return rc; 
    3.78 +    if( !nr_doms ) return rc;
    3.79  
    3.80      return nr_doms;
    3.81  }
    3.82 @@ -167,7 +167,7 @@ int xc_domain_getinfolist(int xc_handle,
    3.83  
    3.84      if ( mlock(info, max_domains*sizeof(xc_domaininfo_t)) != 0 )
    3.85          return -1;
    3.86 -    
    3.87 +
    3.88      op.cmd = DOM0_GETDOMAININFOLIST;
    3.89      op.u.getdomaininfolist.first_domain = first_domain;
    3.90      op.u.getdomaininfolist.max_domains  = max_domains;
    3.91 @@ -177,10 +177,10 @@ int xc_domain_getinfolist(int xc_handle,
    3.92          ret = -1;
    3.93      else
    3.94          ret = op.u.getdomaininfolist.num_domains;
    3.95 -    
    3.96 +
    3.97      if ( munlock(info, max_domains*sizeof(xc_domaininfo_t)) != 0 )
    3.98          ret = -1;
    3.99 -    
   3.100 +
   3.101      return ret;
   3.102  }
   3.103  
   3.104 @@ -209,7 +209,7 @@ int xc_vcpu_getcontext(int xc_handle,
   3.105  
   3.106  
   3.107  int xc_shadow_control(int xc_handle,
   3.108 -                      uint32_t domid, 
   3.109 +                      uint32_t domid,
   3.110                        unsigned int sop,
   3.111                        unsigned long *dirty_bitmap,
   3.112                        unsigned long pages,
   3.113 @@ -238,11 +238,11 @@ int xc_domain_setcpuweight(int xc_handle
   3.114  {
   3.115      int sched_id;
   3.116      int ret;
   3.117 -    
   3.118 +
   3.119      /* Figure out which scheduler is currently used: */
   3.120      if ( (ret = xc_sched_id(xc_handle, &sched_id)) != 0 )
   3.121          return ret;
   3.122 -    
   3.123 +
   3.124      switch ( sched_id )
   3.125      {
   3.126          case SCHED_BVT:
   3.127 @@ -253,20 +253,20 @@ int xc_domain_setcpuweight(int xc_handle
   3.128              long long warpl;
   3.129              long long warpu;
   3.130  
   3.131 -            /* Preserve all the scheduling parameters apart 
   3.132 +            /* Preserve all the scheduling parameters apart
   3.133                 of MCU advance. */
   3.134              if ( (ret = xc_bvtsched_domain_get(
   3.135 -                xc_handle, domid, &mcuadv, 
   3.136 +                xc_handle, domid, &mcuadv,
   3.137                  &warpback, &warpvalue, &warpl, &warpu)) != 0 )
   3.138                  return ret;
   3.139 -            
   3.140 +
   3.141              /* The MCU advance is inverse of the weight.
   3.142                 Default value of the weight is 1, default mcuadv 10.
   3.143                 The scaling factor is therefore 10. */
   3.144              if ( weight > 0 )
   3.145                  mcuadv = 10 / weight;
   3.146 -            
   3.147 -            ret = xc_bvtsched_domain_set(xc_handle, domid, mcuadv, 
   3.148 +
   3.149 +            ret = xc_bvtsched_domain_set(xc_handle, domid, mcuadv,
   3.150                                           warpback, warpvalue, warpl, warpu);
   3.151              break;
   3.152          }
   3.153 @@ -276,7 +276,7 @@ int xc_domain_setcpuweight(int xc_handle
   3.154  }
   3.155  
   3.156  int xc_domain_setmaxmem(int xc_handle,
   3.157 -                        uint32_t domid, 
   3.158 +                        uint32_t domid,
   3.159                          unsigned int max_memkb)
   3.160  {
   3.161      DECLARE_DOM0_OP;
   3.162 @@ -287,7 +287,7 @@ int xc_domain_setmaxmem(int xc_handle,
   3.163  }
   3.164  
   3.165  int xc_domain_memory_increase_reservation(int xc_handle,
   3.166 -                                          uint32_t domid, 
   3.167 +                                          uint32_t domid,
   3.168                                            unsigned long nr_extents,
   3.169                                            unsigned int extent_order,
   3.170                                            unsigned int address_bits,
   3.171 @@ -297,7 +297,7 @@ int xc_domain_memory_increase_reservatio
   3.172      struct xen_memory_reservation reservation = {
   3.173          .extent_start = extent_start, /* may be NULL */
   3.174          .nr_extents   = nr_extents,
   3.175 -        .extent_order = extent_order,  
   3.176 +        .extent_order = extent_order,
   3.177          .address_bits = address_bits,
   3.178          .domid        = domid
   3.179      };
   3.180 @@ -319,16 +319,16 @@ int xc_domain_memory_increase_reservatio
   3.181  }
   3.182  
   3.183  int xc_domain_memory_decrease_reservation(int xc_handle,
   3.184 -                                          uint32_t domid, 
   3.185 +                                          uint32_t domid,
   3.186                                            unsigned long nr_extents,
   3.187                                            unsigned int extent_order,
   3.188                                            unsigned long *extent_start)
   3.189  {
   3.190      int err;
   3.191      struct xen_memory_reservation reservation = {
   3.192 -        .extent_start = extent_start, 
   3.193 +        .extent_start = extent_start,
   3.194          .nr_extents   = nr_extents,
   3.195 -        .extent_order = extent_order,  
   3.196 +        .extent_order = extent_order,
   3.197          .address_bits = 0,
   3.198          .domid        = domid
   3.199      };
   3.200 @@ -411,7 +411,7 @@ int xc_domain_max_vcpus(int xc_handle, u
   3.201      return do_dom0_op(xc_handle, &op);
   3.202  }
   3.203  
   3.204 -int xc_domain_sethandle(int xc_handle, uint32_t domid, 
   3.205 +int xc_domain_sethandle(int xc_handle, uint32_t domid,
   3.206                          xen_domain_handle_t handle)
   3.207  {
   3.208      DECLARE_DOM0_OP;
   3.209 @@ -506,7 +506,7 @@ int xc_domain_iomem_permission(int xc_ha
   3.210      op.cmd = DOM0_IOMEM_PERMISSION;
   3.211      op.u.iomem_permission.domain = domid;
   3.212      op.u.iomem_permission.first_mfn = first_mfn;
   3.213 -	op.u.iomem_permission.nr_mfns = nr_mfns;
   3.214 +    op.u.iomem_permission.nr_mfns = nr_mfns;
   3.215      op.u.iomem_permission.allow_access = allow_access;
   3.216  
   3.217      return do_dom0_op(xc_handle, &op);
     4.1 --- a/tools/libxc/xc_elf.h	Sat Apr 15 09:52:32 2006 +0100
     4.2 +++ b/tools/libxc/xc_elf.h	Sat Apr 15 10:07:31 2006 +0100
     4.3 @@ -46,7 +46,7 @@ typedef uint32_t	Elf64_Half;
     4.4  typedef uint16_t	Elf64_Quarter;
     4.5  
     4.6  /*
     4.7 - * e_ident[] identification indexes 
     4.8 + * e_ident[] identification indexes
     4.9   * See http://www.caldera.com/developers/gabi/2000-07-17/ch4.eheader.html
    4.10   */
    4.11  #define EI_MAG0		0		/* file ID */
    4.12 @@ -57,7 +57,7 @@ typedef uint16_t	Elf64_Quarter;
    4.13  #define EI_DATA		5		/* data encoding */
    4.14  #define EI_VERSION	6		/* ELF header version */
    4.15  #define EI_OSABI	7		/* OS/ABI ID */
    4.16 -#define EI_ABIVERSION	8		/* ABI version */ 
    4.17 +#define EI_ABIVERSION	8		/* ABI version */
    4.18  #define EI_PAD		9		/* start of pad bytes */
    4.19  #define EI_NIDENT	16		/* Size of e_ident[] */
    4.20  
    4.21 @@ -119,7 +119,7 @@ typedef struct elfhdr {
    4.22  	Elf32_Half	e_phnum;	/* number of program header entries */
    4.23  	Elf32_Half	e_shentsize;	/* section header entry size */
    4.24  	Elf32_Half	e_shnum;	/* number of section header entries */
    4.25 -	Elf32_Half	e_shstrndx;	/* section header table's "section 
    4.26 +	Elf32_Half	e_shstrndx;	/* section header table's "section
    4.27  					   header string table" entry offset */
    4.28  } Elf32_Ehdr;
    4.29  
    4.30 @@ -160,7 +160,7 @@ typedef struct {
    4.31  #define EM_486		6		/* Intel 80486 - unused? */
    4.32  #define EM_860		7		/* Intel 80860 */
    4.33  #define EM_MIPS		8		/* MIPS R3000 Big-Endian only */
    4.34 -/* 
    4.35 +/*
    4.36   * Don't know if EM_MIPS_RS4_BE,
    4.37   * EM_SPARC64, EM_PARISC,
    4.38   * or EM_PPC are ABI compliant
    4.39 @@ -441,7 +441,7 @@ typedef struct {
    4.40  #define DT_NUM		25		/* Number used. */
    4.41  #define DT_LOPROC	0x70000000	/* reserved range for processor */
    4.42  #define DT_HIPROC	0x7fffffff	/*  specific dynamic array tags */
    4.43 -	
    4.44 +
    4.45  /* Standard ELF hashing function */
    4.46  unsigned int elf_hash(const unsigned char *name);
    4.47  
     5.1 --- a/tools/libxc/xc_evtchn.c	Sat Apr 15 09:52:32 2006 +0100
     5.2 +++ b/tools/libxc/xc_evtchn.c	Sat Apr 15 10:07:31 2006 +0100
     5.3 @@ -1,8 +1,8 @@
     5.4  /******************************************************************************
     5.5   * xc_evtchn.c
     5.6 - * 
     5.7 + *
     5.8   * API for manipulating and accessing inter-domain event channels.
     5.9 - * 
    5.10 + *
    5.11   * Copyright (c) 2004, K A Fraser.
    5.12   */
    5.13  
    5.14 @@ -44,7 +44,7 @@ int xc_evtchn_alloc_unbound(int xc_handl
    5.15  
    5.16      if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
    5.17          rc = op.u.alloc_unbound.port;
    5.18 -    
    5.19 +
    5.20      return rc;
    5.21  }
    5.22  
    5.23 @@ -62,6 +62,6 @@ int xc_evtchn_status(int xc_handle,
    5.24  
    5.25      if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
    5.26          memcpy(status, &op.u.status, sizeof(*status));
    5.27 -    
    5.28 +
    5.29      return rc;
    5.30  }
     6.1 --- a/tools/libxc/xc_ia64_stubs.c	Sat Apr 15 09:52:32 2006 +0100
     6.2 +++ b/tools/libxc/xc_ia64_stubs.c	Sat Apr 15 10:07:31 2006 +0100
     6.3 @@ -22,7 +22,7 @@ unsigned long xc_ia64_fpsr_default(void)
     6.4          return FPSR_DEFAULT;
     6.5  }
     6.6  
     6.7 -int xc_linux_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters, 
     6.8 +int xc_linux_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
     6.9                    uint32_t max_factor, uint32_t flags /* XCFLAGS_xxx */,
    6.10                    int (*suspend)(int domid))
    6.11  {
    6.12 @@ -50,8 +50,8 @@ xc_plan9_build(int xc_handle,
    6.13  }
    6.14  
    6.15  int xc_ia64_get_pfn_list(int xc_handle,
    6.16 -                         uint32_t domid, 
    6.17 -                         unsigned long *pfn_buf, 
    6.18 +                         uint32_t domid,
    6.19 +                         unsigned long *pfn_buf,
    6.20                           unsigned int start_page,
    6.21                           unsigned int nr_pages)
    6.22  {
    6.23 @@ -65,16 +65,16 @@ int xc_ia64_get_pfn_list(int xc_handle,
    6.24      op.u.getmemlist.buffer   = pfn_buf;
    6.25  
    6.26      if ( (max_pfns != -1UL)
    6.27 -		&& mlock(pfn_buf, nr_pages * sizeof(unsigned long)) != 0 )
    6.28 +        && mlock(pfn_buf, nr_pages * sizeof(unsigned long)) != 0 )
    6.29      {
    6.30          PERROR("Could not lock pfn list buffer");
    6.31          return -1;
    6.32 -    }    
    6.33 +    }
    6.34  
    6.35      ret = do_dom0_op(xc_handle, &op);
    6.36  
    6.37      if (max_pfns != -1UL)
    6.38 -    	(void)munlock(pfn_buf, nr_pages * sizeof(unsigned long));
    6.39 +        (void)munlock(pfn_buf, nr_pages * sizeof(unsigned long));
    6.40  
    6.41      return (ret < 0) ? -1 : op.u.getmemlist.num_pfns;
    6.42  }
    6.43 @@ -84,7 +84,7 @@ long xc_get_max_pages(int xc_handle, uin
    6.44      dom0_op_t op;
    6.45      op.cmd = DOM0_GETDOMAININFO;
    6.46      op.u.getdomaininfo.domain = (domid_t)domid;
    6.47 -    return (do_dom0_op(xc_handle, &op) < 0) ? 
    6.48 +    return (do_dom0_op(xc_handle, &op) < 0) ?
    6.49          -1 : op.u.getdomaininfo.max_pages;
    6.50  }
    6.51  
    6.52 @@ -92,7 +92,7 @@ int xc_ia64_copy_to_domain_pages(int xc_
    6.53          void* src_page, unsigned long dst_pfn, int nr_pages)
    6.54  {
    6.55      // N.B. gva should be page aligned
    6.56 -    
    6.57 +
    6.58      unsigned long *page_array = NULL;
    6.59      int i;
    6.60  
    6.61 @@ -107,13 +107,13 @@ int xc_ia64_copy_to_domain_pages(int xc_
    6.62      }
    6.63  
    6.64      for ( i=0; i< nr_pages; i++ ){
    6.65 -	if (xc_copy_to_domain_page(xc_handle, domid, page_array[i],
    6.66 -			src_page + (i << PAGE_SHIFT)))
    6.67 -	    goto error_out;
    6.68 +        if (xc_copy_to_domain_page(xc_handle, domid, page_array[i],
    6.69 +                    src_page + (i << PAGE_SHIFT)))
    6.70 +            goto error_out;
    6.71      }
    6.72      free(page_array);
    6.73      return 0;
    6.74 -    
    6.75 +
    6.76  error_out:
    6.77      free(page_array);
    6.78      return -1;
    6.79 @@ -123,8 +123,8 @@ error_out:
    6.80  #define HOB_SIGNATURE 0x3436474953424f48 // "HOBSIG64"
    6.81  #define GFW_HOB_START    ((4UL<<30)-(14UL<<20))    //4G -14M
    6.82  #define GFW_HOB_SIZE     (1UL<<20)              //1M
    6.83 -#define MEM_G   (1UL << 30) 
    6.84 -#define MEM_M   (1UL << 20) 
    6.85 +#define MEM_G   (1UL << 30)
    6.86 +#define MEM_M   (1UL << 20)
    6.87  
    6.88  typedef struct {
    6.89      unsigned long signature;
    6.90 @@ -136,7 +136,7 @@ typedef struct {
    6.91   * INFO HOB is the first data data in one HOB list
    6.92   * it contains the control information of the HOB list
    6.93   */
    6.94 -typedef struct { 
    6.95 +typedef struct {
    6.96      HOB_GENERIC_HEADER  header;
    6.97      unsigned long       length;    // current length of hob
    6.98      unsigned long       cur_pos;   // current poisiton of hob
    6.99 @@ -216,7 +216,7 @@ hob_init( void  *buffer ,unsigned long b
   6.100          // buffer too small
   6.101          return -1;
   6.102      }
   6.103 -    
   6.104 +
   6.105      phit = (HOB_INFO*)buffer;
   6.106      phit->header.signature = HOB_SIGNATURE;
   6.107      phit->header.type = HOB_TYPE_INFO;
   6.108 @@ -224,7 +224,7 @@ hob_init( void  *buffer ,unsigned long b
   6.109      phit->length = sizeof(HOB_INFO) + sizeof(HOB_GENERIC_HEADER);
   6.110      phit->cur_pos = 0;
   6.111      phit->buf_size = buf_size;
   6.112 -    
   6.113 +
   6.114      terminal = (HOB_GENERIC_HEADER*) (buffer + sizeof(HOB_INFO));
   6.115      terminal->signature= HOB_SIGNATURE;
   6.116      terminal->type = HOB_TYPE_TERMINAL;
   6.117 @@ -235,7 +235,7 @@ hob_init( void  *buffer ,unsigned long b
   6.118  
   6.119  /*
   6.120   *  Add a new HOB to the HOB List.
   6.121 - *       
   6.122 + *
   6.123   *  hob_start  -  start address of hob buffer
   6.124   *  type       -  type of the hob to be added
   6.125   *  data       -  data of the hob to be added
   6.126 @@ -250,8 +250,8 @@ hob_add(
   6.127  )
   6.128  {
   6.129      HOB_INFO *phit;
   6.130 -    HOB_GENERIC_HEADER     *newhob,*tail;   
   6.131 -    
   6.132 +    HOB_GENERIC_HEADER     *newhob,*tail;
   6.133 +
   6.134      phit = (HOB_INFO*)hob_start;
   6.135  
   6.136      if (phit->length + data_size > phit->buf_size){
   6.137 @@ -259,7 +259,7 @@ hob_add(
   6.138          return -1;
   6.139      }
   6.140  
   6.141 -    //append new HOB 
   6.142 +    //append new HOB
   6.143      newhob = (HOB_GENERIC_HEADER*)
   6.144          (hob_start + phit->length - sizeof(HOB_GENERIC_HEADER));
   6.145      newhob->signature = HOB_SIGNATURE;
   6.146 @@ -267,7 +267,7 @@ hob_add(
   6.147      newhob->length = data_size + sizeof(HOB_GENERIC_HEADER);
   6.148      memcpy((void*)newhob + sizeof(HOB_GENERIC_HEADER), data, data_size);
   6.149  
   6.150 -    // append terminal HOB  
   6.151 +    // append terminal HOB
   6.152      tail = (HOB_GENERIC_HEADER*) ( hob_start + phit->length + data_size);
   6.153      tail->signature = HOB_SIGNATURE;
   6.154      tail->type = HOB_TYPE_TERMINAL;
   6.155 @@ -281,9 +281,9 @@ hob_add(
   6.156  }
   6.157  
   6.158  int get_hob_size(void* hob_buf){
   6.159 -    
   6.160 +
   6.161      HOB_INFO *phit = (HOB_INFO*)hob_buf;
   6.162 -    
   6.163 +
   6.164      if (phit->header.signature != HOB_SIGNATURE){
   6.165          PERROR("xc_get_hob_size:Incorrect signature");
   6.166          return -1;
   6.167 @@ -293,30 +293,30 @@ int get_hob_size(void* hob_buf){
   6.168  
   6.169  int build_hob (void* hob_buf, unsigned long hob_buf_size,
   6.170                    unsigned long dom_mem_size)
   6.171 -{   
   6.172 -    //Init HOB List 
   6.173 +{
   6.174 +    //Init HOB List
   6.175      if (hob_init (hob_buf, hob_buf_size)<0){
   6.176          PERROR("buffer too small");
   6.177          goto err_out;
   6.178      }
   6.179 -    
   6.180 +
   6.181      if ( add_mem_hob( hob_buf,dom_mem_size) < 0){
   6.182          PERROR("Add memory hob failed, buffer too small");
   6.183          goto err_out;
   6.184      }
   6.185 -    
   6.186 +
   6.187      if ( add_pal_hob( hob_buf ) < 0 ){
   6.188          PERROR("Add PAL hob failed, buffer too small");
   6.189          goto err_out;
   6.190      }
   6.191 -    
   6.192 +
   6.193      return 0;
   6.194  
   6.195  err_out:
   6.196 -    return -1;  
   6.197 +    return -1;
   6.198  }
   6.199  
   6.200 -static int 
   6.201 +static int
   6.202  load_hob(int xc_handle, uint32_t dom, void *hob_buf)
   6.203  {
   6.204      // hob_buf should be page aligned
   6.205 @@ -334,22 +334,22 @@ load_hob(int xc_handle, uint32_t dom, vo
   6.206      }
   6.207  
   6.208      nr_pages = (hob_size + PAGE_SIZE -1) >> PAGE_SHIFT;
   6.209 -    
   6.210 +
   6.211      return xc_ia64_copy_to_domain_pages(xc_handle, dom,
   6.212              hob_buf, GFW_HOB_START, nr_pages );
   6.213  }
   6.214  
   6.215  #define MIN(x, y) ((x) < (y)) ? (x) : (y)
   6.216 -static int 
   6.217 +static int
   6.218  add_mem_hob(void* hob_buf, unsigned long dom_mem_size){
   6.219      hob_mem_t memhob;
   6.220  
   6.221      // less than 3G
   6.222      memhob.start = 0;
   6.223      memhob.size = MIN(dom_mem_size, 0xC0000000);
   6.224 -    
   6.225 +
   6.226      if (hob_add(hob_buf, HOB_TYPE_MEM, &memhob, sizeof(memhob)) < 0){
   6.227 -	return -1;
   6.228 +        return -1;
   6.229      }
   6.230  
   6.231      if (dom_mem_size > 0xC0000000) {
   6.232 @@ -373,29 +373,29 @@ unsigned char config_pal_mem_attrib[8] =
   6.233  };
   6.234  unsigned char config_pal_cache_info[152] = {
   6.235      3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   6.236 -    6, 4, 6, 7, 255, 1, 0, 1, 0, 64, 0, 0, 12, 12, 
   6.237 +    6, 4, 6, 7, 255, 1, 0, 1, 0, 64, 0, 0, 12, 12,
   6.238      49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 6, 7, 0, 1,
   6.239 -    0, 1, 0, 64, 0, 0, 12, 12, 49, 0, 0, 0, 0, 0, 0, 
   6.240 -    0, 0, 0, 6, 8, 7, 7, 255, 7, 0, 11, 0, 0, 16, 0, 
   6.241 -    12, 17, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 8, 7, 
   6.242 +    0, 1, 0, 64, 0, 0, 12, 12, 49, 0, 0, 0, 0, 0, 0,
   6.243 +    0, 0, 0, 6, 8, 7, 7, 255, 7, 0, 11, 0, 0, 16, 0,
   6.244 +    12, 17, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 8, 7,
   6.245      7, 7, 5, 9, 11, 0, 0, 4, 0, 12, 15, 49, 0, 254, 255,
   6.246 -    255, 255, 255, 255, 255, 255, 2, 8, 7, 7, 7, 5, 9, 
   6.247 -    11, 0, 0, 4, 0, 12, 15, 49, 0, 0, 0, 0, 0, 0, 0, 0, 
   6.248 +    255, 255, 255, 255, 255, 255, 2, 8, 7, 7, 7, 5, 9,
   6.249 +    11, 0, 0, 4, 0, 12, 15, 49, 0, 0, 0, 0, 0, 0, 0, 0,
   6.250      0, 3, 12, 7, 7, 7, 14, 1, 3, 0, 0, 192, 0, 12, 20, 49, 0
   6.251  };
   6.252  unsigned char config_pal_cache_prot_info[200] = {
   6.253 -    3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
   6.254 +    3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   6.255      45, 0, 16, 8, 0, 76, 12, 64, 0, 0, 0, 0, 0, 0, 0,
   6.256 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
   6.257 -    8, 0, 16, 4, 0, 76, 44, 68, 0, 0, 0, 0, 0, 0, 0, 0, 
   6.258 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 
   6.259 -    0, 16, 8, 0, 81, 44, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
   6.260 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   6.261 +    8, 0, 16, 4, 0, 76, 44, 68, 0, 0, 0, 0, 0, 0, 0, 0,
   6.262 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32,
   6.263 +    0, 16, 8, 0, 81, 44, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   6.264      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0,
   6.265 -    112, 12, 0, 79, 124, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
   6.266 -    0, 0, 0, 0, 0, 0, 254, 255, 255, 255, 255, 255, 255, 255, 
   6.267 +    112, 12, 0, 79, 124, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   6.268 +    0, 0, 0, 0, 0, 0, 254, 255, 255, 255, 255, 255, 255, 255,
   6.269      32, 0, 112, 12, 0, 79, 124, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   6.270 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 160, 
   6.271 -    12, 0, 84, 124, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
   6.272 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 160,
   6.273 +    12, 0, 84, 124, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   6.274      0, 0, 0
   6.275  };
   6.276  unsigned char config_pal_debug_info[16] = {
   6.277 @@ -408,37 +408,37 @@ unsigned char config_pal_freq_base[8] = 
   6.278      109, 219, 182, 13, 0, 0, 0, 0
   6.279  };
   6.280  unsigned char config_pal_freq_ratios[24] = {
   6.281 -    11, 1, 0, 0, 77, 7, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 4, 
   6.282 +    11, 1, 0, 0, 77, 7, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 4,
   6.283      0, 0, 0, 7, 0, 0, 0
   6.284  };
   6.285  unsigned char config_pal_halt_info[64] = {
   6.286 -    0, 0, 0, 0, 0, 0, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, 
   6.287 +    0, 0, 0, 0, 0, 0, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0,
   6.288      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   6.289 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
   6.290 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   6.291      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
   6.292  };
   6.293  unsigned char config_pal_perf_mon_info[136] = {
   6.294 -    12, 47, 18, 8, 0, 0, 0, 0, 241, 255, 0, 0, 255, 7, 0, 0, 
   6.295 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
   6.296 -    0, 0, 0, 0, 0, 0, 0, 0, 241, 255, 0, 0, 223, 0, 255, 255, 
   6.297 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
   6.298 -    0, 0, 0, 0, 0, 0, 0, 0, 240, 255, 0, 0, 0, 0, 0, 0, 
   6.299 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
   6.300 -    0, 0, 0, 0, 0, 0, 0, 0, 240, 255, 0, 0, 0, 0, 0, 0, 
   6.301 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
   6.302 +    12, 47, 18, 8, 0, 0, 0, 0, 241, 255, 0, 0, 255, 7, 0, 0,
   6.303 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   6.304 +    0, 0, 0, 0, 0, 0, 0, 0, 241, 255, 0, 0, 223, 0, 255, 255,
   6.305 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   6.306 +    0, 0, 0, 0, 0, 0, 0, 0, 240, 255, 0, 0, 0, 0, 0, 0,
   6.307 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   6.308 +    0, 0, 0, 0, 0, 0, 0, 0, 240, 255, 0, 0, 0, 0, 0, 0,
   6.309 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   6.310      0, 0, 0, 0, 0, 0, 0, 0
   6.311  };
   6.312  unsigned char config_pal_proc_get_features[104] = {
   6.313 -    3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
   6.314 -    0, 0, 0, 0, 64, 6, 64, 49, 0, 0, 0, 0, 64, 6, 0, 0, 
   6.315 -    0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 
   6.316 -    231, 0, 0, 0, 0, 0, 0, 0, 228, 0, 0, 0, 0, 0, 0, 0, 
   6.317 -    0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 0, 0, 0, 0, 0, 0, 
   6.318 +    3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   6.319 +    0, 0, 0, 0, 64, 6, 64, 49, 0, 0, 0, 0, 64, 6, 0, 0,
   6.320 +    0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0,
   6.321 +    231, 0, 0, 0, 0, 0, 0, 0, 228, 0, 0, 0, 0, 0, 0, 0,
   6.322 +    0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 0, 0, 0, 0, 0, 0,
   6.323      63, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0,
   6.324      0, 0, 0, 0, 0, 0, 0, 0
   6.325  };
   6.326  unsigned char config_pal_ptce_info[24] = {
   6.327 -    0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 
   6.328 +    0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,
   6.329      0, 0, 0, 0, 0, 0, 0, 0
   6.330  };
   6.331  unsigned char config_pal_register_info[64] = {
   6.332 @@ -473,7 +473,7 @@ unsigned char config_pal_vm_page_size[16
   6.333  typedef struct{
   6.334      hob_type_t type;
   6.335      void* data;
   6.336 -    unsigned long size;     
   6.337 +    unsigned long size;
   6.338  }hob_batch_t;
   6.339  
   6.340  hob_batch_t hob_batch[]={
   6.341 @@ -552,13 +552,13 @@ hob_batch_t hob_batch[]={
   6.342      {  HOB_TYPE_PAL_VM_PAGE_SIZE,
   6.343          &config_pal_vm_page_size,
   6.344          sizeof(config_pal_vm_page_size)
   6.345 -    },      
   6.346 +    },
   6.347  };
   6.348  
   6.349  static int add_pal_hob(void* hob_buf){
   6.350      int i;
   6.351      for (i=0; i<sizeof(hob_batch)/sizeof(hob_batch_t); i++){
   6.352 -        if (hob_add(hob_buf, hob_batch[i].type, 
   6.353 +        if (hob_add(hob_buf, hob_batch[i].type,
   6.354                      hob_batch[i].data,
   6.355                      hob_batch[i].size)<0)
   6.356              return -1;
   6.357 @@ -579,17 +579,17 @@ static int setup_guest(  int xc_handle,
   6.358  
   6.359      // FIXME: initialize pfn list for a temp hack
   6.360      if (xc_ia64_get_pfn_list(xc_handle, dom, NULL, -1, -1) == -1) {
   6.361 -	PERROR("Could not allocate continuous memory");
   6.362 -	goto error_out;
   6.363 +        PERROR("Could not allocate continuous memory");
   6.364 +        goto error_out;
   6.365      }
   6.366 -    
   6.367 +
   6.368      if ((image_size > 12 * MEM_M) || (image_size & (PAGE_SIZE - 1))) {
   6.369          PERROR("Guest firmware size is incorrect [%ld]?", image_size);
   6.370          return -1;
   6.371      }
   6.372  
   6.373      /* Load guest firmware */
   6.374 -    if( xc_ia64_copy_to_domain_pages( xc_handle, dom, 
   6.375 +    if( xc_ia64_copy_to_domain_pages( xc_handle, dom,
   6.376              image, 4*MEM_G-image_size, image_size>>PAGE_SHIFT)) {
   6.377          PERROR("Could not load guest firmware into domain");
   6.378          goto error_out;
   6.379 @@ -610,9 +610,9 @@ static int setup_guest(  int xc_handle,
   6.380  
   6.381      *store_mfn = page_array[1];
   6.382      if ((sp = (shared_iopage_t *) xc_map_foreign_range(
   6.383 -		xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
   6.384 -		page_array[0])) == 0)
   6.385 -	goto error_out;
   6.386 +                    xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
   6.387 +                    page_array[0])) == 0)
   6.388 +        goto error_out;
   6.389      memset(sp, 0, PAGE_SIZE);
   6.390  
   6.391      for (i = 0; i < vcpus; i++) {
   6.392 @@ -665,14 +665,14 @@ int xc_hvm_build(int xc_handle,
   6.393  
   6.394      image_size = (image_size + PAGE_SIZE - 1) & PAGE_MASK;
   6.395  
   6.396 -    if ( mlock(&st_ctxt, sizeof(st_ctxt) ) ){   
   6.397 +    if ( mlock(&st_ctxt, sizeof(st_ctxt) ) ){
   6.398          PERROR("Unable to mlock ctxt");
   6.399          return 1;
   6.400      }
   6.401  
   6.402      op.cmd = DOM0_GETDOMAININFO;
   6.403      op.u.getdomaininfo.domain = (domid_t)domid;
   6.404 -    if ( (do_dom0_op(xc_handle, &op) < 0) || 
   6.405 +    if ( (do_dom0_op(xc_handle, &op) < 0) ||
   6.406           ((uint16_t)op.u.getdomaininfo.domain != domid) ) {
   6.407          PERROR("Could not get info on domain");
   6.408          goto error_out;
     7.1 --- a/tools/libxc/xc_linux_build.c	Sat Apr 15 09:52:32 2006 +0100
     7.2 +++ b/tools/libxc/xc_linux_build.c	Sat Apr 15 10:07:31 2006 +0100
     7.3 @@ -237,7 +237,7 @@ static int setup_pg_tables(int xc_handle
     7.4          else
     7.5          {
     7.6              *vl1e = (page_array[count] << PAGE_SHIFT) | L1_PROT;
     7.7 -            if ( (count >= ((vpt_start-dsi_v_start)>>PAGE_SHIFT)) && 
     7.8 +            if ( (count >= ((vpt_start-dsi_v_start)>>PAGE_SHIFT)) &&
     7.9                   (count <  ((vpt_end  -dsi_v_start)>>PAGE_SHIFT)) )
    7.10                  *vl1e &= ~_PAGE_RW;
    7.11          }
    7.12 @@ -314,7 +314,7 @@ static int setup_pg_tables_pae(int xc_ha
    7.13              else
    7.14                  *vl2e++ = l1tab | L2_PROT;
    7.15          }
    7.16 -        
    7.17 +
    7.18          if ( shadow_mode_enabled )
    7.19          {
    7.20              *vl1e = (count << PAGE_SHIFT) | L1_PROT;
    7.21 @@ -323,12 +323,12 @@ static int setup_pg_tables_pae(int xc_ha
    7.22          {
    7.23              *vl1e = ((uint64_t)page_array[count] << PAGE_SHIFT) | L1_PROT;
    7.24              if ( (count >= ((vpt_start-dsi_v_start)>>PAGE_SHIFT)) &&
    7.25 -                 (count <  ((vpt_end  -dsi_v_start)>>PAGE_SHIFT)) ) 
    7.26 +                 (count <  ((vpt_end  -dsi_v_start)>>PAGE_SHIFT)) )
    7.27                  *vl1e &= ~_PAGE_RW;
    7.28          }
    7.29          vl1e++;
    7.30      }
    7.31 -     
    7.32 +
    7.33      munmap(vl1tab, PAGE_SIZE);
    7.34      munmap(vl2tab, PAGE_SIZE);
    7.35      munmap(vl3tab, PAGE_SIZE);
    7.36 @@ -376,13 +376,13 @@ static int setup_pg_tables_64(int xc_han
    7.37          ctxt->ctrlreg[3] = pl4tab;
    7.38      else
    7.39          ctxt->ctrlreg[3] = l4tab;
    7.40 -    
    7.41 +
    7.42      for ( count = 0; count < ((v_end-dsi_v_start)>>PAGE_SHIFT); count++)
    7.43      {
    7.44          if ( !((unsigned long)vl1e & (PAGE_SIZE-1)) )
    7.45          {
    7.46              alloc_pt(l1tab, vl1tab, pl1tab);
    7.47 -            
    7.48 +
    7.49              if ( !((unsigned long)vl2e & (PAGE_SIZE-1)) )
    7.50              {
    7.51                  alloc_pt(l2tab, vl2tab, pl2tab);
    7.52 @@ -410,7 +410,7 @@ static int setup_pg_tables_64(int xc_han
    7.53                  *vl2e = l1tab | L2_PROT;
    7.54              vl2e++;
    7.55          }
    7.56 -        
    7.57 +
    7.58          if ( shadow_mode_enabled )
    7.59          {
    7.60              *vl1e = (count << PAGE_SHIFT) | L1_PROT;
    7.61 @@ -419,14 +419,14 @@ static int setup_pg_tables_64(int xc_han
    7.62          {
    7.63              *vl1e = (page_array[count] << PAGE_SHIFT) | L1_PROT;
    7.64              if ( (count >= ((vpt_start-dsi_v_start)>>PAGE_SHIFT)) &&
    7.65 -                 (count <  ((vpt_end  -dsi_v_start)>>PAGE_SHIFT)) ) 
    7.66 +                 (count <  ((vpt_end  -dsi_v_start)>>PAGE_SHIFT)) )
    7.67                  {
    7.68                      *vl1e &= ~_PAGE_RW;
    7.69                  }
    7.70          }
    7.71          vl1e++;
    7.72      }
    7.73 -     
    7.74 +
    7.75      munmap(vl1tab, PAGE_SIZE);
    7.76      munmap(vl2tab, PAGE_SIZE);
    7.77      munmap(vl3tab, PAGE_SIZE);
    7.78 @@ -509,7 +509,7 @@ static int setup_guest(int xc_handle,
    7.79             " Loaded kernel: %p->%p\n"
    7.80             " Init. ramdisk: %p->%p\n"
    7.81             " TOTAL:         %p->%p\n",
    7.82 -           _p(dsi.v_kernstart), _p(dsi.v_kernend), 
    7.83 +           _p(dsi.v_kernstart), _p(dsi.v_kernend),
    7.84             _p(vinitrd_start),   _p(vinitrd_end),
    7.85             _p(dsi.v_start),     _p(v_end));
    7.86      printf(" ENTRY ADDRESS: %p\n", _p(dsi.v_kernentry));
    7.87 @@ -696,10 +696,10 @@ static int setup_guest(int xc_handle,
    7.88                                             required_features);
    7.89  
    7.90      /*
    7.91 -     * Why do we need this? The number of page-table frames depends on the 
    7.92 -     * size of the bootstrap address space. But the size of the address space 
    7.93 -     * depends on the number of page-table frames (since each one is mapped 
    7.94 -     * read-only). We have a pair of simultaneous equations in two unknowns, 
    7.95 +     * Why do we need this? The number of page-table frames depends on the
    7.96 +     * size of the bootstrap address space. But the size of the address space
    7.97 +     * depends on the number of page-table frames (since each one is mapped
    7.98 +     * read-only). We have a pair of simultaneous equations in two unknowns,
    7.99       * which we solve by exhaustive search.
   7.100       */
   7.101      v_end = round_pgup(dsi.v_end);
   7.102 @@ -731,13 +731,13 @@ static int setup_guest(int xc_handle,
   7.103          if ( dsi.pae_kernel )
   7.104          {
   7.105              /* FIXME: assumes one L2 pgtable @ 0xc0000000 */
   7.106 -            if ( (((v_end - dsi.v_start + ((1<<L2_PAGETABLE_SHIFT_PAE)-1)) >> 
   7.107 +            if ( (((v_end - dsi.v_start + ((1<<L2_PAGETABLE_SHIFT_PAE)-1)) >>
   7.108                     L2_PAGETABLE_SHIFT_PAE) + 2) <= nr_pt_pages )
   7.109                  break;
   7.110          }
   7.111          else
   7.112          {
   7.113 -            if ( (((v_end - dsi.v_start + ((1<<L2_PAGETABLE_SHIFT)-1)) >> 
   7.114 +            if ( (((v_end - dsi.v_start + ((1<<L2_PAGETABLE_SHIFT)-1)) >>
   7.115                     L2_PAGETABLE_SHIFT) + 1) <= nr_pt_pages )
   7.116                  break;
   7.117          }
   7.118 @@ -873,7 +873,7 @@ static int setup_guest(int xc_handle,
   7.119              count) )
   7.120          {
   7.121              fprintf(stderr,"m2p update failure p=%lx m=%lx\n",
   7.122 -                    count, page_array[count]); 
   7.123 +                    count, page_array[count]);
   7.124              munmap(physmap, PAGE_SIZE);
   7.125              goto error_out;
   7.126          }
   7.127 @@ -982,7 +982,7 @@ static int setup_guest(int xc_handle,
   7.128          start_info->mod_len      = initrd->len;
   7.129      }
   7.130      if ( cmdline != NULL )
   7.131 -    { 
   7.132 +    {
   7.133          strncpy((char *)start_info->cmd_line, cmdline, MAX_GUEST_CMDLINE);
   7.134          start_info->cmd_line[MAX_GUEST_CMDLINE-1] = '\0';
   7.135      }
   7.136 @@ -1073,14 +1073,14 @@ static int xc_linux_build_internal(int x
   7.137  #endif
   7.138  
   7.139      if ( mlock(&st_ctxt, sizeof(st_ctxt) ) )
   7.140 -    {   
   7.141 +    {
   7.142          PERROR("%s: ctxt mlock failed", __func__);
   7.143          return 1;
   7.144      }
   7.145  
   7.146      op.cmd = DOM0_GETDOMAININFO;
   7.147      op.u.getdomaininfo.domain = (domid_t)domid;
   7.148 -    if ( (xc_dom0_op(xc_handle, &op) < 0) || 
   7.149 +    if ( (xc_dom0_op(xc_handle, &op) < 0) ||
   7.150           ((uint16_t)op.u.getdomaininfo.domain != domid) )
   7.151      {
   7.152          PERROR("Could not get info on domain");
   7.153 @@ -1089,9 +1089,9 @@ static int xc_linux_build_internal(int x
   7.154  
   7.155      memset(ctxt, 0, sizeof(*ctxt));
   7.156  
   7.157 -    if ( setup_guest(xc_handle, domid, image, image_size, 
   7.158 +    if ( setup_guest(xc_handle, domid, image, image_size,
   7.159                       initrd,
   7.160 -                     nr_pages, 
   7.161 +                     nr_pages,
   7.162                       &vstartinfo_start, &vkern_entry,
   7.163                       &vstack_start, ctxt, cmdline,
   7.164                       op.u.getdomaininfo.shared_info_frame,
   7.165 @@ -1152,7 +1152,7 @@ static int xc_linux_build_internal(int x
   7.166  
   7.167      /* No LDT. */
   7.168      ctxt->ldt_ents = 0;
   7.169 -    
   7.170 +
   7.171      /* Use the default Xen-provided GDT. */
   7.172      ctxt->gdt_ents = 0;
   7.173  
   7.174 @@ -1184,7 +1184,7 @@ static int xc_linux_build_internal(int x
   7.175  
   7.176      launch_op.cmd = DOM0_SETVCPUCONTEXT;
   7.177      rc = xc_dom0_op(xc_handle, &launch_op);
   7.178 -    
   7.179 +
   7.180      return rc;
   7.181  
   7.182   error_out:
     8.1 --- a/tools/libxc/xc_linux_restore.c	Sat Apr 15 09:52:32 2006 +0100
     8.2 +++ b/tools/libxc/xc_linux_restore.c	Sat Apr 15 10:07:31 2006 +0100
     8.3 @@ -1,8 +1,8 @@
     8.4  /******************************************************************************
     8.5   * xc_linux_restore.c
     8.6 - * 
     8.7 + *
     8.8   * Restore the state of a Linux session.
     8.9 - * 
    8.10 + *
    8.11   * Copyright (c) 2003, K A Fraser.
    8.12   */
    8.13  
    8.14 @@ -13,13 +13,13 @@
    8.15  #include "xg_save_restore.h"
    8.16  
    8.17  /* max mfn of the whole machine */
    8.18 -static unsigned long max_mfn; 
    8.19 +static unsigned long max_mfn;
    8.20  
    8.21  /* virtual starting address of the hypervisor */
    8.22 -static unsigned long hvirt_start; 
    8.23 +static unsigned long hvirt_start;
    8.24  
    8.25  /* #levels of page tables used by the currrent guest */
    8.26 -static unsigned int pt_levels; 
    8.27 +static unsigned int pt_levels;
    8.28  
    8.29  /* total number of pages used by the current guest */
    8.30  static unsigned long max_pfn;
    8.31 @@ -41,84 +41,84 @@ read_exact(int fd, void *buf, size_t cou
    8.32          s = read(fd, &b[r], count - r);
    8.33          if ((s == -1) && (errno == EINTR))
    8.34              continue;
    8.35 -        if (s <= 0) { 
    8.36 +        if (s <= 0) {
    8.37              break;
    8.38 -        } 
    8.39 +        }
    8.40          r += s;
    8.41      }
    8.42  
    8.43 -    return (r == count) ? 1 : 0; 
    8.44 +    return (r == count) ? 1 : 0;
    8.45  }
    8.46  
    8.47  /*
    8.48 -** In the state file (or during transfer), all page-table pages are 
    8.49 -** converted into a 'canonical' form where references to actual mfns 
    8.50 -** are replaced with references to the corresponding pfns. 
    8.51 -** This function inverts that operation, replacing the pfn values with 
    8.52 -** the (now known) appropriate mfn values. 
    8.53 +** In the state file (or during transfer), all page-table pages are
    8.54 +** converted into a 'canonical' form where references to actual mfns
    8.55 +** are replaced with references to the corresponding pfns.
    8.56 +** This function inverts that operation, replacing the pfn values with
    8.57 +** the (now known) appropriate mfn values.
    8.58  */
    8.59 -int uncanonicalize_pagetable(unsigned long type, void *page) 
    8.60 -{ 
    8.61 -    int i, pte_last; 
    8.62 -    unsigned long pfn; 
    8.63 -    uint64_t pte; 
    8.64 +int uncanonicalize_pagetable(unsigned long type, void *page)
    8.65 +{
    8.66 +    int i, pte_last;
    8.67 +    unsigned long pfn;
    8.68 +    uint64_t pte;
    8.69  
    8.70 -    pte_last = PAGE_SIZE / ((pt_levels == 2)? 4 : 8); 
    8.71 +    pte_last = PAGE_SIZE / ((pt_levels == 2)? 4 : 8);
    8.72  
    8.73      /* Now iterate through the page table, uncanonicalizing each PTE */
    8.74 -    for(i = 0; i < pte_last; i++) { 
    8.75 -        
    8.76 -        if(pt_levels == 2) 
    8.77 -            pte = ((uint32_t *)page)[i]; 
    8.78 -        else 
    8.79 -            pte = ((uint64_t *)page)[i]; 
    8.80 +    for(i = 0; i < pte_last; i++) {
    8.81  
    8.82 -        if(pte & _PAGE_PRESENT) { 
    8.83 +        if(pt_levels == 2)
    8.84 +            pte = ((uint32_t *)page)[i];
    8.85 +        else
    8.86 +            pte = ((uint64_t *)page)[i];
    8.87 +
    8.88 +        if(pte & _PAGE_PRESENT) {
    8.89  
    8.90              pfn = (pte >> PAGE_SHIFT) & 0xffffffff;
    8.91 -            
    8.92 -            if(pfn >= max_pfn) { 
    8.93 +
    8.94 +            if(pfn >= max_pfn) {
    8.95                  /* This "page table page" is probably not one; bail. */
    8.96                  ERR("Frame number in type %lu page table is out of range: "
    8.97 -                    "i=%d pfn=0x%lx max_pfn=%lu", 
    8.98 +                    "i=%d pfn=0x%lx max_pfn=%lu",
    8.99                      type >> 28, i, pfn, max_pfn);
   8.100 -                return 0; 
   8.101 -            } 
   8.102 -            
   8.103 -            
   8.104 +                return 0;
   8.105 +            }
   8.106 +
   8.107 +
   8.108              pte &= 0xffffff0000000fffULL;
   8.109              pte |= (uint64_t)p2m[pfn] << PAGE_SHIFT;
   8.110  
   8.111 -            if(pt_levels == 2) 
   8.112 -                ((uint32_t *)page)[i] = (uint32_t)pte; 
   8.113 -            else 
   8.114 -                ((uint64_t *)page)[i] = (uint64_t)pte; 
   8.115 +            if(pt_levels == 2)
   8.116 +                ((uint32_t *)page)[i] = (uint32_t)pte;
   8.117 +            else
   8.118 +                ((uint64_t *)page)[i] = (uint64_t)pte;
   8.119  
   8.120 -        
   8.121 +
   8.122  
   8.123          }
   8.124      }
   8.125 -    
   8.126 -    return 1; 
   8.127 +
   8.128 +    return 1;
   8.129  }
   8.130  
   8.131 -int xc_linux_restore(int xc_handle, int io_fd, 
   8.132 -                     uint32_t dom, unsigned long nr_pfns, 
   8.133 +int xc_linux_restore(int xc_handle, int io_fd,
   8.134 +                     uint32_t dom, unsigned long nr_pfns,
   8.135                       unsigned int store_evtchn, unsigned long *store_mfn,
   8.136                       unsigned int console_evtchn, unsigned long *console_mfn)
   8.137  {
   8.138      DECLARE_DOM0_OP;
   8.139      int rc = 1, i, n;
   8.140 -    unsigned long mfn, pfn; 
   8.141 +    unsigned long mfn, pfn;
   8.142      unsigned int prev_pc, this_pc;
   8.143      int verify = 0;
   8.144 -    int nraces = 0; 
   8.145 +    int nraces = 0;
   8.146  
   8.147      /* The new domain's shared-info frame number. */
   8.148      unsigned long shared_info_frame;
   8.149      unsigned char shared_info_page[PAGE_SIZE]; /* saved contents from file */
   8.150      shared_info_t *shared_info = (shared_info_t *)shared_info_page;
   8.151 -    
   8.152 +
   8.153      /* A copy of the CPU context of the guest. */
   8.154      vcpu_guest_context_t ctxt;
   8.155  
   8.156 @@ -135,7 +135,7 @@ int xc_linux_restore(int xc_handle, int 
   8.157      unsigned long *page = NULL;
   8.158  
   8.159      /* A copy of the pfn-to-mfn table frame list. */
   8.160 -    unsigned long *p2m_frame_list = NULL; 
   8.161 +    unsigned long *p2m_frame_list = NULL;
   8.162  
   8.163      /* A temporary mapping of the guest's start_info page. */
   8.164      start_info_t *start_info;
   8.165 @@ -148,17 +148,17 @@ int xc_linux_restore(int xc_handle, int 
   8.166      unsigned long buf[PAGE_SIZE/sizeof(unsigned long)];
   8.167  
   8.168      struct mmuext_op pin[MAX_PIN_BATCH];
   8.169 -    unsigned int nr_pins; 
   8.170 +    unsigned int nr_pins;
   8.171  
   8.172  
   8.173 -    max_pfn = nr_pfns; 
   8.174 +    max_pfn = nr_pfns;
   8.175  
   8.176      DPRINTF("xc_linux_restore start: max_pfn = %lx\n", max_pfn);
   8.177  
   8.178  
   8.179 -    if(!get_platform_info(xc_handle, dom, 
   8.180 +    if(!get_platform_info(xc_handle, dom,
   8.181                            &max_mfn, &hvirt_start, &pt_levels)) {
   8.182 -        ERR("Unable to get platform info."); 
   8.183 +        ERR("Unable to get platform info.");
   8.184          return 1;
   8.185      }
   8.186  
   8.187 @@ -171,20 +171,20 @@ int xc_linux_restore(int xc_handle, int 
   8.188  
   8.189  
   8.190      /* Read the saved P2M frame list */
   8.191 -    if(!(p2m_frame_list = malloc(P2M_FL_SIZE))) { 
   8.192 +    if(!(p2m_frame_list = malloc(P2M_FL_SIZE))) {
   8.193          ERR("Couldn't allocate p2m_frame_list array");
   8.194          goto out;
   8.195      }
   8.196 -    
   8.197 -    if (!read_exact(io_fd, p2m_frame_list, P2M_FL_SIZE)) { 
   8.198 +
   8.199 +    if (!read_exact(io_fd, p2m_frame_list, P2M_FL_SIZE)) {
   8.200          ERR("read p2m_frame_list failed");
   8.201          goto out;
   8.202      }
   8.203  
   8.204 -    
   8.205 +
   8.206      /* We want zeroed memory so use calloc rather than malloc. */
   8.207 -    p2m        = calloc(sizeof(unsigned long), max_pfn); 
   8.208 -    pfn_type   = calloc(sizeof(unsigned long), max_pfn);    
   8.209 +    p2m        = calloc(sizeof(unsigned long), max_pfn);
   8.210 +    pfn_type   = calloc(sizeof(unsigned long), max_pfn);
   8.211      region_mfn = calloc(sizeof(unsigned long), MAX_BATCH_SIZE);
   8.212  
   8.213      if ((p2m == NULL) || (pfn_type == NULL) || (region_mfn == NULL)) {
   8.214 @@ -192,7 +192,7 @@ int xc_linux_restore(int xc_handle, int 
   8.215          errno = ENOMEM;
   8.216          goto out;
   8.217      }
   8.218 -    
   8.219 +
   8.220      if (mlock(region_mfn, sizeof(unsigned long) * MAX_BATCH_SIZE)) {
   8.221          ERR("Could not mlock region_mfn");
   8.222          goto out;
   8.223 @@ -207,27 +207,27 @@ int xc_linux_restore(int xc_handle, int 
   8.224      }
   8.225      shared_info_frame = op.u.getdomaininfo.shared_info_frame;
   8.226  
   8.227 -    if(xc_domain_setmaxmem(xc_handle, dom, PFN_TO_KB(max_pfn)) != 0) { 
   8.228 +    if(xc_domain_setmaxmem(xc_handle, dom, PFN_TO_KB(max_pfn)) != 0) {
   8.229          errno = ENOMEM;
   8.230          goto out;
   8.231      }
   8.232 -    
   8.233 +
   8.234      if(xc_domain_memory_increase_reservation(
   8.235 -           xc_handle, dom, max_pfn, 0, 0, NULL) != 0) { 
   8.236 +           xc_handle, dom, max_pfn, 0, 0, NULL) != 0) {
   8.237          ERR("Failed to increase reservation by %lx KB", PFN_TO_KB(max_pfn));
   8.238          errno = ENOMEM;
   8.239          goto out;
   8.240      }
   8.241  
   8.242 -    DPRINTF("Increased domain reservation by %lx KB\n", PFN_TO_KB(max_pfn)); 
   8.243 +    DPRINTF("Increased domain reservation by %lx KB\n", PFN_TO_KB(max_pfn));
   8.244  
   8.245      /* Build the pfn-to-mfn table. We choose MFN ordering returned by Xen. */
   8.246      if (xc_get_pfn_list(xc_handle, dom, p2m, max_pfn) != max_pfn) {
   8.247          ERR("Did not read correct number of frame numbers for new dom");
   8.248          goto out;
   8.249      }
   8.250 -    
   8.251 -    if(!(mmu = xc_init_mmu_updates(xc_handle, dom))) { 
   8.252 +
   8.253 +    if(!(mmu = xc_init_mmu_updates(xc_handle, dom))) {
   8.254          ERR("Could not initialise for MMU updates");
   8.255          goto out;
   8.256      }
   8.257 @@ -242,7 +242,7 @@ int xc_linux_restore(int xc_handle, int 
   8.258      prev_pc = 0;
   8.259  
   8.260      n = 0;
   8.261 -    while (1) { 
   8.262 +    while (1) {
   8.263  
   8.264          int j;
   8.265  
   8.266 @@ -253,13 +253,13 @@ int xc_linux_restore(int xc_handle, int 
   8.267              prev_pc = this_pc;
   8.268          }
   8.269  
   8.270 -        if (!read_exact(io_fd, &j, sizeof(int))) { 
   8.271 +        if (!read_exact(io_fd, &j, sizeof(int))) {
   8.272              ERR("Error when reading batch size");
   8.273              goto out;
   8.274          }
   8.275  
   8.276          PPRINTF("batch %d\n",j);
   8.277 - 
   8.278 +
   8.279          if (j == -1) {
   8.280              verify = 1;
   8.281              fprintf(stderr, "Entering page verify mode\n");
   8.282 @@ -269,27 +269,27 @@ int xc_linux_restore(int xc_handle, int 
   8.283          if (j == 0)
   8.284              break;  /* our work here is done */
   8.285  
   8.286 -        if (j > MAX_BATCH_SIZE) { 
   8.287 +        if (j > MAX_BATCH_SIZE) {
   8.288              ERR("Max batch size exceeded. Giving up.");
   8.289              goto out;
   8.290          }
   8.291 - 
   8.292 -        if (!read_exact(io_fd, region_pfn_type, j*sizeof(unsigned long))) { 
   8.293 +
   8.294 +        if (!read_exact(io_fd, region_pfn_type, j*sizeof(unsigned long))) {
   8.295              ERR("Error when reading region pfn types");
   8.296              goto out;
   8.297          }
   8.298  
   8.299 -        for (i = 0; i < j; i++) { 
   8.300 +        for (i = 0; i < j; i++) {
   8.301  
   8.302              if ((region_pfn_type[i] & LTAB_MASK) == XTAB)
   8.303                  region_mfn[i] = 0; /* we know map will fail, but don't care */
   8.304 -            else 
   8.305 -                region_mfn[i] = p2m[region_pfn_type[i] & ~LTAB_MASK]; 
   8.306 +            else
   8.307 +                region_mfn[i] = p2m[region_pfn_type[i] & ~LTAB_MASK];
   8.308  
   8.309          }
   8.310 - 
   8.311 +
   8.312          if (!(region_base = xc_map_foreign_batch(
   8.313 -                  xc_handle, dom, PROT_WRITE, region_mfn, j))) {  
   8.314 +                  xc_handle, dom, PROT_WRITE, region_mfn, j))) {
   8.315              ERR("map batch failed");
   8.316              goto out;
   8.317          }
   8.318 @@ -297,12 +297,12 @@ int xc_linux_restore(int xc_handle, int 
   8.319          for ( i = 0; i < j; i++ )
   8.320          {
   8.321              void *page;
   8.322 -            unsigned long pagetype; 
   8.323 +            unsigned long pagetype;
   8.324  
   8.325              pfn      = region_pfn_type[i] & ~LTAB_MASK;
   8.326 -            pagetype = region_pfn_type[i] & LTAB_MASK; 
   8.327 +            pagetype = region_pfn_type[i] & LTAB_MASK;
   8.328  
   8.329 -            if (pagetype == XTAB) 
   8.330 +            if (pagetype == XTAB)
   8.331                  /* a bogus/unmapped page: skip it */
   8.332                  continue;
   8.333  
   8.334 @@ -311,72 +311,72 @@ int xc_linux_restore(int xc_handle, int 
   8.335                  goto out;
   8.336              }
   8.337  
   8.338 -            pfn_type[pfn] = pagetype; 
   8.339 +            pfn_type[pfn] = pagetype;
   8.340  
   8.341              mfn = p2m[pfn];
   8.342  
   8.343              /* In verify mode, we use a copy; otherwise we work in place */
   8.344 -            page = verify ? (void *)buf : (region_base + i*PAGE_SIZE); 
   8.345 +            page = verify ? (void *)buf : (region_base + i*PAGE_SIZE);
   8.346  
   8.347 -            if (!read_exact(io_fd, page, PAGE_SIZE)) { 
   8.348 +            if (!read_exact(io_fd, page, PAGE_SIZE)) {
   8.349                  ERR("Error when reading page (type was %lx)", pagetype);
   8.350                  goto out;
   8.351              }
   8.352  
   8.353 -            pagetype &= LTABTYPE_MASK; 
   8.354 +            pagetype &= LTABTYPE_MASK;
   8.355  
   8.356 -            if(pagetype >= L1TAB && pagetype <= L4TAB) { 
   8.357 -                
   8.358 -                /* 
   8.359 -                ** A page table page - need to 'uncanonicalize' it, i.e. 
   8.360 -                ** replace all the references to pfns with the corresponding 
   8.361 -                ** mfns for the new domain. 
   8.362 -                ** 
   8.363 -                ** On PAE we need to ensure that PGDs are in MFNs < 4G, and 
   8.364 -                ** so we may need to update the p2m after the main loop. 
   8.365 -                ** Hence we defer canonicalization of L1s until then. 
   8.366 +            if(pagetype >= L1TAB && pagetype <= L4TAB) {
   8.367 +
   8.368 +                /*
   8.369 +                ** A page table page - need to 'uncanonicalize' it, i.e.
   8.370 +                ** replace all the references to pfns with the corresponding
   8.371 +                ** mfns for the new domain.
   8.372 +                **
   8.373 +                ** On PAE we need to ensure that PGDs are in MFNs < 4G, and
   8.374 +                ** so we may need to update the p2m after the main loop.
   8.375 +                ** Hence we defer canonicalization of L1s until then.
   8.376                  */
   8.377 -                if(pt_levels != 3 || pagetype != L1TAB) { 
   8.378 +                if(pt_levels != 3 || pagetype != L1TAB) {
   8.379  
   8.380                      if(!uncanonicalize_pagetable(pagetype, page)) {
   8.381 -                        /* 
   8.382 +                        /*
   8.383                          ** Failing to uncanonicalize a page table can be ok
   8.384                          ** under live migration since the pages type may have
   8.385 -                        ** changed by now (and we'll get an update later). 
   8.386 +                        ** changed by now (and we'll get an update later).
   8.387                          */
   8.388 -                        DPRINTF("PT L%ld race on pfn=%08lx mfn=%08lx\n", 
   8.389 -                                pagetype >> 28, pfn, mfn); 
   8.390 -                        nraces++; 
   8.391 -                        continue; 
   8.392 +                        DPRINTF("PT L%ld race on pfn=%08lx mfn=%08lx\n",
   8.393 +                                pagetype >> 28, pfn, mfn);
   8.394 +                        nraces++;
   8.395 +                        continue;
   8.396                      }
   8.397  
   8.398 -                } 
   8.399 -                    
   8.400 -            } else if(pagetype != NOTAB) { 
   8.401 +                }
   8.402 +
   8.403 +            } else if(pagetype != NOTAB) {
   8.404  
   8.405                  ERR("Bogus page type %lx page table is out of range: "
   8.406                      "i=%d max_pfn=%lu", pagetype, i, max_pfn);
   8.407                  goto out;
   8.408  
   8.409 -            } 
   8.410 +            }
   8.411  
   8.412  
   8.413              if (verify) {
   8.414  
   8.415                  int res = memcmp(buf, (region_base + i*PAGE_SIZE), PAGE_SIZE);
   8.416  
   8.417 -                if (res) { 
   8.418 +                if (res) {
   8.419  
   8.420                      int v;
   8.421  
   8.422                      DPRINTF("************** pfn=%lx type=%lx gotcs=%08lx "
   8.423 -                            "actualcs=%08lx\n", pfn, pfn_type[pfn], 
   8.424 -                            csum_page(region_base + i*PAGE_SIZE), 
   8.425 +                            "actualcs=%08lx\n", pfn, pfn_type[pfn],
   8.426 +                            csum_page(region_base + i*PAGE_SIZE),
   8.427                              csum_page(buf));
   8.428  
   8.429                      for (v = 0; v < 4; v++) {
   8.430 -                        
   8.431 -                        unsigned long *p = (unsigned long *) 
   8.432 +
   8.433 +                        unsigned long *p = (unsigned long *)
   8.434                              (region_base + i*PAGE_SIZE);
   8.435                          if (buf[v] != p[v])
   8.436                              DPRINTF("    %d: %08lx %08lx\n", v, buf[v], p[v]);
   8.437 @@ -384,8 +384,8 @@ int xc_linux_restore(int xc_handle, int 
   8.438                  }
   8.439              }
   8.440  
   8.441 -            if (xc_add_mmu_update(xc_handle, mmu, 
   8.442 -                                  (((unsigned long long)mfn) << PAGE_SHIFT) 
   8.443 +            if (xc_add_mmu_update(xc_handle, mmu,
   8.444 +                                  (((unsigned long long)mfn) << PAGE_SHIFT)
   8.445                                    | MMU_MACHPHYS_UPDATE, pfn)) {
   8.446                  ERR("failed machpys update mfn=%lx pfn=%lx", mfn, pfn);
   8.447                  goto out;
   8.448 @@ -398,149 +398,149 @@ int xc_linux_restore(int xc_handle, int 
   8.449  
   8.450      DPRINTF("Received all pages (%d races)\n", nraces);
   8.451  
   8.452 -    if(pt_levels == 3) { 
   8.453 +    if(pt_levels == 3) {
   8.454  
   8.455 -        /* 
   8.456 -        ** XXX SMH on PAE we need to ensure PGDs are in MFNs < 4G. This 
   8.457 +        /*
   8.458 +        ** XXX SMH on PAE we need to ensure PGDs are in MFNs < 4G. This
   8.459          ** is a little awkward and involves (a) finding all such PGDs and
   8.460 -        ** replacing them with 'lowmem' versions; (b) upating the p2m[] 
   8.461 +        ** replacing them with 'lowmem' versions; (b) upating the p2m[]
   8.462          ** with the new info; and (c) canonicalizing all the L1s using the
   8.463 -        ** (potentially updated) p2m[]. 
   8.464 -        ** 
   8.465 +        ** (potentially updated) p2m[].
   8.466 +        **
   8.467          ** This is relatively slow (and currently involves two passes through
   8.468          ** the pfn_type[] array), but at least seems to be correct. May wish
   8.469 -        ** to consider more complex approaches to optimize this later. 
   8.470 +        ** to consider more complex approaches to optimize this later.
   8.471          */
   8.472  
   8.473 -        int j, k; 
   8.474 +        int j, k;
   8.475  
   8.476          /* First pass: find all L3TABs current in > 4G mfns and get new mfns */
   8.477          for (i = 0; i < max_pfn; i++) {
   8.478 -            
   8.479 +
   8.480              if (((pfn_type[i] & LTABTYPE_MASK)==L3TAB) && (p2m[i]>0xfffffUL)) {
   8.481  
   8.482 -                unsigned long new_mfn; 
   8.483 -                uint64_t l3ptes[4]; 
   8.484 -                uint64_t *l3tab; 
   8.485 +                unsigned long new_mfn;
   8.486 +                uint64_t l3ptes[4];
   8.487 +                uint64_t *l3tab;
   8.488  
   8.489                  l3tab = (uint64_t *)
   8.490 -                    xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, 
   8.491 -                                         PROT_READ, p2m[i]); 
   8.492 +                    xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
   8.493 +                                         PROT_READ, p2m[i]);
   8.494  
   8.495 -                for(j = 0; j < 4; j++) 
   8.496 -                    l3ptes[j] = l3tab[j]; 
   8.497 -                
   8.498 -                munmap(l3tab, PAGE_SIZE); 
   8.499 +                for(j = 0; j < 4; j++)
   8.500 +                    l3ptes[j] = l3tab[j];
   8.501 +
   8.502 +                munmap(l3tab, PAGE_SIZE);
   8.503  
   8.504                  if (!(new_mfn=xc_make_page_below_4G(xc_handle, dom, p2m[i]))) {
   8.505                      ERR("Couldn't get a page below 4GB :-(");
   8.506                      goto out;
   8.507                  }
   8.508 -                
   8.509 +
   8.510                  p2m[i] = new_mfn;
   8.511 -                if (xc_add_mmu_update(xc_handle, mmu, 
   8.512 -                                      (((unsigned long long)new_mfn) 
   8.513 -                                       << PAGE_SHIFT) | 
   8.514 +                if (xc_add_mmu_update(xc_handle, mmu,
   8.515 +                                      (((unsigned long long)new_mfn)
   8.516 +                                       << PAGE_SHIFT) |
   8.517                                        MMU_MACHPHYS_UPDATE, i)) {
   8.518                      ERR("Couldn't m2p on PAE root pgdir");
   8.519                      goto out;
   8.520                  }
   8.521 -                
   8.522 +
   8.523                  l3tab = (uint64_t *)
   8.524 -                    xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, 
   8.525 -                                         PROT_READ | PROT_WRITE, p2m[i]); 
   8.526 -                
   8.527 -                for(j = 0; j < 4; j++) 
   8.528 -                    l3tab[j] = l3ptes[j]; 
   8.529 -                
   8.530 -                munmap(l3tab, PAGE_SIZE); 
   8.531 -                
   8.532 +                    xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
   8.533 +                                         PROT_READ | PROT_WRITE, p2m[i]);
   8.534 +
   8.535 +                for(j = 0; j < 4; j++)
   8.536 +                    l3tab[j] = l3ptes[j];
   8.537 +
   8.538 +                munmap(l3tab, PAGE_SIZE);
   8.539 +
   8.540              }
   8.541          }
   8.542  
   8.543          /* Second pass: find all L1TABs and uncanonicalize them */
   8.544 -        j = 0; 
   8.545 +        j = 0;
   8.546  
   8.547 -        for(i = 0; i < max_pfn; i++) { 
   8.548 -            
   8.549 -            if (((pfn_type[i] & LTABTYPE_MASK)==L1TAB)) { 
   8.550 -                region_mfn[j] = p2m[i]; 
   8.551 -                j++; 
   8.552 +        for(i = 0; i < max_pfn; i++) {
   8.553 +
   8.554 +            if (((pfn_type[i] & LTABTYPE_MASK)==L1TAB)) {
   8.555 +                region_mfn[j] = p2m[i];
   8.556 +                j++;
   8.557              }
   8.558  
   8.559 -            if(i == (max_pfn-1) || j == MAX_BATCH_SIZE) { 
   8.560 +            if(i == (max_pfn-1) || j == MAX_BATCH_SIZE) {
   8.561  
   8.562                  if (!(region_base = xc_map_foreign_batch(
   8.563 -                          xc_handle, dom, PROT_READ | PROT_WRITE, 
   8.564 -                          region_mfn, j))) {  
   8.565 +                          xc_handle, dom, PROT_READ | PROT_WRITE,
   8.566 +                          region_mfn, j))) {
   8.567                      ERR("map batch failed");
   8.568                      goto out;
   8.569                  }
   8.570  
   8.571                  for(k = 0; k < j; k++) {
   8.572 -                    if(!uncanonicalize_pagetable(L1TAB, 
   8.573 +                    if(!uncanonicalize_pagetable(L1TAB,
   8.574                                                   region_base + k*PAGE_SIZE)) {
   8.575 -                        ERR("failed uncanonicalize pt!"); 
   8.576 -                        goto out; 
   8.577 -                    } 
   8.578 +                        ERR("failed uncanonicalize pt!");
   8.579 +                        goto out;
   8.580 +                    }
   8.581                  }
   8.582 -                
   8.583 -                munmap(region_base, j*PAGE_SIZE); 
   8.584 -                j = 0; 
   8.585 +
   8.586 +                munmap(region_base, j*PAGE_SIZE);
   8.587 +                j = 0;
   8.588              }
   8.589          }
   8.590  
   8.591      }
   8.592  
   8.593  
   8.594 -    if (xc_finish_mmu_updates(xc_handle, mmu)) { 
   8.595 -        ERR("Error doing finish_mmu_updates()"); 
   8.596 +    if (xc_finish_mmu_updates(xc_handle, mmu)) {
   8.597 +        ERR("Error doing finish_mmu_updates()");
   8.598          goto out;
   8.599 -    } 
   8.600 +    }
   8.601  
   8.602  
   8.603      /*
   8.604       * Pin page tables. Do this after writing to them as otherwise Xen
   8.605       * will barf when doing the type-checking.
   8.606       */
   8.607 -    nr_pins = 0; 
   8.608 +    nr_pins = 0;
   8.609      for (i = 0; i < max_pfn; i++) {
   8.610  
   8.611          if (i == (max_pfn-1) || nr_pins == MAX_PIN_BATCH) {
   8.612 -            if (xc_mmuext_op(xc_handle, pin, nr_pins, dom) < 0) { 
   8.613 -                ERR("Failed to pin batch of %d page tables", nr_pins); 
   8.614 +            if (xc_mmuext_op(xc_handle, pin, nr_pins, dom) < 0) {
   8.615 +                ERR("Failed to pin batch of %d page tables", nr_pins);
   8.616                  goto out;
   8.617 -            } 
   8.618 +            }
   8.619              nr_pins = 0;
   8.620          }
   8.621  
   8.622          if ( (pfn_type[i] & LPINTAB) == 0 )
   8.623              continue;
   8.624  
   8.625 -        switch(pfn_type[i]) { 
   8.626 +        switch(pfn_type[i]) {
   8.627  
   8.628 -        case (L1TAB|LPINTAB): 
   8.629 +        case (L1TAB|LPINTAB):
   8.630              pin[nr_pins].cmd = MMUEXT_PIN_L1_TABLE;
   8.631 -            break; 
   8.632 -            
   8.633 -        case (L2TAB|LPINTAB): 
   8.634 +            break;
   8.635 +
   8.636 +        case (L2TAB|LPINTAB):
   8.637              pin[nr_pins].cmd = MMUEXT_PIN_L2_TABLE;
   8.638 -            break; 
   8.639 -            
   8.640 -        case (L3TAB|LPINTAB): 
   8.641 +            break;
   8.642 +
   8.643 +        case (L3TAB|LPINTAB):
   8.644              pin[nr_pins].cmd = MMUEXT_PIN_L3_TABLE;
   8.645 -            break; 
   8.646 +            break;
   8.647  
   8.648          case (L4TAB|LPINTAB):
   8.649              pin[nr_pins].cmd = MMUEXT_PIN_L4_TABLE;
   8.650 -            break; 
   8.651 -            
   8.652 -        default: 
   8.653 -            continue; 
   8.654 +            break;
   8.655 +
   8.656 +        default:
   8.657 +            continue;
   8.658          }
   8.659  
   8.660          pin[nr_pins].arg1.mfn = p2m[i];
   8.661 -        nr_pins++; 
   8.662 +        nr_pins++;
   8.663  
   8.664      }
   8.665  
   8.666 @@ -553,17 +553,17 @@ int xc_linux_restore(int xc_handle, int 
   8.667          unsigned long *pfntab;
   8.668          int rc;
   8.669  
   8.670 -        if (!read_exact(io_fd, &count, sizeof(count))) { 
   8.671 +        if (!read_exact(io_fd, &count, sizeof(count))) {
   8.672              ERR("Error when reading pfn count");
   8.673              goto out;
   8.674          }
   8.675  
   8.676 -        if(!(pfntab = malloc(sizeof(unsigned long) * count))) { 
   8.677 +        if(!(pfntab = malloc(sizeof(unsigned long) * count))) {
   8.678              ERR("Out of memory");
   8.679              goto out;
   8.680          }
   8.681 -        
   8.682 -        if (!read_exact(io_fd, pfntab, sizeof(unsigned long)*count)) { 
   8.683 +
   8.684 +        if (!read_exact(io_fd, pfntab, sizeof(unsigned long)*count)) {
   8.685              ERR("Error when reading pfntab");
   8.686              goto out;
   8.687          }
   8.688 @@ -572,14 +572,14 @@ int xc_linux_restore(int xc_handle, int 
   8.689  
   8.690              unsigned long pfn = pfntab[i];
   8.691  
   8.692 -            if(pfn > max_pfn) 
   8.693 +            if(pfn > max_pfn)
   8.694                  /* shouldn't happen - continue optimistically */
   8.695 -                continue; 
   8.696 +                continue;
   8.697  
   8.698 -            pfntab[i] = p2m[pfn];   
   8.699 -            p2m[pfn]  = INVALID_P2M_ENTRY; // not in pseudo-physical map 
   8.700 +            pfntab[i] = p2m[pfn];
   8.701 +            p2m[pfn]  = INVALID_P2M_ENTRY; // not in pseudo-physical map
   8.702          }
   8.703 -        
   8.704 +
   8.705          if (count > 0) {
   8.706  
   8.707              struct xen_memory_reservation reservation = {
   8.708 @@ -590,16 +590,16 @@ int xc_linux_restore(int xc_handle, int 
   8.709              };
   8.710  
   8.711              if ((rc = xc_memory_op(xc_handle, XENMEM_decrease_reservation,
   8.712 -                                   &reservation)) != count) { 
   8.713 +                                   &reservation)) != count) {
   8.714                  ERR("Could not decrease reservation : %d", rc);
   8.715                  goto out;
   8.716              } else
   8.717                  DPRINTF("Decreased reservation by %d pages\n", count);
   8.718 -        } 
   8.719 +        }
   8.720      }
   8.721  
   8.722 -    if (!read_exact(io_fd, &ctxt, sizeof(ctxt)) || 
   8.723 -        !read_exact(io_fd, shared_info_page, PAGE_SIZE)) { 
   8.724 +    if (!read_exact(io_fd, &ctxt, sizeof(ctxt)) ||
   8.725 +        !read_exact(io_fd, shared_info_page, PAGE_SIZE)) {
   8.726          ERR("Error when reading ctxt or shared info page");
   8.727          goto out;
   8.728      }
   8.729 @@ -642,15 +642,15 @@ int xc_linux_restore(int xc_handle, int 
   8.730  
   8.731      if (pfn >= max_pfn) {
   8.732          ERR("PT base is bad: pfn=%lu max_pfn=%lu type=%08lx",
   8.733 -            pfn, max_pfn, pfn_type[pfn]); 
   8.734 +            pfn, max_pfn, pfn_type[pfn]);
   8.735          goto out;
   8.736      }
   8.737  
   8.738 -    if ( (pfn_type[pfn] & LTABTYPE_MASK) != 
   8.739 +    if ( (pfn_type[pfn] & LTABTYPE_MASK) !=
   8.740           ((unsigned long)pt_levels<<LTAB_SHIFT) ) {
   8.741          ERR("PT base is bad. pfn=%lu nr=%lu type=%08lx %08lx",
   8.742 -            pfn, max_pfn, pfn_type[pfn], 
   8.743 -            (unsigned long)pt_levels<<LTAB_SHIFT); 
   8.744 +            pfn, max_pfn, pfn_type[pfn],
   8.745 +            (unsigned long)pt_levels<<LTAB_SHIFT);
   8.746          goto out;
   8.747      }
   8.748  
   8.749 @@ -667,7 +667,7 @@ int xc_linux_restore(int xc_handle, int 
   8.750          xc_handle, dom, PAGE_SIZE, PROT_WRITE, shared_info_frame);
   8.751      memcpy(page, shared_info, sizeof(shared_info_t));
   8.752      munmap(page, PAGE_SIZE);
   8.753 -    
   8.754 +
   8.755      /* Uncanonicalise the pfn-to-mfn table frame-number list. */
   8.756      for (i = 0; i < P2M_FL_ENTRIES; i++) {
   8.757          pfn = p2m_frame_list[i];
   8.758 @@ -678,16 +678,16 @@ int xc_linux_restore(int xc_handle, int 
   8.759  
   8.760          p2m_frame_list[i] = p2m[pfn];
   8.761      }
   8.762 -    
   8.763 +
   8.764      /* Copy the P2M we've constructed to the 'live' P2M */
   8.765 -    if (!(live_p2m = xc_map_foreign_batch(xc_handle, dom, PROT_WRITE, 
   8.766 +    if (!(live_p2m = xc_map_foreign_batch(xc_handle, dom, PROT_WRITE,
   8.767                                            p2m_frame_list, P2M_FL_ENTRIES))) {
   8.768          ERR("Couldn't map p2m table");
   8.769          goto out;
   8.770      }
   8.771  
   8.772 -    memcpy(live_p2m, p2m, P2M_SIZE); 
   8.773 -    munmap(live_p2m, P2M_SIZE); 
   8.774 +    memcpy(live_p2m, p2m, P2M_SIZE);
   8.775 +    munmap(live_p2m, P2M_SIZE);
   8.776  
   8.777      /*
   8.778       * Safety checking of saved context:
     9.1 --- a/tools/libxc/xc_linux_save.c	Sat Apr 15 09:52:32 2006 +0100
     9.2 +++ b/tools/libxc/xc_linux_save.c	Sat Apr 15 10:07:31 2006 +0100
     9.3 @@ -1,8 +1,8 @@
     9.4  /******************************************************************************
     9.5   * xc_linux_save.c
     9.6 - * 
     9.7 + *
     9.8   * Save the state of a running Linux session.
     9.9 - * 
    9.10 + *
    9.11   * Copyright (c) 2003, K A Fraser.
    9.12   */
    9.13  
    9.14 @@ -17,23 +17,23 @@
    9.15  
    9.16  /*
    9.17  ** Default values for important tuning parameters. Can override by passing
    9.18 -** non-zero replacement values to xc_linux_save().  
    9.19 +** non-zero replacement values to xc_linux_save().
    9.20  **
    9.21 -** XXX SMH: should consider if want to be able to override MAX_MBIT_RATE too. 
    9.22 -** 
    9.23 +** XXX SMH: should consider if want to be able to override MAX_MBIT_RATE too.
    9.24 +**
    9.25  */
    9.26 -#define DEF_MAX_ITERS   29   /* limit us to 30 times round loop   */ 
    9.27 +#define DEF_MAX_ITERS   29   /* limit us to 30 times round loop   */
    9.28  #define DEF_MAX_FACTOR   3   /* never send more than 3x nr_pfns   */
    9.29  
    9.30  
    9.31  /* max mfn of the whole machine */
    9.32 -static unsigned long max_mfn; 
    9.33 +static unsigned long max_mfn;
    9.34  
    9.35  /* virtual starting address of the hypervisor */
    9.36 -static unsigned long hvirt_start; 
    9.37 +static unsigned long hvirt_start;
    9.38  
    9.39  /* #levels of page tables used by the currrent guest */
    9.40 -static unsigned int pt_levels; 
    9.41 +static unsigned int pt_levels;
    9.42  
    9.43  /* total number of pages used by the current guest */
    9.44  static unsigned long max_pfn;
    9.45 @@ -56,8 +56,8 @@ static unsigned long *live_m2p = NULL;
    9.46  (((_mfn) < (max_mfn)) &&                        \
    9.47   ((mfn_to_pfn(_mfn) < (max_pfn)) &&               \
    9.48    (live_p2m[mfn_to_pfn(_mfn)] == (_mfn))))
    9.49 -    
    9.50 - 
    9.51 +
    9.52 +
    9.53  /* Returns TRUE if MFN is successfully converted to a PFN. */
    9.54  #define translate_mfn_to_pfn(_pmfn)                             \
    9.55  ({                                                              \
    9.56 @@ -70,12 +70,12 @@ static unsigned long *live_m2p = NULL;
    9.57      _res;                                                       \
    9.58  })
    9.59  
    9.60 -/* 
    9.61 -** During (live) save/migrate, we maintain a number of bitmaps to track 
    9.62 -** which pages we have to send, to fixup, and to skip. 
    9.63 +/*
    9.64 +** During (live) save/migrate, we maintain a number of bitmaps to track
    9.65 +** which pages we have to send, to fixup, and to skip.
    9.66  */
    9.67  
    9.68 -#define BITS_PER_LONG (sizeof(unsigned long) * 8) 
    9.69 +#define BITS_PER_LONG (sizeof(unsigned long) * 8)
    9.70  #define BITMAP_SIZE   ((max_pfn + BITS_PER_LONG - 1) / 8)
    9.71  
    9.72  #define BITMAP_ENTRY(_nr,_bmap) \
    9.73 @@ -85,17 +85,17 @@ static unsigned long *live_m2p = NULL;
    9.74  
    9.75  static inline int test_bit (int nr, volatile void * addr)
    9.76  {
    9.77 -    return (BITMAP_ENTRY(nr, addr) >> BITMAP_SHIFT(nr)) & 1; 
    9.78 +    return (BITMAP_ENTRY(nr, addr) >> BITMAP_SHIFT(nr)) & 1;
    9.79  }
    9.80  
    9.81  static inline void clear_bit (int nr, volatile void * addr)
    9.82  {
    9.83 -    BITMAP_ENTRY(nr, addr) &= ~(1 << BITMAP_SHIFT(nr)); 
    9.84 +    BITMAP_ENTRY(nr, addr) &= ~(1 << BITMAP_SHIFT(nr));
    9.85  }
    9.86  
    9.87  static inline void set_bit ( int nr, volatile void * addr)
    9.88  {
    9.89 -    BITMAP_ENTRY(nr, addr) |= (1 << BITMAP_SHIFT(nr)); 
    9.90 +    BITMAP_ENTRY(nr, addr) |= (1 << BITMAP_SHIFT(nr));
    9.91  }
    9.92  
    9.93  /* Returns the hamming weight (i.e. the number of bits set) in a N-bit word */
    9.94 @@ -122,7 +122,7 @@ static inline int permute( int i, int nr
    9.95  {
    9.96      /* Need a simple permutation function so that we scan pages in a
    9.97         pseudo random order, enabling us to get a better estimate of
    9.98 -       the domain's page dirtying rate as we go (there are often 
    9.99 +       the domain's page dirtying rate as we go (there are often
   9.100         contiguous ranges of pfns that have similar behaviour, and we
   9.101         want to mix them up. */
   9.102  
   9.103 @@ -130,21 +130,21 @@ static inline int permute( int i, int nr
   9.104      /* 512MB domain, 128k pages, order 17 */
   9.105  
   9.106      /*
   9.107 -      QPONMLKJIHGFEDCBA  
   9.108 -             QPONMLKJIH  
   9.109 -      GFEDCBA  
   9.110 +      QPONMLKJIHGFEDCBA
   9.111 +             QPONMLKJIH
   9.112 +      GFEDCBA
   9.113       */
   9.114 -    
   9.115 +
   9.116      /*
   9.117 -      QPONMLKJIHGFEDCBA  
   9.118 -                  EDCBA  
   9.119 +      QPONMLKJIHGFEDCBA
   9.120 +                  EDCBA
   9.121               QPONM
   9.122        LKJIHGF
   9.123        */
   9.124  
   9.125      do { i = ((i>>(order_nr-10)) | ( i<<10 ) ) & ((1<<order_nr)-1); }
   9.126      while ( i >= nr ); /* this won't ever loop if nr is a power of 2 */
   9.127 -    
   9.128 +
   9.129      return i;
   9.130  }
   9.131  
   9.132 @@ -165,7 +165,7 @@ static uint64_t llgettimeofday(void)
   9.133  
   9.134  static uint64_t tv_delta(struct timeval *new, struct timeval *old)
   9.135  {
   9.136 -    return ((new->tv_sec - old->tv_sec)*1000000 ) + 
   9.137 +    return ((new->tv_sec - old->tv_sec)*1000000 ) +
   9.138          (new->tv_usec - old->tv_usec);
   9.139  }
   9.140  
   9.141 @@ -175,7 +175,7 @@ static uint64_t tv_delta(struct timeval 
   9.142  
   9.143  /*
   9.144  ** We control the rate at which we transmit (or save) to minimize impact
   9.145 -** on running domains (including the target if we're doing live migrate). 
   9.146 +** on running domains (including the target if we're doing live migrate).
   9.147  */
   9.148  
   9.149  #define MAX_MBIT_RATE    500      /* maximum transmit rate for migrate */
   9.150 @@ -193,10 +193,10 @@ static uint64_t tv_delta(struct timeval 
   9.151  static int mbit_rate, ombit_rate = 0;
   9.152  
   9.153  /* Have we reached the maximum transmission rate? */
   9.154 -#define RATE_IS_MAX() (mbit_rate == MAX_MBIT_RATE) 
   9.155 +#define RATE_IS_MAX() (mbit_rate == MAX_MBIT_RATE)
   9.156  
   9.157  
   9.158 -static inline void initialize_mbit_rate() 
   9.159 +static inline void initialize_mbit_rate()
   9.160  {
   9.161      mbit_rate = START_MBIT_RATE;
   9.162  }
   9.163 @@ -213,7 +213,7 @@ static int ratewrite(int io_fd, void *bu
   9.164  
   9.165      if (START_MBIT_RATE == 0)
   9.166          return write(io_fd, buf, n);
   9.167 -    
   9.168 +
   9.169      budget -= n;
   9.170      if (budget < 0) {
   9.171          if (mbit_rate != ombit_rate) {
   9.172 @@ -253,46 +253,46 @@ static int ratewrite(int io_fd, void *bu
   9.173  
   9.174  #else /* ! ADAPTIVE SAVE */
   9.175  
   9.176 -#define RATE_IS_MAX() (0) 
   9.177 -#define ratewrite(_io_fd, _buf, _n) write((_io_fd), (_buf), (_n)) 
   9.178 -#define initialize_mbit_rate() 
   9.179 +#define RATE_IS_MAX() (0)
   9.180 +#define ratewrite(_io_fd, _buf, _n) write((_io_fd), (_buf), (_n))
   9.181 +#define initialize_mbit_rate()
   9.182  
   9.183  #endif
   9.184  
   9.185  
   9.186  static inline ssize_t write_exact(int fd, void *buf, size_t count)
   9.187  {
   9.188 -    if(write(fd, buf, count) != count) 
   9.189 -        return 0; 
   9.190 -    return 1; 
   9.191 -} 
   9.192 +    if(write(fd, buf, count) != count)
   9.193 +        return 0;
   9.194 +    return 1;
   9.195 +}
   9.196  
   9.197  
   9.198  
   9.199 -static int print_stats(int xc_handle, uint32_t domid, int pages_sent, 
   9.200 +static int print_stats(int xc_handle, uint32_t domid, int pages_sent,
   9.201                         xc_shadow_control_stats_t *stats, int print)
   9.202  {
   9.203      static struct timeval wall_last;
   9.204      static long long      d0_cpu_last;
   9.205      static long long      d1_cpu_last;
   9.206 -    
   9.207 +
   9.208      struct timeval        wall_now;
   9.209      long long             wall_delta;
   9.210      long long             d0_cpu_now, d0_cpu_delta;
   9.211      long long             d1_cpu_now, d1_cpu_delta;
   9.212 -    
   9.213 +
   9.214      gettimeofday(&wall_now, NULL);
   9.215 -    
   9.216 +
   9.217      d0_cpu_now = xc_domain_get_cpu_usage(xc_handle, 0, /* FIXME */ 0)/1000;
   9.218      d1_cpu_now = xc_domain_get_cpu_usage(xc_handle, domid, /* FIXME */ 0)/1000;
   9.219  
   9.220 -    if ( (d0_cpu_now == -1) || (d1_cpu_now == -1) ) 
   9.221 +    if ( (d0_cpu_now == -1) || (d1_cpu_now == -1) )
   9.222          fprintf(stderr, "ARRHHH!!\n");
   9.223 -    
   9.224 +
   9.225      wall_delta = tv_delta(&wall_now,&wall_last)/1000;
   9.226 -    
   9.227 +
   9.228      if (wall_delta == 0) wall_delta = 1;
   9.229 -    
   9.230 +
   9.231      d0_cpu_delta = (d0_cpu_now - d0_cpu_last)/1000;
   9.232      d1_cpu_delta = (d1_cpu_now - d1_cpu_last)/1000;
   9.233  
   9.234 @@ -300,14 +300,14 @@ static int print_stats(int xc_handle, ui
   9.235          fprintf(stderr,
   9.236                  "delta %lldms, dom0 %d%%, target %d%%, sent %dMb/s, "
   9.237                  "dirtied %dMb/s %" PRId32 " pages\n",
   9.238 -                wall_delta, 
   9.239 +                wall_delta,
   9.240                  (int)((d0_cpu_delta*100)/wall_delta),
   9.241                  (int)((d1_cpu_delta*100)/wall_delta),
   9.242                  (int)((pages_sent*PAGE_SIZE)/(wall_delta*(1000/8))),
   9.243                  (int)((stats->dirty_count*PAGE_SIZE)/(wall_delta*(1000/8))),
   9.244                  stats->dirty_count);
   9.245  
   9.246 -#ifdef ADAPTIVE_SAVE    
   9.247 +#ifdef ADAPTIVE_SAVE
   9.248      if (((stats->dirty_count*PAGE_SIZE)/(wall_delta*(1000/8))) > mbit_rate) {
   9.249          mbit_rate = (int)((stats->dirty_count*PAGE_SIZE)/(wall_delta*(1000/8)))
   9.250              + 50;
   9.251 @@ -315,16 +315,16 @@ static int print_stats(int xc_handle, ui
   9.252              mbit_rate = MAX_MBIT_RATE;
   9.253      }
   9.254  #endif
   9.255 -    
   9.256 +
   9.257      d0_cpu_last = d0_cpu_now;
   9.258      d1_cpu_last = d1_cpu_now;
   9.259 -    wall_last   = wall_now; 
   9.260 +    wall_last   = wall_now;
   9.261  
   9.262      return 0;
   9.263  }
   9.264  
   9.265  
   9.266 -static int analysis_phase(int xc_handle, uint32_t domid, int max_pfn, 
   9.267 +static int analysis_phase(int xc_handle, uint32_t domid, int max_pfn,
   9.268                            unsigned long *arr, int runs)
   9.269  {
   9.270      long long start, now;
   9.271 @@ -335,24 +335,24 @@ static int analysis_phase(int xc_handle,
   9.272  
   9.273      for (j = 0; j < runs; j++) {
   9.274          int i;
   9.275 -        
   9.276 +
   9.277          xc_shadow_control(xc_handle, domid, DOM0_SHADOW_CONTROL_OP_CLEAN,
   9.278                            arr, max_pfn, NULL);
   9.279          fprintf(stderr, "#Flush\n");
   9.280 -        for ( i = 0; i < 40; i++ ) {     
   9.281 -            usleep(50000);     
   9.282 +        for ( i = 0; i < 40; i++ ) {
   9.283 +            usleep(50000);
   9.284              now = llgettimeofday();
   9.285              xc_shadow_control(xc_handle, domid, DOM0_SHADOW_CONTROL_OP_PEEK,
   9.286                                NULL, 0, &stats);
   9.287 -            
   9.288 +
   9.289              fprintf(stderr, "now= %lld faults= %" PRId32 " dirty= %" PRId32
   9.290 -                    " dirty_net= %" PRId32 " dirty_block= %" PRId32"\n", 
   9.291 -                    ((now-start)+500)/1000, 
   9.292 +                    " dirty_net= %" PRId32 " dirty_block= %" PRId32"\n",
   9.293 +                    ((now-start)+500)/1000,
   9.294                      stats.fault_count, stats.dirty_count,
   9.295                      stats.dirty_net_count, stats.dirty_block_count);
   9.296          }
   9.297      }
   9.298 -    
   9.299 +
   9.300      return -1;
   9.301  }
   9.302  
   9.303 @@ -375,7 +375,7 @@ static int suspend_and_state(int (*suspe
   9.304          return -1;
   9.305      }
   9.306  
   9.307 -    if ( xc_vcpu_getcontext(xc_handle, dom, 0 /* XXX */, ctxt)) 
   9.308 +    if ( xc_vcpu_getcontext(xc_handle, dom, 0 /* XXX */, ctxt))
   9.309          ERR("Could not get vcpu context");
   9.310  
   9.311  
   9.312 @@ -383,22 +383,22 @@ static int suspend_and_state(int (*suspe
   9.313          return 0; // success
   9.314  
   9.315      if (info->paused) {
   9.316 -        // try unpausing domain, wait, and retest 
   9.317 +        // try unpausing domain, wait, and retest
   9.318          xc_domain_unpause( xc_handle, dom );
   9.319 -        
   9.320 +
   9.321          ERR("Domain was paused. Wait and re-test.");
   9.322          usleep(10000);  // 10ms
   9.323 -        
   9.324 +
   9.325          goto retry;
   9.326      }
   9.327  
   9.328  
   9.329      if( ++i < 100 ) {
   9.330          ERR("Retry suspend domain.");
   9.331 -        usleep(10000);  // 10ms 
   9.332 +        usleep(10000);  // 10ms
   9.333          goto retry;
   9.334      }
   9.335 -    
   9.336 +
   9.337      ERR("Unable to suspend domain.");
   9.338  
   9.339      return -1;
   9.340 @@ -406,173 +406,173 @@ static int suspend_and_state(int (*suspe
   9.341  
   9.342  
   9.343  /*
   9.344 -** During transfer (or in the state file), all page-table pages must be  
   9.345 -** converted into a 'canonical' form where references to actual mfns 
   9.346 -** are replaced with references to the corresponding pfns. 
   9.347 +** During transfer (or in the state file), all page-table pages must be
   9.348 +** converted into a 'canonical' form where references to actual mfns
   9.349 +** are replaced with references to the corresponding pfns.
   9.350  **
   9.351 -** This function performs the appropriate conversion, taking into account 
   9.352 -** which entries do not require canonicalization (in particular, those 
   9.353 -** entries which map the virtual address reserved for the hypervisor). 
   9.354 +** This function performs the appropriate conversion, taking into account
   9.355 +** which entries do not require canonicalization (in particular, those
   9.356 +** entries which map the virtual address reserved for the hypervisor).
   9.357  */
   9.358 -void canonicalize_pagetable(unsigned long type, unsigned long pfn, 
   9.359 -                             const void *spage, void *dpage) 
   9.360 -{ 
   9.361 -    
   9.362 +void canonicalize_pagetable(unsigned long type, unsigned long pfn,
   9.363 +                             const void *spage, void *dpage)
   9.364 +{
   9.365 +
   9.366      int i, pte_last, xen_start, xen_end;
   9.367      uint64_t pte;
   9.368  
   9.369 -    /* 
   9.370 +    /*
   9.371      ** We need to determine which entries in this page table hold
   9.372      ** reserved hypervisor mappings. This depends on the current
   9.373 -    ** page table type as well as the number of paging levels. 
   9.374 +    ** page table type as well as the number of paging levels.
   9.375      */
   9.376 -    xen_start = xen_end = pte_last = PAGE_SIZE / ((pt_levels == 2)? 4 : 8); 
   9.377 -    
   9.378 -    if (pt_levels == 2 && type == L2TAB)
   9.379 -        xen_start = (hvirt_start >> L2_PAGETABLE_SHIFT); 
   9.380 +    xen_start = xen_end = pte_last = PAGE_SIZE / ((pt_levels == 2)? 4 : 8);
   9.381  
   9.382 -    if (pt_levels == 3 && type == L3TAB) 
   9.383 -        xen_start = L3_PAGETABLE_ENTRIES_PAE; 
   9.384 -        
   9.385 -    /* 
   9.386 -    ** in PAE only the L2 mapping the top 1GB contains Xen mappings. 
   9.387 +    if (pt_levels == 2 && type == L2TAB)
   9.388 +        xen_start = (hvirt_start >> L2_PAGETABLE_SHIFT);
   9.389 +
   9.390 +    if (pt_levels == 3 && type == L3TAB)
   9.391 +        xen_start = L3_PAGETABLE_ENTRIES_PAE;
   9.392 +
   9.393 +    /*
   9.394 +    ** in PAE only the L2 mapping the top 1GB contains Xen mappings.
   9.395      ** We can spot this by looking for the guest linear mapping which
   9.396 -    ** Xen always ensures is present in that L2. Guests must ensure 
   9.397 -    ** that this check will fail for other L2s. 
   9.398 +    ** Xen always ensures is present in that L2. Guests must ensure
   9.399 +    ** that this check will fail for other L2s.
   9.400      */
   9.401      if (pt_levels == 3 && type == L2TAB) {
   9.402  
   9.403  /* XXX index of the L2 entry in PAE mode which holds the guest LPT */
   9.404 -#define PAE_GLPT_L2ENTRY (495) 
   9.405 -        pte = ((uint64_t*)spage)[PAE_GLPT_L2ENTRY]; 
   9.406 +#define PAE_GLPT_L2ENTRY (495)
   9.407 +        pte = ((uint64_t*)spage)[PAE_GLPT_L2ENTRY];
   9.408  
   9.409          if(((pte >> PAGE_SHIFT) & 0x0fffffff) == live_p2m[pfn])
   9.410 -            xen_start = (hvirt_start >> L2_PAGETABLE_SHIFT_PAE) & 0x1ff; 
   9.411 +            xen_start = (hvirt_start >> L2_PAGETABLE_SHIFT_PAE) & 0x1ff;
   9.412      }
   9.413  
   9.414 -    if (pt_levels == 4 && type == L4TAB) { 
   9.415 +    if (pt_levels == 4 && type == L4TAB) {
   9.416          /*
   9.417 -        ** XXX SMH: should compute these from hvirt_start (which we have) 
   9.418 -        ** and hvirt_end (which we don't) 
   9.419 +        ** XXX SMH: should compute these from hvirt_start (which we have)
   9.420 +        ** and hvirt_end (which we don't)
   9.421          */
   9.422 -        xen_start = 256; 
   9.423 -        xen_end   = 272; 
   9.424 +        xen_start = 256;
   9.425 +        xen_end   = 272;
   9.426      }
   9.427  
   9.428      /* Now iterate through the page table, canonicalizing each PTE */
   9.429      for (i = 0; i < pte_last; i++ ) {
   9.430  
   9.431 -        unsigned long pfn, mfn; 
   9.432 -        
   9.433 +        unsigned long pfn, mfn;
   9.434 +
   9.435          if (pt_levels == 2)
   9.436              pte = ((uint32_t*)spage)[i];
   9.437          else
   9.438              pte = ((uint64_t*)spage)[i];
   9.439 -        
   9.440 +
   9.441          if (i >= xen_start && i < xen_end)
   9.442              pte = 0;
   9.443 -        
   9.444 +
   9.445          if (pte & _PAGE_PRESENT) {
   9.446 -            
   9.447 -            mfn = (pte >> PAGE_SHIFT) & 0xfffffff;      
   9.448 +
   9.449 +            mfn = (pte >> PAGE_SHIFT) & 0xfffffff;
   9.450              if (!MFN_IS_IN_PSEUDOPHYS_MAP(mfn)) {
   9.451 -                /* This will happen if the type info is stale which 
   9.452 +                /* This will happen if the type info is stale which
   9.453                     is quite feasible under live migration */
   9.454                  DPRINTF("PT Race: [%08lx,%d] pte=%llx, mfn=%08lx\n",
   9.455 -                        type, i, (unsigned long long)pte, mfn); 
   9.456 +                        type, i, (unsigned long long)pte, mfn);
   9.457                  pfn = 0; /* zap it - we'll retransmit this page later */
   9.458 -            } else 
   9.459 +            } else
   9.460                  pfn = mfn_to_pfn(mfn);
   9.461 -            
   9.462 +
   9.463              pte &= 0xffffff0000000fffULL;
   9.464              pte |= (uint64_t)pfn << PAGE_SHIFT;
   9.465          }
   9.466 -        
   9.467 +
   9.468          if (pt_levels == 2)
   9.469              ((uint32_t*)dpage)[i] = pte;
   9.470          else
   9.471 -            ((uint64_t*)dpage)[i] = pte;		       
   9.472 -        
   9.473 -    } 
   9.474 -    
   9.475 -    return; 
   9.476 +            ((uint64_t*)dpage)[i] = pte;
   9.477 +
   9.478 +    }
   9.479 +
   9.480 +    return;
   9.481  }
   9.482  
   9.483  
   9.484  
   9.485 -static unsigned long *xc_map_m2p(int xc_handle, 
   9.486 -                                 unsigned long max_mfn, 
   9.487 -                                 int prot) 
   9.488 -{ 
   9.489 +static unsigned long *xc_map_m2p(int xc_handle,
   9.490 +                                 unsigned long max_mfn,
   9.491 +                                 int prot)
   9.492 +{
   9.493      struct xen_machphys_mfn_list xmml;
   9.494 -    privcmd_mmap_t ioctlx; 
   9.495 -    privcmd_mmap_entry_t *entries; 
   9.496 -    unsigned long m2p_chunks, m2p_size; 
   9.497 -    unsigned long *m2p; 
   9.498 -    int i, rc; 
   9.499 +    privcmd_mmap_t ioctlx;
   9.500 +    privcmd_mmap_entry_t *entries;
   9.501 +    unsigned long m2p_chunks, m2p_size;
   9.502 +    unsigned long *m2p;
   9.503 +    int i, rc;
   9.504  
   9.505 -    m2p_size   = M2P_SIZE(max_mfn); 
   9.506 -    m2p_chunks = M2P_CHUNKS(max_mfn); 
   9.507 +    m2p_size   = M2P_SIZE(max_mfn);
   9.508 +    m2p_chunks = M2P_CHUNKS(max_mfn);
   9.509  
   9.510      xmml.max_extents = m2p_chunks;
   9.511 -    if (!(xmml.extent_start = malloc(m2p_chunks * sizeof(unsigned long)))) { 
   9.512 -        ERR("failed to allocate space for m2p mfns"); 
   9.513 -        return NULL; 
   9.514 -    } 
   9.515 +    if (!(xmml.extent_start = malloc(m2p_chunks * sizeof(unsigned long)))) {
   9.516 +        ERR("failed to allocate space for m2p mfns");
   9.517 +        return NULL;
   9.518 +    }
   9.519  
   9.520      if (xc_memory_op(xc_handle, XENMEM_machphys_mfn_list, &xmml) ||
   9.521          (xmml.nr_extents != m2p_chunks)) {
   9.522 -        ERR("xc_get_m2p_mfns"); 
   9.523 +        ERR("xc_get_m2p_mfns");
   9.524          return NULL;
   9.525      }
   9.526  
   9.527 -    if ((m2p = mmap(NULL, m2p_size, prot, 
   9.528 +    if ((m2p = mmap(NULL, m2p_size, prot,
   9.529                      MAP_SHARED, xc_handle, 0)) == MAP_FAILED) {
   9.530 -        ERR("failed to mmap m2p"); 
   9.531 -        return NULL; 
   9.532 -    } 
   9.533 +        ERR("failed to mmap m2p");
   9.534 +        return NULL;
   9.535 +    }
   9.536  
   9.537 -    if (!(entries = malloc(m2p_chunks * sizeof(privcmd_mmap_entry_t)))) { 
   9.538 -        ERR("failed to allocate space for mmap entries"); 
   9.539 -        return NULL; 
   9.540 -    } 
   9.541 +    if (!(entries = malloc(m2p_chunks * sizeof(privcmd_mmap_entry_t)))) {
   9.542 +        ERR("failed to allocate space for mmap entries");
   9.543 +        return NULL;
   9.544 +    }
   9.545  
   9.546      ioctlx.num   = m2p_chunks;
   9.547 -    ioctlx.dom   = DOMID_XEN; 
   9.548 -    ioctlx.entry = entries; 
   9.549 -    
   9.550 -    for (i=0; i < m2p_chunks; i++) { 
   9.551 -        entries[i].va = (unsigned long)(((void *)m2p) + (i * M2P_CHUNK_SIZE)); 
   9.552 +    ioctlx.dom   = DOMID_XEN;
   9.553 +    ioctlx.entry = entries;
   9.554 +
   9.555 +    for (i=0; i < m2p_chunks; i++) {
   9.556 +        entries[i].va = (unsigned long)(((void *)m2p) + (i * M2P_CHUNK_SIZE));
   9.557          entries[i].mfn = xmml.extent_start[i];
   9.558          entries[i].npages = M2P_CHUNK_SIZE >> PAGE_SHIFT;
   9.559      }
   9.560  
   9.561      if ((rc = ioctl(xc_handle, IOCTL_PRIVCMD_MMAP, &ioctlx)) < 0) {
   9.562 -        ERR("ioctl_mmap failed (rc = %d)", rc); 
   9.563 -        return NULL; 
   9.564 +        ERR("ioctl_mmap failed (rc = %d)", rc);
   9.565 +        return NULL;
   9.566      }
   9.567  
   9.568      free(xmml.extent_start);
   9.569 -    free(entries); 
   9.570 +    free(entries);
   9.571  
   9.572 -    return m2p; 
   9.573 +    return m2p;
   9.574  }
   9.575  
   9.576  
   9.577  
   9.578 -int xc_linux_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters, 
   9.579 +int xc_linux_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
   9.580                    uint32_t max_factor, uint32_t flags, int (*suspend)(int))
   9.581  {
   9.582      xc_dominfo_t info;
   9.583  
   9.584      int rc = 1, i, j, last_iter, iter = 0;
   9.585 -    int live  = (flags & XCFLAGS_LIVE); 
   9.586 -    int debug = (flags & XCFLAGS_DEBUG); 
   9.587 +    int live  = (flags & XCFLAGS_LIVE);
   9.588 +    int debug = (flags & XCFLAGS_DEBUG);
   9.589      int sent_last_iter, skip_this_iter;
   9.590  
   9.591      /* The new domain's shared-info frame number. */
   9.592      unsigned long shared_info_frame;
   9.593 -    
   9.594 +
   9.595      /* A copy of the CPU context of the guest. */
   9.596      vcpu_guest_context_t ctxt;
   9.597  
   9.598 @@ -581,7 +581,7 @@ int xc_linux_save(int xc_handle, int io_
   9.599      unsigned long *pfn_batch = NULL;
   9.600  
   9.601      /* A temporary mapping, and a copy, of one frame of guest memory. */
   9.602 -    char page[PAGE_SIZE]; 
   9.603 +    char page[PAGE_SIZE];
   9.604  
   9.605      /* Double and single indirect references to the live P2M table */
   9.606      unsigned long *live_p2m_frame_list_list = NULL;
   9.607 @@ -597,14 +597,14 @@ int xc_linux_save(int xc_handle, int io_
   9.608      unsigned char *region_base = NULL;
   9.609  
   9.610      /* power of 2 order of max_pfn */
   9.611 -    int order_nr; 
   9.612 +    int order_nr;
   9.613  
   9.614      /* bitmap of pages:
   9.615 -       - that should be sent this iteration (unless later marked as skip); 
   9.616 +       - that should be sent this iteration (unless later marked as skip);
   9.617         - to skip this iteration because already dirty;
   9.618         - to fixup by sending at the end if not already resent; */
   9.619      unsigned long *to_send = NULL, *to_skip = NULL, *to_fix = NULL;
   9.620 -    
   9.621 +
   9.622      xc_shadow_control_stats_t stats;
   9.623  
   9.624      unsigned long needed_to_fix = 0;
   9.625 @@ -612,29 +612,29 @@ int xc_linux_save(int xc_handle, int io_
   9.626  
   9.627  
   9.628      /* If no explicit control parameters given, use defaults */
   9.629 -    if(!max_iters) 
   9.630 -        max_iters = DEF_MAX_ITERS; 
   9.631 -    if(!max_factor) 
   9.632 -        max_factor = DEF_MAX_FACTOR; 
   9.633 -    
   9.634 -    initialize_mbit_rate(); 
   9.635 +    if(!max_iters)
   9.636 +        max_iters = DEF_MAX_ITERS;
   9.637 +    if(!max_factor)
   9.638 +        max_factor = DEF_MAX_FACTOR;
   9.639  
   9.640 -    if(!get_platform_info(xc_handle, dom, 
   9.641 +    initialize_mbit_rate();
   9.642 +
   9.643 +    if(!get_platform_info(xc_handle, dom,
   9.644                            &max_mfn, &hvirt_start, &pt_levels)) {
   9.645 -        ERR("Unable to get platform info."); 
   9.646 +        ERR("Unable to get platform info.");
   9.647          return 1;
   9.648      }
   9.649  
   9.650      if (xc_domain_getinfo(xc_handle, dom, 1, &info) != 1) {
   9.651          ERR("Could not get domain info");
   9.652 -        return 1; 
   9.653 +        return 1;
   9.654      }
   9.655  
   9.656      if (mlock(&ctxt, sizeof(ctxt))) {
   9.657          ERR("Unable to mlock ctxt");
   9.658          return 1;
   9.659      }
   9.660 -    
   9.661 +
   9.662      /* Only have to worry about vcpu 0 even for SMP */
   9.663      if (xc_vcpu_getcontext(xc_handle, dom, 0, &ctxt)) {
   9.664          ERR("Could not get vcpu context");
   9.665 @@ -648,16 +648,16 @@ int xc_linux_save(int xc_handle, int io_
   9.666          ERR("Domain is not in a valid Linux guest OS state");
   9.667          goto out;
   9.668      }
   9.669 -  
   9.670 +
   9.671     /* cheesy sanity check */
   9.672      if ((info.max_memkb >> (PAGE_SHIFT - 10)) > max_mfn) {
   9.673 -        ERR("Invalid state record -- pfn count out of range: %lu", 
   9.674 -            (info.max_memkb >> (PAGE_SHIFT - 10))); 
   9.675 +        ERR("Invalid state record -- pfn count out of range: %lu",
   9.676 +            (info.max_memkb >> (PAGE_SHIFT - 10)));
   9.677          goto out;
   9.678       }
   9.679 - 
   9.680 +
   9.681      /* Map the shared info frame */
   9.682 -    if(!(live_shinfo = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, 
   9.683 +    if(!(live_shinfo = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
   9.684                                              PROT_READ, shared_info_frame))) {
   9.685          ERR("Couldn't map live_shinfo");
   9.686          goto out;
   9.687 @@ -665,8 +665,8 @@ int xc_linux_save(int xc_handle, int io_
   9.688  
   9.689      max_pfn = live_shinfo->arch.max_pfn;
   9.690  
   9.691 -    live_p2m_frame_list_list = 
   9.692 -        xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, PROT_READ, 
   9.693 +    live_p2m_frame_list_list =
   9.694 +        xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, PROT_READ,
   9.695                               live_shinfo->arch.pfn_to_mfn_frame_list_list);
   9.696  
   9.697      if (!live_p2m_frame_list_list) {
   9.698 @@ -674,24 +674,24 @@ int xc_linux_save(int xc_handle, int io_
   9.699          goto out;
   9.700      }
   9.701  
   9.702 -    live_p2m_frame_list = 
   9.703 +    live_p2m_frame_list =
   9.704          xc_map_foreign_batch(xc_handle, dom, PROT_READ,
   9.705                               live_p2m_frame_list_list,
   9.706 -                             P2M_FLL_ENTRIES); 
   9.707 -    
   9.708 +                             P2M_FLL_ENTRIES);
   9.709 +
   9.710      if (!live_p2m_frame_list) {
   9.711          ERR("Couldn't map p2m_frame_list");
   9.712          goto out;
   9.713      }
   9.714  
   9.715 -    /* Map all the frames of the pfn->mfn table. For migrate to succeed, 
   9.716 -       the guest must not change which frames are used for this purpose. 
   9.717 +    /* Map all the frames of the pfn->mfn table. For migrate to succeed,
   9.718 +       the guest must not change which frames are used for this purpose.
   9.719         (its not clear why it would want to change them, and we'll be OK
   9.720         from a safety POV anyhow. */
   9.721  
   9.722      live_p2m = xc_map_foreign_batch(xc_handle, dom, PROT_READ,
   9.723                                      live_p2m_frame_list,
   9.724 -                                    P2M_FL_ENTRIES); 
   9.725 +                                    P2M_FL_ENTRIES);
   9.726  
   9.727      if (!live_p2m) {
   9.728          ERR("Couldn't map p2m table");
   9.729 @@ -699,25 +699,25 @@ int xc_linux_save(int xc_handle, int io_
   9.730      }
   9.731  
   9.732      /* Setup the mfn_to_pfn table mapping */
   9.733 -    if(!(live_m2p = xc_map_m2p(xc_handle, max_mfn, PROT_READ))) { 
   9.734 -        ERR("Failed to map live M2P table"); 
   9.735 -        goto out; 
   9.736 -    } 
   9.737 +    if(!(live_m2p = xc_map_m2p(xc_handle, max_mfn, PROT_READ))) {
   9.738 +        ERR("Failed to map live M2P table");
   9.739 +        goto out;
   9.740 +    }
   9.741  
   9.742 -    
   9.743 +
   9.744      /* Get a local copy of the live_P2M_frame_list */
   9.745 -    if(!(p2m_frame_list = malloc(P2M_FL_SIZE))) { 
   9.746 +    if(!(p2m_frame_list = malloc(P2M_FL_SIZE))) {
   9.747          ERR("Couldn't allocate p2m_frame_list array");
   9.748          goto out;
   9.749      }
   9.750 -    memcpy(p2m_frame_list, live_p2m_frame_list, P2M_FL_SIZE); 
   9.751 +    memcpy(p2m_frame_list, live_p2m_frame_list, P2M_FL_SIZE);
   9.752  
   9.753      /* Canonicalise the pfn-to-mfn table frame-number list. */
   9.754      for (i = 0; i < max_pfn; i += ulpp) {
   9.755 -        if (!translate_mfn_to_pfn(&p2m_frame_list[i/ulpp])) { 
   9.756 +        if (!translate_mfn_to_pfn(&p2m_frame_list[i/ulpp])) {
   9.757              ERR("Frame# in pfn-to-mfn frame list is not in pseudophys");
   9.758 -            ERR("entry %d: p2m_frame_list[%ld] is 0x%lx", i, i/ulpp, 
   9.759 -                p2m_frame_list[i/ulpp]); 
   9.760 +            ERR("entry %d: p2m_frame_list[%ld] is 0x%lx", i, i/ulpp,
   9.761 +                p2m_frame_list[i/ulpp]);
   9.762              goto out;
   9.763          }
   9.764      }
   9.765 @@ -725,31 +725,31 @@ int xc_linux_save(int xc_handle, int io_
   9.766      /* Domain is still running at this point */
   9.767      if (live) {
   9.768  
   9.769 -        if (xc_shadow_control(xc_handle, dom, 
   9.770 +        if (xc_shadow_control(xc_handle, dom,
   9.771                                DOM0_SHADOW_CONTROL_OP_ENABLE_LOGDIRTY,
   9.772 -                              NULL, 0, NULL ) < 0) { 
   9.773 +                              NULL, 0, NULL ) < 0) {
   9.774              ERR("Couldn't enable shadow mode");
   9.775              goto out;
   9.776          }
   9.777 -        
   9.778 +
   9.779          last_iter = 0;
   9.780 -        
   9.781 +
   9.782      } else {
   9.783 -        
   9.784 +
   9.785          /* This is a non-live suspend. Issue the call back to get the
   9.786             domain suspended */
   9.787 -        
   9.788 +
   9.789          last_iter = 1;
   9.790 -        
   9.791 +
   9.792          if (suspend_and_state(suspend, xc_handle, io_fd, dom, &info, &ctxt)) {
   9.793              ERR("Domain appears not to have suspended");
   9.794              goto out;
   9.795          }
   9.796 -        
   9.797 +
   9.798      }
   9.799  
   9.800      /* pretend we sent all the pages last iteration */
   9.801 -    sent_last_iter = max_pfn; 
   9.802 +    sent_last_iter = max_pfn;
   9.803  
   9.804  
   9.805      /* calculate the power of 2 order of max_pfn, e.g.
   9.806 @@ -758,15 +758,15 @@ int xc_linux_save(int xc_handle, int io_
   9.807          continue;
   9.808  
   9.809      /* Setup to_send / to_fix and to_skip bitmaps */
   9.810 -    to_send = malloc(BITMAP_SIZE); 
   9.811 -    to_fix  = calloc(1, BITMAP_SIZE); 
   9.812 -    to_skip = malloc(BITMAP_SIZE); 
   9.813 -    
   9.814 +    to_send = malloc(BITMAP_SIZE);
   9.815 +    to_fix  = calloc(1, BITMAP_SIZE);
   9.816 +    to_skip = malloc(BITMAP_SIZE);
   9.817 +
   9.818      if (!to_send || !to_fix || !to_skip) {
   9.819          ERR("Couldn't allocate to_send array");
   9.820          goto out;
   9.821      }
   9.822 -    
   9.823 +
   9.824      memset(to_send, 0xff, BITMAP_SIZE);
   9.825  
   9.826      if (mlock(to_send, BITMAP_SIZE)) {
   9.827 @@ -779,7 +779,7 @@ int xc_linux_save(int xc_handle, int io_
   9.828          ERR("Unable to mlock to_skip");
   9.829          return 1;
   9.830      }
   9.831 -        
   9.832 +
   9.833      analysis_phase(xc_handle, dom, max_pfn, to_skip, 0);
   9.834  
   9.835      /* We want zeroed memory so use calloc rather than malloc. */
   9.836 @@ -787,7 +787,7 @@ int xc_linux_save(int xc_handle, int io_
   9.837      pfn_batch = calloc(MAX_BATCH_SIZE, sizeof(unsigned long));
   9.838  
   9.839      if ((pfn_type == NULL) || (pfn_batch == NULL)) {
   9.840 -        ERR("failed to alloc memory for pfn_type and/or pfn_batch arrays"); 
   9.841 +        ERR("failed to alloc memory for pfn_type and/or pfn_batch arrays");
   9.842          errno = ENOMEM;
   9.843          goto out;
   9.844      }
   9.845 @@ -803,12 +803,12 @@ int xc_linux_save(int xc_handle, int io_
   9.846       */
   9.847      {
   9.848          int err=0;
   9.849 -        unsigned long mfn; 
   9.850 +        unsigned long mfn;
   9.851          for (i = 0; i < max_pfn; i++) {
   9.852  
   9.853              mfn = live_p2m[i];
   9.854 -            if((mfn != INVALID_P2M_ENTRY) && (mfn_to_pfn(mfn) != i)) { 
   9.855 -                DPRINTF("i=0x%x mfn=%lx live_m2p=%lx\n", i, 
   9.856 +            if((mfn != INVALID_P2M_ENTRY) && (mfn_to_pfn(mfn) != i)) {
   9.857 +                DPRINTF("i=0x%x mfn=%lx live_m2p=%lx\n", i,
   9.858                          mfn, mfn_to_pfn(mfn));
   9.859                  err++;
   9.860              }
   9.861 @@ -819,16 +819,16 @@ int xc_linux_save(int xc_handle, int io_
   9.862  
   9.863      /* Start writing out the saved-domain record. */
   9.864  
   9.865 -    if(!write_exact(io_fd, &max_pfn, sizeof(unsigned long))) { 
   9.866 +    if(!write_exact(io_fd, &max_pfn, sizeof(unsigned long))) {
   9.867          ERR("write: max_pfn");
   9.868          goto out;
   9.869      }
   9.870  
   9.871 -    if(!write_exact(io_fd, p2m_frame_list, P2M_FL_SIZE)) { 
   9.872 +    if(!write_exact(io_fd, p2m_frame_list, P2M_FL_SIZE)) {
   9.873          ERR("write: p2m_frame_list");
   9.874          goto out;
   9.875      }
   9.876 -    
   9.877 +
   9.878      print_stats(xc_handle, dom, 0, &stats, 0);
   9.879  
   9.880      /* Now write out each data page, canonicalising page tables as we go... */
   9.881 @@ -853,8 +853,8 @@ int xc_linux_save(int xc_handle, int io_
   9.882                  DPRINTF("\b\b\b\b%3d%%", this_pc);
   9.883                  prev_pc = this_pc;
   9.884              }
   9.885 -            
   9.886 -            /* slightly wasteful to peek the whole array evey time, 
   9.887 +
   9.888 +            /* slightly wasteful to peek the whole array evey time,
   9.889                 but this is fast enough for the moment. */
   9.890              if (!last_iter && xc_shadow_control(
   9.891                      xc_handle, dom, DOM0_SHADOW_CONTROL_OP_PEEK,
   9.892 @@ -862,7 +862,7 @@ int xc_linux_save(int xc_handle, int io_
   9.893                  ERR("Error peeking shadow bitmap");
   9.894                  goto out;
   9.895              }
   9.896 -     
   9.897 +
   9.898  
   9.899              /* load pfn_type[] with the mfn of all the pages we're doing in
   9.900                 this batch. */
   9.901 @@ -873,11 +873,11 @@ int xc_linux_save(int xc_handle, int io_
   9.902                  if (debug) {
   9.903                      DPRINTF("%d pfn= %08lx mfn= %08lx %d  [mfn]= %08lx\n",
   9.904                              iter, (unsigned long)n, live_p2m[n],
   9.905 -                            test_bit(n, to_send), 
   9.906 +                            test_bit(n, to_send),
   9.907                              mfn_to_pfn(live_p2m[n]&0xFFFFF));
   9.908                  }
   9.909 -                
   9.910 -                if (!last_iter && test_bit(n, to_send)&& test_bit(n, to_skip)) 
   9.911 +
   9.912 +                if (!last_iter && test_bit(n, to_send)&& test_bit(n, to_skip))
   9.913                      skip_this_iter++; /* stats keeping */
   9.914  
   9.915                  if (!((test_bit(n, to_send) && !test_bit(n, to_skip)) ||
   9.916 @@ -885,13 +885,13 @@ int xc_linux_save(int xc_handle, int io_
   9.917                        (test_bit(n, to_fix)  && last_iter)))
   9.918                      continue;
   9.919  
   9.920 -                /* 
   9.921 +                /*
   9.922                  ** we get here if:
   9.923                  **  1. page is marked to_send & hasn't already been re-dirtied
   9.924                  **  2. (ignore to_skip in last iteration)
   9.925                  **  3. add in pages that still need fixup (net bufs)
   9.926                  */
   9.927 -  
   9.928 +
   9.929                  pfn_batch[batch] = n;
   9.930                  pfn_type[batch]  = live_p2m[n];
   9.931  
   9.932 @@ -914,80 +914,80 @@ int xc_linux_save(int xc_handle, int io_
   9.933                              iter,n,pfn_type[batch]);
   9.934                  }
   9.935  
   9.936 -                clear_bit(n, to_fix); 
   9.937 -                
   9.938 +                clear_bit(n, to_fix);
   9.939 +
   9.940                  batch++;
   9.941              }
   9.942 -     
   9.943 +
   9.944              if (batch == 0)
   9.945                  goto skip; /* vanishingly unlikely... */
   9.946 -      
   9.947 +
   9.948              if ((region_base = xc_map_foreign_batch(
   9.949 -                     xc_handle, dom, PROT_READ, pfn_type, batch)) == 0) { 
   9.950 +                     xc_handle, dom, PROT_READ, pfn_type, batch)) == 0) {
   9.951                  ERR("map batch failed");
   9.952                  goto out;
   9.953              }
   9.954 -     
   9.955 +
   9.956              if (xc_get_pfn_type_batch(xc_handle, dom, batch, pfn_type)) {
   9.957                  ERR("get_pfn_type_batch failed");
   9.958                  goto out;
   9.959              }
   9.960 -     
   9.961 +
   9.962              for (j = 0; j < batch; j++) {
   9.963  
   9.964                  if ((pfn_type[j] & LTAB_MASK) == XTAB) {
   9.965                      DPRINTF("type fail: page %i mfn %08lx\n", j, pfn_type[j]);
   9.966                      continue;
   9.967                  }
   9.968 -  
   9.969 -                if (debug) 
   9.970 +
   9.971 +                if (debug)
   9.972                      fprintf(stderr, "%d pfn= %08lx mfn= %08lx [mfn]= %08lx"
   9.973                              " sum= %08lx\n",
   9.974 -                            iter, 
   9.975 +                            iter,
   9.976                              (pfn_type[j] & LTAB_MASK) | pfn_batch[j],
   9.977                              pfn_type[j],
   9.978                              mfn_to_pfn(pfn_type[j]&(~LTAB_MASK)),
   9.979                              csum_page(region_base + (PAGE_SIZE*j)));
   9.980 -                
   9.981 +
   9.982                  /* canonicalise mfn->pfn */
   9.983                  pfn_type[j] = (pfn_type[j] & LTAB_MASK) | pfn_batch[j];
   9.984              }
   9.985  
   9.986 -            if(!write_exact(io_fd, &batch, sizeof(unsigned int))) { 
   9.987 +            if(!write_exact(io_fd, &batch, sizeof(unsigned int))) {
   9.988                  ERR("Error when writing to state file (2)");
   9.989                  goto out;
   9.990              }
   9.991  
   9.992 -            if(!write_exact(io_fd, pfn_type, sizeof(unsigned long)*j)) { 
   9.993 +            if(!write_exact(io_fd, pfn_type, sizeof(unsigned long)*j)) {
   9.994                  ERR("Error when writing to state file (3)");
   9.995                  goto out;
   9.996              }
   9.997 -            
   9.998 +
   9.999              /* entering this loop, pfn_type is now in pfns (Not mfns) */
  9.1000              for (j = 0; j < batch; j++) {
  9.1001 -                
  9.1002 -                unsigned long pfn      = pfn_type[j] & ~LTAB_MASK; 
  9.1003 -                unsigned long pagetype = pfn_type[j] & LTAB_MASK; 
  9.1004 -                void *spage            = (void *) region_base + (PAGE_SIZE*j); 
  9.1005 +
  9.1006 +                unsigned long pfn      = pfn_type[j] & ~LTAB_MASK;
  9.1007 +                unsigned long pagetype = pfn_type[j] & LTAB_MASK;
  9.1008 +                void *spage            = (void *) region_base + (PAGE_SIZE*j);
  9.1009  
  9.1010  
  9.1011                  /* write out pages in batch */
  9.1012                  if (pagetype == XTAB)
  9.1013                      continue;
  9.1014  
  9.1015 -                pagetype &= LTABTYPE_MASK; 
  9.1016 -                
  9.1017 +                pagetype &= LTABTYPE_MASK;
  9.1018 +
  9.1019                  if (pagetype >= L1TAB && pagetype <= L4TAB) {
  9.1020 -                    
  9.1021 +
  9.1022                      /* We have a pagetable page: need to rewrite it. */
  9.1023 -                    canonicalize_pagetable(pagetype, pfn, spage, page); 
  9.1024 -                    
  9.1025 +                    canonicalize_pagetable(pagetype, pfn, spage, page);
  9.1026 +
  9.1027                      if (ratewrite(io_fd, page, PAGE_SIZE) != PAGE_SIZE) {
  9.1028                          ERR("Error when writing to state file (4)");
  9.1029                          goto out;
  9.1030                      }
  9.1031 -                    
  9.1032 -                }  else {  
  9.1033 +
  9.1034 +                }  else {
  9.1035  
  9.1036                      /* We have a normal page: just write it directly. */
  9.1037                      if (ratewrite(io_fd, spage, PAGE_SIZE) != PAGE_SIZE) {
  9.1038 @@ -996,36 +996,36 @@ int xc_linux_save(int xc_handle, int io_
  9.1039                      }
  9.1040                  }
  9.1041              } /* end of the write out for this batch */
  9.1042 -            
  9.1043 +
  9.1044              sent_this_iter += batch;
  9.1045  
  9.1046              munmap(region_base, batch*PAGE_SIZE);
  9.1047 -        
  9.1048 +
  9.1049          } /* end of this while loop for this iteration */
  9.1050 -        
  9.1051 -      skip: 
  9.1052 -        
  9.1053 +
  9.1054 +      skip:
  9.1055 +
  9.1056          total_sent += sent_this_iter;
  9.1057  
  9.1058 -        DPRINTF("\r %d: sent %d, skipped %d, ", 
  9.1059 +        DPRINTF("\r %d: sent %d, skipped %d, ",
  9.1060                  iter, sent_this_iter, skip_this_iter );
  9.1061  
  9.1062          if (last_iter) {
  9.1063              print_stats( xc_handle, dom, sent_this_iter, &stats, 1);
  9.1064  
  9.1065 -            DPRINTF("Total pages sent= %ld (%.2fx)\n", 
  9.1066 +            DPRINTF("Total pages sent= %ld (%.2fx)\n",
  9.1067                      total_sent, ((float)total_sent)/max_pfn );
  9.1068              DPRINTF("(of which %ld were fixups)\n", needed_to_fix  );
  9.1069 -        }       
  9.1070 +        }
  9.1071  
  9.1072          if (last_iter && debug){
  9.1073              int minusone = -1;
  9.1074 -            memset(to_send, 0xff, BITMAP_SIZE); 
  9.1075 +            memset(to_send, 0xff, BITMAP_SIZE);
  9.1076              debug = 0;
  9.1077              fprintf(stderr, "Entering debug resend-all mode\n");
  9.1078 -    
  9.1079 +
  9.1080              /* send "-1" to put receiver into debug mode */
  9.1081 -            if(!write_exact(io_fd, &minusone, sizeof(int))) { 
  9.1082 +            if(!write_exact(io_fd, &minusone, sizeof(int))) {
  9.1083                  ERR("Error when writing to state file (6)");
  9.1084                  goto out;
  9.1085              }
  9.1086 @@ -1033,34 +1033,34 @@ int xc_linux_save(int xc_handle, int io_
  9.1087              continue;
  9.1088          }
  9.1089  
  9.1090 -        if (last_iter) break; 
  9.1091 +        if (last_iter) break;
  9.1092  
  9.1093          if (live) {
  9.1094  
  9.1095  
  9.1096 -            if( 
  9.1097 +            if(
  9.1098                  ((sent_this_iter > sent_last_iter) && RATE_IS_MAX()) ||
  9.1099                  (iter >= max_iters) ||
  9.1100                  (sent_this_iter+skip_this_iter < 50) ||
  9.1101 -                (total_sent > max_pfn*max_factor) ) { 
  9.1102 +                (total_sent > max_pfn*max_factor) ) {
  9.1103  
  9.1104                  DPRINTF("Start last iteration\n");
  9.1105                  last_iter = 1;
  9.1106 -                
  9.1107 +
  9.1108                  if (suspend_and_state(suspend, xc_handle, io_fd, dom, &info,
  9.1109                                        &ctxt)) {
  9.1110                      ERR("Domain appears not to have suspended");
  9.1111                      goto out;
  9.1112                  }
  9.1113 -                
  9.1114 -                DPRINTF("SUSPEND shinfo %08lx eip %08lx edx %08lx\n", 
  9.1115 -                        info.shared_info_frame, 
  9.1116 -                        (unsigned long)ctxt.user_regs.eip, 
  9.1117 +
  9.1118 +                DPRINTF("SUSPEND shinfo %08lx eip %08lx edx %08lx\n",
  9.1119 +                        info.shared_info_frame,
  9.1120 +                        (unsigned long)ctxt.user_regs.eip,
  9.1121                          (unsigned long)ctxt.user_regs.edx);
  9.1122 -            } 
  9.1123 -            
  9.1124 +            }
  9.1125 +
  9.1126              if (xc_shadow_control(xc_handle, dom, DOM0_SHADOW_CONTROL_OP_CLEAN,
  9.1127 -                                  to_send, max_pfn, &stats ) != max_pfn) {  
  9.1128 +                                  to_send, max_pfn, &stats ) != max_pfn) {
  9.1129                  ERR("Error flushing shadow PT");
  9.1130                  goto out;
  9.1131              }
  9.1132 @@ -1068,7 +1068,7 @@ int xc_linux_save(int xc_handle, int io_
  9.1133              sent_last_iter = sent_this_iter;
  9.1134  
  9.1135              print_stats(xc_handle, dom, sent_this_iter, &stats, 1);
  9.1136 -     
  9.1137 +
  9.1138          }
  9.1139  
  9.1140  
  9.1141 @@ -1077,8 +1077,8 @@ int xc_linux_save(int xc_handle, int io_
  9.1142      DPRINTF("All memory is saved\n");
  9.1143  
  9.1144      /* Zero terminate */
  9.1145 -    i = 0; 
  9.1146 -    if (!write_exact(io_fd, &i, sizeof(int))) { 
  9.1147 +    i = 0;
  9.1148 +    if (!write_exact(io_fd, &i, sizeof(int))) {
  9.1149          ERR("Error when writing to state file (6)");
  9.1150          goto out;
  9.1151      }
  9.1152 @@ -1086,18 +1086,18 @@ int xc_linux_save(int xc_handle, int io_
  9.1153      /* Send through a list of all the PFNs that were not in map at the close */
  9.1154      {
  9.1155          unsigned int i,j;
  9.1156 -        unsigned long pfntab[1024]; 
  9.1157 +        unsigned long pfntab[1024];
  9.1158  
  9.1159          for (i = 0, j = 0; i < max_pfn; i++) {
  9.1160              if (!is_mapped(live_p2m[i]))
  9.1161                  j++;
  9.1162          }
  9.1163 -        
  9.1164 -        if(!write_exact(io_fd, &j, sizeof(unsigned int))) { 
  9.1165 +
  9.1166 +        if(!write_exact(io_fd, &j, sizeof(unsigned int))) {
  9.1167              ERR("Error when writing to state file (6a)");
  9.1168              goto out;
  9.1169 -        }	
  9.1170 -        
  9.1171 +        }
  9.1172 +
  9.1173          for (i = 0, j = 0; i < max_pfn; ) {
  9.1174  
  9.1175              if (!is_mapped(live_p2m[i]))
  9.1176 @@ -1105,16 +1105,16 @@ int xc_linux_save(int xc_handle, int io_
  9.1177  
  9.1178              i++;
  9.1179              if (j == 1024 || i == max_pfn) {
  9.1180 -                if(!write_exact(io_fd, &pfntab, sizeof(unsigned long)*j)) { 
  9.1181 +                if(!write_exact(io_fd, &pfntab, sizeof(unsigned long)*j)) {
  9.1182                      ERR("Error when writing to state file (6b)");
  9.1183                      goto out;
  9.1184 -                } 
  9.1185 +                }
  9.1186                  j = 0;
  9.1187              }
  9.1188          }
  9.1189  
  9.1190      }
  9.1191 -    
  9.1192 +
  9.1193      /* Canonicalise the suspend-record frame number. */
  9.1194      if ( !translate_mfn_to_pfn(&ctxt.user_regs.edx) ){
  9.1195          ERR("Suspend record is not in range of pseudophys map");
  9.1196 @@ -1138,7 +1138,7 @@ int xc_linux_save(int xc_handle, int io_
  9.1197          PAGE_SHIFT;
  9.1198  
  9.1199      if (!write_exact(io_fd, &ctxt, sizeof(ctxt)) ||
  9.1200 -        !write_exact(io_fd, live_shinfo, PAGE_SIZE)) { 
  9.1201 +        !write_exact(io_fd, live_shinfo, PAGE_SIZE)) {
  9.1202          ERR("Error when writing to state file (1)");
  9.1203          goto out;
  9.1204      }
  9.1205 @@ -1149,26 +1149,26 @@ int xc_linux_save(int xc_handle, int io_
  9.1206   out:
  9.1207  
  9.1208      if (live) {
  9.1209 -        if(xc_shadow_control(xc_handle, dom, DOM0_SHADOW_CONTROL_OP_OFF, 
  9.1210 -                             NULL, 0, NULL ) < 0) { 
  9.1211 +        if(xc_shadow_control(xc_handle, dom, DOM0_SHADOW_CONTROL_OP_OFF,
  9.1212 +                             NULL, 0, NULL ) < 0) {
  9.1213              DPRINTF("Warning - couldn't disable shadow mode");
  9.1214          }
  9.1215      }
  9.1216 -    
  9.1217 +
  9.1218      if (live_shinfo)
  9.1219          munmap(live_shinfo, PAGE_SIZE);
  9.1220 -    
  9.1221 -    if (live_p2m_frame_list_list) 
  9.1222 -        munmap(live_p2m_frame_list_list, PAGE_SIZE); 
  9.1223  
  9.1224 -    if (live_p2m_frame_list) 
  9.1225 -        munmap(live_p2m_frame_list, P2M_FLL_ENTRIES * PAGE_SIZE); 
  9.1226 +    if (live_p2m_frame_list_list)
  9.1227 +        munmap(live_p2m_frame_list_list, PAGE_SIZE);
  9.1228  
  9.1229 -    if(live_p2m) 
  9.1230 -        munmap(live_p2m, P2M_SIZE); 
  9.1231 +    if (live_p2m_frame_list)
  9.1232 +        munmap(live_p2m_frame_list, P2M_FLL_ENTRIES * PAGE_SIZE);
  9.1233  
  9.1234 -    if(live_m2p) 
  9.1235 -        munmap(live_m2p, M2P_SIZE(max_mfn)); 
  9.1236 +    if(live_p2m)
  9.1237 +        munmap(live_p2m, P2M_SIZE);
  9.1238 +
  9.1239 +    if(live_m2p)
  9.1240 +        munmap(live_m2p, M2P_SIZE(max_mfn));
  9.1241  
  9.1242      free(pfn_type);
  9.1243      free(pfn_batch);
    10.1 --- a/tools/libxc/xc_load_aout9.c	Sat Apr 15 09:52:32 2006 +0100
    10.2 +++ b/tools/libxc/xc_load_aout9.c	Sat Apr 15 10:07:31 2006 +0100
    10.3 @@ -22,7 +22,7 @@ static void copyout(int, uint32_t, unsig
    10.4  struct Exec *get_header(const char *, unsigned long, struct Exec *);
    10.5  
    10.6  
    10.7 -int 
    10.8 +int
    10.9  probe_aout9(
   10.10      const char *image,
   10.11      unsigned long image_size,
   10.12 @@ -40,7 +40,7 @@ probe_aout9(
   10.13      return 0;
   10.14  }
   10.15  
   10.16 -static int 
   10.17 +static int
   10.18  parseaout9image(
   10.19      const char *image,
   10.20      unsigned long image_size,
   10.21 @@ -74,7 +74,7 @@ parseaout9image(
   10.22      return 0;
   10.23  }
   10.24  
   10.25 -static int 
   10.26 +static int
   10.27  loadaout9image(
   10.28      const char *image,
   10.29      unsigned long image_size,
   10.30 @@ -123,7 +123,7 @@ copyout(
   10.31          if(chunksz > PAGE_SIZE - pgoff)
   10.32              chunksz = PAGE_SIZE - pgoff;
   10.33  
   10.34 -        pg = xc_map_foreign_range(xch, dom, PAGE_SIZE, PROT_WRITE, 
   10.35 +        pg = xc_map_foreign_range(xch, dom, PAGE_SIZE, PROT_WRITE,
   10.36                                    parray[off>>PAGE_SHIFT]);
   10.37          memcpy(pg + pgoff, buf, chunksz);
   10.38          munmap(pg, PAGE_SIZE);
    11.1 --- a/tools/libxc/xc_load_bin.c	Sat Apr 15 09:52:32 2006 +0100
    11.2 +++ b/tools/libxc/xc_load_bin.c	Sat Apr 15 10:07:31 2006 +0100
    11.3 @@ -161,7 +161,7 @@ findtable(const char *image, unsigned lo
    11.4      return NULL;
    11.5  }
    11.6  
    11.7 -static int parsebinimage(const char *image, 
    11.8 +static int parsebinimage(const char *image,
    11.9                           unsigned long image_size,
   11.10                           struct domain_setup_info *dsi)
   11.11  {
    12.1 --- a/tools/libxc/xc_load_elf.c	Sat Apr 15 09:52:32 2006 +0100
    12.2 +++ b/tools/libxc/xc_load_elf.c	Sat Apr 15 10:07:31 2006 +0100
    12.3 @@ -51,7 +51,7 @@ static inline int is_loadable_phdr(Elf_P
    12.4              ((phdr->p_flags & (PF_W|PF_X)) != 0));
    12.5  }
    12.6  
    12.7 -static int parseelfimage(const char *image, 
    12.8 +static int parseelfimage(const char *image,
    12.9                           unsigned long elfsize,
   12.10                           struct domain_setup_info *dsi)
   12.11  {
   12.12 @@ -102,10 +102,10 @@ static int parseelfimage(const char *ima
   12.13          ERROR("ELF image has no section-header strings table (shstrtab).");
   12.14          return -EINVAL;
   12.15      }
   12.16 -    shdr = (Elf_Shdr *)(image + ehdr->e_shoff + 
   12.17 +    shdr = (Elf_Shdr *)(image + ehdr->e_shoff +
   12.18                          (ehdr->e_shstrndx*ehdr->e_shentsize));
   12.19      shstrtab = image + shdr->sh_offset;
   12.20 -    
   12.21 +
   12.22      /* Find the special '__xen_guest' section and check its contents. */
   12.23      for ( h = 0; h < ehdr->e_shnum; h++ )
   12.24      {
   12.25 @@ -148,7 +148,7 @@ static int parseelfimage(const char *ima
   12.26  
   12.27      dsi->xen_guest_string = guestinfo;
   12.28  
   12.29 -    for ( h = 0; h < ehdr->e_phnum; h++ ) 
   12.30 +    for ( h = 0; h < ehdr->e_phnum; h++ )
   12.31      {
   12.32          phdr = (Elf_Phdr *)(image + ehdr->e_phoff + (h*ehdr->e_phentsize));
   12.33          if ( !is_loadable_phdr(phdr) )
   12.34 @@ -159,8 +159,8 @@ static int parseelfimage(const char *ima
   12.35              kernend = phdr->p_paddr + phdr->p_memsz;
   12.36      }
   12.37  
   12.38 -    if ( (kernstart > kernend) || 
   12.39 -         (ehdr->e_entry < kernstart) || 
   12.40 +    if ( (kernstart > kernend) ||
   12.41 +         (ehdr->e_entry < kernstart) ||
   12.42           (ehdr->e_entry > kernend) )
   12.43      {
   12.44          ERROR("Malformed ELF image.");
   12.45 @@ -196,12 +196,12 @@ loadelfimage(
   12.46      char         *va;
   12.47      unsigned long pa, done, chunksz;
   12.48  
   12.49 -    for ( h = 0; h < ehdr->e_phnum; h++ ) 
   12.50 +    for ( h = 0; h < ehdr->e_phnum; h++ )
   12.51      {
   12.52          phdr = (Elf_Phdr *)(image + ehdr->e_phoff + (h*ehdr->e_phentsize));
   12.53          if ( !is_loadable_phdr(phdr) )
   12.54              continue;
   12.55 -        
   12.56 +
   12.57          for ( done = 0; done < phdr->p_filesz; done += chunksz )
   12.58          {
   12.59              pa = (phdr->p_paddr + done) - dsi->v_start;
   12.60 @@ -265,7 +265,7 @@ loadelfsymtab(
   12.61      shdr = (Elf_Shdr *)(p + sizeof(int) + sizeof(Elf_Ehdr));
   12.62      memcpy(shdr, image + ehdr->e_shoff, ehdr->e_shnum * sizeof(Elf_Shdr));
   12.63  
   12.64 -    for ( h = 0; h < ehdr->e_shnum; h++ ) 
   12.65 +    for ( h = 0; h < ehdr->e_shnum; h++ )
   12.66      {
   12.67          if ( shdr[h].sh_type == SHT_STRTAB )
   12.68          {
    13.1 --- a/tools/libxc/xc_misc.c	Sat Apr 15 09:52:32 2006 +0100
    13.2 +++ b/tools/libxc/xc_misc.c	Sat Apr 15 10:07:31 2006 +0100
    13.3 @@ -1,6 +1,6 @@
    13.4  /******************************************************************************
    13.5   * xc_misc.c
    13.6 - * 
    13.7 + *
    13.8   * Miscellaneous control interface functions.
    13.9   */
   13.10  
   13.11 @@ -21,7 +21,7 @@ int xc_interface_close(int xc_handle)
   13.12  
   13.13  int xc_readconsolering(int xc_handle,
   13.14                         char **pbuffer,
   13.15 -                       unsigned int *pnr_chars, 
   13.16 +                       unsigned int *pnr_chars,
   13.17                         int clear)
   13.18  {
   13.19      int ret;
   13.20 @@ -46,14 +46,14 @@ int xc_readconsolering(int xc_handle,
   13.21      safe_munlock(buffer, nr_chars);
   13.22  
   13.23      return ret;
   13.24 -}    
   13.25 +}
   13.26  
   13.27  int xc_physinfo(int xc_handle,
   13.28                  xc_physinfo_t *put_info)
   13.29  {
   13.30      int ret;
   13.31      DECLARE_DOM0_OP;
   13.32 -    
   13.33 +
   13.34      op.cmd = DOM0_PHYSINFO;
   13.35      op.interface_version = DOM0_INTERFACE_VERSION;
   13.36  
   13.37 @@ -70,15 +70,15 @@ int xc_sched_id(int xc_handle,
   13.38  {
   13.39      int ret;
   13.40      DECLARE_DOM0_OP;
   13.41 -    
   13.42 +
   13.43      op.cmd = DOM0_SCHED_ID;
   13.44      op.interface_version = DOM0_INTERFACE_VERSION;
   13.45 -    
   13.46 +
   13.47      if ( (ret = do_dom0_op(xc_handle, &op)) != 0 )
   13.48          return ret;
   13.49 -    
   13.50 +
   13.51      *sched_id = op.u.sched_id.sched_id;
   13.52 -    
   13.53 +
   13.54      return 0;
   13.55  }
   13.56  
   13.57 @@ -100,9 +100,9 @@ int xc_perfc_control(int xc_handle,
   13.58  
   13.59  long long xc_msr_read(int xc_handle, int cpu_mask, int msr)
   13.60  {
   13.61 -    int rc;    
   13.62 +    int rc;
   13.63      DECLARE_DOM0_OP;
   13.64 -    
   13.65 +
   13.66      op.cmd = DOM0_MSR;
   13.67      op.u.msr.write = 0;
   13.68      op.u.msr.msr = msr;
   13.69 @@ -116,9 +116,9 @@ long long xc_msr_read(int xc_handle, int
   13.70  int xc_msr_write(int xc_handle, int cpu_mask, int msr, unsigned int low,
   13.71                    unsigned int high)
   13.72  {
   13.73 -    int rc;    
   13.74 +    int rc;
   13.75      DECLARE_DOM0_OP;
   13.76 -    
   13.77 +
   13.78      op.cmd = DOM0_MSR;
   13.79      op.u.msr.write = 1;
   13.80      op.u.msr.msr = msr;
   13.81 @@ -127,7 +127,7 @@ int xc_msr_write(int xc_handle, int cpu_
   13.82      op.u.msr.in2 = high;
   13.83  
   13.84      rc = do_dom0_op(xc_handle, &op);
   13.85 -    
   13.86 +
   13.87      return rc;
   13.88  }
   13.89  
    14.1 --- a/tools/libxc/xc_physdev.c	Sat Apr 15 09:52:32 2006 +0100
    14.2 +++ b/tools/libxc/xc_physdev.c	Sat Apr 15 10:07:31 2006 +0100
    14.3 @@ -1,8 +1,8 @@
    14.4  /******************************************************************************
    14.5   * xc_physdev.c
    14.6 - * 
    14.7 + *
    14.8   * API for manipulating physical-device access permissions.
    14.9 - * 
   14.10 + *
   14.11   * Copyright (c) 2004, Rolf Neugebauer (Intel Research Cambridge)
   14.12   * Copyright (c) 2004, K A Fraser (University of Cambridge)
   14.13   */
    15.1 --- a/tools/libxc/xc_private.c	Sat Apr 15 09:52:32 2006 +0100
    15.2 +++ b/tools/libxc/xc_private.c	Sat Apr 15 10:07:31 2006 +0100
    15.3 @@ -1,6 +1,6 @@
    15.4  /******************************************************************************
    15.5   * xc_private.c
    15.6 - * 
    15.7 + *
    15.8   * Helper functions for the rest of the library.
    15.9   */
   15.10  
   15.11 @@ -10,7 +10,7 @@
   15.12  void *xc_map_foreign_batch(int xc_handle, uint32_t dom, int prot,
   15.13                             unsigned long *arr, int num )
   15.14  {
   15.15 -    privcmd_mmapbatch_t ioctlx; 
   15.16 +    privcmd_mmapbatch_t ioctlx;
   15.17      void *addr;
   15.18      addr = mmap(NULL, num*PAGE_SIZE, prot, MAP_SHARED, xc_handle, 0);
   15.19      if ( addr == MAP_FAILED )
   15.20 @@ -38,8 +38,8 @@ void *xc_map_foreign_range(int xc_handle
   15.21                             int size, int prot,
   15.22                             unsigned long mfn )
   15.23  {
   15.24 -    privcmd_mmap_t ioctlx; 
   15.25 -    privcmd_mmap_entry_t entry; 
   15.26 +    privcmd_mmap_t ioctlx;
   15.27 +    privcmd_mmap_entry_t entry;
   15.28      void *addr;
   15.29      addr = mmap(NULL, size, prot, MAP_SHARED, xc_handle, 0);
   15.30      if ( addr == MAP_FAILED )
   15.31 @@ -64,7 +64,7 @@ void *xc_map_foreign_range(int xc_handle
   15.32  /*******************/
   15.33  
   15.34  /* NB: arr must be mlock'ed */
   15.35 -int xc_get_pfn_type_batch(int xc_handle, 
   15.36 +int xc_get_pfn_type_batch(int xc_handle,
   15.37                            uint32_t dom, int num, unsigned long *arr)
   15.38  {
   15.39      DECLARE_DOM0_OP;
   15.40 @@ -76,8 +76,8 @@ int xc_get_pfn_type_batch(int xc_handle,
   15.41  }
   15.42  
   15.43  #define GETPFN_ERR (~0U)
   15.44 -unsigned int get_pfn_type(int xc_handle, 
   15.45 -                          unsigned long mfn, 
   15.46 +unsigned int get_pfn_type(int xc_handle,
   15.47 +                          unsigned long mfn,
   15.48                            uint32_t dom)
   15.49  {
   15.50      DECLARE_DOM0_OP;
   15.51 @@ -119,7 +119,7 @@ int xc_mmuext_op(
   15.52  
   15.53   out1:
   15.54      return ret;
   15.55 -}    
   15.56 +}
   15.57  
   15.58  static int flush_mmu_updates(int xc_handle, xc_mmu_t *mmu)
   15.59  {
   15.60 @@ -166,7 +166,7 @@ xc_mmu_t *xc_init_mmu_updates(int xc_han
   15.61      return mmu;
   15.62  }
   15.63  
   15.64 -int xc_add_mmu_update(int xc_handle, xc_mmu_t *mmu, 
   15.65 +int xc_add_mmu_update(int xc_handle, xc_mmu_t *mmu,
   15.66                        unsigned long long ptr, unsigned long long val)
   15.67  {
   15.68      mmu->updates[mmu->idx].ptr = ptr;
   15.69 @@ -288,7 +288,7 @@ int xc_memory_op(int xc_handle,
   15.70  
   15.71   out1:
   15.72      return ret;
   15.73 -}    
   15.74 +}
   15.75  
   15.76  
   15.77  long long xc_domain_get_cpu_usage( int xc_handle, domid_t domid, int vcpu )
   15.78 @@ -308,8 +308,8 @@ long long xc_domain_get_cpu_usage( int x
   15.79  
   15.80  
   15.81  int xc_get_pfn_list(int xc_handle,
   15.82 -                    uint32_t domid, 
   15.83 -                    unsigned long *pfn_buf, 
   15.84 +                    uint32_t domid,
   15.85 +                    unsigned long *pfn_buf,
   15.86                      unsigned long max_pfns)
   15.87  {
   15.88      DECLARE_DOM0_OP;
   15.89 @@ -327,7 +327,7 @@ int xc_get_pfn_list(int xc_handle,
   15.90      {
   15.91          PERROR("xc_get_pfn_list: pfn_buf mlock failed");
   15.92          return -1;
   15.93 -    }    
   15.94 +    }
   15.95  
   15.96      ret = do_dom0_op(xc_handle, &op);
   15.97  
   15.98 @@ -356,13 +356,13 @@ long xc_get_tot_pages(int xc_handle, uin
   15.99      DECLARE_DOM0_OP;
  15.100      op.cmd = DOM0_GETDOMAININFO;
  15.101      op.u.getdomaininfo.domain = (domid_t)domid;
  15.102 -    return (do_dom0_op(xc_handle, &op) < 0) ? 
  15.103 +    return (do_dom0_op(xc_handle, &op) < 0) ?
  15.104          -1 : op.u.getdomaininfo.tot_pages;
  15.105  }
  15.106  
  15.107  int xc_copy_to_domain_page(int xc_handle,
  15.108                             uint32_t domid,
  15.109 -                           unsigned long dst_pfn, 
  15.110 +                           unsigned long dst_pfn,
  15.111                             const char *src_page)
  15.112  {
  15.113      void *vaddr = xc_map_foreign_range(
  15.114 @@ -481,7 +481,7 @@ unsigned long xc_make_page_below_4G(
  15.115  {
  15.116      unsigned long new_mfn;
  15.117  
  15.118 -    if ( xc_domain_memory_decrease_reservation( 
  15.119 +    if ( xc_domain_memory_decrease_reservation(
  15.120          xc_handle, domid, 1, 0, &mfn) != 0 )
  15.121      {
  15.122          fprintf(stderr,"xc_make_page_below_4G decrease failed. mfn=%lx\n",mfn);
    16.1 --- a/tools/libxc/xc_private.h	Sat Apr 15 09:52:32 2006 +0100
    16.2 +++ b/tools/libxc/xc_private.h	Sat Apr 15 10:07:31 2006 +0100
    16.3 @@ -57,7 +57,7 @@ static inline void safe_munlock(const vo
    16.4  }
    16.5  
    16.6  static inline int do_privcmd(int xc_handle,
    16.7 -                             unsigned int cmd, 
    16.8 +                             unsigned int cmd,
    16.9                               unsigned long data)
   16.10  {
   16.11      return ioctl(xc_handle, cmd, data);
   16.12 @@ -67,7 +67,7 @@ static inline int do_xen_hypercall(int x
   16.13                                     privcmd_hypercall_t *hypercall)
   16.14  {
   16.15      return do_privcmd(xc_handle,
   16.16 -                      IOCTL_PRIVCMD_HYPERCALL, 
   16.17 +                      IOCTL_PRIVCMD_HYPERCALL,
   16.18                        (unsigned long)hypercall);
   16.19  }
   16.20  
   16.21 @@ -78,7 +78,7 @@ static inline int do_xen_version(int xc_
   16.22      hypercall.op     = __HYPERVISOR_xen_version;
   16.23      hypercall.arg[0] = (unsigned long) cmd;
   16.24      hypercall.arg[1] = (unsigned long) dest;
   16.25 -    
   16.26 +
   16.27      return do_xen_hypercall(xc_handle, &hypercall);
   16.28  }
   16.29  
   16.30 @@ -121,13 +121,13 @@ typedef struct privcmd_mmap_entry {
   16.31      unsigned long va;
   16.32      unsigned long mfn;
   16.33      unsigned long npages;
   16.34 -} privcmd_mmap_entry_t; 
   16.35 +} privcmd_mmap_entry_t;
   16.36  
   16.37  typedef struct privcmd_mmap {
   16.38      int num;
   16.39      domid_t dom;
   16.40      privcmd_mmap_entry_t *entry;
   16.41 -} privcmd_mmap_t; 
   16.42 +} privcmd_mmap_t;
   16.43  */
   16.44  
   16.45  #endif /* __XC_PRIVATE_H__ */
    17.1 --- a/tools/libxc/xc_ptrace.c	Sat Apr 15 09:52:32 2006 +0100
    17.2 +++ b/tools/libxc/xc_ptrace.c	Sat Apr 15 10:07:31 2006 +0100
    17.3 @@ -46,7 +46,7 @@ static cpumap_t                 regs_val
    17.4  static vcpu_guest_context_t     ctxt[MAX_VIRT_CPUS];
    17.5  
    17.6  extern int ffsll(long long int);
    17.7 -#define FOREACH_CPU(cpumap, i)  for ( cpumap = online_cpumap; (i = ffsll(cpumap)); cpumap &= ~(1 << (index - 1)) ) 
    17.8 +#define FOREACH_CPU(cpumap, i)  for ( cpumap = online_cpumap; (i = ffsll(cpumap)); cpumap &= ~(1 << (index - 1)) )
    17.9  
   17.10  
   17.11  static int
   17.12 @@ -58,22 +58,22 @@ fetch_regs(int xc_handle, int cpu, int *
   17.13      if (online)
   17.14          *online = 0;
   17.15      if ( !(regs_valid & (1 << cpu)) )
   17.16 -    { 
   17.17 -        retval = xc_vcpu_getcontext(xc_handle, current_domid, 
   17.18 -						cpu, &ctxt[cpu]);
   17.19 -        if ( retval ) 
   17.20 +    {
   17.21 +        retval = xc_vcpu_getcontext(xc_handle, current_domid,
   17.22 +                cpu, &ctxt[cpu]);
   17.23 +        if ( retval )
   17.24              goto done;
   17.25 -	regs_valid |= (1 << cpu);
   17.26 +        regs_valid |= (1 << cpu);
   17.27  
   17.28      }
   17.29 -	if ( online == NULL )
   17.30 -	    goto done;
   17.31 +    if ( online == NULL )
   17.32 +        goto done;
   17.33  
   17.34 -	retval = xc_vcpu_getinfo(xc_handle, current_domid, cpu, &info);
   17.35 -	*online = info.online;
   17.36 -    
   17.37 +    retval = xc_vcpu_getinfo(xc_handle, current_domid, cpu, &info);
   17.38 +    *online = info.online;
   17.39 +
   17.40   done:
   17.41 -    return retval;    
   17.42 +    return retval;
   17.43  }
   17.44  
   17.45  static struct thr_ev_handlers {
   17.46 @@ -81,8 +81,8 @@ static struct thr_ev_handlers {
   17.47      thr_ev_handler_t td_death;
   17.48  } handlers;
   17.49  
   17.50 -void 
   17.51 -xc_register_event_handler(thr_ev_handler_t h, 
   17.52 +void
   17.53 +xc_register_event_handler(thr_ev_handler_t h,
   17.54                            td_event_e e)
   17.55  {
   17.56      switch (e) {
   17.57 @@ -97,7 +97,7 @@ xc_register_event_handler(thr_ev_handler
   17.58      }
   17.59  }
   17.60  
   17.61 -static inline int 
   17.62 +static inline int
   17.63  paging_enabled(vcpu_guest_context_t *v)
   17.64  {
   17.65      unsigned long cr0 = v->ctrlreg[0];
   17.66 @@ -114,19 +114,19 @@ static int
   17.67  get_online_cpumap(int xc_handle, dom0_getdomaininfo_t *d, cpumap_t *cpumap)
   17.68  {
   17.69      int i, online, retval;
   17.70 -    
   17.71 +
   17.72      *cpumap = 0;
   17.73      for (i = 0; i <= d->max_vcpu_id; i++) {
   17.74          if ((retval = fetch_regs(xc_handle, i, &online)))
   17.75              return retval;
   17.76          if (online)
   17.77 -            *cpumap |= (1 << i);            
   17.78 +            *cpumap |= (1 << i);
   17.79      }
   17.80 -    
   17.81 +
   17.82      return 0;
   17.83  }
   17.84  
   17.85 -/* 
   17.86 +/*
   17.87   * Notify GDB of any vcpus that have come online or gone offline
   17.88   * update online_cpumap
   17.89   *
   17.90 @@ -137,7 +137,7 @@ online_vcpus_changed(cpumap_t cpumap)
   17.91  {
   17.92      cpumap_t changed_cpumap = cpumap ^ online_cpumap;
   17.93      int index;
   17.94 -    
   17.95 +
   17.96      while ( (index = ffsll(changed_cpumap)) ) {
   17.97          if ( cpumap & (1 << (index - 1)) )
   17.98          {
   17.99 @@ -149,7 +149,7 @@ online_vcpus_changed(cpumap_t cpumap)
  17.100          changed_cpumap &= ~(1 << (index - 1));
  17.101      }
  17.102      online_cpumap = cpumap;
  17.103 -    
  17.104 +
  17.105  }
  17.106  
  17.107  /* --------------------- */
  17.108 @@ -172,7 +172,7 @@ map_domain_va_32(
  17.109      static unsigned long  pde_phys[MAX_VIRT_CPUS];
  17.110      static uint32_t *pde_virt[MAX_VIRT_CPUS];
  17.111      static unsigned long  page_phys[MAX_VIRT_CPUS];
  17.112 -    static uint32_t *page_virt[MAX_VIRT_CPUS];    
  17.113 +    static uint32_t *page_virt[MAX_VIRT_CPUS];
  17.114      static int            prev_perm[MAX_VIRT_CPUS];
  17.115  
  17.116     if (ctxt[cpu].ctrlreg[3] == 0)
  17.117 @@ -221,7 +221,7 @@ map_domain_va_32(
  17.118              return NULL;
  17.119          }
  17.120          prev_perm[cpu] = perm;
  17.121 -    } 
  17.122 +    }
  17.123  
  17.124      return (void *)(((unsigned long)page_virt[cpu]) | (va & BSD_PAGE_MASK));
  17.125  }
  17.126 @@ -284,7 +284,7 @@ map_domain_va_64(
  17.127      if ((ctxt[cpu].ctrlreg[4] & 0x20) == 0 ) /* legacy ia32 mode */
  17.128          return map_domain_va_32(xc_handle, cpu, guest_va, perm);
  17.129  
  17.130 -    l4 = xc_map_foreign_range( xc_handle, current_domid, PAGE_SIZE, 
  17.131 +    l4 = xc_map_foreign_range( xc_handle, current_domid, PAGE_SIZE,
  17.132              PROT_READ, ctxt[cpu].ctrlreg[3] >> PAGE_SHIFT);
  17.133      if ( l4 == NULL )
  17.134          return NULL;
  17.135 @@ -349,7 +349,7 @@ map_domain_va(
  17.136              mode = MODE_64;
  17.137          else if ( strstr(caps, "-x86_32p") )
  17.138              mode = MODE_PAE;
  17.139 -        else if ( strstr(caps, "-x86_32") ) 
  17.140 +        else if ( strstr(caps, "-x86_32") )
  17.141              mode = MODE_32;
  17.142      }
  17.143  
  17.144 @@ -374,7 +374,7 @@ map_domain_va(
  17.145      if (fetch_regs(xc_handle, cpu, NULL))
  17.146          return NULL;
  17.147  
  17.148 -    if (!paging_enabled(&ctxt[cpu])) { 
  17.149 +    if (!paging_enabled(&ctxt[cpu])) {
  17.150          static void * v;
  17.151          unsigned long page;
  17.152  
  17.153 @@ -383,9 +383,9 @@ map_domain_va(
  17.154  
  17.155          page = page_array[va >> PAGE_SHIFT] << PAGE_SHIFT;
  17.156  
  17.157 -        v = xc_map_foreign_range( xc_handle, current_domid, PAGE_SIZE, 
  17.158 +        v = xc_map_foreign_range( xc_handle, current_domid, PAGE_SIZE,
  17.159                  perm, page >> PAGE_SHIFT);
  17.160 -    
  17.161 +
  17.162          if ( v == NULL )
  17.163              return NULL;
  17.164  
  17.165 @@ -403,7 +403,7 @@ map_domain_va(
  17.166  
  17.167  int control_c_pressed_flag = 0;
  17.168  
  17.169 -static int 
  17.170 +static int
  17.171  __xc_waitdomain(
  17.172      int xc_handle,
  17.173      int domain,
  17.174 @@ -420,7 +420,7 @@ static int
  17.175  
  17.176      op.cmd = DOM0_GETDOMAININFO;
  17.177      op.u.getdomaininfo.domain = domain;
  17.178 -    
  17.179 +
  17.180   retry:
  17.181      retval = do_dom0_op(xc_handle, &op);
  17.182      if ( retval || (op.u.getdomaininfo.domain != domain) )
  17.183 @@ -429,7 +429,7 @@ static int
  17.184          goto done;
  17.185      }
  17.186      *status = op.u.getdomaininfo.flags;
  17.187 -    
  17.188 +
  17.189      if ( options & WNOHANG )
  17.190          goto done;
  17.191  
  17.192 @@ -472,16 +472,16 @@ xc_ptrace(
  17.193      void           *data = (char *)edata;
  17.194  
  17.195      cpu = (request != PTRACE_ATTACH) ? domid_tid : 0;
  17.196 -    
  17.197 +
  17.198      switch ( request )
  17.199 -    { 
  17.200 +    {
  17.201      case PTRACE_PEEKTEXT:
  17.202      case PTRACE_PEEKDATA:
  17.203          if (current_isfile)
  17.204 -            guest_va = (unsigned long *)map_domain_va_core(current_domid, 
  17.205 +            guest_va = (unsigned long *)map_domain_va_core(current_domid,
  17.206                                  cpu, addr, ctxt);
  17.207          else
  17.208 -            guest_va = (unsigned long *)map_domain_va(xc_handle, 
  17.209 +            guest_va = (unsigned long *)map_domain_va(xc_handle,
  17.210                                  cpu, addr, PROT_READ);
  17.211          if ( guest_va == NULL )
  17.212              goto out_error;
  17.213 @@ -492,26 +492,26 @@ xc_ptrace(
  17.214      case PTRACE_POKEDATA:
  17.215          /* XXX assume that all CPUs have the same address space */
  17.216          if (current_isfile)
  17.217 -            guest_va = (unsigned long *)map_domain_va_core(current_domid, 
  17.218 +            guest_va = (unsigned long *)map_domain_va_core(current_domid,
  17.219                                  cpu, addr, ctxt);
  17.220          else
  17.221 -            guest_va = (unsigned long *)map_domain_va(xc_handle, 
  17.222 +            guest_va = (unsigned long *)map_domain_va(xc_handle,
  17.223                                  cpu, addr, PROT_READ|PROT_WRITE);
  17.224 -        if ( guest_va == NULL ) 
  17.225 +        if ( guest_va == NULL )
  17.226              goto out_error;
  17.227          *guest_va = (unsigned long)data;
  17.228          break;
  17.229  
  17.230      case PTRACE_GETREGS:
  17.231 -        if (!current_isfile && fetch_regs(xc_handle, cpu, NULL)) 
  17.232 +        if (!current_isfile && fetch_regs(xc_handle, cpu, NULL))
  17.233              goto out_error;
  17.234 -        SET_PT_REGS(pt, ctxt[cpu].user_regs); 
  17.235 +        SET_PT_REGS(pt, ctxt[cpu].user_regs);
  17.236          memcpy(data, &pt, sizeof(struct gdb_regs));
  17.237          break;
  17.238  
  17.239      case PTRACE_GETFPREGS:
  17.240      case PTRACE_GETFPXREGS:
  17.241 -        if (!current_isfile && fetch_regs(xc_handle, cpu, NULL)) 
  17.242 +        if (!current_isfile && fetch_regs(xc_handle, cpu, NULL))
  17.243                  goto out_error;
  17.244          memcpy(data, &ctxt[cpu].fpu_ctxt, sizeof(ctxt[cpu].fpu_ctxt));
  17.245          break;
  17.246 @@ -520,7 +520,7 @@ xc_ptrace(
  17.247          if (current_isfile)
  17.248                  goto out_unspported; /* XXX not yet supported */
  17.249          SET_XC_REGS(((struct gdb_regs *)data), ctxt[cpu].user_regs);
  17.250 -        if ((retval = xc_vcpu_setcontext(xc_handle, current_domid, cpu, 
  17.251 +        if ((retval = xc_vcpu_setcontext(xc_handle, current_domid, cpu,
  17.252                                  &ctxt[cpu])))
  17.253              goto out_error_dom0;
  17.254          break;
  17.255 @@ -531,8 +531,8 @@ xc_ptrace(
  17.256          /*  XXX we can still have problems if the user switches threads
  17.257           *  during single-stepping - but that just seems retarded
  17.258           */
  17.259 -        ctxt[cpu].user_regs.eflags |= PSL_T; 
  17.260 -        if ((retval = xc_vcpu_setcontext(xc_handle, current_domid, cpu, 
  17.261 +        ctxt[cpu].user_regs.eflags |= PSL_T;
  17.262 +        if ((retval = xc_vcpu_setcontext(xc_handle, current_domid, cpu,
  17.263                                  &ctxt[cpu])))
  17.264              goto out_error_dom0;
  17.265          /* FALLTHROUGH */
  17.266 @@ -545,13 +545,13 @@ xc_ptrace(
  17.267          {
  17.268              FOREACH_CPU(cpumap, index) {
  17.269                  cpu = index - 1;
  17.270 -                if (fetch_regs(xc_handle, cpu, NULL)) 
  17.271 +                if (fetch_regs(xc_handle, cpu, NULL))
  17.272                      goto out_error;
  17.273                  /* Clear trace flag */
  17.274 -                if ( ctxt[cpu].user_regs.eflags & PSL_T ) 
  17.275 +                if ( ctxt[cpu].user_regs.eflags & PSL_T )
  17.276                  {
  17.277                      ctxt[cpu].user_regs.eflags &= ~PSL_T;
  17.278 -                    if ((retval = xc_vcpu_setcontext(xc_handle, current_domid, 
  17.279 +                    if ((retval = xc_vcpu_setcontext(xc_handle, current_domid,
  17.280                                                  cpu, &ctxt[cpu])))
  17.281                          goto out_error_dom0;
  17.282                  }
  17.283 @@ -566,7 +566,7 @@ xc_ptrace(
  17.284                  goto out_error_dom0;
  17.285          }
  17.286          regs_valid = 0;
  17.287 -        if ((retval = xc_domain_unpause(xc_handle, current_domid > 0 ? 
  17.288 +        if ((retval = xc_domain_unpause(xc_handle, current_domid > 0 ?
  17.289                                  current_domid : -current_domid)))
  17.290              goto out_error_dom0;
  17.291          break;
  17.292 @@ -627,7 +627,7 @@ xc_ptrace(
  17.293  
  17.294  }
  17.295  
  17.296 -int 
  17.297 +int
  17.298  xc_waitdomain(
  17.299      int xc_handle,
  17.300      int domain,
    18.1 --- a/tools/libxc/xc_ptrace.h	Sat Apr 15 09:52:32 2006 +0100
    18.2 +++ b/tools/libxc/xc_ptrace.h	Sat Apr 15 10:07:31 2006 +0100
    18.3 @@ -107,7 +107,7 @@ struct gdb_regs {
    18.4      long esi; /* 12 */
    18.5      long edi; /* 16 */
    18.6      long ebp; /* 20 */
    18.7 -    long eax; /* 24 */ 
    18.8 +    long eax; /* 24 */
    18.9      int  xds; /* 28 */
   18.10      int  xes; /* 32 */
   18.11      int  xfs; /* 36 */
   18.12 @@ -116,7 +116,7 @@ struct gdb_regs {
   18.13      long eip;    /* 48 */
   18.14      int  xcs;    /* 52 */
   18.15      long eflags; /* 56 */
   18.16 -    long esp;    /* 60 */     
   18.17 +    long esp;    /* 60 */
   18.18      int  xss;    /* 64 */
   18.19  };
   18.20  
   18.21 @@ -169,20 +169,20 @@ struct gdb_regs {
   18.22  typedef void (*thr_ev_handler_t)(long);
   18.23  
   18.24  void xc_register_event_handler(
   18.25 -    thr_ev_handler_t h, 
   18.26 +    thr_ev_handler_t h,
   18.27      td_event_e e);
   18.28  
   18.29  long xc_ptrace(
   18.30      int xc_handle,
   18.31 -    enum __ptrace_request request, 
   18.32 +    enum __ptrace_request request,
   18.33      uint32_t  domid,
   18.34 -    long addr, 
   18.35 +    long addr,
   18.36      long data);
   18.37  
   18.38  int xc_waitdomain(
   18.39      int xc_handle,
   18.40 -    int domain, 
   18.41 -    int *status, 
   18.42 +    int domain,
   18.43 +    int *status,
   18.44      int options);
   18.45  
   18.46  #endif /* XC_PTRACE */
    19.1 --- a/tools/libxc/xc_ptrace_core.c	Sat Apr 15 09:52:32 2006 +0100
    19.2 +++ b/tools/libxc/xc_ptrace_core.c	Sat Apr 15 10:07:31 2006 +0100
    19.3 @@ -39,7 +39,7 @@ map_domain_va_core(unsigned long domfd, 
    19.4      static unsigned long  page_phys[MAX_VIRT_CPUS];
    19.5      static unsigned long *page_virt[MAX_VIRT_CPUS];
    19.6  
    19.7 -    if (cr3[cpu] != cr3_phys[cpu]) 
    19.8 +    if (cr3[cpu] != cr3_phys[cpu])
    19.9      {
   19.10          cr3_phys[cpu] = cr3[cpu];
   19.11          if (cr3_virt[cpu])
   19.12 @@ -53,12 +53,12 @@ map_domain_va_core(unsigned long domfd, 
   19.13              return NULL;
   19.14          }
   19.15          cr3_virt[cpu] = v;
   19.16 -    } 
   19.17 +    }
   19.18      if ((pde = cr3_virt[cpu][vtopdi(va)]) == 0) /* logical address */
   19.19          return NULL;
   19.20      if (ctxt[cpu].flags & VGCF_HVM_GUEST)
   19.21          pde = p2m_array[pde >> PAGE_SHIFT] << PAGE_SHIFT;
   19.22 -    if (pde != pde_phys[cpu]) 
   19.23 +    if (pde != pde_phys[cpu])
   19.24      {
   19.25          pde_phys[cpu] = pde;
   19.26          if (pde_virt[cpu])
   19.27 @@ -74,7 +74,7 @@ map_domain_va_core(unsigned long domfd, 
   19.28          return NULL;
   19.29      if (ctxt[cpu].flags & VGCF_HVM_GUEST)
   19.30          page = p2m_array[page >> PAGE_SHIFT] << PAGE_SHIFT;
   19.31 -    if (page != page_phys[cpu]) 
   19.32 +    if (page != page_phys[cpu])
   19.33      {
   19.34          page_phys[cpu] = page;
   19.35          if (page_virt[cpu])
   19.36 @@ -89,11 +89,11 @@ map_domain_va_core(unsigned long domfd, 
   19.37              return NULL;
   19.38          }
   19.39          page_virt[cpu] = v;
   19.40 -    } 
   19.41 +    }
   19.42      return (void *)(((unsigned long)page_virt[cpu]) | (va & BSD_PAGE_MASK));
   19.43  }
   19.44  
   19.45 -int 
   19.46 +int
   19.47  xc_waitdomain_core(
   19.48      int xc_handle,
   19.49      int domfd,
   19.50 @@ -122,7 +122,7 @@ xc_waitdomain_core(
   19.51          nr_vcpus = header.xch_nr_vcpus;
   19.52          pages_offset = header.xch_pages_offset;
   19.53  
   19.54 -        if (read(domfd, ctxt, sizeof(vcpu_guest_context_t)*nr_vcpus) != 
   19.55 +        if (read(domfd, ctxt, sizeof(vcpu_guest_context_t)*nr_vcpus) !=
   19.56              sizeof(vcpu_guest_context_t)*nr_vcpus)
   19.57              return -1;
   19.58  
   19.59 @@ -134,7 +134,7 @@ xc_waitdomain_core(
   19.60              printf("Could not allocate p2m_array\n");
   19.61              return -1;
   19.62          }
   19.63 -        if (read(domfd, p2m_array, sizeof(unsigned long)*nr_pages) != 
   19.64 +        if (read(domfd, p2m_array, sizeof(unsigned long)*nr_pages) !=
   19.65              sizeof(unsigned long)*nr_pages)
   19.66              return -1;
   19.67  
    20.1 --- a/tools/libxc/xc_sedf.c	Sat Apr 15 09:52:32 2006 +0100
    20.2 +++ b/tools/libxc/xc_sedf.c	Sat Apr 15 10:07:31 2006 +0100
    20.3 @@ -1,8 +1,8 @@
    20.4  /******************************************************************************
    20.5   * xc_sedf.c
    20.6 - * 
    20.7 + *
    20.8   * API for manipulating parameters of the Simple EDF scheduler.
    20.9 - * 
   20.10 + *
   20.11   * changes by Stephan Diestelhorst
   20.12   * based on code
   20.13   * by Mark Williamson, Copyright (c) 2004 Intel Research Cambridge.
   20.14 @@ -35,7 +35,7 @@ int xc_sedf_domain_get(int xc_handle, ui
   20.15      int ret;
   20.16      struct sedf_adjdom *p = &op.u.adjustdom.u.sedf;
   20.17  
   20.18 -    op.cmd = DOM0_ADJUSTDOM;    
   20.19 +    op.cmd = DOM0_ADJUSTDOM;
   20.20      op.u.adjustdom.domain = (domid_t)domid;
   20.21      op.u.adjustdom.sched_id = SCHED_SEDF;
   20.22      op.u.adjustdom.direction = SCHED_INFO_GET;
    21.1 --- a/tools/libxc/xc_tbuf.c	Sat Apr 15 09:52:32 2006 +0100
    21.2 +++ b/tools/libxc/xc_tbuf.c	Sat Apr 15 10:07:31 2006 +0100
    21.3 @@ -1,8 +1,8 @@
    21.4  /******************************************************************************
    21.5   * xc_tbuf.c
    21.6 - * 
    21.7 + *
    21.8   * API for manipulating and accessing trace buffer parameters
    21.9 - * 
   21.10 + *
   21.11   * Copyright (c) 2005, Rob Gardner
   21.12   */
   21.13  
   21.14 @@ -18,7 +18,7 @@ int xc_tbuf_enable(int xc_handle, int en
   21.15      op.u.tbufcontrol.op  = DOM0_TBUF_ENABLE;
   21.16    else
   21.17      op.u.tbufcontrol.op  = DOM0_TBUF_DISABLE;
   21.18 -  
   21.19 +
   21.20    return xc_dom0_op(xc_handle, &op);
   21.21  }
   21.22  
   21.23 @@ -30,10 +30,10 @@ int xc_tbuf_set_size(int xc_handle, uint
   21.24    op.interface_version = DOM0_INTERFACE_VERSION;
   21.25    op.u.tbufcontrol.op  = DOM0_TBUF_SET_SIZE;
   21.26    op.u.tbufcontrol.size = size;
   21.27 -  
   21.28 +
   21.29    return xc_dom0_op(xc_handle, &op);
   21.30  }
   21.31 -  
   21.32 +
   21.33  int xc_tbuf_get_size(int xc_handle, uint32_t *size)
   21.34  {
   21.35    int rc;
    22.1 --- a/tools/libxc/xenctrl.h	Sat Apr 15 09:52:32 2006 +0100
    22.2 +++ b/tools/libxc/xenctrl.h	Sat Apr 15 10:07:31 2006 +0100
    22.3 @@ -1,8 +1,8 @@
    22.4  /******************************************************************************
    22.5   * xenctrl.h
    22.6 - * 
    22.7 + *
    22.8   * A library for low-level access to the Xen control interfaces.
    22.9 - * 
   22.10 + *
   22.11   * Copyright (c) 2003-2004, K A Fraser.
   22.12   */
   22.13  
   22.14 @@ -30,7 +30,7 @@
   22.15  
   22.16  /*
   22.17   *  DEFINITIONS FOR CPU BARRIERS
   22.18 - */ 
   22.19 + */
   22.20  
   22.21  #if defined(__i386__)
   22.22  #define mb()  __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
   22.23 @@ -51,7 +51,7 @@
   22.24  
   22.25  /*
   22.26   *  INITIALIZATION FUNCTIONS
   22.27 - */ 
   22.28 + */
   22.29  
   22.30  /**
   22.31   * This function opens a handle to the hypervisor interface.  This function can
   22.32 @@ -96,20 +96,20 @@ typedef struct xc_core_header {
   22.33  
   22.34  long xc_ptrace_core(
   22.35      int xc_handle,
   22.36 -    enum __ptrace_request request, 
   22.37 -    uint32_t domid, 
   22.38 -    long addr, 
   22.39 +    enum __ptrace_request request,
   22.40 +    uint32_t domid,
   22.41 +    long addr,
   22.42      long data,
   22.43      vcpu_guest_context_t *ctxt);
   22.44  void * map_domain_va_core(
   22.45 -    unsigned long domfd, 
   22.46 -    int cpu, 
   22.47 +    unsigned long domfd,
   22.48 +    int cpu,
   22.49      void *guest_va,
   22.50      vcpu_guest_context_t *ctxt);
   22.51  int xc_waitdomain_core(
   22.52      int xc_handle,
   22.53 -    int domain, 
   22.54 -    int *status, 
   22.55 +    int domain,
   22.56 +    int *status,
   22.57      int options,
   22.58      vcpu_guest_context_t *ctxt);
   22.59  
   22.60 @@ -120,7 +120,7 @@ int xc_waitdomain_core(
   22.61  typedef struct {
   22.62      uint32_t      domid;
   22.63      uint32_t      ssidref;
   22.64 -    unsigned int  dying:1, crashed:1, shutdown:1, 
   22.65 +    unsigned int  dying:1, crashed:1, shutdown:1,
   22.66                    paused:1, blocked:1, running:1;
   22.67      unsigned int  shutdown_reason; /* only meaningful if shutdown==1 */
   22.68      unsigned long nr_pages;
   22.69 @@ -133,7 +133,7 @@ typedef struct {
   22.70  } xc_dominfo_t;
   22.71  
   22.72  typedef dom0_getdomaininfo_t xc_domaininfo_t;
   22.73 -int xc_domain_create(int xc_handle, 
   22.74 +int xc_domain_create(int xc_handle,
   22.75                       uint32_t ssidref,
   22.76                       xen_domain_handle_t handle,
   22.77                       uint32_t *pdomid);
   22.78 @@ -144,7 +144,7 @@ int xc_domain_create(int xc_handle,
   22.79   *  xc_domain_dumpcore_via_callback - produces a dump, using a specified
   22.80   *                                    callback function
   22.81   */
   22.82 -int xc_domain_dumpcore(int xc_handle, 
   22.83 +int xc_domain_dumpcore(int xc_handle,
   22.84                         uint32_t domid,
   22.85                         const char *corename);
   22.86  
   22.87 @@ -156,7 +156,7 @@ int xc_domain_dumpcore(int xc_handle,
   22.88   */
   22.89  typedef int (dumpcore_rtn_t)(void *arg, char *buffer, unsigned int length);
   22.90  
   22.91 -int xc_domain_dumpcore_via_callback(int xc_handle, 
   22.92 +int xc_domain_dumpcore_via_callback(int xc_handle,
   22.93                                      uint32_t domid,
   22.94                                      void *arg,
   22.95                                      dumpcore_rtn_t dump_rtn);
   22.96 @@ -170,7 +170,7 @@ int xc_domain_dumpcore_via_callback(int 
   22.97   * @return 0 on success, -1 on failure.
   22.98   */
   22.99  int xc_domain_max_vcpus(int xc_handle,
  22.100 -                        uint32_t domid, 
  22.101 +                        uint32_t domid,
  22.102                          unsigned int max);
  22.103  
  22.104  /**
  22.105 @@ -181,7 +181,7 @@ int xc_domain_max_vcpus(int xc_handle,
  22.106   * @parm domid the domain id to pause
  22.107   * @return 0 on success, -1 on failure.
  22.108   */
  22.109 -int xc_domain_pause(int xc_handle, 
  22.110 +int xc_domain_pause(int xc_handle,
  22.111                      uint32_t domid);
  22.112  /**
  22.113   * This function unpauses a domain.  The domain should have been previously
  22.114 @@ -191,7 +191,7 @@ int xc_domain_pause(int xc_handle,
  22.115   * @parm domid the domain id to unpause
  22.116   * return 0 on success, -1 on failure
  22.117   */
  22.118 -int xc_domain_unpause(int xc_handle, 
  22.119 +int xc_domain_unpause(int xc_handle,
  22.120                        uint32_t domid);
  22.121  
  22.122  /**
  22.123 @@ -203,7 +203,7 @@ int xc_domain_unpause(int xc_handle,
  22.124   * @parm domid the domain id to destroy
  22.125   * @return 0 on success, -1 on failure
  22.126   */
  22.127 -int xc_domain_destroy(int xc_handle, 
  22.128 +int xc_domain_destroy(int xc_handle,
  22.129                        uint32_t domid);
  22.130  
  22.131  /**
  22.132 @@ -217,7 +217,7 @@ int xc_domain_destroy(int xc_handle,
  22.133   * @parm reason is the reason (SHUTDOWN_xxx) for the shutdown
  22.134   * @return 0 on success, -1 on failure
  22.135   */
  22.136 -int xc_domain_shutdown(int xc_handle, 
  22.137 +int xc_domain_shutdown(int xc_handle,
  22.138                         uint32_t domid,
  22.139                         int reason);
  22.140  
  22.141 @@ -242,7 +242,7 @@ int xc_vcpu_setaffinity(int xc_handle,
  22.142   * @return the number of domains enumerated or -1 on error
  22.143   */
  22.144  int xc_domain_getinfo(int xc_handle,
  22.145 -                      uint32_t first_domid, 
  22.146 +                      uint32_t first_domid,
  22.147                        unsigned int max_doms,
  22.148                        xc_dominfo_t *info);
  22.149  
  22.150 @@ -307,12 +307,12 @@ long long xc_domain_get_cpu_usage(int xc
  22.151                                    domid_t domid,
  22.152                                    int vcpu);
  22.153  
  22.154 -int xc_domain_sethandle(int xc_handle, uint32_t domid, 
  22.155 +int xc_domain_sethandle(int xc_handle, uint32_t domid,
  22.156                          xen_domain_handle_t handle);
  22.157  
  22.158  typedef dom0_shadow_control_stats_t xc_shadow_control_stats_t;
  22.159  int xc_shadow_control(int xc_handle,
  22.160 -                      uint32_t domid, 
  22.161 +                      uint32_t domid,
  22.162                        unsigned int sop,
  22.163                        unsigned long *dirty_bitmap,
  22.164                        unsigned long pages,
  22.165 @@ -386,7 +386,7 @@ int xc_physdev_pci_access_modify(int xc_
  22.166  
  22.167  int xc_readconsolering(int xc_handle,
  22.168                         char **pbuffer,
  22.169 -                       unsigned int *pnr_chars, 
  22.170 +                       unsigned int *pnr_chars,
  22.171                         int clear);
  22.172  
  22.173  typedef dom0_physinfo_t xc_physinfo_t;
  22.174 @@ -397,18 +397,18 @@ int xc_sched_id(int xc_handle,
  22.175                  int *sched_id);
  22.176  
  22.177  int xc_domain_setmaxmem(int xc_handle,
  22.178 -                        uint32_t domid, 
  22.179 +                        uint32_t domid,
  22.180                          unsigned int max_memkb);
  22.181  
  22.182  int xc_domain_memory_increase_reservation(int xc_handle,
  22.183 -                                          uint32_t domid, 
  22.184 +                                          uint32_t domid,
  22.185                                            unsigned long nr_extents,
  22.186                                            unsigned int extent_order,
  22.187                                            unsigned int address_bits,
  22.188                                            unsigned long *extent_start);
  22.189  
  22.190  int xc_domain_memory_decrease_reservation(int xc_handle,
  22.191 -                                          uint32_t domid, 
  22.192 +                                          uint32_t domid,
  22.193                                            unsigned long nr_extents,
  22.194                                            unsigned int extent_order,
  22.195                                            unsigned long *extent_start);
  22.196 @@ -443,7 +443,7 @@ int xc_domain_iomem_permission(int xc_ha
  22.197                                 unsigned long nr_mfns,
  22.198                                 uint8_t allow_access);
  22.199  
  22.200 -unsigned long xc_make_page_below_4G(int xc_handle, uint32_t domid, 
  22.201 +unsigned long xc_make_page_below_4G(int xc_handle, uint32_t domid,
  22.202                                      unsigned long mfn);
  22.203  
  22.204  typedef dom0_perfc_desc_t xc_perfc_desc_t;
  22.205 @@ -492,11 +492,11 @@ void *xc_map_foreign_batch(int xc_handle
  22.206  unsigned long xc_translate_foreign_address(int xc_handle, uint32_t dom,
  22.207                                             int vcpu, unsigned long long virt);
  22.208  
  22.209 -int xc_get_pfn_list(int xc_handle, uint32_t domid, unsigned long *pfn_buf, 
  22.210 +int xc_get_pfn_list(int xc_handle, uint32_t domid, unsigned long *pfn_buf,
  22.211                      unsigned long max_pfns);
  22.212  
  22.213  int xc_ia64_get_pfn_list(int xc_handle, uint32_t domid,
  22.214 -                         unsigned long *pfn_buf, 
  22.215 +                         unsigned long *pfn_buf,
  22.216                           unsigned int start_page, unsigned int nr_pages);
  22.217  
  22.218  int xc_copy_to_domain_page(int xc_handle, uint32_t domid,
  22.219 @@ -551,7 +551,7 @@ int xc_tbuf_enable(int xc_handle, int en
  22.220  int xc_tbuf_set_size(int xc_handle, uint32_t size);
  22.221  
  22.222  /**
  22.223 - * This function retrieves the current size of the trace buffers. 
  22.224 + * This function retrieves the current size of the trace buffers.
  22.225   * Note that the size returned is in terms of bytes, not pages.
  22.226  
  22.227   * @parm xc_handle a handle to an open hypervisor interface
  22.228 @@ -577,7 +577,7 @@ struct xc_mmu {
  22.229  };
  22.230  typedef struct xc_mmu xc_mmu_t;
  22.231  xc_mmu_t *xc_init_mmu_updates(int xc_handle, domid_t dom);
  22.232 -int xc_add_mmu_update(int xc_handle, xc_mmu_t *mmu, 
  22.233 +int xc_add_mmu_update(int xc_handle, xc_mmu_t *mmu,
  22.234                     unsigned long long ptr, unsigned long long val);
  22.235  int xc_finish_mmu_updates(int xc_handle, xc_mmu_t *mmu);
  22.236  
    23.1 --- a/tools/libxc/xenguest.h	Sat Apr 15 09:52:32 2006 +0100
    23.2 +++ b/tools/libxc/xenguest.h	Sat Apr 15 10:07:31 2006 +0100
    23.3 @@ -1,8 +1,8 @@
    23.4  /******************************************************************************
    23.5   * xenguest.h
    23.6 - * 
    23.7 + *
    23.8   * A library for guest domain management in Xen.
    23.9 - * 
   23.10 + *
   23.11   * Copyright (c) 2003-2004, K A Fraser.
   23.12   */
   23.13  
   23.14 @@ -21,7 +21,7 @@
   23.15   * @parm dom the id of the domain
   23.16   * @return 0 on success, -1 on failure
   23.17   */
   23.18 -int xc_linux_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters, 
   23.19 +int xc_linux_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
   23.20                    uint32_t max_factor, uint32_t flags /* XCFLAGS_xxx */,
   23.21                    int (*suspend)(int domid));
   23.22  
   23.23 @@ -37,8 +37,8 @@ int xc_linux_save(int xc_handle, int io_
   23.24   * @parm store_mfn returned with the mfn of the store page
   23.25   * @return 0 on success, -1 on failure
   23.26   */
   23.27 -int xc_linux_restore(int xc_handle, int io_fd, uint32_t dom, 
   23.28 -                     unsigned long nr_pfns, unsigned int store_evtchn, 
   23.29 +int xc_linux_restore(int xc_handle, int io_fd, uint32_t dom,
   23.30 +                     unsigned long nr_pfns, unsigned int store_evtchn,
   23.31                       unsigned long *store_mfn, unsigned int console_evtchn,
   23.32                       unsigned long *console_mfn);
   23.33  
    24.1 --- a/tools/libxc/xg_private.c	Sat Apr 15 09:52:32 2006 +0100
    24.2 +++ b/tools/libxc/xg_private.c	Sat Apr 15 10:07:31 2006 +0100
    24.3 @@ -1,6 +1,6 @@
    24.4  /******************************************************************************
    24.5   * xg_private.c
    24.6 - * 
    24.7 + *
    24.8   * Helper functions for the rest of the library.
    24.9   */
   24.10  
    25.1 --- a/tools/libxc/xg_private.h	Sat Apr 15 09:52:32 2006 +0100
    25.2 +++ b/tools/libxc/xg_private.h	Sat Apr 15 10:07:31 2006 +0100
    25.3 @@ -11,7 +11,7 @@
    25.4  #include <sys/stat.h>
    25.5  
    25.6  #include "xenctrl.h"
    25.7 -#include "xenguest.h" 
    25.8 +#include "xenguest.h"
    25.9  
   25.10  #include <xen/linux/privcmd.h>
   25.11  #include <xen/memory.h>
   25.12 @@ -62,7 +62,7 @@ unsigned long csum_page (void * page);
   25.13  #define L2_PAGETABLE_ENTRIES_PAE  512
   25.14  #define L3_PAGETABLE_ENTRIES_PAE    4
   25.15  
   25.16 -#if defined(__i386__) 
   25.17 +#if defined(__i386__)
   25.18  #define L1_PAGETABLE_ENTRIES   1024
   25.19  #define L2_PAGETABLE_ENTRIES   1024
   25.20  #elif defined(__x86_64__)
   25.21 @@ -71,7 +71,7 @@ unsigned long csum_page (void * page);
   25.22  #define L3_PAGETABLE_ENTRIES    512
   25.23  #define L4_PAGETABLE_ENTRIES    512
   25.24  #endif
   25.25 - 
   25.26 +
   25.27  #define PAGE_SHIFT              XC_PAGE_SHIFT
   25.28  #define PAGE_SIZE               (1UL << PAGE_SHIFT)
   25.29  #define PAGE_MASK               (~(PAGE_SIZE-1))
   25.30 @@ -167,8 +167,8 @@ typedef struct mfn_mapper {
   25.31      int error;
   25.32      int max_queue_size;
   25.33      void * addr;
   25.34 -    privcmd_mmap_t ioctl; 
   25.35 -    
   25.36 +    privcmd_mmap_t ioctl;
   25.37 +
   25.38  } mfn_mapper_t;
   25.39  
   25.40  int xc_copy_to_domain_page(int xc_handle, uint32_t domid,
    26.1 --- a/tools/libxc/xg_save_restore.h	Sat Apr 15 09:52:32 2006 +0100
    26.2 +++ b/tools/libxc/xg_save_restore.h	Sat Apr 15 10:07:31 2006 +0100
    26.3 @@ -1,7 +1,7 @@
    26.4  /*
    26.5  ** xg_save_restore.h
    26.6 -** 
    26.7 -** Defintions and utilities for save / restore. 
    26.8 +**
    26.9 +** Defintions and utilities for save / restore.
   26.10  */
   26.11  
   26.12  #include "xc_private.h"
   26.13 @@ -29,8 +29,8 @@ while (0)
   26.14  
   26.15  
   26.16  /*
   26.17 -** We process save/restore/migrate in batches of pages; the below 
   26.18 -** determines how many pages we (at maximum) deal with in each batch. 
   26.19 +** We process save/restore/migrate in batches of pages; the below
   26.20 +** determines how many pages we (at maximum) deal with in each batch.
   26.21  */
   26.22  #define MAX_BATCH_SIZE 1024   /* up to 1024 pages (4MB) at a time */
   26.23  
   26.24 @@ -40,56 +40,56 @@ while (0)
   26.25  
   26.26  
   26.27  /*
   26.28 -** Determine various platform information required for save/restore, in 
   26.29 -** particular: 
   26.30 +** Determine various platform information required for save/restore, in
   26.31 +** particular:
   26.32  **
   26.33 -**    - the maximum MFN on this machine, used to compute the size of 
   26.34 -**      the M2P table; 
   26.35 -** 
   26.36 -**    - the starting virtual address of the the hypervisor; we use this 
   26.37 -**      to determine which parts of guest address space(s) do and don't 
   26.38 -**      require canonicalization during save/restore; and 
   26.39 -** 
   26.40 -**    - the number of page-table levels for save/ restore. This should 
   26.41 -**      be a property of the domain, but for the moment we just read it 
   26.42 +**    - the maximum MFN on this machine, used to compute the size of
   26.43 +**      the M2P table;
   26.44 +**
   26.45 +**    - the starting virtual address of the the hypervisor; we use this
   26.46 +**      to determine which parts of guest address space(s) do and don't
   26.47 +**      require canonicalization during save/restore; and
   26.48 +**
   26.49 +**    - the number of page-table levels for save/ restore. This should
   26.50 +**      be a property of the domain, but for the moment we just read it
   26.51  **      from the hypervisor.
   26.52  **
   26.53 -** Returns 1 on success, 0 on failure. 
   26.54 +** Returns 1 on success, 0 on failure.
   26.55  */
   26.56 -static int get_platform_info(int xc_handle, uint32_t dom, 
   26.57 -                             /* OUT */ unsigned long *max_mfn,  
   26.58 -                             /* OUT */ unsigned long *hvirt_start, 
   26.59 +static int get_platform_info(int xc_handle, uint32_t dom,
   26.60 +                             /* OUT */ unsigned long *max_mfn,
   26.61 +                             /* OUT */ unsigned long *hvirt_start,
   26.62                               /* OUT */ unsigned int *pt_levels)
   26.63 -    
   26.64 -{ 
   26.65 +
   26.66 +{
   26.67      xen_capabilities_info_t xen_caps = "";
   26.68      xen_platform_parameters_t xen_params;
   26.69  
   26.70      if (xc_version(xc_handle, XENVER_platform_parameters, &xen_params) != 0)
   26.71          return 0;
   26.72 -    
   26.73 +
   26.74      if (xc_version(xc_handle, XENVER_capabilities, &xen_caps) != 0)
   26.75          return 0;
   26.76  
   26.77      *max_mfn = xc_memory_op(xc_handle, XENMEM_maximum_ram_page, NULL);
   26.78 -    
   26.79 +
   26.80      *hvirt_start = xen_params.virt_start;
   26.81  
   26.82      if (strstr(xen_caps, "xen-3.0-x86_64"))
   26.83          *pt_levels = 4;
   26.84      else if (strstr(xen_caps, "xen-3.0-x86_32p"))
   26.85 -        *pt_levels = 3; 
   26.86 +        *pt_levels = 3;
   26.87      else if (strstr(xen_caps, "xen-3.0-x86_32"))
   26.88 -        *pt_levels = 2; 
   26.89 -    else 
   26.90 -        return 0; 
   26.91 -    
   26.92 +        *pt_levels = 2;
   26.93 +    else
   26.94 +        return 0;
   26.95 +
   26.96      return 1;
   26.97 -} 
   26.98 +}
   26.99  
  26.100  
  26.101 -/* 
  26.102 -** Save/restore deal with the mfn_to_pfn (M2P) and pfn_to_mfn (P2M) tables. 
  26.103 +/*
  26.104 +** Save/restore deal with the mfn_to_pfn (M2P) and pfn_to_mfn (P2M) tables.
  26.105  ** The M2P simply holds the corresponding PFN, while the top bit of a P2M
  26.106  ** entry tell us whether or not the the PFN is currently mapped.
  26.107  */
  26.108 @@ -98,18 +98,18 @@ static int get_platform_info(int xc_hand
  26.109  #define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1))
  26.110  
  26.111  
  26.112 -/* 
  26.113 -** The M2P is made up of some number of 'chunks' of at least 2MB in size. 
  26.114 -** The below definitions and utility function(s) deal with mapping the M2P 
  26.115 -** regarldess of the underlying machine memory size or architecture. 
  26.116 +/*
  26.117 +** The M2P is made up of some number of 'chunks' of at least 2MB in size.
  26.118 +** The below definitions and utility function(s) deal with mapping the M2P
  26.119 +** regarldess of the underlying machine memory size or architecture.
  26.120  */
  26.121 -#define M2P_SHIFT       L2_PAGETABLE_SHIFT_PAE 
  26.122 -#define M2P_CHUNK_SIZE  (1 << M2P_SHIFT) 
  26.123 -#define M2P_SIZE(_m)    ROUNDUP(((_m) * sizeof(unsigned long)), M2P_SHIFT) 
  26.124 +#define M2P_SHIFT       L2_PAGETABLE_SHIFT_PAE
  26.125 +#define M2P_CHUNK_SIZE  (1 << M2P_SHIFT)
  26.126 +#define M2P_SIZE(_m)    ROUNDUP(((_m) * sizeof(unsigned long)), M2P_SHIFT)
  26.127  #define M2P_CHUNKS(_m)  (M2P_SIZE((_m)) >> M2P_SHIFT)
  26.128  
  26.129  /* Size in bytes of the P2M (rounded up to the nearest PAGE_SIZE bytes) */
  26.130 -#define P2M_SIZE        ROUNDUP((max_pfn * sizeof(unsigned long)), PAGE_SHIFT) 
  26.131 +#define P2M_SIZE        ROUNDUP((max_pfn * sizeof(unsigned long)), PAGE_SHIFT)
  26.132  
  26.133  /* Number of unsigned longs in a page */
  26.134  #define ulpp            (PAGE_SIZE/sizeof(unsigned long))
  26.135 @@ -127,12 +127,12 @@ static int get_platform_info(int xc_hand
  26.136  #define NR_SLACK_ENTRIES   ((8 * 1024 * 1024) / PAGE_SIZE)
  26.137  
  26.138  /* Is the given PFN within the 'slack' region at the top of the P2M? */
  26.139 -#define IS_REAL_PFN(_pfn)  ((max_pfn - (_pfn)) > NR_SLACK_ENTRIES) 
  26.140 +#define IS_REAL_PFN(_pfn)  ((max_pfn - (_pfn)) > NR_SLACK_ENTRIES)
  26.141  
  26.142  /* Returns TRUE if the PFN is currently mapped */
  26.143  #define is_mapped(pfn_type) (!((pfn_type) & 0x80000000UL))
  26.144  
  26.145 -#define INVALID_P2M_ENTRY   (~0UL) 
  26.146 +#define INVALID_P2M_ENTRY   (~0UL)
  26.147  
  26.148  
  26.149