ia64/xen-unstable

changeset 14115:c051ed67258a

libxc: Code format cleanups.
Signed-off-by: Keir Fraser <keir@xensource.com>
author Keir Fraser <keir@xensource.com>
date Sat Feb 24 15:30:19 2007 +0000 (2007-02-24)
parents 59b8d5168cc1
children fd7f23e44b11
files tools/libxc/xc_dom.h tools/libxc/xc_dom_binloader.c tools/libxc/xc_dom_boot.c tools/libxc/xc_dom_compat_linux.c tools/libxc/xc_dom_core.c tools/libxc/xc_dom_elfloader.c tools/libxc/xc_dom_ia64.c tools/libxc/xc_dom_x86.c tools/libxc/xc_efi.h tools/libxc/xc_private.c tools/libxc/xg_private.c
line diff
     1.1 --- a/tools/libxc/xc_dom.h	Sat Feb 24 14:48:17 2007 +0000
     1.2 +++ b/tools/libxc/xc_dom.h	Sat Feb 24 15:30:19 2007 +0000
     1.3 @@ -158,9 +158,9 @@ int xc_dom_try_gunzip(struct xc_dom_imag
     1.4  int xc_dom_kernel_file(struct xc_dom_image *dom, const char *filename);
     1.5  int xc_dom_ramdisk_file(struct xc_dom_image *dom, const char *filename);
     1.6  int xc_dom_kernel_mem(struct xc_dom_image *dom, const void *mem,
     1.7 -		      size_t memsize);
     1.8 +                      size_t memsize);
     1.9  int xc_dom_ramdisk_mem(struct xc_dom_image *dom, const void *mem,
    1.10 -		       size_t memsize);
    1.11 +                       size_t memsize);
    1.12  
    1.13  int xc_dom_parse_image(struct xc_dom_image *dom);
    1.14  int xc_dom_build_image(struct xc_dom_image *dom);
    1.15 @@ -169,7 +169,7 @@ int xc_dom_update_guest_p2m(struct xc_do
    1.16  int xc_dom_boot_xen_init(struct xc_dom_image *dom, int xc, domid_t domid);
    1.17  int xc_dom_boot_mem_init(struct xc_dom_image *dom);
    1.18  void *xc_dom_boot_domU_map(struct xc_dom_image *dom, xen_pfn_t pfn,
    1.19 -			   xen_pfn_t count);
    1.20 +                           xen_pfn_t count);
    1.21  int xc_dom_boot_image(struct xc_dom_image *dom);
    1.22  int xc_dom_compat_check(struct xc_dom_image *dom);
    1.23  
    1.24 @@ -180,12 +180,12 @@ extern FILE *xc_dom_logfile;
    1.25  void xc_dom_loginit(void);
    1.26  int xc_dom_printf(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
    1.27  int xc_dom_panic_func(const char *file, int line, xc_error_code err,
    1.28 -		      const char *fmt, ...)
    1.29 +                      const char *fmt, ...)
    1.30      __attribute__ ((format(printf, 4, 5)));
    1.31  #define xc_dom_panic(err, fmt, args...) \
    1.32 -	xc_dom_panic_func(__FILE__, __LINE__, err, fmt, ## args)
    1.33 +    xc_dom_panic_func(__FILE__, __LINE__, err, fmt, ## args)
    1.34  #define xc_dom_trace(mark) \
    1.35 -	xc_dom_printf("%s:%d: trace %s\n", __FILE__, __LINE__, mark)
    1.36 +    xc_dom_printf("%s:%d: trace %s\n", __FILE__, __LINE__, mark)
    1.37  
    1.38  void xc_dom_log_memory_footprint(struct xc_dom_image *dom);
    1.39  
    1.40 @@ -194,25 +194,25 @@ void xc_dom_log_memory_footprint(struct 
    1.41  void *xc_dom_malloc(struct xc_dom_image *dom, size_t size);
    1.42  void *xc_dom_malloc_page_aligned(struct xc_dom_image *dom, size_t size);
    1.43  void *xc_dom_malloc_filemap(struct xc_dom_image *dom,
    1.44 -			    const char *filename, size_t * size);
    1.45 +                            const char *filename, size_t * size);
    1.46  char *xc_dom_strdup(struct xc_dom_image *dom, const char *str);
    1.47  
    1.48  /* --- alloc memory pool ------------------------------------------- */
    1.49  
    1.50  int xc_dom_alloc_page(struct xc_dom_image *dom, char *name);
    1.51  int xc_dom_alloc_segment(struct xc_dom_image *dom,
    1.52 -			 struct xc_dom_seg *seg, char *name,
    1.53 -			 xen_vaddr_t start, xen_vaddr_t size);
    1.54 +                         struct xc_dom_seg *seg, char *name,
    1.55 +                         xen_vaddr_t start, xen_vaddr_t size);
    1.56  
    1.57  /* --- misc bits --------------------------------------------------- */
    1.58  
    1.59  void *xc_dom_pfn_to_ptr(struct xc_dom_image *dom, xen_pfn_t first,
    1.60 -			xen_pfn_t count);
    1.61 +                        xen_pfn_t count);
    1.62  void xc_dom_unmap_one(struct xc_dom_image *dom, xen_pfn_t pfn);
    1.63  void xc_dom_unmap_all(struct xc_dom_image *dom);
    1.64  
    1.65  static inline void *xc_dom_seg_to_ptr(struct xc_dom_image *dom,
    1.66 -				      struct xc_dom_seg *seg)
    1.67 +                                      struct xc_dom_seg *seg)
    1.68  {
    1.69      xen_vaddr_t segsize = seg->vend - seg->vstart;
    1.70      unsigned int page_size = XC_DOM_PAGE_SIZE(dom);
    1.71 @@ -222,16 +222,13 @@ static inline void *xc_dom_seg_to_ptr(st
    1.72  }
    1.73  
    1.74  static inline void *xc_dom_vaddr_to_ptr(struct xc_dom_image *dom,
    1.75 -					xen_vaddr_t vaddr)
    1.76 +                                        xen_vaddr_t vaddr)
    1.77  {
    1.78      unsigned int page_size = XC_DOM_PAGE_SIZE(dom);
    1.79      xen_pfn_t page = (vaddr - dom->parms.virt_base) / page_size;
    1.80      unsigned int offset = (vaddr - dom->parms.virt_base) % page_size;
    1.81      void *ptr = xc_dom_pfn_to_ptr(dom, page, 0);
    1.82 -
    1.83 -    if (!ptr)
    1.84 -	return NULL;
    1.85 -    return ptr + offset;
    1.86 +    return (ptr ? (ptr + offset) : NULL);
    1.87  }
    1.88  
    1.89  static inline int xc_dom_feature_translated(struct xc_dom_image *dom)
    1.90 @@ -242,17 +239,26 @@ static inline int xc_dom_feature_transla
    1.91  static inline xen_pfn_t xc_dom_p2m_host(struct xc_dom_image *dom, xen_pfn_t pfn)
    1.92  {
    1.93      if (dom->shadow_enabled)
    1.94 -	return pfn;
    1.95 +        return pfn;
    1.96      return dom->p2m_host[pfn];
    1.97  }
    1.98  
    1.99  static inline xen_pfn_t xc_dom_p2m_guest(struct xc_dom_image *dom,
   1.100 -					 xen_pfn_t pfn)
   1.101 +                                         xen_pfn_t pfn)
   1.102  {
   1.103      if (xc_dom_feature_translated(dom))
   1.104 -	return pfn;
   1.105 +        return pfn;
   1.106      return dom->p2m_host[pfn];
   1.107  }
   1.108  
   1.109  /* --- arch bits --------------------------------------------------- */
   1.110  
   1.111 +/*
   1.112 + * Local variables:
   1.113 + * mode: C
   1.114 + * c-set-style: "BSD"
   1.115 + * c-basic-offset: 4
   1.116 + * tab-width: 4
   1.117 + * indent-tabs-mode: nil
   1.118 + * End:
   1.119 + */
     2.1 --- a/tools/libxc/xc_dom_binloader.c	Sat Feb 24 14:48:17 2007 +0000
     2.2 +++ b/tools/libxc/xc_dom_binloader.c	Sat Feb 24 15:30:19 2007 +0000
     2.3 @@ -95,7 +95,7 @@ struct xen_bin_image_table
     2.4  
     2.5  /* Flags we test for */
     2.6  #define FLAGS_MASK     ((~ 0) & (~ XEN_MULTIBOOT_FLAG_ALIGN4K) & \
     2.7 -				(~ XEN_MULTIBOOT_FLAG_PAE_MASK))
     2.8 +    (~ XEN_MULTIBOOT_FLAG_PAE_MASK))
     2.9  #define FLAGS_REQUIRED XEN_MULTIBOOT_FLAG_ADDRSVALID
    2.10  
    2.11  /* --------------------------------------------------------------------- */
    2.12 @@ -108,19 +108,17 @@ static struct xen_bin_image_table *find_
    2.13  
    2.14      probe_ptr = dom->kernel_blob;
    2.15      probe_end = dom->kernel_blob + dom->kernel_size - sizeof(*table);
    2.16 -    if ((void*)probe_end > dom->kernel_blob + 8192)
    2.17 +    if ( (void*)probe_end > (dom->kernel_blob + 8192) )
    2.18          probe_end = dom->kernel_blob + 8192;
    2.19  
    2.20 -    for (table = NULL; probe_ptr < probe_end; probe_ptr++)
    2.21 +    for ( table = NULL; probe_ptr < probe_end; probe_ptr++ )
    2.22      {
    2.23 -        if (XEN_MULTIBOOT_MAGIC3 == *probe_ptr)
    2.24 +        if ( *probe_ptr == XEN_MULTIBOOT_MAGIC3 )
    2.25          {
    2.26              table = (struct xen_bin_image_table *) probe_ptr;
    2.27              /* Checksum correct? */
    2.28 -            if (0 == table->magic + table->flags + table->checksum)
    2.29 -            {
    2.30 +            if ( (table->magic + table->flags + table->checksum) == 0 )
    2.31                  return table;
    2.32 -            }
    2.33          }
    2.34      }
    2.35      return NULL;
    2.36 @@ -128,12 +126,7 @@ static struct xen_bin_image_table *find_
    2.37  
    2.38  static int xc_dom_probe_bin_kernel(struct xc_dom_image *dom)
    2.39  {
    2.40 -    struct xen_bin_image_table *table;
    2.41 -
    2.42 -    table = find_table(dom);
    2.43 -    if (!table)
    2.44 -        return -EINVAL;
    2.45 -    return 0;
    2.46 +    return find_table(dom) ? 0 : -EINVAL;
    2.47  }
    2.48  
    2.49  static int xc_dom_parse_bin_kernel(struct xc_dom_image *dom)
    2.50 @@ -147,7 +140,7 @@ static int xc_dom_parse_bin_kernel(struc
    2.51      uint32_t pae_flags;
    2.52  
    2.53      image_info = find_table(dom);
    2.54 -    if (!image_info)
    2.55 +    if ( !image_info )
    2.56          return -EINVAL;
    2.57  
    2.58      xc_dom_printf("%s: multiboot header fields\n", __FUNCTION__);
    2.59 @@ -159,7 +152,7 @@ static int xc_dom_parse_bin_kernel(struc
    2.60      xc_dom_printf("  entry_addr:    0x%" PRIx32 "\n", image_info->entry_addr);
    2.61  
    2.62      /* Check the flags */
    2.63 -    if ( FLAGS_REQUIRED != (image_info->flags & FLAGS_MASK) )
    2.64 +    if ( (image_info->flags & FLAGS_MASK) != FLAGS_REQUIRED )
    2.65      {
    2.66          xc_dom_panic(XC_INVALID_KERNEL,
    2.67                       "%s: xen_bin_image_table flags required "
    2.68 @@ -169,7 +162,7 @@ static int xc_dom_parse_bin_kernel(struc
    2.69      }
    2.70  
    2.71      /* Sanity check on the addresses */
    2.72 -    if ( image_info->header_addr < image_info->load_addr ||
    2.73 +    if ( (image_info->header_addr < image_info->load_addr) ||
    2.74           ((char *) image_info - image) <
    2.75           (image_info->header_addr - image_info->load_addr) )
    2.76      {
    2.77 @@ -187,7 +180,7 @@ static int xc_dom_parse_bin_kernel(struc
    2.78      xc_dom_printf("  load_end_addr: 0x%" PRIx32 "\n", load_end_addr);
    2.79      xc_dom_printf("  bss_end_addr:  0x%" PRIx32 "\n", bss_end_addr);
    2.80  
    2.81 -    if ( start_addr + image_size < load_end_addr )
    2.82 +    if ( (start_addr + image_size) < load_end_addr )
    2.83      {
    2.84          xc_dom_panic(XC_INVALID_KERNEL, "%s: Invalid load_end_addr.\n",
    2.85                       __FUNCTION__);
    2.86 @@ -209,25 +202,26 @@ static int xc_dom_parse_bin_kernel(struc
    2.87      pae_flags = image_info->flags & XEN_MULTIBOOT_FLAG_PAE_MASK;
    2.88      switch (pae_flags >> XEN_MULTIBOOT_FLAG_PAE_SHIFT) {
    2.89      case 0:
    2.90 -	dom->guest_type = "xen-3.0-x86_32";
    2.91 -	break;
    2.92 +        dom->guest_type = "xen-3.0-x86_32";
    2.93 +        break;
    2.94      case 1:
    2.95 -	dom->guest_type = "xen-3.0-x86_32p";
    2.96 -	break;
    2.97 +        dom->guest_type = "xen-3.0-x86_32p";
    2.98 +        break;
    2.99      case 2:
   2.100 -	dom->guest_type = "xen-3.0-x86_64";
   2.101 -	break;
   2.102 +        dom->guest_type = "xen-3.0-x86_64";
   2.103 +        break;
   2.104      case 3:
   2.105 -	/* Kernel detects PAE at runtime.  So try to figure whenever
   2.106 -	 * xen supports PAE and advertise a PAE-capable kernel in case
   2.107 -	 * it does. */
   2.108 -	dom->guest_type = "xen-3.0-x86_32";
   2.109 -	if (strstr(dom->xen_caps, "xen-3.0-x86_32p")) {
   2.110 -	    xc_dom_printf("%s: PAE fixup\n", __FUNCTION__);
   2.111 -	    dom->guest_type = "xen-3.0-x86_32p";
   2.112 -	    dom->parms.pae  = 2;
   2.113 -	}
   2.114 -	break;
   2.115 +        /* Kernel detects PAE at runtime.  So try to figure whenever
   2.116 +         * xen supports PAE and advertise a PAE-capable kernel in case
   2.117 +         * it does. */
   2.118 +        dom->guest_type = "xen-3.0-x86_32";
   2.119 +        if ( strstr(dom->xen_caps, "xen-3.0-x86_32p") )
   2.120 +        {
   2.121 +            xc_dom_printf("%s: PAE fixup\n", __FUNCTION__);
   2.122 +            dom->guest_type = "xen-3.0-x86_32p";
   2.123 +            dom->parms.pae  = 2;
   2.124 +        }
   2.125 +        break;
   2.126      }
   2.127      return 0;
   2.128  }
   2.129 @@ -242,10 +236,9 @@ static int xc_dom_load_bin_kernel(struct
   2.130      uint32_t load_end_addr;
   2.131      uint32_t bss_end_addr;
   2.132      uint32_t skip, text_size, bss_size;
   2.133 -    uint32_t pae_flags;
   2.134  
   2.135      image_info = find_table(dom);
   2.136 -    if (!image_info)
   2.137 +    if ( !image_info )
   2.138          return -EINVAL;
   2.139  
   2.140      start_addr = image_info->header_addr - ((char *)image_info - image);
   2.141 @@ -266,10 +259,6 @@ static int xc_dom_load_bin_kernel(struct
   2.142      memcpy(dest, image + skip, text_size);
   2.143      memset(dest + text_size, 0, bss_size);
   2.144  
   2.145 -    pae_flags = image_info->flags & XEN_MULTIBOOT_FLAG_PAE_MASK;
   2.146 -    if (3 == (pae_flags >> XEN_MULTIBOOT_FLAG_PAE_SHIFT) && dom->guest_xc > 0)
   2.147 -    {
   2.148 -    }
   2.149      return 0;
   2.150  }
   2.151  
   2.152 @@ -289,6 +278,10 @@ static void __init register_loader(void)
   2.153  
   2.154  /*
   2.155   * Local variables:
   2.156 + * mode: C
   2.157 + * c-set-style: "BSD"
   2.158   * c-basic-offset: 4
   2.159 + * tab-width: 4
   2.160 + * indent-tabs-mode: nil
   2.161   * End:
   2.162   */
     3.1 --- a/tools/libxc/xc_dom_boot.c	Sat Feb 24 14:48:17 2007 +0000
     3.2 +++ b/tools/libxc/xc_dom_boot.c	Sat Feb 24 15:30:19 2007 +0000
     3.3 @@ -29,20 +29,20 @@ static int setup_hypercall_page(struct x
     3.4      xen_pfn_t pfn;
     3.5      int rc;
     3.6  
     3.7 -    if (-1 == dom->parms.virt_hypercall)
     3.8 -	return 0;
     3.9 +    if ( dom->parms.virt_hypercall == -1 )
    3.10 +        return 0;
    3.11      pfn = (dom->parms.virt_hypercall - dom->parms.virt_base)
    3.12 -	>> XC_DOM_PAGE_SHIFT(dom);
    3.13 +        >> XC_DOM_PAGE_SHIFT(dom);
    3.14  
    3.15      xc_dom_printf("%s: vaddr=0x%" PRIx64 " pfn=0x%" PRIpfn "\n", __FUNCTION__,
    3.16 -		  dom->parms.virt_hypercall, pfn);
    3.17 +                  dom->parms.virt_hypercall, pfn);
    3.18      domctl.cmd = XEN_DOMCTL_hypercall_init;
    3.19      domctl.domain = dom->guest_domid;
    3.20      domctl.u.hypercall_init.gmfn = xc_dom_p2m_guest(dom, pfn);
    3.21      rc = do_domctl(dom->guest_xc, &domctl);
    3.22 -    if (0 != rc)
    3.23 -	xc_dom_panic(XC_INTERNAL_ERROR, "%s: HYPERCALL_INIT failed (rc=%d)\n",
    3.24 -		     __FUNCTION__, rc);
    3.25 +    if ( rc != 0 )
    3.26 +        xc_dom_panic(XC_INTERNAL_ERROR, "%s: HYPERCALL_INIT failed (rc=%d)\n",
    3.27 +                     __FUNCTION__, rc);
    3.28      return rc;
    3.29  }
    3.30  
    3.31 @@ -58,9 +58,9 @@ static int launch_vm(int xc, domid_t dom
    3.32      domctl.u.vcpucontext.vcpu = 0;
    3.33      set_xen_guest_handle(domctl.u.vcpucontext.ctxt, ctxt);
    3.34      rc = do_domctl(xc, &domctl);
    3.35 -    if (0 != rc)
    3.36 -	xc_dom_panic(XC_INTERNAL_ERROR,
    3.37 -		     "%s: SETVCPUCONTEXT failed (rc=%d)\n", __FUNCTION__, rc);
    3.38 +    if ( rc != 0 )
    3.39 +        xc_dom_panic(XC_INTERNAL_ERROR,
    3.40 +                     "%s: SETVCPUCONTEXT failed (rc=%d)\n", __FUNCTION__, rc);
    3.41      return rc;
    3.42  }
    3.43  
    3.44 @@ -69,17 +69,17 @@ static int clear_page(struct xc_dom_imag
    3.45      xen_pfn_t dst;
    3.46      int rc;
    3.47  
    3.48 -    if (0 == pfn)
    3.49 -	return 0;
    3.50 +    if ( pfn == 0 )
    3.51 +        return 0;
    3.52  
    3.53      dst = xc_dom_p2m_host(dom, pfn);
    3.54      xc_dom_printf("%s: pfn 0x%" PRIpfn ", mfn 0x%" PRIpfn "\n",
    3.55 -		  __FUNCTION__, pfn, dst);
    3.56 +                  __FUNCTION__, pfn, dst);
    3.57      rc = xc_clear_domain_page(dom->guest_xc, dom->guest_domid, dst);
    3.58 -    if (0 != rc)
    3.59 -	xc_dom_panic(XC_INTERNAL_ERROR,
    3.60 -		     "%s: xc_clear_domain_page failed (pfn 0x%" PRIpfn
    3.61 -		     ", rc=%d)\n", __FUNCTION__, pfn, rc);
    3.62 +    if ( rc != 0 )
    3.63 +        xc_dom_panic(XC_INTERNAL_ERROR,
    3.64 +                     "%s: xc_clear_domain_page failed (pfn 0x%" PRIpfn
    3.65 +                     ", rc=%d)\n", __FUNCTION__, pfn, rc);
    3.66      return rc;
    3.67  }
    3.68  
    3.69 @@ -92,11 +92,11 @@ static int clear_page(struct xc_dom_imag
    3.70  static int x86_compat(int xc, domid_t domid, char *guest_type)
    3.71  {
    3.72      static const struct {
    3.73 -	char           *guest;
    3.74 -	uint32_t        size;
    3.75 +        char           *guest;
    3.76 +        uint32_t        size;
    3.77      } types[] = {
    3.78 -	{ "xen-3.0-x86_32p", 32 },
    3.79 -	{ "xen-3.0-x86_64",  64 },
    3.80 +        { "xen-3.0-x86_32p", 32 },
    3.81 +        { "xen-3.0-x86_64",  64 },
    3.82      };
    3.83      DECLARE_DOMCTL;
    3.84      int i,rc;
    3.85 @@ -104,19 +104,19 @@ static int x86_compat(int xc, domid_t do
    3.86      memset(&domctl, 0, sizeof(domctl));
    3.87      domctl.domain = domid;
    3.88      domctl.cmd    = XEN_DOMCTL_set_address_size;
    3.89 -    for (i = 0; i < sizeof(types)/sizeof(types[0]); i++)
    3.90 -	if (0 == strcmp(types[i].guest, guest_type))
    3.91 -	    domctl.u.address_size.size = types[i].size;
    3.92 -    if (0 == domctl.u.address_size.size)
    3.93 -	/* nothing to do */
    3.94 -	return 0;
    3.95 +    for ( i = 0; i < sizeof(types)/sizeof(types[0]); i++ )
    3.96 +        if ( !strcmp(types[i].guest, guest_type) )
    3.97 +            domctl.u.address_size.size = types[i].size;
    3.98 +    if ( domctl.u.address_size.size == 0 )
    3.99 +        /* nothing to do */
   3.100 +        return 0;
   3.101  
   3.102      xc_dom_printf("%s: guest %s, address size %" PRId32 "\n", __FUNCTION__,
   3.103 -		  guest_type, domctl.u.address_size.size);
   3.104 +                  guest_type, domctl.u.address_size.size);
   3.105      rc = do_domctl(xc, &domctl);
   3.106 -    if (0 != rc)
   3.107 -	xc_dom_printf("%s: warning: failed (rc=%d)\n",
   3.108 -		      __FUNCTION__, rc);
   3.109 +    if ( rc != 0 )
   3.110 +        xc_dom_printf("%s: warning: failed (rc=%d)\n",
   3.111 +                      __FUNCTION__, rc);
   3.112      return rc;
   3.113  }
   3.114  
   3.115 @@ -128,17 +128,17 @@ static int x86_shadow(int xc, domid_t do
   3.116      xc_dom_printf("%s: called\n", __FUNCTION__);
   3.117  
   3.118      mode = XEN_DOMCTL_SHADOW_ENABLE_REFCOUNT |
   3.119 -	XEN_DOMCTL_SHADOW_ENABLE_TRANSLATE;
   3.120 +        XEN_DOMCTL_SHADOW_ENABLE_TRANSLATE;
   3.121  
   3.122      rc = xc_shadow_control(xc, domid,
   3.123 -			   XEN_DOMCTL_SHADOW_OP_ENABLE,
   3.124 -			   NULL, 0, NULL, mode, NULL);
   3.125 -    if (0 != rc)
   3.126 +                           XEN_DOMCTL_SHADOW_OP_ENABLE,
   3.127 +                           NULL, 0, NULL, mode, NULL);
   3.128 +    if ( rc != 0 )
   3.129      {
   3.130 -	xc_dom_panic(XC_INTERNAL_ERROR,
   3.131 -		     "%s: SHADOW_OP_ENABLE (mode=0x%x) failed (rc=%d)\n",
   3.132 -		     __FUNCTION__, mode, rc);
   3.133 -	return rc;
   3.134 +        xc_dom_panic(XC_INTERNAL_ERROR,
   3.135 +                     "%s: SHADOW_OP_ENABLE (mode=0x%x) failed (rc=%d)\n",
   3.136 +                     __FUNCTION__, mode, rc);
   3.137 +        return rc;
   3.138      }
   3.139      xc_dom_printf("%s: shadow enabled (mode=0x%x)\n", __FUNCTION__, mode);
   3.140      return rc;
   3.141 @@ -149,10 +149,10 @@ static int arch_setup_meminit(struct xc_
   3.142      int rc = 0;
   3.143  
   3.144      x86_compat(dom->guest_xc, dom->guest_domid, dom->guest_type);
   3.145 -    if (xc_dom_feature_translated(dom))
   3.146 +    if ( xc_dom_feature_translated(dom) )
   3.147      {
   3.148 -	dom->shadow_enabled = 1;
   3.149 -	rc = x86_shadow(dom->guest_xc, dom->guest_domid);
   3.150 +        dom->shadow_enabled = 1;
   3.151 +        rc = x86_shadow(dom->guest_xc, dom->guest_domid);
   3.152      }
   3.153      return rc;
   3.154  }
   3.155 @@ -166,92 +166,92 @@ static int arch_setup_bootearly(struct x
   3.156  static int arch_setup_bootlate(struct xc_dom_image *dom)
   3.157  {
   3.158      static const struct {
   3.159 -	char *guest;
   3.160 -	unsigned long pgd_type;
   3.161 +        char *guest;
   3.162 +        unsigned long pgd_type;
   3.163      } types[] = {
   3.164 -	{ "xen-3.0-x86_32",  MMUEXT_PIN_L2_TABLE},
   3.165 -	{ "xen-3.0-x86_32p", MMUEXT_PIN_L3_TABLE},
   3.166 -	{ "xen-3.0-x86_64",  MMUEXT_PIN_L4_TABLE},
   3.167 +        { "xen-3.0-x86_32",  MMUEXT_PIN_L2_TABLE},
   3.168 +        { "xen-3.0-x86_32p", MMUEXT_PIN_L3_TABLE},
   3.169 +        { "xen-3.0-x86_64",  MMUEXT_PIN_L4_TABLE},
   3.170      };
   3.171      unsigned long pgd_type = 0;
   3.172      shared_info_t *shared_info;
   3.173      xen_pfn_t shinfo;
   3.174      int i, rc;
   3.175  
   3.176 -    for (i = 0; i < sizeof(types) / sizeof(types[0]); i++)
   3.177 -	if (0 == strcmp(types[i].guest, dom->guest_type))
   3.178 -	    pgd_type = types[i].pgd_type;
   3.179 +    for ( i = 0; i < sizeof(types) / sizeof(types[0]); i++ )
   3.180 +        if ( !strcmp(types[i].guest, dom->guest_type) )
   3.181 +            pgd_type = types[i].pgd_type;
   3.182  
   3.183 -    if (!xc_dom_feature_translated(dom))
   3.184 +    if ( !xc_dom_feature_translated(dom) )
   3.185      {
   3.186 -	/* paravirtualized guest */
   3.187 -	xc_dom_unmap_one(dom, dom->pgtables_seg.pfn);
   3.188 -	rc = pin_table(dom->guest_xc, pgd_type,
   3.189 -		       xc_dom_p2m_host(dom, dom->pgtables_seg.pfn),
   3.190 -		       dom->guest_domid);
   3.191 -	if (0 != rc)
   3.192 -	{
   3.193 -	    xc_dom_panic(XC_INTERNAL_ERROR,
   3.194 -			 "%s: pin_table failed (pfn 0x%" PRIpfn ", rc=%d)\n",
   3.195 -			 __FUNCTION__, dom->pgtables_seg.pfn, rc);
   3.196 -	    return rc;
   3.197 -	}
   3.198 -	shinfo = dom->shared_info_mfn;
   3.199 +        /* paravirtualized guest */
   3.200 +        xc_dom_unmap_one(dom, dom->pgtables_seg.pfn);
   3.201 +        rc = pin_table(dom->guest_xc, pgd_type,
   3.202 +                       xc_dom_p2m_host(dom, dom->pgtables_seg.pfn),
   3.203 +                       dom->guest_domid);
   3.204 +        if ( rc != 0 )
   3.205 +        {
   3.206 +            xc_dom_panic(XC_INTERNAL_ERROR,
   3.207 +                         "%s: pin_table failed (pfn 0x%" PRIpfn ", rc=%d)\n",
   3.208 +                         __FUNCTION__, dom->pgtables_seg.pfn, rc);
   3.209 +            return rc;
   3.210 +        }
   3.211 +        shinfo = dom->shared_info_mfn;
   3.212      }
   3.213      else
   3.214      {
   3.215 -	/* paravirtualized guest with auto-translation */
   3.216 -	struct xen_add_to_physmap xatp;
   3.217 -	int i;
   3.218 +        /* paravirtualized guest with auto-translation */
   3.219 +        struct xen_add_to_physmap xatp;
   3.220 +        int i;
   3.221  
   3.222 -	/* Map shared info frame into guest physmap. */
   3.223 -	xatp.domid = dom->guest_domid;
   3.224 -	xatp.space = XENMAPSPACE_shared_info;
   3.225 -	xatp.idx = 0;
   3.226 -	xatp.gpfn = dom->shared_info_pfn;
   3.227 -	rc = xc_memory_op(dom->guest_xc, XENMEM_add_to_physmap, &xatp);
   3.228 -	if (rc != 0)
   3.229 -	{
   3.230 -	    xc_dom_panic(XC_INTERNAL_ERROR, "%s: mapping shared_info failed "
   3.231 -			 "(pfn=0x%" PRIpfn ", rc=%d)\n",
   3.232 -			 __FUNCTION__, xatp.gpfn, rc);
   3.233 -	    return rc;
   3.234 -	}
   3.235 +        /* Map shared info frame into guest physmap. */
   3.236 +        xatp.domid = dom->guest_domid;
   3.237 +        xatp.space = XENMAPSPACE_shared_info;
   3.238 +        xatp.idx = 0;
   3.239 +        xatp.gpfn = dom->shared_info_pfn;
   3.240 +        rc = xc_memory_op(dom->guest_xc, XENMEM_add_to_physmap, &xatp);
   3.241 +        if ( rc != 0 )
   3.242 +        {
   3.243 +            xc_dom_panic(XC_INTERNAL_ERROR, "%s: mapping shared_info failed "
   3.244 +                         "(pfn=0x%" PRIpfn ", rc=%d)\n",
   3.245 +                         __FUNCTION__, xatp.gpfn, rc);
   3.246 +            return rc;
   3.247 +        }
   3.248  
   3.249 -	/* Map grant table frames into guest physmap. */
   3.250 -	for (i = 0;; i++)
   3.251 -	{
   3.252 -	    xatp.domid = dom->guest_domid;
   3.253 -	    xatp.space = XENMAPSPACE_grant_table;
   3.254 -	    xatp.idx = i;
   3.255 -	    xatp.gpfn = dom->total_pages + i;
   3.256 -	    rc = xc_memory_op(dom->guest_xc, XENMEM_add_to_physmap, &xatp);
   3.257 -	    if (rc != 0)
   3.258 -	    {
   3.259 -		if (i > 0 && errno == EINVAL)
   3.260 -		{
   3.261 -		    xc_dom_printf("%s: %d grant tables mapped\n", __FUNCTION__,
   3.262 -				  i);
   3.263 -		    break;
   3.264 -		}
   3.265 -		xc_dom_panic(XC_INTERNAL_ERROR,
   3.266 -			     "%s: mapping grant tables failed " "(pfn=0x%"
   3.267 -			     PRIpfn ", rc=%d)\n", __FUNCTION__, xatp.gpfn, rc);
   3.268 -		return rc;
   3.269 -	    }
   3.270 -	}
   3.271 -	shinfo = dom->shared_info_pfn;
   3.272 +        /* Map grant table frames into guest physmap. */
   3.273 +        for ( i = 0; ; i++ )
   3.274 +        {
   3.275 +            xatp.domid = dom->guest_domid;
   3.276 +            xatp.space = XENMAPSPACE_grant_table;
   3.277 +            xatp.idx = i;
   3.278 +            xatp.gpfn = dom->total_pages + i;
   3.279 +            rc = xc_memory_op(dom->guest_xc, XENMEM_add_to_physmap, &xatp);
   3.280 +            if ( rc != 0 )
   3.281 +            {
   3.282 +                if ( (i > 0) && (errno == EINVAL) )
   3.283 +                {
   3.284 +                    xc_dom_printf("%s: %d grant tables mapped\n", __FUNCTION__,
   3.285 +                                  i);
   3.286 +                    break;
   3.287 +                }
   3.288 +                xc_dom_panic(XC_INTERNAL_ERROR,
   3.289 +                             "%s: mapping grant tables failed " "(pfn=0x%"
   3.290 +                             PRIpfn ", rc=%d)\n", __FUNCTION__, xatp.gpfn, rc);
   3.291 +                return rc;
   3.292 +            }
   3.293 +        }
   3.294 +        shinfo = dom->shared_info_pfn;
   3.295      }
   3.296  
   3.297      /* setup shared_info page */
   3.298      xc_dom_printf("%s: shared_info: pfn 0x%" PRIpfn ", mfn 0x%" PRIpfn "\n",
   3.299 -		  __FUNCTION__, dom->shared_info_pfn, dom->shared_info_mfn);
   3.300 +                  __FUNCTION__, dom->shared_info_pfn, dom->shared_info_mfn);
   3.301      shared_info = xc_map_foreign_range(dom->guest_xc, dom->guest_domid,
   3.302 -				       PAGE_SIZE_X86,
   3.303 -				       PROT_READ | PROT_WRITE,
   3.304 -				       shinfo);
   3.305 -    if (NULL == shared_info)
   3.306 -	return -1;
   3.307 +                                       PAGE_SIZE_X86,
   3.308 +                                       PROT_READ | PROT_WRITE,
   3.309 +                                       shinfo);
   3.310 +    if ( shared_info == NULL )
   3.311 +        return -1;
   3.312      dom->arch_hooks->shared_info(dom, shared_info);
   3.313      munmap(shared_info, PAGE_SIZE_X86);
   3.314  
   3.315 @@ -282,7 +282,7 @@ static int arch_setup_bootearly(struct x
   3.316      domctl.u.arch_setup.flags = 0;
   3.317  
   3.318      domctl.u.arch_setup.bp = (dom->start_info_pfn << PAGE_SHIFT)
   3.319 -	+ sizeof(start_info_t);
   3.320 +        + sizeof(start_info_t);
   3.321      /* 3 = start info page, xenstore page and console page */
   3.322      domctl.u.arch_setup.maxmem = (dom->total_pages - 3) << PAGE_SHIFT;
   3.323      rc = do_domctl(dom->guest_xc, &domctl);
   3.324 @@ -296,13 +296,13 @@ static int arch_setup_bootlate(struct xc
   3.325  
   3.326      /* setup shared_info page */
   3.327      xc_dom_printf("%s: shared_info: mfn 0x%" PRIpfn "\n",
   3.328 -		  __FUNCTION__, dom->shared_info_mfn);
   3.329 +                  __FUNCTION__, dom->shared_info_mfn);
   3.330      shared_info = xc_map_foreign_range(dom->guest_xc, dom->guest_domid,
   3.331 -				       page_size,
   3.332 -				       PROT_READ | PROT_WRITE,
   3.333 -				       dom->shared_info_mfn);
   3.334 -    if (NULL == shared_info)
   3.335 -	return -1;
   3.336 +                                       page_size,
   3.337 +                                       PROT_READ | PROT_WRITE,
   3.338 +                                       dom->shared_info_mfn);
   3.339 +    if ( shared_info == NULL )
   3.340 +        return -1;
   3.341      dom->arch_hooks->shared_info(dom, shared_info);
   3.342      munmap(shared_info, page_size);
   3.343      return 0;
   3.344 @@ -328,20 +328,20 @@ static int arch_setup_bootearly(struct x
   3.345  static int arch_setup_bootlate(struct xc_dom_image *dom)
   3.346  {
   3.347      start_info_t *si =
   3.348 -	xc_dom_pfn_to_ptr(dom, dom->start_info_pfn, 1);
   3.349 +        xc_dom_pfn_to_ptr(dom, dom->start_info_pfn, 1);
   3.350  
   3.351      xc_dom_printf("%s: TODO: setup devtree\n", __FUNCTION__);
   3.352  
   3.353  #if 0
   3.354      load_devtree(dom->guest_xc,
   3.355 -		 dom->guest_domid,
   3.356 -		 dom->p2m_host,
   3.357 -		 devtree,           // FIXME
   3.358 -		 devtree_addr,      // FIXME
   3.359 -		 dom->ramdisk_seg.vstart,
   3.360 -		 dom->ramdisk_seg.vend - dom->ramdisk_seg.vstart,
   3.361 -		 si,
   3.362 -		 dom->start_info_pfn << PAGE_SHIFT);
   3.363 +                 dom->guest_domid,
   3.364 +                 dom->p2m_host,
   3.365 +                 devtree,           // FIXME
   3.366 +                 devtree_addr,      // FIXME
   3.367 +                 dom->ramdisk_seg.vstart,
   3.368 +                 dom->ramdisk_seg.vend - dom->ramdisk_seg.vstart,
   3.369 +                 si,
   3.370 +                 dom->start_info_pfn << PAGE_SHIFT);
   3.371  #endif
   3.372      return rc;
   3.373  }
   3.374 @@ -380,19 +380,19 @@ int xc_dom_compat_check(struct xc_dom_im
   3.375      int match, found = 0;
   3.376  
   3.377      strcpy(xen_caps, dom->xen_caps);
   3.378 -    for (item = strtok_r(xen_caps, " ", &ptr);
   3.379 -	 NULL != item; item = strtok_r(NULL, " ", &ptr))
   3.380 +    for ( item = strtok_r(xen_caps, " ", &ptr);
   3.381 +          item != NULL ; item = strtok_r(NULL, " ", &ptr) )
   3.382      {
   3.383 -	match = (0 == strcmp(dom->guest_type, item));
   3.384 -	xc_dom_printf("%s: supported guest type: %s%s\n", __FUNCTION__,
   3.385 -		      item, match ? " <= matches" : "");
   3.386 -	if (match)
   3.387 -	    found++;
   3.388 +        match = !strcmp(dom->guest_type, item);
   3.389 +        xc_dom_printf("%s: supported guest type: %s%s\n", __FUNCTION__,
   3.390 +                      item, match ? " <= matches" : "");
   3.391 +        if ( match )
   3.392 +            found++;
   3.393      }
   3.394 -    if (!found)
   3.395 -	xc_dom_panic(XC_INVALID_KERNEL,
   3.396 -		     "%s: guest type %s not supported by xen kernel, sorry\n",
   3.397 -		     __FUNCTION__, dom->guest_type);
   3.398 +    if ( !found )
   3.399 +        xc_dom_panic(XC_INVALID_KERNEL,
   3.400 +                     "%s: guest type %s not supported by xen kernel, sorry\n",
   3.401 +                     __FUNCTION__, dom->guest_type);
   3.402  
   3.403      return found;
   3.404  }
   3.405 @@ -403,13 +403,14 @@ int xc_dom_boot_xen_init(struct xc_dom_i
   3.406      dom->guest_domid = domid;
   3.407  
   3.408      dom->xen_version = xc_version(dom->guest_xc, XENVER_version, NULL);
   3.409 -    if (xc_version(xc, XENVER_capabilities, &dom->xen_caps) < 0) {
   3.410 -	xc_dom_panic(XC_INTERNAL_ERROR, "can't get xen capabilities");
   3.411 -	return -1;
   3.412 +    if ( xc_version(xc, XENVER_capabilities, &dom->xen_caps) < 0 )
   3.413 +    {
   3.414 +        xc_dom_panic(XC_INTERNAL_ERROR, "can't get xen capabilities");
   3.415 +        return -1;
   3.416      }
   3.417      xc_dom_printf("%s: ver %d.%d, caps %s\n", __FUNCTION__,
   3.418 -		  dom->xen_version >> 16, dom->xen_version & 0xff,
   3.419 -		  dom->xen_caps);
   3.420 +                  dom->xen_version >> 16, dom->xen_version & 0xff,
   3.421 +                  dom->xen_caps);
   3.422      return 0;
   3.423  }
   3.424  
   3.425 @@ -419,26 +420,26 @@ int xc_dom_boot_mem_init(struct xc_dom_i
   3.426  
   3.427      xc_dom_printf("%s: called\n", __FUNCTION__);
   3.428  
   3.429 -    if (0 != (rc = arch_setup_meminit(dom)))
   3.430 -	return rc;
   3.431 +    if ( (rc = arch_setup_meminit(dom)) != 0 )
   3.432 +        return rc;
   3.433  
   3.434      /* allocate guest memory */
   3.435      rc = xc_domain_memory_populate_physmap(dom->guest_xc, dom->guest_domid,
   3.436 -					   dom->total_pages, 0, 0,
   3.437 -					   dom->p2m_host);
   3.438 -    if (0 != rc)
   3.439 +                                           dom->total_pages, 0, 0,
   3.440 +                                           dom->p2m_host);
   3.441 +    if ( rc != 0 )
   3.442      {
   3.443 -	xc_dom_panic(XC_OUT_OF_MEMORY,
   3.444 -		     "%s: can't allocate low memory for domain\n",
   3.445 -		     __FUNCTION__);
   3.446 -	return rc;
   3.447 +        xc_dom_panic(XC_OUT_OF_MEMORY,
   3.448 +                     "%s: can't allocate low memory for domain\n",
   3.449 +                     __FUNCTION__);
   3.450 +        return rc;
   3.451      }
   3.452  
   3.453      return 0;
   3.454  }
   3.455  
   3.456  void *xc_dom_boot_domU_map(struct xc_dom_image *dom, xen_pfn_t pfn,
   3.457 -			   xen_pfn_t count)
   3.458 +                           xen_pfn_t count)
   3.459  {
   3.460      int page_shift = XC_DOM_PAGE_SHIFT(dom);
   3.461      privcmd_mmap_entry_t *entries;
   3.462 @@ -446,38 +447,39 @@ void *xc_dom_boot_domU_map(struct xc_dom
   3.463      int i, rc;
   3.464  
   3.465      entries = xc_dom_malloc(dom, count * sizeof(privcmd_mmap_entry_t));
   3.466 -    if (NULL == entries)
   3.467 +    if ( entries == NULL )
   3.468      {
   3.469 -	xc_dom_panic(XC_INTERNAL_ERROR,
   3.470 -		     "%s: failed to mmap domU pages 0x%" PRIpfn "+0x%" PRIpfn
   3.471 -		     " [malloc]\n", __FUNCTION__, pfn, count);
   3.472 -	return NULL;
   3.473 +        xc_dom_panic(XC_INTERNAL_ERROR,
   3.474 +                     "%s: failed to mmap domU pages 0x%" PRIpfn "+0x%" PRIpfn
   3.475 +                     " [malloc]\n", __FUNCTION__, pfn, count);
   3.476 +        return NULL;
   3.477      }
   3.478  
   3.479      ptr = mmap(NULL, count << page_shift, PROT_READ | PROT_WRITE,
   3.480 -	       MAP_SHARED, dom->guest_xc, 0);
   3.481 -    if (MAP_FAILED == ptr)
   3.482 +               MAP_SHARED, dom->guest_xc, 0);
   3.483 +    if ( ptr == MAP_FAILED )
   3.484      {
   3.485 -	xc_dom_panic(XC_INTERNAL_ERROR,
   3.486 -		     "%s: failed to mmap domU pages 0x%" PRIpfn "+0x%" PRIpfn
   3.487 -		     " [mmap]\n", __FUNCTION__, pfn, count);
   3.488 -	return NULL;
   3.489 +        xc_dom_panic(XC_INTERNAL_ERROR,
   3.490 +                     "%s: failed to mmap domU pages 0x%" PRIpfn "+0x%" PRIpfn
   3.491 +                     " [mmap]\n", __FUNCTION__, pfn, count);
   3.492 +        return NULL;
   3.493      }
   3.494  
   3.495 -    for (i = 0; i < count; i++)
   3.496 +    for ( i = 0; i < count; i++ )
   3.497      {
   3.498 -	entries[i].va = (uintptr_t) ptr + (i << page_shift);
   3.499 -	entries[i].mfn = xc_dom_p2m_host(dom, pfn + i);
   3.500 -	entries[i].npages = 1;
   3.501 +        entries[i].va = (uintptr_t) ptr + (i << page_shift);
   3.502 +        entries[i].mfn = xc_dom_p2m_host(dom, pfn + i);
   3.503 +        entries[i].npages = 1;
   3.504      }
   3.505  
   3.506 -    rc = xc_map_foreign_ranges(dom->guest_xc, dom->guest_domid, entries, count);
   3.507 -    if (rc < 0)
   3.508 +    rc = xc_map_foreign_ranges(dom->guest_xc, dom->guest_domid,
   3.509 +                               entries, count);
   3.510 +    if ( rc < 0 )
   3.511      {
   3.512 -	xc_dom_panic(XC_INTERNAL_ERROR,
   3.513 -		     "%s: failed to mmap domU pages 0x%" PRIpfn "+0x%" PRIpfn
   3.514 -		     " [xenctl, rc=%d]\n", __FUNCTION__, pfn, count, rc);
   3.515 -	return NULL;
   3.516 +        xc_dom_panic(XC_INTERNAL_ERROR,
   3.517 +                     "%s: failed to mmap domU pages 0x%" PRIpfn "+0x%" PRIpfn
   3.518 +                     " [xenctl, rc=%d]\n", __FUNCTION__, pfn, count, rc);
   3.519 +        return NULL;
   3.520      }
   3.521      return ptr;
   3.522  }
   3.523 @@ -491,64 +493,74 @@ int xc_dom_boot_image(struct xc_dom_imag
   3.524      xc_dom_printf("%s: called\n", __FUNCTION__);
   3.525  
   3.526      /* misc ia64 stuff*/
   3.527 -    if (0 != (rc = arch_setup_bootearly(dom)))
   3.528 -	return rc;
   3.529 +    if ( (rc = arch_setup_bootearly(dom)) != 0 )
   3.530 +        return rc;
   3.531  
   3.532      /* collect some info */
   3.533      domctl.cmd = XEN_DOMCTL_getdomaininfo;
   3.534      domctl.domain = dom->guest_domid;
   3.535      rc = do_domctl(dom->guest_xc, &domctl);
   3.536 -    if (0 != rc)
   3.537 +    if ( rc != 0 )
   3.538      {
   3.539 -	xc_dom_panic(XC_INTERNAL_ERROR,
   3.540 -		     "%s: getdomaininfo failed (rc=%d)\n", __FUNCTION__, rc);
   3.541 -	return rc;
   3.542 +        xc_dom_panic(XC_INTERNAL_ERROR,
   3.543 +                     "%s: getdomaininfo failed (rc=%d)\n", __FUNCTION__, rc);
   3.544 +        return rc;
   3.545      }
   3.546 -    if (domctl.domain != dom->guest_domid)
   3.547 +    if ( domctl.domain != dom->guest_domid )
   3.548      {
   3.549 -	xc_dom_panic(XC_INTERNAL_ERROR,
   3.550 -		     "%s: Huh? domid mismatch (%d != %d)\n", __FUNCTION__,
   3.551 -		     domctl.domain, dom->guest_domid);
   3.552 -	return -1;
   3.553 +        xc_dom_panic(XC_INTERNAL_ERROR,
   3.554 +                     "%s: Huh? domid mismatch (%d != %d)\n", __FUNCTION__,
   3.555 +                     domctl.domain, dom->guest_domid);
   3.556 +        return -1;
   3.557      }
   3.558      dom->shared_info_mfn = domctl.u.getdomaininfo.shared_info_frame;
   3.559  
   3.560      /* sanity checks */
   3.561 -    if (!xc_dom_compat_check(dom))
   3.562 -	return -1;
   3.563 +    if ( !xc_dom_compat_check(dom) )
   3.564 +        return -1;
   3.565  
   3.566      /* initial mm setup */
   3.567 -    if (0 != (rc = xc_dom_update_guest_p2m(dom)))
   3.568 -	return rc;
   3.569 -    if (dom->arch_hooks->setup_pgtables)
   3.570 -	if (0 != (rc = dom->arch_hooks->setup_pgtables(dom)))
   3.571 -	    return rc;
   3.572 +    if ( (rc = xc_dom_update_guest_p2m(dom)) != 0 )
   3.573 +        return rc;
   3.574 +    if ( dom->arch_hooks->setup_pgtables )
   3.575 +        if ( (rc = dom->arch_hooks->setup_pgtables(dom)) != 0 )
   3.576 +            return rc;
   3.577  
   3.578 -    if (0 != (rc = clear_page(dom, dom->console_pfn)))
   3.579 -	return rc;
   3.580 -    if (0 != (rc = clear_page(dom, dom->xenstore_pfn)))
   3.581 -	return rc;
   3.582 +    if ( (rc = clear_page(dom, dom->console_pfn)) != 0 )
   3.583 +        return rc;
   3.584 +    if ( (rc = clear_page(dom, dom->xenstore_pfn)) != 0 )
   3.585 +        return rc;
   3.586  
   3.587      /* start info page */
   3.588 -    if (dom->arch_hooks->start_info)
   3.589 -	dom->arch_hooks->start_info(dom);
   3.590 +    if ( dom->arch_hooks->start_info )
   3.591 +        dom->arch_hooks->start_info(dom);
   3.592  
   3.593      /* hypercall page */
   3.594 -    if (0 != (rc = setup_hypercall_page(dom)))
   3.595 -	return rc;
   3.596 +    if ( (rc = setup_hypercall_page(dom)) != 0 )
   3.597 +        return rc;
   3.598      xc_dom_log_memory_footprint(dom);
   3.599  
   3.600      /* misc x86 stuff */
   3.601 -    if (0 != (rc = arch_setup_bootlate(dom)))
   3.602 -	return rc;
   3.603 +    if ( (rc = arch_setup_bootlate(dom)) != 0 )
   3.604 +        return rc;
   3.605  
   3.606      /* let the vm run */
   3.607      ctxt = xc_dom_malloc(dom, PAGE_SIZE * 2 /* FIXME */ );
   3.608      memset(ctxt, 0, PAGE_SIZE * 2);
   3.609 -    if (0 != (rc = dom->arch_hooks->vcpu(dom, ctxt)))
   3.610 -	return rc;
   3.611 +    if ( (rc = dom->arch_hooks->vcpu(dom, ctxt)) != 0 )
   3.612 +        return rc;
   3.613      xc_dom_unmap_all(dom);
   3.614      rc = launch_vm(dom->guest_xc, dom->guest_domid, ctxt);
   3.615  
   3.616      return rc;
   3.617  }
   3.618 +
   3.619 +/*
   3.620 + * Local variables:
   3.621 + * mode: C
   3.622 + * c-set-style: "BSD"
   3.623 + * c-basic-offset: 4
   3.624 + * tab-width: 4
   3.625 + * indent-tabs-mode: nil
   3.626 + * End:
   3.627 + */
     4.1 --- a/tools/libxc/xc_dom_compat_linux.c	Sat Feb 24 14:48:17 2007 +0000
     4.2 +++ b/tools/libxc/xc_dom_compat_linux.c	Sat Feb 24 15:30:19 2007 +0000
     4.3 @@ -22,103 +22,112 @@
     4.4  /* ------------------------------------------------------------------------ */
     4.5  
     4.6  static int xc_linux_build_internal(struct xc_dom_image *dom,
     4.7 -				   int xc_handle, uint32_t domid,
     4.8 -				   unsigned int mem_mb,
     4.9 -				   unsigned long flags,
    4.10 -				   unsigned int store_evtchn,
    4.11 -				   unsigned long *store_mfn,
    4.12 -				   unsigned int console_evtchn,
    4.13 -				   unsigned long *console_mfn)
    4.14 +                                   int xc_handle, uint32_t domid,
    4.15 +                                   unsigned int mem_mb,
    4.16 +                                   unsigned long flags,
    4.17 +                                   unsigned int store_evtchn,
    4.18 +                                   unsigned long *store_mfn,
    4.19 +                                   unsigned int console_evtchn,
    4.20 +                                   unsigned long *console_mfn)
    4.21  {
    4.22      int rc;
    4.23  
    4.24 -    if (0 != (rc = xc_dom_boot_xen_init(dom, xc_handle, domid)))
    4.25 -	goto out;
    4.26 -    if (0 != (rc = xc_dom_parse_image(dom)))
    4.27 -	goto out;
    4.28 -    if (0 != (rc = xc_dom_mem_init(dom, mem_mb)))
    4.29 -	goto out;
    4.30 -    if (0 != (rc = xc_dom_boot_mem_init(dom)))
    4.31 -	goto out;
    4.32 -    if (0 != (rc = xc_dom_build_image(dom)))
    4.33 -	goto out;
    4.34 +    if ( (rc = xc_dom_boot_xen_init(dom, xc_handle, domid)) != 0 )
    4.35 +        goto out;
    4.36 +    if ( (rc = xc_dom_parse_image(dom)) != 0 )
    4.37 +        goto out;
    4.38 +    if ( (rc = xc_dom_mem_init(dom, mem_mb)) != 0 )
    4.39 +        goto out;
    4.40 +    if ( (rc = xc_dom_boot_mem_init(dom)) != 0 )
    4.41 +        goto out;
    4.42 +    if ( (rc = xc_dom_build_image(dom)) != 0 )
    4.43 +        goto out;
    4.44  
    4.45      dom->flags = flags;
    4.46      dom->console_evtchn = console_evtchn;
    4.47      dom->xenstore_evtchn = store_evtchn;
    4.48      rc = xc_dom_boot_image(dom);
    4.49 -    if (0 != rc)
    4.50 -	goto out;
    4.51 +    if ( rc != 0 )
    4.52 +        goto out;
    4.53  
    4.54      *console_mfn = xc_dom_p2m_host(dom, dom->console_pfn);
    4.55      *store_mfn = xc_dom_p2m_host(dom, dom->xenstore_pfn);
    4.56  
    4.57 -  out:
    4.58 + out:
    4.59      return rc;
    4.60  }
    4.61  
    4.62  int xc_linux_build_mem(int xc_handle, uint32_t domid,
    4.63 -		       unsigned int mem_mb,
    4.64 -		       const char *image_buffer,
    4.65 -		       unsigned long image_size,
    4.66 -		       const char *initrd,
    4.67 -		       unsigned long initrd_len,
    4.68 -		       const char *cmdline,
    4.69 -		       const char *features,
    4.70 -		       unsigned long flags,
    4.71 -		       unsigned int store_evtchn,
    4.72 -		       unsigned long *store_mfn,
    4.73 -		       unsigned int console_evtchn, unsigned long *console_mfn)
    4.74 +                       unsigned int mem_mb,
    4.75 +                       const char *image_buffer,
    4.76 +                       unsigned long image_size,
    4.77 +                       const char *initrd,
    4.78 +                       unsigned long initrd_len,
    4.79 +                       const char *cmdline,
    4.80 +                       const char *features,
    4.81 +                       unsigned long flags,
    4.82 +                       unsigned int store_evtchn,
    4.83 +                       unsigned long *store_mfn,
    4.84 +                       unsigned int console_evtchn, unsigned long *console_mfn)
    4.85  {
    4.86      struct xc_dom_image *dom;
    4.87      int rc;
    4.88  
    4.89      xc_dom_loginit();
    4.90      dom = xc_dom_allocate(cmdline, features);
    4.91 -    if (0 != (rc = xc_dom_kernel_mem(dom, image_buffer, image_size)))
    4.92 -	goto out;
    4.93 -    if (initrd)
    4.94 -	if (0 != (rc = xc_dom_ramdisk_mem(dom, initrd, initrd_len)))
    4.95 -	    goto out;
    4.96 +    if ( (rc = xc_dom_kernel_mem(dom, image_buffer, image_size)) != 0 )
    4.97 +        goto out;
    4.98 +    if ( initrd && ((rc = xc_dom_ramdisk_mem(dom, initrd, initrd_len)) != 0) )
    4.99 +        goto out;
   4.100  
   4.101      rc = xc_linux_build_internal(dom, xc_handle, domid,
   4.102 -				 mem_mb, flags,
   4.103 -				 store_evtchn, store_mfn,
   4.104 -				 console_evtchn, console_mfn);
   4.105 +                                 mem_mb, flags,
   4.106 +                                 store_evtchn, store_mfn,
   4.107 +                                 console_evtchn, console_mfn);
   4.108  
   4.109 -  out:
   4.110 + out:
   4.111      xc_dom_release(dom);
   4.112      return rc;
   4.113  }
   4.114  
   4.115  int xc_linux_build(int xc_handle, uint32_t domid,
   4.116 -		   unsigned int mem_mb,
   4.117 -		   const char *image_name,
   4.118 -		   const char *initrd_name,
   4.119 -		   const char *cmdline,
   4.120 -		   const char *features,
   4.121 -		   unsigned long flags,
   4.122 -		   unsigned int store_evtchn,
   4.123 -		   unsigned long *store_mfn,
   4.124 -		   unsigned int console_evtchn, unsigned long *console_mfn)
   4.125 +                   unsigned int mem_mb,
   4.126 +                   const char *image_name,
   4.127 +                   const char *initrd_name,
   4.128 +                   const char *cmdline,
   4.129 +                   const char *features,
   4.130 +                   unsigned long flags,
   4.131 +                   unsigned int store_evtchn,
   4.132 +                   unsigned long *store_mfn,
   4.133 +                   unsigned int console_evtchn, unsigned long *console_mfn)
   4.134  {
   4.135      struct xc_dom_image *dom;
   4.136      int rc;
   4.137  
   4.138      xc_dom_loginit();
   4.139      dom = xc_dom_allocate(cmdline, features);
   4.140 -    if (0 != (rc = xc_dom_kernel_file(dom, image_name)))
   4.141 -	goto out;
   4.142 -    if (initrd_name && strlen(initrd_name))
   4.143 -	if (0 != (rc = xc_dom_ramdisk_file(dom, initrd_name)))
   4.144 -	    goto out;
   4.145 +    if ( (rc = xc_dom_kernel_file(dom, image_name)) != 0 )
   4.146 +        goto out;
   4.147 +    if ( initrd_name && strlen(initrd_name) &&
   4.148 +         ((rc = xc_dom_ramdisk_file(dom, initrd_name)) != 0) )
   4.149 +        goto out;
   4.150  
   4.151      rc = xc_linux_build_internal(dom, xc_handle, domid,
   4.152 -				 mem_mb, flags,
   4.153 -				 store_evtchn, store_mfn,
   4.154 -				 console_evtchn, console_mfn);
   4.155 +                                 mem_mb, flags,
   4.156 +                                 store_evtchn, store_mfn,
   4.157 +                                 console_evtchn, console_mfn);
   4.158  
   4.159 -  out:
   4.160 + out:
   4.161      xc_dom_release(dom);
   4.162      return rc;
   4.163  }
   4.164 +
   4.165 +/*
   4.166 + * Local variables:
   4.167 + * mode: C
   4.168 + * c-set-style: "BSD"
   4.169 + * c-basic-offset: 4
   4.170 + * tab-width: 4
   4.171 + * indent-tabs-mode: nil
   4.172 + * End:
   4.173 + */
     5.1 --- a/tools/libxc/xc_dom_core.c	Sat Feb 24 14:48:17 2007 +0000
     5.2 +++ b/tools/libxc/xc_dom_core.c	Sat Feb 24 15:30:19 2007 +0000
     5.3 @@ -27,8 +27,8 @@ FILE *xc_dom_logfile = NULL;
     5.4  
     5.5  void xc_dom_loginit(void)
     5.6  {
     5.7 -    if (xc_dom_logfile)
     5.8 -	return;
     5.9 +    if ( xc_dom_logfile )
    5.10 +        return;
    5.11      xc_dom_logfile = fopen("/var/log/xen/domain-builder-ng.log", "a");
    5.12      setvbuf(xc_dom_logfile, NULL, _IONBF, 0);
    5.13      xc_dom_printf("### ----- xc domain builder logfile opened -----\n");
    5.14 @@ -40,8 +40,8 @@ int xc_dom_printf(const char *fmt, ...)
    5.15      char buf[1024];
    5.16      int rc;
    5.17  
    5.18 -    if (!xc_dom_logfile)
    5.19 -	return 0;
    5.20 +    if ( !xc_dom_logfile )
    5.21 +        return 0;
    5.22  
    5.23      va_start(args, fmt);
    5.24      rc = vsnprintf(buf, sizeof(buf), fmt, args);
    5.25 @@ -52,7 +52,7 @@ int xc_dom_printf(const char *fmt, ...)
    5.26  }
    5.27  
    5.28  int xc_dom_panic_func(const char *file, int line, xc_error_code err,
    5.29 -		      const char *fmt, ...)
    5.30 +                      const char *fmt, ...)
    5.31  {
    5.32      va_list args;
    5.33      FILE *fp = stderr;
    5.34 @@ -60,8 +60,8 @@ int xc_dom_panic_func(const char *file, 
    5.35      char pos[256];
    5.36      char msg[XC_MAX_ERROR_MSG_LEN];
    5.37  
    5.38 -    if (xc_dom_logfile)
    5.39 -	fp = xc_dom_logfile;
    5.40 +    if ( xc_dom_logfile )
    5.41 +        fp = xc_dom_logfile;
    5.42  
    5.43      snprintf(pos, sizeof(pos), "%s:%d: panic: ", file, line);
    5.44      va_start(args, fmt);
    5.45 @@ -74,12 +74,12 @@ int xc_dom_panic_func(const char *file, 
    5.46  
    5.47  static void print_mem(const char *name, size_t mem)
    5.48  {
    5.49 -    if (mem > 32 * 1024 * 1024)
    5.50 -	xc_dom_printf("%-24s : %zd MB\n", name, mem / (1024 * 1024));
    5.51 -    else if (mem > 32 * 1024)
    5.52 -	xc_dom_printf("%-24s : %zd kB\n", name, mem / 1024);
    5.53 +    if ( mem > (32 * 1024 * 1024) )
    5.54 +        xc_dom_printf("%-24s : %zd MB\n", name, mem / (1024 * 1024));
    5.55 +    else if ( mem > (32 * 1024) )
    5.56 +        xc_dom_printf("%-24s : %zd kB\n", name, mem / 1024);
    5.57      else
    5.58 -	xc_dom_printf("%-24s : %zd bytes\n", name, mem);
    5.59 +        xc_dom_printf("%-24s : %zd bytes\n", name, mem);
    5.60  }
    5.61  
    5.62  void xc_dom_log_memory_footprint(struct xc_dom_image *dom)
    5.63 @@ -101,14 +101,14 @@ void *xc_dom_malloc(struct xc_dom_image 
    5.64      struct xc_dom_mem *block;
    5.65  
    5.66      block = malloc(sizeof(*block) + size);
    5.67 -    if (NULL == block)
    5.68 -	return NULL;
    5.69 +    if ( block == NULL )
    5.70 +        return NULL;
    5.71      memset(block, 0, sizeof(*block) + size);
    5.72      block->next = dom->memblocks;
    5.73      dom->memblocks = block;
    5.74      dom->alloc_malloc += sizeof(*block) + size;
    5.75 -    if (size > 100 * 1024)
    5.76 -	print_mem(__FUNCTION__, size);
    5.77 +    if ( size > (100 * 1024) )
    5.78 +        print_mem(__FUNCTION__, size);
    5.79      return block->memory;
    5.80  }
    5.81  
    5.82 @@ -117,62 +117,63 @@ void *xc_dom_malloc_page_aligned(struct 
    5.83      struct xc_dom_mem *block;
    5.84  
    5.85      block = malloc(sizeof(*block));
    5.86 -    if (NULL == block)
    5.87 -	return NULL;
    5.88 +    if ( block == NULL )
    5.89 +        return NULL;
    5.90      memset(block, 0, sizeof(*block));
    5.91      block->mmap_len = size;
    5.92      block->mmap_ptr = mmap(NULL, block->mmap_len,
    5.93 -			   PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS,
    5.94 -			   -1, 0);
    5.95 -    if (MAP_FAILED == block->mmap_ptr)
    5.96 +                           PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS,
    5.97 +                           -1, 0);
    5.98 +    if ( block->mmap_ptr == MAP_FAILED )
    5.99      {
   5.100 -	free(block);
   5.101 -	return NULL;
   5.102 +        free(block);
   5.103 +        return NULL;
   5.104      }
   5.105      block->next = dom->memblocks;
   5.106      dom->memblocks = block;
   5.107      dom->alloc_malloc += sizeof(*block);
   5.108      dom->alloc_mem_map += block->mmap_len;
   5.109 -    if (size > 100 * 1024)
   5.110 -	print_mem(__FUNCTION__, size);
   5.111 +    if ( size > (100 * 1024) )
   5.112 +        print_mem(__FUNCTION__, size);
   5.113      return block->mmap_ptr;
   5.114  }
   5.115  
   5.116  void *xc_dom_malloc_filemap(struct xc_dom_image *dom,
   5.117 -			    const char *filename, size_t * size)
   5.118 +                            const char *filename, size_t * size)
   5.119  {
   5.120      struct xc_dom_mem *block = NULL;
   5.121      int fd = -1;
   5.122  
   5.123      fd = open(filename, O_RDONLY);
   5.124 -    if (-1 == fd)
   5.125 -	goto err;
   5.126 +    if ( fd == -1 )
   5.127 +        goto err;
   5.128  
   5.129      lseek(fd, 0, SEEK_SET);
   5.130      *size = lseek(fd, 0, SEEK_END);
   5.131  
   5.132      block = malloc(sizeof(*block));
   5.133 -    if (NULL == block)
   5.134 -	goto err;
   5.135 +    if ( block == NULL )
   5.136 +        goto err;
   5.137      memset(block, 0, sizeof(*block));
   5.138      block->mmap_len = *size;
   5.139 -    block->mmap_ptr = mmap(NULL, block->mmap_len, PROT_READ, MAP_SHARED, fd, 0);
   5.140 -    if (MAP_FAILED == block->mmap_ptr)
   5.141 -	goto err;
   5.142 +    block->mmap_ptr = mmap(NULL, block->mmap_len, PROT_READ,
   5.143 +                           MAP_SHARED, fd, 0);
   5.144 +    if ( block->mmap_ptr == MAP_FAILED )
   5.145 +        goto err;
   5.146      block->next = dom->memblocks;
   5.147      dom->memblocks = block;
   5.148      dom->alloc_malloc += sizeof(*block);
   5.149      dom->alloc_file_map += block->mmap_len;
   5.150      close(fd);
   5.151 -    if (*size > 100 * 1024)
   5.152 -	print_mem(__FUNCTION__, *size);
   5.153 +    if ( *size > (100 * 1024) )
   5.154 +        print_mem(__FUNCTION__, *size);
   5.155      return block->mmap_ptr;
   5.156  
   5.157 -  err:
   5.158 -    if (-1 != fd)
   5.159 -	close(fd);
   5.160 -    if (block)
   5.161 -	free(block);
   5.162 + err:
   5.163 +    if ( fd != -1 )
   5.164 +        close(fd);
   5.165 +    if ( block != NULL )
   5.166 +        free(block);
   5.167      return NULL;
   5.168  }
   5.169  
   5.170 @@ -180,12 +181,12 @@ static void xc_dom_free_all(struct xc_do
   5.171  {
   5.172      struct xc_dom_mem *block;
   5.173  
   5.174 -    while (NULL != (block = dom->memblocks))
   5.175 +    while ( (block = dom->memblocks) != NULL )
   5.176      {
   5.177 -	dom->memblocks = block->next;
   5.178 -	if (block->mmap_ptr)
   5.179 -	    munmap(block->mmap_ptr, block->mmap_len);
   5.180 -	free(block);
   5.181 +        dom->memblocks = block->next;
   5.182 +        if ( block->mmap_ptr )
   5.183 +            munmap(block->mmap_ptr, block->mmap_len);
   5.184 +        free(block);
   5.185      }
   5.186  }
   5.187  
   5.188 @@ -194,8 +195,8 @@ char *xc_dom_strdup(struct xc_dom_image 
   5.189      size_t len = strlen(str) + 1;
   5.190      char *nstr = xc_dom_malloc(dom, len);
   5.191  
   5.192 -    if (NULL == nstr)
   5.193 -	return NULL;
   5.194 +    if ( nstr == NULL )
   5.195 +        return NULL;
   5.196      memcpy(nstr, str, len);
   5.197      return nstr;
   5.198  }
   5.199 @@ -208,18 +209,18 @@ size_t xc_dom_check_gzip(void *blob, siz
   5.200      unsigned char *gzlen;
   5.201      size_t unziplen;
   5.202  
   5.203 -    if (0 != strncmp(blob, "\037\213", 2))
   5.204 -	/* not gzipped */
   5.205 -	return 0;
   5.206 +    if (strncmp(blob, "\037\213", 2))
   5.207 +        /* not gzipped */
   5.208 +        return 0;
   5.209  
   5.210      gzlen = blob + ziplen - 4;
   5.211      unziplen = gzlen[3] << 24 | gzlen[2] << 16 | gzlen[1] << 8 | gzlen[0];
   5.212 -    if (unziplen < ziplen || unziplen > ziplen * 8)
   5.213 +    if ( (unziplen < ziplen) || (unziplen > (ziplen * 8)) )
   5.214      {
   5.215 -	xc_dom_printf
   5.216 -	    ("%s: size (zip %zd, unzip %zd) looks insane, skip gunzip\n",
   5.217 -	     __FUNCTION__, ziplen, unziplen);
   5.218 -	return 0;
   5.219 +        xc_dom_printf
   5.220 +            ("%s: size (zip %zd, unzip %zd) looks insane, skip gunzip\n",
   5.221 +             __FUNCTION__, ziplen, unziplen);
   5.222 +        return 0;
   5.223      }
   5.224  
   5.225      return unziplen + 16;
   5.226 @@ -235,23 +236,23 @@ int xc_dom_do_gunzip(void *src, size_t s
   5.227      zStream.avail_in = srclen;
   5.228      zStream.next_out = dst;
   5.229      zStream.avail_out = dstlen;
   5.230 -    rc = inflateInit2(&zStream, (MAX_WBITS + 32));	/* +32 means "handle gzip" */
   5.231 -    if (rc != Z_OK)
   5.232 +    rc = inflateInit2(&zStream, (MAX_WBITS + 32)); /* +32 means "handle gzip" */
   5.233 +    if ( rc != Z_OK )
   5.234      {
   5.235 -	xc_dom_panic(XC_INTERNAL_ERROR,
   5.236 -		     "%s: inflateInit2 failed (rc=%d)\n", __FUNCTION__, rc);
   5.237 -	return -1;
   5.238 +        xc_dom_panic(XC_INTERNAL_ERROR,
   5.239 +                     "%s: inflateInit2 failed (rc=%d)\n", __FUNCTION__, rc);
   5.240 +        return -1;
   5.241      }
   5.242      rc = inflate(&zStream, Z_FINISH);
   5.243 -    if (rc != Z_STREAM_END)
   5.244 +    if ( rc != Z_STREAM_END )
   5.245      {
   5.246 -	xc_dom_panic(XC_INTERNAL_ERROR,
   5.247 -		     "%s: inflate failed (rc=%d)\n", __FUNCTION__, rc);
   5.248 -	return -1;
   5.249 +        xc_dom_panic(XC_INTERNAL_ERROR,
   5.250 +                     "%s: inflate failed (rc=%d)\n", __FUNCTION__, rc);
   5.251 +        return -1;
   5.252      }
   5.253  
   5.254      xc_dom_printf("%s: unzip ok, 0x%zx -> 0x%zx\n",
   5.255 -		  __FUNCTION__, srclen, dstlen);
   5.256 +                  __FUNCTION__, srclen, dstlen);
   5.257      return 0;
   5.258  }
   5.259  
   5.260 @@ -261,15 +262,15 @@ int xc_dom_try_gunzip(struct xc_dom_imag
   5.261      size_t unziplen;
   5.262  
   5.263      unziplen = xc_dom_check_gzip(*blob, *size);
   5.264 -    if (0 == unziplen)
   5.265 -	return 0;
   5.266 +    if ( unziplen == 0 )
   5.267 +        return 0;
   5.268  
   5.269      unzip = xc_dom_malloc(dom, unziplen);
   5.270 -    if (NULL == unzip)
   5.271 -	return -1;
   5.272 +    if ( unzip == NULL )
   5.273 +        return -1;
   5.274  
   5.275 -    if (-1 == xc_dom_do_gunzip(*blob, *size, unzip, unziplen))
   5.276 -	return -1;
   5.277 +    if ( xc_dom_do_gunzip(*blob, *size, unzip, unziplen) == -1 )
   5.278 +        return -1;
   5.279  
   5.280      *blob = unzip;
   5.281      *size = unziplen;
   5.282 @@ -280,92 +281,94 @@ int xc_dom_try_gunzip(struct xc_dom_imag
   5.283  /* domain memory                                                            */
   5.284  
   5.285  void *xc_dom_pfn_to_ptr(struct xc_dom_image *dom, xen_pfn_t pfn,
   5.286 -			xen_pfn_t count)
   5.287 +                        xen_pfn_t count)
   5.288  {
   5.289      struct xc_dom_phys *phys;
   5.290      unsigned int page_shift = XC_DOM_PAGE_SHIFT(dom);
   5.291      char *mode = "unset";
   5.292  
   5.293 -    if (pfn > dom->total_pages)
   5.294 +    if ( pfn > dom->total_pages )
   5.295      {
   5.296 -	xc_dom_printf("%s: pfn out of range (0x%" PRIpfn " > 0x%" PRIpfn ")\n",
   5.297 -		      __FUNCTION__, pfn, dom->total_pages);
   5.298 -	return NULL;
   5.299 +        xc_dom_printf("%s: pfn out of range (0x%" PRIpfn " > 0x%" PRIpfn ")\n",
   5.300 +                      __FUNCTION__, pfn, dom->total_pages);
   5.301 +        return NULL;
   5.302      }
   5.303  
   5.304      /* already allocated? */
   5.305 -    for (phys = dom->phys_pages; NULL != phys; phys = phys->next)
   5.306 +    for ( phys = dom->phys_pages; phys != NULL; phys = phys->next )
   5.307      {
   5.308 -	if (pfn >= phys->first + phys->count)
   5.309 -	    continue;
   5.310 -	if (count)
   5.311 -	{
   5.312 -	    /* size given: must be completely within the already allocated block */
   5.313 -	    if (pfn + count <= phys->first)
   5.314 -		continue;
   5.315 -	    if (pfn < phys->first || pfn + count > phys->first + phys->count)
   5.316 -	    {
   5.317 -		xc_dom_printf("%s: request overlaps allocated block"
   5.318 -			      " (req 0x%" PRIpfn "+0x%" PRIpfn ","
   5.319 -			      " blk 0x%" PRIpfn "+0x%" PRIpfn ")\n",
   5.320 -			      __FUNCTION__, pfn, count, phys->first,
   5.321 -			      phys->count);
   5.322 -		return NULL;
   5.323 -	    }
   5.324 -	}
   5.325 -	else
   5.326 -	{
   5.327 -	    /* no size given: block must be allocated already,
   5.328 -	       just hand out a pointer to it */
   5.329 -	    if (pfn < phys->first)
   5.330 -		continue;
   5.331 -	}
   5.332 -	return phys->ptr + ((pfn - phys->first) << page_shift);
   5.333 +        if ( pfn >= (phys->first + phys->count) )
   5.334 +            continue;
   5.335 +        if ( count )
   5.336 +        {
   5.337 +            /* size given: must be completely within the already allocated block */
   5.338 +            if ( (pfn + count) <= phys->first )
   5.339 +                continue;
   5.340 +            if ( (pfn < phys->first) ||
   5.341 +                 ((pfn + count) > (phys->first + phys->count)) )
   5.342 +            {
   5.343 +                xc_dom_printf("%s: request overlaps allocated block"
   5.344 +                              " (req 0x%" PRIpfn "+0x%" PRIpfn ","
   5.345 +                              " blk 0x%" PRIpfn "+0x%" PRIpfn ")\n",
   5.346 +                              __FUNCTION__, pfn, count, phys->first,
   5.347 +                              phys->count);
   5.348 +                return NULL;
   5.349 +            }
   5.350 +        }
   5.351 +        else
   5.352 +        {
   5.353 +            /* no size given: block must be allocated already,
   5.354 +               just hand out a pointer to it */
   5.355 +            if ( pfn < phys->first )
   5.356 +                continue;
   5.357 +        }
   5.358 +        return phys->ptr + ((pfn - phys->first) << page_shift);
   5.359      }
   5.360  
   5.361      /* allocating is allowed with size specified only */
   5.362 -    if (0 == count)
   5.363 +    if ( count == 0 )
   5.364      {
   5.365 -	xc_dom_printf("%s: no block found, no size given,"
   5.366 -		      " can't malloc (pfn 0x%" PRIpfn ")\n", __FUNCTION__, pfn);
   5.367 -	return NULL;
   5.368 +        xc_dom_printf("%s: no block found, no size given,"
   5.369 +                      " can't malloc (pfn 0x%" PRIpfn ")\n",
   5.370 +                      __FUNCTION__, pfn);
   5.371 +        return NULL;
   5.372      }
   5.373  
   5.374      /* not found, no overlap => allocate */
   5.375      phys = xc_dom_malloc(dom, sizeof(*phys));
   5.376 -    if (NULL == phys)
   5.377 -	return NULL;
   5.378 +    if ( phys == NULL )
   5.379 +        return NULL;
   5.380      memset(phys, 0, sizeof(*phys));
   5.381      phys->first = pfn;
   5.382      phys->count = count;
   5.383  
   5.384 -    if (dom->guest_domid)
   5.385 +    if ( dom->guest_domid )
   5.386      {
   5.387 -	mode = "domU mapping";
   5.388 -	phys->ptr = xc_dom_boot_domU_map(dom, phys->first, phys->count);
   5.389 -	if (NULL == phys->ptr)
   5.390 -	    return NULL;
   5.391 -	dom->alloc_domU_map += phys->count << page_shift;
   5.392 +        mode = "domU mapping";
   5.393 +        phys->ptr = xc_dom_boot_domU_map(dom, phys->first, phys->count);
   5.394 +        if ( phys->ptr == NULL )
   5.395 +            return NULL;
   5.396 +        dom->alloc_domU_map += phys->count << page_shift;
   5.397      }
   5.398      else
   5.399      {
   5.400 -	mode = "anonymous memory";
   5.401 -	phys->ptr = mmap(NULL, phys->count << page_shift,
   5.402 -			 PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS,
   5.403 -			 -1, 0);
   5.404 -	if (MAP_FAILED == phys->ptr)
   5.405 -	{
   5.406 -	    xc_dom_panic(XC_OUT_OF_MEMORY,
   5.407 -			 "%s: oom: can't allocate 0x%" PRIpfn " pages\n",
   5.408 -			 __FUNCTION__, count);
   5.409 -	    return NULL;
   5.410 -	}
   5.411 -	dom->alloc_mem_map += phys->count << page_shift;
   5.412 +        mode = "anonymous memory";
   5.413 +        phys->ptr = mmap(NULL, phys->count << page_shift,
   5.414 +                         PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS,
   5.415 +                         -1, 0);
   5.416 +        if ( phys->ptr == MAP_FAILED )
   5.417 +        {
   5.418 +            xc_dom_panic(XC_OUT_OF_MEMORY,
   5.419 +                         "%s: oom: can't allocate 0x%" PRIpfn " pages\n",
   5.420 +                         __FUNCTION__, count);
   5.421 +            return NULL;
   5.422 +        }
   5.423 +        dom->alloc_mem_map += phys->count << page_shift;
   5.424      }
   5.425  
   5.426  #if 1
   5.427      xc_dom_printf("%s: %s: pfn 0x%" PRIpfn "+0x%" PRIpfn " at %p\n",
   5.428 -		  __FUNCTION__, mode, phys->first, phys->count, phys->ptr);
   5.429 +                  __FUNCTION__, mode, phys->first, phys->count, phys->ptr);
   5.430  #endif
   5.431      phys->next = dom->phys_pages;
   5.432      dom->phys_pages = phys;
   5.433 @@ -373,29 +376,29 @@ void *xc_dom_pfn_to_ptr(struct xc_dom_im
   5.434  }
   5.435  
   5.436  int xc_dom_alloc_segment(struct xc_dom_image *dom,
   5.437 -			 struct xc_dom_seg *seg, char *name,
   5.438 -			 xen_vaddr_t start, xen_vaddr_t size)
   5.439 +                         struct xc_dom_seg *seg, char *name,
   5.440 +                         xen_vaddr_t start, xen_vaddr_t size)
   5.441  {
   5.442      unsigned int page_size = XC_DOM_PAGE_SIZE(dom);
   5.443      xen_pfn_t pages = (size + page_size - 1) / page_size;
   5.444      void *ptr;
   5.445  
   5.446 -    if (0 == start)
   5.447 -	start = dom->virt_alloc_end;
   5.448 +    if ( start == 0 )
   5.449 +        start = dom->virt_alloc_end;
   5.450  
   5.451 -    if (start & (page_size - 1))
   5.452 +    if ( start & (page_size - 1) )
   5.453      {
   5.454 -	xc_dom_panic(XC_INTERNAL_ERROR,
   5.455 -		     "%s: segment start isn't page aligned (0x%" PRIx64 ")\n",
   5.456 -		     __FUNCTION__, start);
   5.457 -	return -1;
   5.458 +        xc_dom_panic(XC_INTERNAL_ERROR,
   5.459 +                     "%s: segment start isn't page aligned (0x%" PRIx64 ")\n",
   5.460 +                     __FUNCTION__, start);
   5.461 +        return -1;
   5.462      }
   5.463 -    if (start < dom->virt_alloc_end)
   5.464 +    if ( start < dom->virt_alloc_end )
   5.465      {
   5.466 -	xc_dom_panic(XC_INTERNAL_ERROR,
   5.467 -		     "%s: segment start too low (0x%" PRIx64 " < 0x%" PRIx64
   5.468 -		     ")\n", __FUNCTION__, start, dom->virt_alloc_end);
   5.469 -	return -1;
   5.470 +        xc_dom_panic(XC_INTERNAL_ERROR,
   5.471 +                     "%s: segment start too low (0x%" PRIx64 " < 0x%" PRIx64
   5.472 +                     ")\n", __FUNCTION__, start, dom->virt_alloc_end);
   5.473 +        return -1;
   5.474      }
   5.475  
   5.476      seg->vstart = start;
   5.477 @@ -404,13 +407,13 @@ int xc_dom_alloc_segment(struct xc_dom_i
   5.478      dom->virt_alloc_end = seg->vend;
   5.479  
   5.480      xc_dom_printf("%-20s:   %-12s : 0x%" PRIx64 " -> 0x%" PRIx64
   5.481 -		  "  (pfn 0x%" PRIpfn " + 0x%" PRIpfn " pages)\n",
   5.482 -		  __FUNCTION__, name, seg->vstart, seg->vend, seg->pfn, pages);
   5.483 +                  "  (pfn 0x%" PRIpfn " + 0x%" PRIpfn " pages)\n",
   5.484 +                  __FUNCTION__, name, seg->vstart, seg->vend, seg->pfn, pages);
   5.485  
   5.486      /* map and clear pages */
   5.487      ptr = xc_dom_seg_to_ptr(dom, seg);
   5.488 -    if (NULL == ptr)
   5.489 -	return -1;
   5.490 +    if ( ptr == NULL )
   5.491 +        return -1;
   5.492      memset(ptr, 0, pages * page_size);
   5.493  
   5.494      return 0;
   5.495 @@ -427,7 +430,7 @@ int xc_dom_alloc_page(struct xc_dom_imag
   5.496      pfn = (start - dom->parms.virt_base) / page_size;
   5.497  
   5.498      xc_dom_printf("%-20s:   %-12s : 0x%" PRIx64 " (pfn 0x%" PRIpfn ")\n",
   5.499 -		  __FUNCTION__, name, start, pfn);
   5.500 +                  __FUNCTION__, name, start, pfn);
   5.501      return pfn;
   5.502  }
   5.503  
   5.504 @@ -436,30 +439,30 @@ void xc_dom_unmap_one(struct xc_dom_imag
   5.505      unsigned int page_shift = XC_DOM_PAGE_SHIFT(dom);
   5.506      struct xc_dom_phys *phys, *prev = NULL;
   5.507  
   5.508 -    for (phys = dom->phys_pages; NULL != phys; phys = phys->next)
   5.509 +    for ( phys = dom->phys_pages; phys != NULL; phys = phys->next )
   5.510      {
   5.511 -	if (pfn >= phys->first && pfn < phys->first + phys->count)
   5.512 -	    break;
   5.513 -	prev = phys;
   5.514 +        if ( (pfn >= phys->first) && (pfn < (phys->first + phys->count)) )
   5.515 +            break;
   5.516 +        prev = phys;
   5.517      }
   5.518 -    if (!phys)
   5.519 +    if ( !phys )
   5.520      {
   5.521 -	xc_dom_printf("%s: Huh? no mapping with pfn 0x%" PRIpfn "\n",
   5.522 -		      __FUNCTION__, pfn);
   5.523 -	return;
   5.524 +        xc_dom_printf("%s: Huh? no mapping with pfn 0x%" PRIpfn "\n",
   5.525 +                      __FUNCTION__, pfn);
   5.526 +        return;
   5.527      }
   5.528  
   5.529      munmap(phys->ptr, phys->count << page_shift);
   5.530 -    if (prev)
   5.531 -	prev->next = phys->next;
   5.532 +    if ( prev )
   5.533 +        prev->next = phys->next;
   5.534      else
   5.535 -	dom->phys_pages = phys->next;
   5.536 +        dom->phys_pages = phys->next;
   5.537  }
   5.538  
   5.539  void xc_dom_unmap_all(struct xc_dom_image *dom)
   5.540  {
   5.541 -    while (dom->phys_pages)
   5.542 -	xc_dom_unmap_one(dom, dom->phys_pages->first);
   5.543 +    while ( dom->phys_pages )
   5.544 +        xc_dom_unmap_one(dom, dom->phys_pages->first);
   5.545  }
   5.546  
   5.547  /* ------------------------------------------------------------------------ */
   5.548 @@ -478,16 +481,16 @@ static struct xc_dom_loader *xc_dom_find
   5.549  {
   5.550      struct xc_dom_loader *loader = first_loader;
   5.551  
   5.552 -    while (NULL != loader)
   5.553 +    while ( loader != NULL )
   5.554      {
   5.555 -	xc_dom_printf("%s: trying %s loader ... ", __FUNCTION__, loader->name);
   5.556 -	if (0 == loader->probe(dom))
   5.557 -	{
   5.558 -	    xc_dom_printf("OK\n");
   5.559 -	    return loader;
   5.560 -	}
   5.561 -	xc_dom_printf("failed\n");
   5.562 -	loader = loader->next;
   5.563 +        xc_dom_printf("%s: trying %s loader ... ", __FUNCTION__, loader->name);
   5.564 +        if ( loader->probe(dom) == 0 )
   5.565 +        {
   5.566 +            xc_dom_printf("OK\n");
   5.567 +            return loader;
   5.568 +        }
   5.569 +        xc_dom_printf("failed\n");
   5.570 +        loader = loader->next;
   5.571      }
   5.572      xc_dom_panic(XC_INVALID_KERNEL, "%s: no loader found\n", __FUNCTION__);
   5.573      return NULL;
   5.574 @@ -503,14 +506,14 @@ static struct xc_dom_arch *xc_dom_find_a
   5.575  {
   5.576      struct xc_dom_arch *hooks = first_hook;
   5.577  
   5.578 -    while (NULL != hooks)
   5.579 +    while (  hooks != NULL )
   5.580      {
   5.581 -	if (0 == strcmp(hooks->guest_type, guest_type))
   5.582 -	    return hooks;
   5.583 -	hooks = hooks->next;
   5.584 +        if ( !strcmp(hooks->guest_type, guest_type))
   5.585 +            return hooks;
   5.586 +        hooks = hooks->next;
   5.587      }
   5.588      xc_dom_panic(XC_INVALID_KERNEL,
   5.589 -		 "%s: not found (type %s)\n", __FUNCTION__, guest_type);
   5.590 +                 "%s: not found (type %s)\n", __FUNCTION__, guest_type);
   5.591      return NULL;
   5.592  }
   5.593  
   5.594 @@ -520,8 +523,8 @@ static struct xc_dom_arch *xc_dom_find_a
   5.595  void xc_dom_release(struct xc_dom_image *dom)
   5.596  {
   5.597      xc_dom_printf("%s: called\n", __FUNCTION__);
   5.598 -    if (dom->phys_pages)
   5.599 -	xc_dom_unmap_all(dom);
   5.600 +    if ( dom->phys_pages )
   5.601 +        xc_dom_unmap_all(dom);
   5.602      xc_dom_free_all(dom);
   5.603      free(dom);
   5.604  }
   5.605 @@ -531,16 +534,16 @@ struct xc_dom_image *xc_dom_allocate(con
   5.606      struct xc_dom_image *dom;
   5.607  
   5.608      xc_dom_printf("%s: cmdline=\"%s\", features=\"%s\"\n",
   5.609 -		  __FUNCTION__, cmdline, features);
   5.610 +                  __FUNCTION__, cmdline, features);
   5.611      dom = malloc(sizeof(*dom));
   5.612 -    if (!dom)
   5.613 -	goto err;
   5.614 +    if ( !dom )
   5.615 +        goto err;
   5.616  
   5.617      memset(dom, 0, sizeof(*dom));
   5.618 -    if (cmdline)
   5.619 -	dom->cmdline = xc_dom_strdup(dom, cmdline);
   5.620 -    if (features)
   5.621 -	elf_xen_parse_features(features, dom->f_requested, NULL);
   5.622 +    if ( cmdline )
   5.623 +        dom->cmdline = xc_dom_strdup(dom, cmdline);
   5.624 +    if ( features )
   5.625 +        elf_xen_parse_features(features, dom->f_requested, NULL);
   5.626  
   5.627      dom->parms.virt_base = UNSET_ADDR;
   5.628      dom->parms.virt_entry = UNSET_ADDR;
   5.629 @@ -551,9 +554,9 @@ struct xc_dom_image *xc_dom_allocate(con
   5.630      dom->alloc_malloc += sizeof(*dom);
   5.631      return dom;
   5.632  
   5.633 -  err:
   5.634 -    if (dom)
   5.635 -	xc_dom_release(dom);
   5.636 + err:
   5.637 +    if ( dom )
   5.638 +        xc_dom_release(dom);
   5.639      return NULL;
   5.640  }
   5.641  
   5.642 @@ -561,8 +564,8 @@ int xc_dom_kernel_file(struct xc_dom_ima
   5.643  {
   5.644      xc_dom_printf("%s: filename=\"%s\"\n", __FUNCTION__, filename);
   5.645      dom->kernel_blob = xc_dom_malloc_filemap(dom, filename, &dom->kernel_size);
   5.646 -    if (NULL == dom->kernel_blob)
   5.647 -	return -1;
   5.648 +    if ( dom->kernel_blob == NULL )
   5.649 +        return -1;
   5.650      return xc_dom_try_gunzip(dom, &dom->kernel_blob, &dom->kernel_size);
   5.651  }
   5.652  
   5.653 @@ -570,9 +573,9 @@ int xc_dom_ramdisk_file(struct xc_dom_im
   5.654  {
   5.655      xc_dom_printf("%s: filename=\"%s\"\n", __FUNCTION__, filename);
   5.656      dom->ramdisk_blob =
   5.657 -	xc_dom_malloc_filemap(dom, filename, &dom->ramdisk_size);
   5.658 -    if (NULL == dom->ramdisk_blob)
   5.659 -	return -1;
   5.660 +        xc_dom_malloc_filemap(dom, filename, &dom->ramdisk_size);
   5.661 +    if ( dom->ramdisk_blob == NULL )
   5.662 +        return -1;
   5.663  //    return xc_dom_try_gunzip(dom, &dom->ramdisk_blob, &dom->ramdisk_size);
   5.664      return 0;
   5.665  }
   5.666 @@ -586,7 +589,7 @@ int xc_dom_kernel_mem(struct xc_dom_imag
   5.667  }
   5.668  
   5.669  int xc_dom_ramdisk_mem(struct xc_dom_image *dom, const void *mem,
   5.670 -		       size_t memsize)
   5.671 +                       size_t memsize)
   5.672  {
   5.673      xc_dom_printf("%s: called\n", __FUNCTION__);
   5.674      dom->ramdisk_blob = (void *)mem;
   5.675 @@ -603,32 +606,33 @@ int xc_dom_parse_image(struct xc_dom_ima
   5.676  
   5.677      /* parse kernel image */
   5.678      dom->kernel_loader = xc_dom_find_loader(dom);
   5.679 -    if (NULL == dom->kernel_loader)
   5.680 -	goto err;
   5.681 -    if (0 != dom->kernel_loader->parser(dom))
   5.682 -	goto err;
   5.683 -    if (NULL == dom->guest_type)
   5.684 +    if ( dom->kernel_loader == NULL )
   5.685 +        goto err;
   5.686 +    if ( dom->kernel_loader->parser(dom) != 0 )
   5.687 +        goto err;
   5.688 +    if ( dom->guest_type == NULL )
   5.689      {
   5.690 -	xc_dom_panic(XC_INTERNAL_ERROR,
   5.691 -		     "%s: guest_type not set\n", __FUNCTION__);
   5.692 -	goto err;
   5.693 +        xc_dom_panic(XC_INTERNAL_ERROR,
   5.694 +                     "%s: guest_type not set\n", __FUNCTION__);
   5.695 +        goto err;
   5.696      }
   5.697  
   5.698      /* check features */
   5.699 -    for (i = 0; i < XENFEAT_NR_SUBMAPS; i++)
   5.700 +    for ( i = 0; i < XENFEAT_NR_SUBMAPS; i++ )
   5.701      {
   5.702 -	dom->f_active[i] |= dom->f_requested[i];	/* cmd line */
   5.703 -	dom->f_active[i] |= dom->parms.f_required[i];	/* kernel   */
   5.704 -	if ((dom->f_active[i] & dom->parms.f_supported[i]) != dom->f_active[i])
   5.705 -	{
   5.706 -	    xc_dom_panic(XC_INVALID_PARAM,
   5.707 -			 "%s: unsupported feature requested\n", __FUNCTION__);
   5.708 -	    goto err;
   5.709 -	}
   5.710 +        dom->f_active[i] |= dom->f_requested[i]; /* cmd line */
   5.711 +        dom->f_active[i] |= dom->parms.f_required[i]; /* kernel   */
   5.712 +        if ( (dom->f_active[i] & dom->parms.f_supported[i]) !=
   5.713 +             dom->f_active[i] )
   5.714 +        {
   5.715 +            xc_dom_panic(XC_INVALID_PARAM,
   5.716 +                         "%s: unsupported feature requested\n", __FUNCTION__);
   5.717 +            goto err;
   5.718 +        }
   5.719      }
   5.720      return 0;
   5.721  
   5.722 -  err:
   5.723 + err:
   5.724      return -1;
   5.725  }
   5.726  
   5.727 @@ -638,27 +642,27 @@ int xc_dom_mem_init(struct xc_dom_image 
   5.728      xen_pfn_t nr_pages, pfn;
   5.729  
   5.730      dom->arch_hooks = xc_dom_find_arch_hooks(dom->guest_type);
   5.731 -    if (NULL == dom->arch_hooks)
   5.732 +    if ( dom->arch_hooks == NULL )
   5.733      {
   5.734 -	xc_dom_panic(XC_INTERNAL_ERROR, "%s: arch hooks not set\n",
   5.735 -		     __FUNCTION__);
   5.736 -	return -1;
   5.737 +        xc_dom_panic(XC_INTERNAL_ERROR, "%s: arch hooks not set\n",
   5.738 +                     __FUNCTION__);
   5.739 +        return -1;
   5.740      }
   5.741  
   5.742      page_shift = XC_DOM_PAGE_SHIFT(dom);
   5.743      nr_pages = mem_mb << (20 - page_shift);
   5.744  
   5.745      xc_dom_printf("%s: mem %d MB, pages 0x%" PRIpfn " pages, %dk each\n",
   5.746 -		  __FUNCTION__, mem_mb, nr_pages, 1 << (page_shift-10));
   5.747 +                  __FUNCTION__, mem_mb, nr_pages, 1 << (page_shift-10));
   5.748      dom->total_pages = nr_pages;
   5.749  
   5.750      xc_dom_printf("%s: 0x%" PRIpfn " pages\n",
   5.751 -		  __FUNCTION__, dom->total_pages);
   5.752 +                  __FUNCTION__, dom->total_pages);
   5.753  
   5.754      /* setup initial p2m */
   5.755      dom->p2m_host = xc_dom_malloc(dom, sizeof(xen_pfn_t) * dom->total_pages);
   5.756 -    for (pfn = 0; pfn < dom->total_pages; pfn++)
   5.757 -	dom->p2m_host[pfn] = pfn;
   5.758 +    for ( pfn = 0; pfn < dom->total_pages; pfn++ )
   5.759 +        dom->p2m_host[pfn] = pfn;
   5.760      return 0;
   5.761  }
   5.762  
   5.763 @@ -668,36 +672,36 @@ int xc_dom_update_guest_p2m(struct xc_do
   5.764      uint64_t *p2m_64;
   5.765      xen_pfn_t i;
   5.766  
   5.767 -    if (!dom->p2m_guest)
   5.768 -	return 0;
   5.769 +    if ( !dom->p2m_guest )
   5.770 +        return 0;
   5.771  
   5.772 -    switch (dom->arch_hooks->sizeof_pfn)
   5.773 +    switch ( dom->arch_hooks->sizeof_pfn )
   5.774      {
   5.775      case 4:
   5.776 -	xc_dom_printf("%s: dst 32bit, pages 0x%" PRIpfn " \n",
   5.777 -		      __FUNCTION__, dom->total_pages);
   5.778 -	p2m_32 = dom->p2m_guest;
   5.779 -	for (i = 0; i < dom->total_pages; i++)
   5.780 -	    if (INVALID_P2M_ENTRY != dom->p2m_host[i])
   5.781 -		p2m_32[i] = dom->p2m_host[i];
   5.782 -	    else
   5.783 -		p2m_32[i] = (uint32_t) - 1;
   5.784 -	break;
   5.785 +        xc_dom_printf("%s: dst 32bit, pages 0x%" PRIpfn " \n",
   5.786 +                      __FUNCTION__, dom->total_pages);
   5.787 +        p2m_32 = dom->p2m_guest;
   5.788 +        for ( i = 0; i < dom->total_pages; i++ )
   5.789 +            if ( dom->p2m_host[i] != INVALID_P2M_ENTRY )
   5.790 +                p2m_32[i] = dom->p2m_host[i];
   5.791 +            else
   5.792 +                p2m_32[i] = (uint32_t) - 1;
   5.793 +        break;
   5.794      case 8:
   5.795 -	xc_dom_printf("%s: dst 64bit, pages 0x%" PRIpfn " \n",
   5.796 -		      __FUNCTION__, dom->total_pages);
   5.797 -	p2m_64 = dom->p2m_guest;
   5.798 -	for (i = 0; i < dom->total_pages; i++)
   5.799 -	    if (INVALID_P2M_ENTRY != dom->p2m_host[i])
   5.800 -		p2m_64[i] = dom->p2m_host[i];
   5.801 -	    else
   5.802 -		p2m_64[i] = (uint64_t) - 1;
   5.803 -	break;
   5.804 +        xc_dom_printf("%s: dst 64bit, pages 0x%" PRIpfn " \n",
   5.805 +                      __FUNCTION__, dom->total_pages);
   5.806 +        p2m_64 = dom->p2m_guest;
   5.807 +        for ( i = 0; i < dom->total_pages; i++ )
   5.808 +            if ( dom->p2m_host[i] != INVALID_P2M_ENTRY )
   5.809 +                p2m_64[i] = dom->p2m_host[i];
   5.810 +            else
   5.811 +                p2m_64[i] = (uint64_t) - 1;
   5.812 +        break;
   5.813      default:
   5.814 -	xc_dom_panic(XC_INTERNAL_ERROR,
   5.815 -		     "sizeof_pfn is invalid (is %d, can be 4 or 8)",
   5.816 -		     dom->arch_hooks->sizeof_pfn);
   5.817 -	return -1;
   5.818 +        xc_dom_panic(XC_INTERNAL_ERROR,
   5.819 +                     "sizeof_pfn is invalid (is %d, can be 4 or 8)",
   5.820 +                     dom->arch_hooks->sizeof_pfn);
   5.821 +        return -1;
   5.822      }
   5.823      return 0;
   5.824  }
   5.825 @@ -709,11 +713,11 @@ int xc_dom_build_image(struct xc_dom_ima
   5.826      xc_dom_printf("%s: called\n", __FUNCTION__);
   5.827  
   5.828      /* check for arch hooks */
   5.829 -    if (NULL == dom->arch_hooks)
   5.830 +    if ( dom->arch_hooks == NULL )
   5.831      {
   5.832 -	xc_dom_panic(XC_INTERNAL_ERROR, "%s: arch hooks not set\n",
   5.833 -		     __FUNCTION__);
   5.834 -	goto err;
   5.835 +        xc_dom_panic(XC_INTERNAL_ERROR, "%s: arch hooks not set\n",
   5.836 +                     __FUNCTION__);
   5.837 +        goto err;
   5.838      }
   5.839      page_size = XC_DOM_PAGE_SIZE(dom);
   5.840  
   5.841 @@ -721,56 +725,65 @@ int xc_dom_build_image(struct xc_dom_ima
   5.842      dom->parms.virt_base &= ~(((uint64_t)1<<22)-1);
   5.843  
   5.844      /* load kernel */
   5.845 -    if (0 != xc_dom_alloc_segment(dom, &dom->kernel_seg, "kernel",
   5.846 -				  dom->kernel_seg.vstart,
   5.847 -				  dom->kernel_seg.vend -
   5.848 -				  dom->kernel_seg.vstart))
   5.849 -	goto err;
   5.850 -    if (0 != dom->kernel_loader->loader(dom))
   5.851 -	goto err;
   5.852 +    if ( xc_dom_alloc_segment(dom, &dom->kernel_seg, "kernel",
   5.853 +                              dom->kernel_seg.vstart,
   5.854 +                              dom->kernel_seg.vend -
   5.855 +                              dom->kernel_seg.vstart) != 0 )
   5.856 +        goto err;
   5.857 +    if ( dom->kernel_loader->loader(dom) != 0 )
   5.858 +        goto err;
   5.859  
   5.860      /* load ramdisk */
   5.861 -    if (dom->ramdisk_blob)
   5.862 +    if ( dom->ramdisk_blob )
   5.863      {
   5.864 -	size_t unziplen, ramdisklen;
   5.865 -	void *ramdiskmap;
   5.866 +        size_t unziplen, ramdisklen;
   5.867 +        void *ramdiskmap;
   5.868  
   5.869 -	unziplen = xc_dom_check_gzip(dom->ramdisk_blob, dom->ramdisk_size);
   5.870 -	ramdisklen = unziplen ? unziplen : dom->ramdisk_size;
   5.871 -	if (0 != xc_dom_alloc_segment(dom, &dom->ramdisk_seg, "ramdisk", 0,
   5.872 -				      ramdisklen))
   5.873 -	    goto err;
   5.874 -	ramdiskmap = xc_dom_seg_to_ptr(dom, &dom->ramdisk_seg);
   5.875 -	if (unziplen)
   5.876 -	{
   5.877 -	    if (-1 == xc_dom_do_gunzip(dom->ramdisk_blob, dom->ramdisk_size,
   5.878 -				       ramdiskmap, ramdisklen))
   5.879 -		goto err;
   5.880 -	}
   5.881 -	else
   5.882 -	    memcpy(ramdiskmap, dom->ramdisk_blob, dom->ramdisk_size);
   5.883 +        unziplen = xc_dom_check_gzip(dom->ramdisk_blob, dom->ramdisk_size);
   5.884 +        ramdisklen = unziplen ? unziplen : dom->ramdisk_size;
   5.885 +        if ( xc_dom_alloc_segment(dom, &dom->ramdisk_seg, "ramdisk", 0,
   5.886 +                                  ramdisklen) != 0 )
   5.887 +            goto err;
   5.888 +        ramdiskmap = xc_dom_seg_to_ptr(dom, &dom->ramdisk_seg);
   5.889 +        if ( unziplen )
   5.890 +        {
   5.891 +            if ( xc_dom_do_gunzip(dom->ramdisk_blob, dom->ramdisk_size,
   5.892 +                                  ramdiskmap, ramdisklen) == -1 )
   5.893 +                goto err;
   5.894 +        }
   5.895 +        else
   5.896 +            memcpy(ramdiskmap, dom->ramdisk_blob, dom->ramdisk_size);
   5.897      }
   5.898  
   5.899      /* allocate other pages */
   5.900 -    if (0 != dom->arch_hooks->alloc_magic_pages(dom))
   5.901 -	goto err;
   5.902 -    if (dom->arch_hooks->count_pgtables)
   5.903 +    if ( dom->arch_hooks->alloc_magic_pages(dom) != 0 )
   5.904 +        goto err;
   5.905 +    if ( dom->arch_hooks->count_pgtables )
   5.906      {
   5.907 -	dom->arch_hooks->count_pgtables(dom);
   5.908 -	if (dom->pgtables > 0)
   5.909 -	    if (0 !=
   5.910 -		xc_dom_alloc_segment(dom, &dom->pgtables_seg, "page tables", 0,
   5.911 -				     dom->pgtables * page_size))
   5.912 -		goto err;
   5.913 +        dom->arch_hooks->count_pgtables(dom);
   5.914 +        if ( (dom->pgtables > 0) &&
   5.915 +             (xc_dom_alloc_segment(dom, &dom->pgtables_seg, "page tables", 0,
   5.916 +                                   dom->pgtables * page_size) != 0) )
   5.917 +                goto err;
   5.918      }
   5.919 -    if (dom->alloc_bootstack)
   5.920 -	dom->bootstack_pfn = xc_dom_alloc_page(dom, "boot stack");
   5.921 +    if ( dom->alloc_bootstack )
   5.922 +        dom->bootstack_pfn = xc_dom_alloc_page(dom, "boot stack");
   5.923      xc_dom_printf("%-20s: virt_alloc_end : 0x%" PRIx64 "\n",
   5.924 -		  __FUNCTION__, dom->virt_alloc_end);
   5.925 +                  __FUNCTION__, dom->virt_alloc_end);
   5.926      xc_dom_printf("%-20s: virt_pgtab_end : 0x%" PRIx64 "\n",
   5.927 -		  __FUNCTION__, dom->virt_pgtab_end);
   5.928 +                  __FUNCTION__, dom->virt_pgtab_end);
   5.929      return 0;
   5.930  
   5.931 -  err:
   5.932 + err:
   5.933      return -1;
   5.934  }
   5.935 +
   5.936 +/*
   5.937 + * Local variables:
   5.938 + * mode: C
   5.939 + * c-set-style: "BSD"
   5.940 + * c-basic-offset: 4
   5.941 + * tab-width: 4
   5.942 + * indent-tabs-mode: nil
   5.943 + * End:
   5.944 + */
     6.1 --- a/tools/libxc/xc_dom_elfloader.c	Sat Feb 24 14:48:17 2007 +0000
     6.2 +++ b/tools/libxc/xc_dom_elfloader.c	Sat Feb 24 15:30:19 2007 +0000
     6.3 @@ -19,33 +19,34 @@
     6.4  /* ------------------------------------------------------------------------ */
     6.5  
     6.6  static char *xc_dom_guest_type(struct xc_dom_image *dom,
     6.7 -			       struct elf_binary *elf)
     6.8 +                               struct elf_binary *elf)
     6.9  {
    6.10      uint64_t machine = elf_uval(elf, elf->ehdr, e_machine);
    6.11  
    6.12 -    switch (machine) {
    6.13 +    switch ( machine )
    6.14 +    {
    6.15      case EM_386:
    6.16 -	switch (dom->parms.pae) {
    6.17 -	case 3 /* PAEKERN_bimodal */:
    6.18 -	    if (strstr(dom->xen_caps, "xen-3.0-x86_32p"))
    6.19 -		return "xen-3.0-x86_32p";
    6.20 -	    return "xen-3.0-x86_32";
    6.21 -	case PAEKERN_extended_cr3:
    6.22 -	case PAEKERN_yes:
    6.23 -	    return "xen-3.0-x86_32p";
    6.24 -	    break;
    6.25 -	case PAEKERN_no:
    6.26 -	default:
    6.27 -	    return "xen-3.0-x86_32";
    6.28 -	}
    6.29 +        switch ( dom->parms.pae )
    6.30 +        {
    6.31 +        case 3 /* PAEKERN_bimodal */:
    6.32 +            if ( strstr(dom->xen_caps, "xen-3.0-x86_32p") )
    6.33 +                return "xen-3.0-x86_32p";
    6.34 +            return "xen-3.0-x86_32";
    6.35 +        case PAEKERN_extended_cr3:
    6.36 +        case PAEKERN_yes:
    6.37 +            return "xen-3.0-x86_32p";
    6.38 +        case PAEKERN_no:
    6.39 +        default:
    6.40 +            return "xen-3.0-x86_32";
    6.41 +        }
    6.42      case EM_X86_64:
    6.43 -	return "xen-3.0-x86_64";
    6.44 +        return "xen-3.0-x86_64";
    6.45      case EM_IA_64:
    6.46 -	return elf_msb(elf) ? "xen-3.0-ia64be" : "xen-3.0-ia64";
    6.47 +        return elf_msb(elf) ? "xen-3.0-ia64be" : "xen-3.0-ia64";
    6.48      case EM_PPC64:
    6.49 -	return "xen-3.0-powerpc64";
    6.50 +        return "xen-3.0-powerpc64";
    6.51      default:
    6.52 -	return "xen-3.0-unknown";
    6.53 +        return "xen-3.0-unknown";
    6.54      }
    6.55  }
    6.56  
    6.57 @@ -54,20 +55,20 @@ static char *xc_dom_guest_type(struct xc
    6.58  
    6.59  static int check_elf_kernel(struct xc_dom_image *dom, int verbose)
    6.60  {
    6.61 -    if (NULL == dom->kernel_blob)
    6.62 +    if ( dom->kernel_blob == NULL )
    6.63      {
    6.64 -	if (verbose)
    6.65 -	    xc_dom_panic(XC_INTERNAL_ERROR, "%s: no kernel image loaded\n",
    6.66 -			 __FUNCTION__);
    6.67 -	return -EINVAL;
    6.68 +        if ( verbose )
    6.69 +            xc_dom_panic(XC_INTERNAL_ERROR, "%s: no kernel image loaded\n",
    6.70 +                         __FUNCTION__);
    6.71 +        return -EINVAL;
    6.72      }
    6.73  
    6.74 -    if (!elf_is_elfbinary(dom->kernel_blob))
    6.75 +    if ( !elf_is_elfbinary(dom->kernel_blob) )
    6.76      {
    6.77 -	if (verbose)
    6.78 -	    xc_dom_panic(XC_INVALID_KERNEL, "%s: kernel is not an ELF image\n",
    6.79 -			 __FUNCTION__);
    6.80 -	return -EINVAL;
    6.81 +        if ( verbose )
    6.82 +            xc_dom_panic(XC_INVALID_KERNEL, "%s: kernel is not an ELF image\n",
    6.83 +                         __FUNCTION__);
    6.84 +        return -EINVAL;
    6.85      }
    6.86      return 0;
    6.87  }
    6.88 @@ -78,7 +79,7 @@ static int xc_dom_probe_elf_kernel(struc
    6.89  }
    6.90  
    6.91  static int xc_dom_load_elf_symtab(struct xc_dom_image *dom,
    6.92 -				  struct elf_binary *elf, int load)
    6.93 +                                  struct elf_binary *elf, int load)
    6.94  {
    6.95      struct elf_binary syms;
    6.96      const elf_shdr *shdr, *shdr2;
    6.97 @@ -87,125 +88,135 @@ static int xc_dom_load_elf_symtab(struct
    6.98      size_t size;
    6.99      int h, count, type, i, tables = 0;
   6.100  
   6.101 -    if (elf_swap(elf)) {
   6.102 -	xc_dom_printf("%s: non-native byte order, bsd symtab not supported\n",
   6.103 -		      __FUNCTION__);
   6.104 -	return 0;
   6.105 +    if ( elf_swap(elf) )
   6.106 +    {
   6.107 +        xc_dom_printf("%s: non-native byte order, bsd symtab not supported\n",
   6.108 +                      __FUNCTION__);
   6.109 +        return 0;
   6.110      }
   6.111  
   6.112 -    if (load) {
   6.113 -	if (!dom->bsd_symtab_start)
   6.114 -	    return 0;
   6.115 -	size = dom->kernel_seg.vend - dom->bsd_symtab_start;
   6.116 -	hdr  = xc_dom_vaddr_to_ptr(dom, dom->bsd_symtab_start);
   6.117 -	*(int *)hdr = size - sizeof(int);
   6.118 -    } else {
   6.119 -	size = sizeof(int) + elf_size(elf, elf->ehdr) +
   6.120 -	    elf_shdr_count(elf) * elf_size(elf, shdr);
   6.121 -	hdr = xc_dom_malloc(dom, size);
   6.122 -	if (hdr == NULL)
   6.123 -	    return 0;
   6.124 -	dom->bsd_symtab_start = elf_round_up(&syms, dom->kernel_seg.vend);
   6.125 +    if ( load )
   6.126 +    {
   6.127 +        if ( !dom->bsd_symtab_start )
   6.128 +            return 0;
   6.129 +        size = dom->kernel_seg.vend - dom->bsd_symtab_start;
   6.130 +        hdr  = xc_dom_vaddr_to_ptr(dom, dom->bsd_symtab_start);
   6.131 +        *(int *)hdr = size - sizeof(int);
   6.132 +    }
   6.133 +    else
   6.134 +    {
   6.135 +        size = sizeof(int) + elf_size(elf, elf->ehdr) +
   6.136 +            elf_shdr_count(elf) * elf_size(elf, shdr);
   6.137 +        hdr = xc_dom_malloc(dom, size);
   6.138 +        if ( hdr == NULL )
   6.139 +            return 0;
   6.140 +        dom->bsd_symtab_start = elf_round_up(&syms, dom->kernel_seg.vend);
   6.141      }
   6.142  
   6.143      memcpy(hdr + sizeof(int),
   6.144 -	   elf->image,
   6.145 -	   elf_size(elf, elf->ehdr));
   6.146 +           elf->image,
   6.147 +           elf_size(elf, elf->ehdr));
   6.148      memcpy(hdr + sizeof(int) + elf_size(elf, elf->ehdr),
   6.149 -	   elf->image + elf_uval(elf, elf->ehdr, e_shoff),
   6.150 -	   elf_shdr_count(elf) * elf_size(elf, shdr));
   6.151 -    if (elf_64bit(elf)) {
   6.152 -	Elf64_Ehdr *ehdr = (Elf64_Ehdr *)(hdr + sizeof(int));
   6.153 -	ehdr->e_phoff = 0;
   6.154 -	ehdr->e_phentsize = 0;
   6.155 -	ehdr->e_phnum = 0;
   6.156 -	ehdr->e_shoff = elf_size(elf, elf->ehdr);
   6.157 -	ehdr->e_shstrndx = SHN_UNDEF;
   6.158 -    } else {
   6.159 -	Elf32_Ehdr *ehdr = (Elf32_Ehdr *)(hdr + sizeof(int));
   6.160 -	ehdr->e_phoff = 0;
   6.161 -	ehdr->e_phentsize = 0;
   6.162 -	ehdr->e_phnum = 0;
   6.163 -	ehdr->e_shoff = elf_size(elf, elf->ehdr);
   6.164 -	ehdr->e_shstrndx = SHN_UNDEF;
   6.165 +           elf->image + elf_uval(elf, elf->ehdr, e_shoff),
   6.166 +           elf_shdr_count(elf) * elf_size(elf, shdr));
   6.167 +    if ( elf_64bit(elf) )
   6.168 +    {
   6.169 +        Elf64_Ehdr *ehdr = (Elf64_Ehdr *)(hdr + sizeof(int));
   6.170 +        ehdr->e_phoff = 0;
   6.171 +        ehdr->e_phentsize = 0;
   6.172 +        ehdr->e_phnum = 0;
   6.173 +        ehdr->e_shoff = elf_size(elf, elf->ehdr);
   6.174 +        ehdr->e_shstrndx = SHN_UNDEF;
   6.175      }
   6.176 -    if (0 != elf_init(&syms, hdr + sizeof(int), size - sizeof(int)))
   6.177 -	return -1;
   6.178 -    if (xc_dom_logfile)
   6.179 -	elf_set_logfile(&syms, xc_dom_logfile, 1);
   6.180 +    else
   6.181 +    {
   6.182 +        Elf32_Ehdr *ehdr = (Elf32_Ehdr *)(hdr + sizeof(int));
   6.183 +        ehdr->e_phoff = 0;
   6.184 +        ehdr->e_phentsize = 0;
   6.185 +        ehdr->e_phnum = 0;
   6.186 +        ehdr->e_shoff = elf_size(elf, elf->ehdr);
   6.187 +        ehdr->e_shstrndx = SHN_UNDEF;
   6.188 +    }
   6.189 +    if ( elf_init(&syms, hdr + sizeof(int), size - sizeof(int)) )
   6.190 +        return -1;
   6.191 +    if ( xc_dom_logfile )
   6.192 +        elf_set_logfile(&syms, xc_dom_logfile, 1);
   6.193  
   6.194      symtab = dom->bsd_symtab_start + sizeof(int);
   6.195      maxaddr = elf_round_up(&syms, symtab + elf_size(&syms, syms.ehdr) +
   6.196 -			   elf_shdr_count(&syms) * elf_size(&syms, shdr));
   6.197 +                           elf_shdr_count(&syms) * elf_size(&syms, shdr));
   6.198  
   6.199      xc_dom_printf("%s/%s: bsd_symtab_start=%" PRIx64 ", kernel.end=0x%" PRIx64
   6.200 -		  " -- symtab=0x%" PRIx64 ", maxaddr=0x%" PRIx64 "\n",
   6.201 -		  __FUNCTION__, load ? "load" : "parse",
   6.202 -		  dom->bsd_symtab_start, dom->kernel_seg.vend, symtab, maxaddr);
   6.203 +                  " -- symtab=0x%" PRIx64 ", maxaddr=0x%" PRIx64 "\n",
   6.204 +                  __FUNCTION__, load ? "load" : "parse",
   6.205 +                  dom->bsd_symtab_start, dom->kernel_seg.vend,
   6.206 +                  symtab, maxaddr);
   6.207  
   6.208      count = elf_shdr_count(&syms);
   6.209 -    for (h = 0; h < count; h++)
   6.210 +    for ( h = 0; h < count; h++ )
   6.211      {
   6.212 -	shdr = elf_shdr_by_index(&syms, h);
   6.213 -	type = elf_uval(&syms, shdr, sh_type);
   6.214 -	if (type == SHT_STRTAB)
   6.215 -	{
   6.216 -	    /* Look for a strtab @i linked to symtab @h. */
   6.217 -	    for (i = 0; i < count; i++) {
   6.218 -		shdr2 = elf_shdr_by_index(&syms, i);
   6.219 -		if ((elf_uval(&syms, shdr2, sh_type) == SHT_SYMTAB) &&
   6.220 -		    (elf_uval(&syms, shdr2, sh_link) == h))
   6.221 -		    break;
   6.222 -	    }
   6.223 -	    /* Skip symtab @h if we found no corresponding strtab @i. */
   6.224 -	    if (i == count)
   6.225 -	    {
   6.226 -		if (elf_64bit(&syms))
   6.227 -		    *(Elf64_Off*)(&shdr->e64.sh_offset) = 0;
   6.228 -		else
   6.229 -		    *(Elf32_Off*)(&shdr->e32.sh_offset) = 0;
   6.230 -		continue;
   6.231 -	    }
   6.232 -	}
   6.233 +        shdr = elf_shdr_by_index(&syms, h);
   6.234 +        type = elf_uval(&syms, shdr, sh_type);
   6.235 +        if ( type == SHT_STRTAB )
   6.236 +        {
   6.237 +            /* Look for a strtab @i linked to symtab @h. */
   6.238 +            for ( i = 0; i < count; i++ )
   6.239 +            {
   6.240 +                shdr2 = elf_shdr_by_index(&syms, i);
   6.241 +                if ( (elf_uval(&syms, shdr2, sh_type) == SHT_SYMTAB) &&
   6.242 +                     (elf_uval(&syms, shdr2, sh_link) == h) )
   6.243 +                    break;
   6.244 +            }
   6.245 +            /* Skip symtab @h if we found no corresponding strtab @i. */
   6.246 +            if ( i == count )
   6.247 +            {
   6.248 +                if ( elf_64bit(&syms) )
   6.249 +                    *(Elf64_Off*)(&shdr->e64.sh_offset) = 0;
   6.250 +                else
   6.251 +                    *(Elf32_Off*)(&shdr->e32.sh_offset) = 0;
   6.252 +                continue;
   6.253 +            }
   6.254 +        }
   6.255  
   6.256 -	if ((type == SHT_STRTAB) || (type == SHT_SYMTAB))
   6.257 -	{
   6.258 -	    /* Mangled to be based on ELF header location. */
   6.259 -	    if (elf_64bit(&syms))
   6.260 -		*(Elf64_Off*)(&shdr->e64.sh_offset) = maxaddr - symtab;
   6.261 -	    else
   6.262 -		*(Elf32_Off*)(&shdr->e32.sh_offset) = maxaddr - symtab;
   6.263 -	    size = elf_uval(&syms, shdr, sh_size);
   6.264 -	    maxaddr = elf_round_up(&syms, maxaddr + size);
   6.265 -	    tables++;
   6.266 -	    xc_dom_printf("%s: h=%d %s, size=0x%zx, maxaddr=0x%" PRIx64 "\n",
   6.267 -			  __FUNCTION__, h,
   6.268 -			  type == SHT_SYMTAB ? "symtab" : "strtab",
   6.269 -			  size, maxaddr);
   6.270 +        if ( (type == SHT_STRTAB) || (type == SHT_SYMTAB) )
   6.271 +        {
   6.272 +            /* Mangled to be based on ELF header location. */
   6.273 +            if ( elf_64bit(&syms) )
   6.274 +                *(Elf64_Off*)(&shdr->e64.sh_offset) = maxaddr - symtab;
   6.275 +            else
   6.276 +                *(Elf32_Off*)(&shdr->e32.sh_offset) = maxaddr - symtab;
   6.277 +            size = elf_uval(&syms, shdr, sh_size);
   6.278 +            maxaddr = elf_round_up(&syms, maxaddr + size);
   6.279 +            tables++;
   6.280 +            xc_dom_printf("%s: h=%d %s, size=0x%zx, maxaddr=0x%" PRIx64 "\n",
   6.281 +                          __FUNCTION__, h,
   6.282 +                          type == SHT_SYMTAB ? "symtab" : "strtab",
   6.283 +                          size, maxaddr);
   6.284  
   6.285 -	    if (load) {
   6.286 -		shdr2 = elf_shdr_by_index(elf, h);
   6.287 -		memcpy((void*)elf_section_start(&syms, shdr),
   6.288 -		       elf_section_start(elf, shdr2),
   6.289 -		       size);
   6.290 -	    }
   6.291 -	}
   6.292 +            if ( load )
   6.293 +            {
   6.294 +                shdr2 = elf_shdr_by_index(elf, h);
   6.295 +                memcpy((void*)elf_section_start(&syms, shdr),
   6.296 +                       elf_section_start(elf, shdr2),
   6.297 +                       size);
   6.298 +            }
   6.299 +        }
   6.300  
   6.301 -	/* Name is NULL. */
   6.302 -	if (elf_64bit(&syms))
   6.303 -	    *(Elf64_Half*)(&shdr->e64.sh_name) = 0;
   6.304 -	else
   6.305 -	    *(Elf32_Word*)(&shdr->e32.sh_name) = 0;
   6.306 +        /* Name is NULL. */
   6.307 +        if ( elf_64bit(&syms) )
   6.308 +            *(Elf64_Half*)(&shdr->e64.sh_name) = 0;
   6.309 +        else
   6.310 +            *(Elf32_Word*)(&shdr->e32.sh_name) = 0;
   6.311      }
   6.312  
   6.313 -    if (0 == tables)
   6.314 +    if ( tables == 0 )
   6.315      {
   6.316 -	xc_dom_printf("%s: no symbol table present\n", __FUNCTION__);
   6.317 -	dom->bsd_symtab_start = 0;
   6.318 -	return 0;
   6.319 +        xc_dom_printf("%s: no symbol table present\n", __FUNCTION__);
   6.320 +        dom->bsd_symtab_start = 0;
   6.321 +        return 0;
   6.322      }
   6.323 -    if (!load)
   6.324 -	dom->kernel_seg.vend = maxaddr;
   6.325 +    if ( !load )
   6.326 +        dom->kernel_seg.vend = maxaddr;
   6.327      return 0;
   6.328  }
   6.329  
   6.330 @@ -215,45 +226,45 @@ static int xc_dom_parse_elf_kernel(struc
   6.331      int rc;
   6.332  
   6.333      rc = check_elf_kernel(dom, 1);
   6.334 -    if (0 != rc)
   6.335 -	return rc;
   6.336 +    if ( rc != 0 )
   6.337 +        return rc;
   6.338  
   6.339      elf = xc_dom_malloc(dom, sizeof(*elf));
   6.340      dom->private_loader = elf;
   6.341      rc = elf_init(elf, dom->kernel_blob, dom->kernel_size);
   6.342 -    if (xc_dom_logfile)
   6.343 -	elf_set_logfile(elf, xc_dom_logfile, 1);
   6.344 -    if (0 != rc)
   6.345 +    if ( xc_dom_logfile )
   6.346 +        elf_set_logfile(elf, xc_dom_logfile, 1);
   6.347 +    if ( rc != 0 )
   6.348      {
   6.349 -	xc_dom_panic(XC_INVALID_KERNEL, "%s: corrupted ELF image\n",
   6.350 -		     __FUNCTION__);
   6.351 -	return rc;
   6.352 +        xc_dom_panic(XC_INVALID_KERNEL, "%s: corrupted ELF image\n",
   6.353 +                     __FUNCTION__);
   6.354 +        return rc;
   6.355      }
   6.356  
   6.357      /* Find the section-header strings table. */
   6.358 -    if (NULL == elf->sec_strtab)
   6.359 +    if ( elf->sec_strtab == NULL )
   6.360      {
   6.361 -	xc_dom_panic(XC_INVALID_KERNEL, "%s: ELF image has no shstrtab\n",
   6.362 -		     __FUNCTION__);
   6.363 -	return -EINVAL;
   6.364 +        xc_dom_panic(XC_INVALID_KERNEL, "%s: ELF image has no shstrtab\n",
   6.365 +                     __FUNCTION__);
   6.366 +        return -EINVAL;
   6.367      }
   6.368  
   6.369      /* parse binary and get xen meta info */
   6.370      elf_parse_binary(elf);
   6.371 -    if (0 != (rc = elf_xen_parse(elf, &dom->parms)))
   6.372 -	return rc;
   6.373 +    if ( (rc = elf_xen_parse(elf, &dom->parms)) != 0 )
   6.374 +        return rc;
   6.375  
   6.376      /* find kernel segment */
   6.377      dom->kernel_seg.vstart = dom->parms.virt_kstart;
   6.378      dom->kernel_seg.vend   = dom->parms.virt_kend;
   6.379  
   6.380 -    if (dom->parms.bsd_symtab)
   6.381 -	xc_dom_load_elf_symtab(dom, elf, 0);
   6.382 +    if ( dom->parms.bsd_symtab )
   6.383 +        xc_dom_load_elf_symtab(dom, elf, 0);
   6.384  
   6.385      dom->guest_type = xc_dom_guest_type(dom, elf);
   6.386      xc_dom_printf("%s: %s: 0x%" PRIx64 " -> 0x%" PRIx64 "\n",
   6.387 -		  __FUNCTION__, dom->guest_type,
   6.388 -		  dom->kernel_seg.vstart, dom->kernel_seg.vend);
   6.389 +                  __FUNCTION__, dom->guest_type,
   6.390 +                  dom->kernel_seg.vstart, dom->kernel_seg.vend);
   6.391      return 0;
   6.392  }
   6.393  
   6.394 @@ -263,8 +274,8 @@ static int xc_dom_load_elf_kernel(struct
   6.395  
   6.396      elf->dest = xc_dom_seg_to_ptr(dom, &dom->kernel_seg);
   6.397      elf_load_binary(elf);
   6.398 -    if (dom->parms.bsd_symtab)
   6.399 -	xc_dom_load_elf_symtab(dom, elf, 1);
   6.400 +    if ( dom->parms.bsd_symtab )
   6.401 +        xc_dom_load_elf_symtab(dom, elf, 1);
   6.402      return 0;
   6.403  }
   6.404  
   6.405 @@ -281,3 +292,13 @@ static void __init register_loader(void)
   6.406  {
   6.407      xc_dom_register_loader(&elf_loader);
   6.408  }
   6.409 +
   6.410 +/*
   6.411 + * Local variables:
   6.412 + * mode: C
   6.413 + * c-set-style: "BSD"
   6.414 + * c-basic-offset: 4
   6.415 + * tab-width: 4
   6.416 + * indent-tabs-mode: nil
   6.417 + * End:
   6.418 + */
     7.1 --- a/tools/libxc/xc_dom_ia64.c	Sat Feb 24 14:48:17 2007 +0000
     7.2 +++ b/tools/libxc/xc_dom_ia64.c	Sat Feb 24 15:30:19 2007 +0000
     7.3 @@ -33,9 +33,9 @@ static int alloc_magic_pages(struct xc_d
     7.4  static int start_info_ia64(struct xc_dom_image *dom)
     7.5  {
     7.6      start_info_ia64_t *start_info =
     7.7 -	xc_dom_pfn_to_ptr(dom, dom->start_info_pfn, 1);
     7.8 +        xc_dom_pfn_to_ptr(dom, dom->start_info_pfn, 1);
     7.9      struct xen_ia64_boot_param_ia64 *bp =
    7.10 -	(struct xen_ia64_boot_param_ia64 *)(start_info + 1);
    7.11 +        (struct xen_ia64_boot_param_ia64 *)(start_info + 1);
    7.12  
    7.13      xc_dom_printf("%s\n", __FUNCTION__);
    7.14  
    7.15 @@ -48,19 +48,19 @@ static int start_info_ia64(struct xc_dom
    7.16      start_info->console.domU.mfn = dom->console_pfn;
    7.17      start_info->console.domU.evtchn = dom->console_evtchn;
    7.18  
    7.19 -    if (dom->ramdisk_blob)
    7.20 +    if ( dom->ramdisk_blob )
    7.21      {
    7.22 -	start_info->mod_start = dom->ramdisk_seg.vstart;
    7.23 -	start_info->mod_len = dom->ramdisk_seg.vend - dom->ramdisk_seg.vstart;
    7.24 -	bp->initrd_start = start_info->mod_start;
    7.25 -	bp->initrd_size = start_info->mod_len;
    7.26 +        start_info->mod_start = dom->ramdisk_seg.vstart;
    7.27 +        start_info->mod_len = dom->ramdisk_seg.vend - dom->ramdisk_seg.vstart;
    7.28 +        bp->initrd_start = start_info->mod_start;
    7.29 +        bp->initrd_size = start_info->mod_len;
    7.30      }
    7.31      bp->command_line = (dom->start_info_pfn << PAGE_SHIFT_IA64)
    7.32 -	    + offsetof(start_info_t, cmd_line);
    7.33 -    if (dom->cmdline)
    7.34 +        + offsetof(start_info_t, cmd_line);
    7.35 +    if ( dom->cmdline )
    7.36      {
    7.37 -	strncpy((char *)start_info->cmd_line, dom->cmdline, MAX_GUEST_CMDLINE);
    7.38 -	start_info->cmd_line[MAX_GUEST_CMDLINE - 1] = '\0';
    7.39 +        strncpy((char *)start_info->cmd_line, dom->cmdline, MAX_GUEST_CMDLINE);
    7.40 +        start_info->cmd_line[MAX_GUEST_CMDLINE - 1] = '\0';
    7.41      }
    7.42      return 0;
    7.43  }
    7.44 @@ -74,7 +74,7 @@ static int shared_info_ia64(struct xc_do
    7.45  
    7.46      memset(shared_info, 0, sizeof(*shared_info));
    7.47      for (i = 0; i < MAX_VIRT_CPUS; i++)
    7.48 -	shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
    7.49 +        shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
    7.50      shared_info->arch.start_info_pfn = dom->start_info_pfn;
    7.51      return 0;
    7.52  }
    7.53 @@ -91,14 +91,14 @@ static int vcpu_ia64(struct xc_dom_image
    7.54      memset(ctxt, 0, sizeof(*ctxt));
    7.55  
    7.56      ctxt->flags = 0;
    7.57 -    ctxt->user_regs.cr_ipsr = 0;	/* all necessary bits filled by hypervisor */
    7.58 +    ctxt->user_regs.cr_ipsr = 0; /* all necessary bits filled by hypervisor */
    7.59      ctxt->user_regs.cr_iip = dom->parms.virt_entry;
    7.60      ctxt->user_regs.cr_ifs = (uint64_t) 1 << 63;
    7.61 -#ifdef __ia64__			/* FIXME */
    7.62 +#ifdef __ia64__   /* FIXME */
    7.63      ctxt->user_regs.ar_fpsr = xc_ia64_fpsr_default();
    7.64  #endif
    7.65      ctxt->user_regs.r28 = (dom->start_info_pfn << PAGE_SHIFT_IA64)
    7.66 -	+ sizeof(start_info_ia64_t);
    7.67 +        + sizeof(start_info_ia64_t);
    7.68      return 0;
    7.69  }
    7.70  
    7.71 @@ -117,3 +117,13 @@ static void __init register_arch_hooks(v
    7.72  {
    7.73      xc_dom_register_arch_hooks(&xc_dom_arch);
    7.74  }
    7.75 +
    7.76 +/*
    7.77 + * Local variables:
    7.78 + * mode: C
    7.79 + * c-set-style: "BSD"
    7.80 + * c-basic-offset: 4
    7.81 + * tab-width: 4
    7.82 + * indent-tabs-mode: nil
    7.83 + * End:
    7.84 + */
     8.1 --- a/tools/libxc/xc_dom_x86.c	Sat Feb 24 14:48:17 2007 +0000
     8.2 +++ b/tools/libxc/xc_dom_x86.c	Sat Feb 24 15:30:19 2007 +0000
     8.3 @@ -29,37 +29,37 @@
     8.4  #define round_down(addr, mask)   ((addr) & ~(mask))
     8.5  #define round_up(addr, mask)     ((addr) | (mask))
     8.6  
     8.7 -static inline unsigned long
     8.8 +static unsigned long
     8.9  nr_page_tables(xen_vaddr_t start, xen_vaddr_t end, unsigned long bits)
    8.10  {
    8.11      xen_vaddr_t mask = bits_to_mask(bits);
    8.12      int tables;
    8.13  
    8.14 -    if (0 == bits)
    8.15 -	return 0;		/* unused */
    8.16 +    if ( bits == 0 )
    8.17 +        return 0;  /* unused */
    8.18  
    8.19 -    if (8 * sizeof(unsigned long) == bits)
    8.20 +    if ( bits == (8 * sizeof(unsigned long)) )
    8.21      {
    8.22 -	/* must be pgd, need one */
    8.23 -	start = 0;
    8.24 -	end = -1;
    8.25 -	tables = 1;
    8.26 +        /* must be pgd, need one */
    8.27 +        start = 0;
    8.28 +        end = -1;
    8.29 +        tables = 1;
    8.30      }
    8.31      else
    8.32      {
    8.33 -	start = round_down(start, mask);
    8.34 -	end = round_up(end, mask);
    8.35 -	tables = ((end - start) >> bits) + 1;
    8.36 +        start = round_down(start, mask);
    8.37 +        end = round_up(end, mask);
    8.38 +        tables = ((end - start) >> bits) + 1;
    8.39      }
    8.40  
    8.41      xc_dom_printf("%s: 0x%016" PRIx64 "/%ld: 0x%016" PRIx64
    8.42 -		  " -> 0x%016" PRIx64 ", %d table(s)\n",
    8.43 -		  __FUNCTION__, mask, bits, start, end, tables);
    8.44 +                  " -> 0x%016" PRIx64 ", %d table(s)\n",
    8.45 +                  __FUNCTION__, mask, bits, start, end, tables);
    8.46      return tables;
    8.47  }
    8.48  
    8.49  static int count_pgtables(struct xc_dom_image *dom, int pae,
    8.50 -			  int l4_bits, int l3_bits, int l2_bits, int l1_bits)
    8.51 +                          int l4_bits, int l3_bits, int l2_bits, int l1_bits)
    8.52  {
    8.53      int pages, extra_pages;
    8.54      xen_vaddr_t try_virt_end;
    8.55 @@ -68,27 +68,28 @@ static int count_pgtables(struct xc_dom_
    8.56      extra_pages += dom->extra_pages;
    8.57      extra_pages += 128; /* 512kB padding */
    8.58      pages = extra_pages;
    8.59 -    for (;;)
    8.60 +    for ( ; ; )
    8.61      {
    8.62 -	try_virt_end = round_up(dom->virt_alloc_end + pages * PAGE_SIZE_X86,
    8.63 -				bits_to_mask(22)); /* 4MB alignment */
    8.64 -	dom->pg_l4 =
    8.65 -	    nr_page_tables(dom->parms.virt_base, try_virt_end, l4_bits);
    8.66 -	dom->pg_l3 =
    8.67 -	    nr_page_tables(dom->parms.virt_base, try_virt_end, l3_bits);
    8.68 -	dom->pg_l2 =
    8.69 -	    nr_page_tables(dom->parms.virt_base, try_virt_end, l2_bits);
    8.70 -	dom->pg_l1 =
    8.71 -	    nr_page_tables(dom->parms.virt_base, try_virt_end, l1_bits);
    8.72 -	if (pae && try_virt_end < 0xc0000000)
    8.73 -	{
    8.74 -	    xc_dom_printf("%s: PAE: extra l2 page table for l3#3\n", __FUNCTION__);
    8.75 -	    dom->pg_l2++;
    8.76 -	}
    8.77 -	dom->pgtables = dom->pg_l4 + dom->pg_l3 + dom->pg_l2 + dom->pg_l1;
    8.78 -	pages = dom->pgtables + extra_pages;
    8.79 -	if (dom->virt_alloc_end + pages * PAGE_SIZE_X86 <= try_virt_end + 1)
    8.80 -	    break;
    8.81 +        try_virt_end = round_up(dom->virt_alloc_end + pages * PAGE_SIZE_X86,
    8.82 +                                bits_to_mask(22)); /* 4MB alignment */
    8.83 +        dom->pg_l4 =
    8.84 +            nr_page_tables(dom->parms.virt_base, try_virt_end, l4_bits);
    8.85 +        dom->pg_l3 =
    8.86 +            nr_page_tables(dom->parms.virt_base, try_virt_end, l3_bits);
    8.87 +        dom->pg_l2 =
    8.88 +            nr_page_tables(dom->parms.virt_base, try_virt_end, l2_bits);
    8.89 +        dom->pg_l1 =
    8.90 +            nr_page_tables(dom->parms.virt_base, try_virt_end, l1_bits);
    8.91 +        if (pae && try_virt_end < 0xc0000000)
    8.92 +        {
    8.93 +            xc_dom_printf("%s: PAE: extra l2 page table for l3#3\n",
    8.94 +                          __FUNCTION__);
    8.95 +            dom->pg_l2++;
    8.96 +        }
    8.97 +        dom->pgtables = dom->pg_l4 + dom->pg_l3 + dom->pg_l2 + dom->pg_l1;
    8.98 +        pages = dom->pgtables + extra_pages;
    8.99 +        if ( dom->virt_alloc_end + pages * PAGE_SIZE_X86 <= try_virt_end + 1 )
   8.100 +            break;
   8.101      }
   8.102      dom->virt_pgtab_end = try_virt_end + 1;
   8.103      return 0;
   8.104 @@ -109,7 +110,7 @@ static int count_pgtables_x86_32(struct 
   8.105  static int count_pgtables_x86_32_pae(struct xc_dom_image *dom)
   8.106  {
   8.107      return count_pgtables(dom, 1, 0, 32,
   8.108 -			  L3_PAGETABLE_SHIFT_PAE, L2_PAGETABLE_SHIFT_PAE);
   8.109 +                          L3_PAGETABLE_SHIFT_PAE, L2_PAGETABLE_SHIFT_PAE);
   8.110  }
   8.111  
   8.112  #define pfn_to_paddr(pfn) ((xen_paddr_t)(pfn) << PAGE_SHIFT_X86)
   8.113 @@ -124,28 +125,29 @@ static int setup_pgtables_x86_32(struct 
   8.114      xen_vaddr_t addr;
   8.115      xen_pfn_t pgpfn;
   8.116  
   8.117 -    for (addr = dom->parms.virt_base; addr < dom->virt_pgtab_end;
   8.118 -	 addr += PAGE_SIZE_X86)
   8.119 +    for ( addr = dom->parms.virt_base; addr < dom->virt_pgtab_end;
   8.120 +          addr += PAGE_SIZE_X86 )
   8.121      {
   8.122 -	if (NULL == l1tab)
   8.123 -	{
   8.124 -	    /* get L1 tab, make L2 entry */
   8.125 -	    l1tab = xc_dom_pfn_to_ptr(dom, l1pfn, 1);
   8.126 -	    l2off = l2_table_offset_i386(addr);
   8.127 -	    l2tab[l2off] =
   8.128 -		pfn_to_paddr(xc_dom_p2m_guest(dom, l1pfn)) | L2_PROT;
   8.129 -	    l1pfn++;
   8.130 -	}
   8.131 +        if ( l1tab == NULL )
   8.132 +        {
   8.133 +            /* get L1 tab, make L2 entry */
   8.134 +            l1tab = xc_dom_pfn_to_ptr(dom, l1pfn, 1);
   8.135 +            l2off = l2_table_offset_i386(addr);
   8.136 +            l2tab[l2off] =
   8.137 +                pfn_to_paddr(xc_dom_p2m_guest(dom, l1pfn)) | L2_PROT;
   8.138 +            l1pfn++;
   8.139 +        }
   8.140  
   8.141 -	/* make L1 entry */
   8.142 -	l1off = l1_table_offset_i386(addr);
   8.143 -	pgpfn = (addr - dom->parms.virt_base) >> PAGE_SHIFT_X86;
   8.144 -	l1tab[l1off] =
   8.145 -	    pfn_to_paddr(xc_dom_p2m_guest(dom, pgpfn)) | L1_PROT;
   8.146 -	if (addr >= dom->pgtables_seg.vstart && addr < dom->pgtables_seg.vend)
   8.147 -	    l1tab[l1off] &= ~_PAGE_RW;	/* page tables are r/o */
   8.148 -	if (L1_PAGETABLE_ENTRIES_I386 - 1 == l1off)
   8.149 -	    l1tab = NULL;
   8.150 +        /* make L1 entry */
   8.151 +        l1off = l1_table_offset_i386(addr);
   8.152 +        pgpfn = (addr - dom->parms.virt_base) >> PAGE_SHIFT_X86;
   8.153 +        l1tab[l1off] =
   8.154 +            pfn_to_paddr(xc_dom_p2m_guest(dom, pgpfn)) | L1_PROT;
   8.155 +        if ( (addr >= dom->pgtables_seg.vstart) && 
   8.156 +             (addr < dom->pgtables_seg.vend) )
   8.157 +            l1tab[l1off] &= ~_PAGE_RW; /* page tables are r/o */
   8.158 +        if ( l1off == (L1_PAGETABLE_ENTRIES_I386 - 1) )
   8.159 +            l1tab = NULL;
   8.160      }
   8.161      return 0;
   8.162  }
   8.163 @@ -162,46 +164,47 @@ static int setup_pgtables_x86_32_pae(str
   8.164      xen_vaddr_t addr;
   8.165      xen_pfn_t pgpfn;
   8.166  
   8.167 -    for (addr = dom->parms.virt_base; addr < dom->virt_pgtab_end;
   8.168 -	 addr += PAGE_SIZE_X86)
   8.169 +    for ( addr = dom->parms.virt_base; addr < dom->virt_pgtab_end;
   8.170 +          addr += PAGE_SIZE_X86 )
   8.171      {
   8.172 -	if (NULL == l2tab)
   8.173 -	{
   8.174 -	    /* get L2 tab, make L3 entry */
   8.175 -	    l2tab = xc_dom_pfn_to_ptr(dom, l2pfn, 1);
   8.176 -	    l3off = l3_table_offset_pae(addr);
   8.177 -	    l3tab[l3off] =
   8.178 -		pfn_to_paddr(xc_dom_p2m_guest(dom, l2pfn)) | L3_PROT;
   8.179 -	    l2pfn++;
   8.180 -	}
   8.181 +        if ( l2tab == NULL )
   8.182 +        {
   8.183 +            /* get L2 tab, make L3 entry */
   8.184 +            l2tab = xc_dom_pfn_to_ptr(dom, l2pfn, 1);
   8.185 +            l3off = l3_table_offset_pae(addr);
   8.186 +            l3tab[l3off] =
   8.187 +                pfn_to_paddr(xc_dom_p2m_guest(dom, l2pfn)) | L3_PROT;
   8.188 +            l2pfn++;
   8.189 +        }
   8.190  
   8.191 -	if (NULL == l1tab)
   8.192 -	{
   8.193 -	    /* get L1 tab, make L2 entry */
   8.194 -	    l1tab = xc_dom_pfn_to_ptr(dom, l1pfn, 1);
   8.195 -	    l2off = l2_table_offset_pae(addr);
   8.196 -	    l2tab[l2off] =
   8.197 -		pfn_to_paddr(xc_dom_p2m_guest(dom, l1pfn)) | L2_PROT;
   8.198 -	    if (L2_PAGETABLE_ENTRIES_PAE - 1 == l2off)
   8.199 -		l2tab = NULL;
   8.200 -	    l1pfn++;
   8.201 -	}
   8.202 +        if ( l1tab == NULL )
   8.203 +        {
   8.204 +            /* get L1 tab, make L2 entry */
   8.205 +            l1tab = xc_dom_pfn_to_ptr(dom, l1pfn, 1);
   8.206 +            l2off = l2_table_offset_pae(addr);
   8.207 +            l2tab[l2off] =
   8.208 +                pfn_to_paddr(xc_dom_p2m_guest(dom, l1pfn)) | L2_PROT;
   8.209 +            if ( l2off == (L2_PAGETABLE_ENTRIES_PAE - 1) )
   8.210 +                l2tab = NULL;
   8.211 +            l1pfn++;
   8.212 +        }
   8.213  
   8.214 -	/* make L1 entry */
   8.215 -	l1off = l1_table_offset_pae(addr);
   8.216 -	pgpfn = (addr - dom->parms.virt_base) >> PAGE_SHIFT_X86;
   8.217 -	l1tab[l1off] =
   8.218 -	    pfn_to_paddr(xc_dom_p2m_guest(dom, pgpfn)) | L1_PROT;
   8.219 -	if (addr >= dom->pgtables_seg.vstart && addr < dom->pgtables_seg.vend)
   8.220 -	    l1tab[l1off] &= ~_PAGE_RW;	/* page tables are r/o */
   8.221 -	if (L1_PAGETABLE_ENTRIES_PAE - 1 == l1off)
   8.222 -	    l1tab = NULL;
   8.223 +        /* make L1 entry */
   8.224 +        l1off = l1_table_offset_pae(addr);
   8.225 +        pgpfn = (addr - dom->parms.virt_base) >> PAGE_SHIFT_X86;
   8.226 +        l1tab[l1off] =
   8.227 +            pfn_to_paddr(xc_dom_p2m_guest(dom, pgpfn)) | L1_PROT;
   8.228 +        if ( (addr >= dom->pgtables_seg.vstart) &&
   8.229 +             (addr < dom->pgtables_seg.vend) )
   8.230 +            l1tab[l1off] &= ~_PAGE_RW; /* page tables are r/o */
   8.231 +        if ( l1off == (L1_PAGETABLE_ENTRIES_PAE - 1) )
   8.232 +            l1tab = NULL;
   8.233      }
   8.234  
   8.235 -    if (dom->virt_pgtab_end <= 0xc0000000)
   8.236 +    if ( dom->virt_pgtab_end <= 0xc0000000 )
   8.237      {
   8.238 -	xc_dom_printf("%s: PAE: extra l2 page table for l3#3\n", __FUNCTION__);
   8.239 -	l3tab[3] = pfn_to_paddr(xc_dom_p2m_guest(dom, l2pfn)) | L3_PROT;
   8.240 +        xc_dom_printf("%s: PAE: extra l2 page table for l3#3\n", __FUNCTION__);
   8.241 +        l3tab[3] = pfn_to_paddr(xc_dom_p2m_guest(dom, l2pfn)) | L3_PROT;
   8.242      }
   8.243      return 0;
   8.244  }
   8.245 @@ -216,9 +219,10 @@ static int setup_pgtables_x86_32_pae(str
   8.246  static int count_pgtables_x86_64(struct xc_dom_image *dom)
   8.247  {
   8.248      return count_pgtables(dom, 0,
   8.249 -			  L4_PAGETABLE_SHIFT_X86_64 + 9,
   8.250 -			  L4_PAGETABLE_SHIFT_X86_64,
   8.251 -			  L3_PAGETABLE_SHIFT_X86_64, L2_PAGETABLE_SHIFT_X86_64);
   8.252 +                          L4_PAGETABLE_SHIFT_X86_64 + 9,
   8.253 +                          L4_PAGETABLE_SHIFT_X86_64,
   8.254 +                          L3_PAGETABLE_SHIFT_X86_64,
   8.255 +                          L2_PAGETABLE_SHIFT_X86_64);
   8.256  }
   8.257  
   8.258  #define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED)
   8.259 @@ -232,7 +236,7 @@ static int setup_pgtables_x86_64(struct 
   8.260      xen_pfn_t l3pfn = dom->pgtables_seg.pfn + dom->pg_l4;
   8.261      xen_pfn_t l2pfn = dom->pgtables_seg.pfn + dom->pg_l4 + dom->pg_l3;
   8.262      xen_pfn_t l1pfn =
   8.263 -	dom->pgtables_seg.pfn + dom->pg_l4 + dom->pg_l3 + dom->pg_l2;
   8.264 +        dom->pgtables_seg.pfn + dom->pg_l4 + dom->pg_l3 + dom->pg_l2;
   8.265      l4_pgentry_64_t *l4tab = xc_dom_pfn_to_ptr(dom, l4pfn, 1);
   8.266      l3_pgentry_64_t *l3tab = NULL;
   8.267      l2_pgentry_64_t *l2tab = NULL;
   8.268 @@ -241,52 +245,53 @@ static int setup_pgtables_x86_64(struct 
   8.269      uint64_t addr;
   8.270      xen_pfn_t pgpfn;
   8.271  
   8.272 -    for (addr = dom->parms.virt_base; addr < dom->virt_pgtab_end;
   8.273 -	 addr += PAGE_SIZE_X86)
   8.274 +    for ( addr = dom->parms.virt_base; addr < dom->virt_pgtab_end;
   8.275 +          addr += PAGE_SIZE_X86 )
   8.276      {
   8.277 -	if (NULL == l3tab)
   8.278 -	{
   8.279 -	    /* get L3 tab, make L4 entry */
   8.280 -	    l3tab = xc_dom_pfn_to_ptr(dom, l3pfn, 1);
   8.281 -	    l4off = l4_table_offset_x86_64(addr);
   8.282 -	    l4tab[l4off] =
   8.283 -		pfn_to_paddr(xc_dom_p2m_guest(dom, l3pfn)) | L4_PROT;
   8.284 -	    l3pfn++;
   8.285 -	}
   8.286 +        if ( l3tab == NULL )
   8.287 +        {
   8.288 +            /* get L3 tab, make L4 entry */
   8.289 +            l3tab = xc_dom_pfn_to_ptr(dom, l3pfn, 1);
   8.290 +            l4off = l4_table_offset_x86_64(addr);
   8.291 +            l4tab[l4off] =
   8.292 +                pfn_to_paddr(xc_dom_p2m_guest(dom, l3pfn)) | L4_PROT;
   8.293 +            l3pfn++;
   8.294 +        }
   8.295  
   8.296 -	if (NULL == l2tab)
   8.297 -	{
   8.298 -	    /* get L2 tab, make L3 entry */
   8.299 -	    l2tab = xc_dom_pfn_to_ptr(dom, l2pfn, 1);
   8.300 -	    l3off = l3_table_offset_x86_64(addr);
   8.301 -	    l3tab[l3off] =
   8.302 -		pfn_to_paddr(xc_dom_p2m_guest(dom, l2pfn)) | L3_PROT;
   8.303 -	    if (L3_PAGETABLE_ENTRIES_X86_64 - 1 == l3off)
   8.304 -		l3tab = NULL;
   8.305 -	    l2pfn++;
   8.306 -	}
   8.307 +        if ( l2tab == NULL )
   8.308 +        {
   8.309 +            /* get L2 tab, make L3 entry */
   8.310 +            l2tab = xc_dom_pfn_to_ptr(dom, l2pfn, 1);
   8.311 +            l3off = l3_table_offset_x86_64(addr);
   8.312 +            l3tab[l3off] =
   8.313 +                pfn_to_paddr(xc_dom_p2m_guest(dom, l2pfn)) | L3_PROT;
   8.314 +            if ( l3off == (L3_PAGETABLE_ENTRIES_X86_64 - 1) )
   8.315 +                l3tab = NULL;
   8.316 +            l2pfn++;
   8.317 +        }
   8.318  
   8.319 -	if (NULL == l1tab)
   8.320 -	{
   8.321 -	    /* get L1 tab, make L2 entry */
   8.322 -	    l1tab = xc_dom_pfn_to_ptr(dom, l1pfn, 1);
   8.323 -	    l2off = l2_table_offset_x86_64(addr);
   8.324 -	    l2tab[l2off] =
   8.325 -		pfn_to_paddr(xc_dom_p2m_guest(dom, l1pfn)) | L2_PROT;
   8.326 -	    if (L2_PAGETABLE_ENTRIES_X86_64 - 1 == l2off)
   8.327 -		l2tab = NULL;
   8.328 -	    l1pfn++;
   8.329 -	}
   8.330 +        if ( l1tab == NULL )
   8.331 +        {
   8.332 +            /* get L1 tab, make L2 entry */
   8.333 +            l1tab = xc_dom_pfn_to_ptr(dom, l1pfn, 1);
   8.334 +            l2off = l2_table_offset_x86_64(addr);
   8.335 +            l2tab[l2off] =
   8.336 +                pfn_to_paddr(xc_dom_p2m_guest(dom, l1pfn)) | L2_PROT;
   8.337 +            if ( l2off == (L2_PAGETABLE_ENTRIES_X86_64 - 1) )
   8.338 +                l2tab = NULL;
   8.339 +            l1pfn++;
   8.340 +        }
   8.341  
   8.342 -	/* make L1 entry */
   8.343 -	l1off = l1_table_offset_x86_64(addr);
   8.344 -	pgpfn = (addr - dom->parms.virt_base) >> PAGE_SHIFT_X86;
   8.345 -	l1tab[l1off] =
   8.346 -	    pfn_to_paddr(xc_dom_p2m_guest(dom, pgpfn)) | L1_PROT;
   8.347 -	if (addr >= dom->pgtables_seg.vstart && addr < dom->pgtables_seg.vend)
   8.348 -	    l1tab[l1off] &= ~_PAGE_RW;	/* page tables are r/o */
   8.349 -	if (L1_PAGETABLE_ENTRIES_X86_64 - 1 == l1off)
   8.350 -	    l1tab = NULL;
   8.351 +        /* make L1 entry */
   8.352 +        l1off = l1_table_offset_x86_64(addr);
   8.353 +        pgpfn = (addr - dom->parms.virt_base) >> PAGE_SHIFT_X86;
   8.354 +        l1tab[l1off] =
   8.355 +            pfn_to_paddr(xc_dom_p2m_guest(dom, pgpfn)) | L1_PROT;
   8.356 +        if ( (addr >= dom->pgtables_seg.vstart) && 
   8.357 +             (addr < dom->pgtables_seg.vend) )
   8.358 +            l1tab[l1off] &= ~_PAGE_RW; /* page tables are r/o */
   8.359 +        if ( l1off == (L1_PAGETABLE_ENTRIES_X86_64 - 1) )
   8.360 +            l1tab = NULL;
   8.361      }
   8.362      return 0;
   8.363  }
   8.364 @@ -303,16 +308,16 @@ static int alloc_magic_pages(struct xc_d
   8.365      size_t p2m_size = dom->total_pages * dom->arch_hooks->sizeof_pfn;
   8.366  
   8.367      /* allocate phys2mach table */
   8.368 -    if (0 != xc_dom_alloc_segment(dom, &dom->p2m_seg, "phys2mach", 0, p2m_size))
   8.369 -	return -1;
   8.370 +    if ( xc_dom_alloc_segment(dom, &dom->p2m_seg, "phys2mach", 0, p2m_size) )
   8.371 +        return -1;
   8.372      dom->p2m_guest = xc_dom_seg_to_ptr(dom, &dom->p2m_seg);
   8.373  
   8.374      /* allocate special pages */
   8.375      dom->start_info_pfn = xc_dom_alloc_page(dom, "start info");
   8.376      dom->xenstore_pfn = xc_dom_alloc_page(dom, "xenstore");
   8.377      dom->console_pfn = xc_dom_alloc_page(dom, "console");
   8.378 -    if (xc_dom_feature_translated(dom))
   8.379 -	dom->shared_info_pfn = xc_dom_alloc_page(dom, "shared info");
   8.380 +    if ( xc_dom_feature_translated(dom) )
   8.381 +        dom->shared_info_pfn = xc_dom_alloc_page(dom, "shared info");
   8.382      dom->alloc_bootstack = 1;
   8.383  
   8.384      return 0;
   8.385 @@ -323,10 +328,10 @@ static int alloc_magic_pages(struct xc_d
   8.386  static int start_info_x86_32(struct xc_dom_image *dom)
   8.387  {
   8.388      start_info_x86_32_t *start_info =
   8.389 -	xc_dom_pfn_to_ptr(dom, dom->start_info_pfn, 1);
   8.390 +        xc_dom_pfn_to_ptr(dom, dom->start_info_pfn, 1);
   8.391      xen_pfn_t shinfo =
   8.392 -	xc_dom_feature_translated(dom) ? dom->shared_info_pfn : dom->
   8.393 -	shared_info_mfn;
   8.394 +        xc_dom_feature_translated(dom) ? dom->shared_info_pfn : dom->
   8.395 +        shared_info_mfn;
   8.396  
   8.397      xc_dom_printf("%s: called\n", __FUNCTION__);
   8.398  
   8.399 @@ -343,26 +348,28 @@ static int start_info_x86_32(struct xc_d
   8.400      start_info->console.domU.mfn = xc_dom_p2m_guest(dom, dom->console_pfn);
   8.401      start_info->console.domU.evtchn = dom->console_evtchn;
   8.402  
   8.403 -    if (dom->ramdisk_blob)
   8.404 +    if ( dom->ramdisk_blob )
   8.405      {
   8.406 -	start_info->mod_start = dom->ramdisk_seg.vstart;
   8.407 -	start_info->mod_len = dom->ramdisk_seg.vend - dom->ramdisk_seg.vstart;
   8.408 +        start_info->mod_start = dom->ramdisk_seg.vstart;
   8.409 +        start_info->mod_len = dom->ramdisk_seg.vend - dom->ramdisk_seg.vstart;
   8.410      }
   8.411 -    if (dom->cmdline)
   8.412 +
   8.413 +    if ( dom->cmdline )
   8.414      {
   8.415 -	strncpy((char *)start_info->cmd_line, dom->cmdline, MAX_GUEST_CMDLINE);
   8.416 -	start_info->cmd_line[MAX_GUEST_CMDLINE - 1] = '\0';
   8.417 +        strncpy((char *)start_info->cmd_line, dom->cmdline, MAX_GUEST_CMDLINE);
   8.418 +        start_info->cmd_line[MAX_GUEST_CMDLINE - 1] = '\0';
   8.419      }
   8.420 +
   8.421      return 0;
   8.422  }
   8.423  
   8.424  static int start_info_x86_64(struct xc_dom_image *dom)
   8.425  {
   8.426      start_info_x86_64_t *start_info =
   8.427 -	xc_dom_pfn_to_ptr(dom, dom->start_info_pfn, 1);
   8.428 +        xc_dom_pfn_to_ptr(dom, dom->start_info_pfn, 1);
   8.429      xen_pfn_t shinfo =
   8.430 -	xc_dom_feature_translated(dom) ? dom->shared_info_pfn : dom->
   8.431 -	shared_info_mfn;
   8.432 +        xc_dom_feature_translated(dom) ? dom->shared_info_pfn : dom->
   8.433 +        shared_info_mfn;
   8.434  
   8.435      xc_dom_printf("%s: called\n", __FUNCTION__);
   8.436  
   8.437 @@ -379,16 +386,18 @@ static int start_info_x86_64(struct xc_d
   8.438      start_info->console.domU.mfn = xc_dom_p2m_guest(dom, dom->console_pfn);
   8.439      start_info->console.domU.evtchn = dom->console_evtchn;
   8.440  
   8.441 -    if (dom->ramdisk_blob)
   8.442 +    if ( dom->ramdisk_blob )
   8.443      {
   8.444 -	start_info->mod_start = dom->ramdisk_seg.vstart;
   8.445 -	start_info->mod_len = dom->ramdisk_seg.vend - dom->ramdisk_seg.vstart;
   8.446 +        start_info->mod_start = dom->ramdisk_seg.vstart;
   8.447 +        start_info->mod_len = dom->ramdisk_seg.vend - dom->ramdisk_seg.vstart;
   8.448      }
   8.449 -    if (dom->cmdline)
   8.450 +
   8.451 +    if ( dom->cmdline )
   8.452      {
   8.453 -	strncpy((char *)start_info->cmd_line, dom->cmdline, MAX_GUEST_CMDLINE);
   8.454 -	start_info->cmd_line[MAX_GUEST_CMDLINE - 1] = '\0';
   8.455 +        strncpy((char *)start_info->cmd_line, dom->cmdline, MAX_GUEST_CMDLINE);
   8.456 +        start_info->cmd_line[MAX_GUEST_CMDLINE - 1] = '\0';
   8.457      }
   8.458 +
   8.459      return 0;
   8.460  }
   8.461  
   8.462 @@ -400,8 +409,8 @@ static int shared_info_x86_32(struct xc_
   8.463      xc_dom_printf("%s: called\n", __FUNCTION__);
   8.464  
   8.465      memset(shared_info, 0, sizeof(*shared_info));
   8.466 -    for (i = 0; i < MAX_VIRT_CPUS; i++)
   8.467 -	shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
   8.468 +    for ( i = 0; i < MAX_VIRT_CPUS; i++ )
   8.469 +        shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
   8.470      return 0;
   8.471  }
   8.472  
   8.473 @@ -413,8 +422,8 @@ static int shared_info_x86_64(struct xc_
   8.474      xc_dom_printf("%s: called\n", __FUNCTION__);
   8.475  
   8.476      memset(shared_info, 0, sizeof(*shared_info));
   8.477 -    for (i = 0; i < MAX_VIRT_CPUS; i++)
   8.478 -	shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
   8.479 +    for ( i = 0; i < MAX_VIRT_CPUS; i++ )
   8.480 +        shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
   8.481      return 0;
   8.482  }
   8.483  
   8.484 @@ -432,10 +441,10 @@ static int vcpu_x86_32(struct xc_dom_ima
   8.485      memset(ctxt, 0, sizeof(*ctxt));
   8.486  
   8.487      /* Virtual IDT is empty at start-of-day. */
   8.488 -    for (i = 0; i < 256; i++)
   8.489 +    for ( i = 0; i < 256; i++ )
   8.490      {
   8.491 -	ctxt->trap_ctxt[i].vector = i;
   8.492 -	ctxt->trap_ctxt[i].cs = FLAT_KERNEL_CS_X86_32;
   8.493 +        ctxt->trap_ctxt[i].vector = i;
   8.494 +        ctxt->trap_ctxt[i].cs = FLAT_KERNEL_CS_X86_32;
   8.495      }
   8.496  
   8.497      /* No callback handlers. */
   8.498 @@ -450,24 +459,24 @@ static int vcpu_x86_32(struct xc_dom_ima
   8.499      ctxt->user_regs.cs = FLAT_KERNEL_CS_X86_32;
   8.500      ctxt->user_regs.eip = dom->parms.virt_entry;
   8.501      ctxt->user_regs.esp =
   8.502 -	dom->parms.virt_base + (dom->bootstack_pfn + 1) * PAGE_SIZE_X86;
   8.503 +        dom->parms.virt_base + (dom->bootstack_pfn + 1) * PAGE_SIZE_X86;
   8.504      ctxt->user_regs.esi =
   8.505 -	dom->parms.virt_base + (dom->start_info_pfn) * PAGE_SIZE_X86;
   8.506 -    ctxt->user_regs.eflags = 1 << 9;	/* Interrupt Enable */
   8.507 +        dom->parms.virt_base + (dom->start_info_pfn) * PAGE_SIZE_X86;
   8.508 +    ctxt->user_regs.eflags = 1 << 9; /* Interrupt Enable */
   8.509  
   8.510      ctxt->kernel_ss = FLAT_KERNEL_SS_X86_32;
   8.511      ctxt->kernel_sp =
   8.512 -	dom->parms.virt_base + (dom->bootstack_pfn + 1) * PAGE_SIZE_X86;
   8.513 +        dom->parms.virt_base + (dom->bootstack_pfn + 1) * PAGE_SIZE_X86;
   8.514  
   8.515      ctxt->flags = VGCF_in_kernel_X86_32;
   8.516 -    if (dom->parms.pae == 2 /* extended_cr3 */ ||
   8.517 -	dom->parms.pae == 3 /* bimodal */)
   8.518 -	ctxt->vm_assist |= (1UL << VMASST_TYPE_pae_extended_cr3);
   8.519 +    if ( dom->parms.pae == 2 /* extended_cr3 */ ||
   8.520 +         dom->parms.pae == 3 /* bimodal */ )
   8.521 +        ctxt->vm_assist |= (1UL << VMASST_TYPE_pae_extended_cr3);
   8.522  
   8.523      cr3_pfn = xc_dom_p2m_guest(dom, dom->pgtables_seg.pfn);
   8.524      ctxt->ctrlreg[3] = xen_pfn_to_cr3_x86_32(cr3_pfn);
   8.525      xc_dom_printf("%s: cr3: pfn 0x%" PRIpfn " mfn 0x%" PRIpfn "\n",
   8.526 -		  __FUNCTION__, dom->pgtables_seg.pfn, cr3_pfn);
   8.527 +                  __FUNCTION__, dom->pgtables_seg.pfn, cr3_pfn);
   8.528  
   8.529      return 0;
   8.530  }
   8.531 @@ -484,10 +493,10 @@ static int vcpu_x86_64(struct xc_dom_ima
   8.532      memset(ctxt, 0, sizeof(*ctxt));
   8.533  
   8.534      /* Virtual IDT is empty at start-of-day. */
   8.535 -    for (i = 0; i < 256; i++)
   8.536 +    for ( i = 0; i < 256; i++ )
   8.537      {
   8.538 -	ctxt->trap_ctxt[i].vector = i;
   8.539 -	ctxt->trap_ctxt[i].cs = FLAT_KERNEL_CS_X86_64;
   8.540 +        ctxt->trap_ctxt[i].vector = i;
   8.541 +        ctxt->trap_ctxt[i].cs = FLAT_KERNEL_CS_X86_64;
   8.542      }
   8.543  
   8.544      ctxt->user_regs.ds = FLAT_KERNEL_DS_X86_64;
   8.545 @@ -498,20 +507,20 @@ static int vcpu_x86_64(struct xc_dom_ima
   8.546      ctxt->user_regs.cs = FLAT_KERNEL_CS_X86_64;
   8.547      ctxt->user_regs.rip = dom->parms.virt_entry;
   8.548      ctxt->user_regs.rsp =
   8.549 -	dom->parms.virt_base + (dom->bootstack_pfn + 1) * PAGE_SIZE_X86;
   8.550 +        dom->parms.virt_base + (dom->bootstack_pfn + 1) * PAGE_SIZE_X86;
   8.551      ctxt->user_regs.rsi =
   8.552 -	dom->parms.virt_base + (dom->start_info_pfn) * PAGE_SIZE_X86;
   8.553 -    ctxt->user_regs.rflags = 1 << 9;	/* Interrupt Enable */
   8.554 +        dom->parms.virt_base + (dom->start_info_pfn) * PAGE_SIZE_X86;
   8.555 +    ctxt->user_regs.rflags = 1 << 9; /* Interrupt Enable */
   8.556  
   8.557      ctxt->kernel_ss = FLAT_KERNEL_SS_X86_64;
   8.558      ctxt->kernel_sp =
   8.559 -	dom->parms.virt_base + (dom->bootstack_pfn + 1) * PAGE_SIZE_X86;
   8.560 +        dom->parms.virt_base + (dom->bootstack_pfn + 1) * PAGE_SIZE_X86;
   8.561  
   8.562      ctxt->flags = VGCF_in_kernel_X86_64;
   8.563      cr3_pfn = xc_dom_p2m_guest(dom, dom->pgtables_seg.pfn);
   8.564      ctxt->ctrlreg[3] = xen_pfn_to_cr3_x86_64(cr3_pfn);
   8.565      xc_dom_printf("%s: cr3: pfn 0x%" PRIpfn " mfn 0x%" PRIpfn "\n",
   8.566 -		  __FUNCTION__, dom->pgtables_seg.pfn, cr3_pfn);
   8.567 +                  __FUNCTION__, dom->pgtables_seg.pfn, cr3_pfn);
   8.568  
   8.569      return 0;
   8.570  }
   8.571 @@ -559,3 +568,13 @@ static void __init register_arch_hooks(v
   8.572      xc_dom_register_arch_hooks(&xc_dom_32_pae);
   8.573      xc_dom_register_arch_hooks(&xc_dom_64);
   8.574  }
   8.575 +
   8.576 +/*
   8.577 + * Local variables:
   8.578 + * mode: C
   8.579 + * c-set-style: "BSD"
   8.580 + * c-basic-offset: 4
   8.581 + * tab-width: 4
   8.582 + * indent-tabs-mode: nil
   8.583 + * End:
   8.584 + */
     9.1 --- a/tools/libxc/xc_efi.h	Sat Feb 24 14:48:17 2007 +0000
     9.2 +++ b/tools/libxc/xc_efi.h	Sat Feb 24 15:30:19 2007 +0000
     9.3 @@ -10,8 +10,8 @@
     9.4   * Copyright (C) 1999 VA Linux Systems
     9.5   * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
     9.6   * Copyright (C) 1999, 2002-2003 Hewlett-Packard Co.
     9.7 - *	David Mosberger-Tang <davidm@hpl.hp.com>
     9.8 - *	Stephane Eranian <eranian@hpl.hp.com>
     9.9 + *      David Mosberger-Tang <davidm@hpl.hp.com>
    9.10 + *      Stephane Eranian <eranian@hpl.hp.com>
    9.11   */
    9.12  
    9.13  /*
    10.1 --- a/tools/libxc/xc_private.c	Sat Feb 24 14:48:17 2007 +0000
    10.2 +++ b/tools/libxc/xc_private.c	Sat Feb 24 15:30:19 2007 +0000
    10.3 @@ -100,7 +100,7 @@ int lock_pages(void *addr, size_t len)
    10.4  void unlock_pages(void *addr, size_t len)
    10.5  {
    10.6  #ifndef __sun__
    10.7 -	safe_munlock(addr, len);
    10.8 +    safe_munlock(addr, len);
    10.9  #endif
   10.10  }
   10.11  
    11.1 --- a/tools/libxc/xg_private.c	Sat Feb 24 14:48:17 2007 +0000
    11.2 +++ b/tools/libxc/xg_private.c	Sat Feb 24 15:30:19 2007 +0000
    11.3 @@ -54,45 +54,45 @@ char *xc_read_image(const char *filename
    11.4  #define CHUNK 1*1024*1024
    11.5      while(1)
    11.6      {
    11.7 -	    if ( (tmp = realloc(image, *size + CHUNK)) == NULL )
    11.8 -	    {
    11.9 -		    PERROR("Could not allocate memory for kernel image");
   11.10 -		    free(image);
   11.11 -		    image = NULL;
   11.12 -		    goto out;
   11.13 -	    }
   11.14 -	    image = tmp;
   11.15 +        if ( (tmp = realloc(image, *size + CHUNK)) == NULL )
   11.16 +        {
   11.17 +            PERROR("Could not allocate memory for kernel image");
   11.18 +            free(image);
   11.19 +            image = NULL;
   11.20 +            goto out;
   11.21 +        }
   11.22 +        image = tmp;
   11.23  
   11.24 -	    bytes = gzread(kernel_gfd, image + *size, CHUNK);
   11.25 -	    switch (bytes)
   11.26 -	    {
   11.27 -	    case -1:
   11.28 -		    PERROR("Error reading kernel image");
   11.29 -		    free(image);
   11.30 -		    image = NULL;
   11.31 -		    goto out;
   11.32 -	    case 0: /* EOF */
   11.33 -		    goto out;
   11.34 -	    default:
   11.35 -		    *size += bytes;
   11.36 -		    break;
   11.37 -	    }
   11.38 +        bytes = gzread(kernel_gfd, image + *size, CHUNK);
   11.39 +        switch (bytes)
   11.40 +        {
   11.41 +        case -1:
   11.42 +            PERROR("Error reading kernel image");
   11.43 +            free(image);
   11.44 +            image = NULL;
   11.45 +            goto out;
   11.46 +        case 0: /* EOF */
   11.47 +            goto out;
   11.48 +        default:
   11.49 +            *size += bytes;
   11.50 +            break;
   11.51 +        }
   11.52      }
   11.53  #undef CHUNK
   11.54  
   11.55   out:
   11.56      if ( *size == 0 )
   11.57      {
   11.58 -	    PERROR("Could not read kernel image");
   11.59 -	    free(image);
   11.60 -	    image = NULL;
   11.61 +        PERROR("Could not read kernel image");
   11.62 +        free(image);
   11.63 +        image = NULL;
   11.64      }
   11.65      else if ( image )
   11.66      {
   11.67 -	    /* Shrink allocation to fit image. */
   11.68 -	    tmp = realloc(image, *size);
   11.69 -	    if ( tmp )
   11.70 -		    image = tmp;
   11.71 +        /* Shrink allocation to fit image. */
   11.72 +        tmp = realloc(image, *size);
   11.73 +        if ( tmp )
   11.74 +            image = tmp;
   11.75      }
   11.76  
   11.77      if ( kernel_gfd != NULL )
   11.78 @@ -189,29 +189,29 @@ unsigned long csum_page(void *page)
   11.79  }
   11.80  
   11.81  __attribute__((weak)) 
   11.82 -int xc_hvm_build(int xc_handle,
   11.83 -                 uint32_t domid,
   11.84 -                 int memsize,
   11.85 -                 const char *image_name)
   11.86 +    int xc_hvm_build(int xc_handle,
   11.87 +                     uint32_t domid,
   11.88 +                     int memsize,
   11.89 +                     const char *image_name)
   11.90  {
   11.91      errno = ENOSYS;
   11.92      return -1;
   11.93  }
   11.94  
   11.95  __attribute__((weak)) 
   11.96 -int xc_hvm_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
   11.97 -                uint32_t max_factor, uint32_t flags,
   11.98 -                int (*suspend)(int domid))
   11.99 +    int xc_hvm_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
  11.100 +                    uint32_t max_factor, uint32_t flags,
  11.101 +                    int (*suspend)(int domid))
  11.102  {
  11.103      errno = ENOSYS;
  11.104      return -1;
  11.105  }
  11.106  
  11.107  __attribute__((weak)) 
  11.108 -int xc_hvm_restore(int xc_handle, int io_fd, uint32_t dom,
  11.109 -                   unsigned long max_pfn, unsigned int store_evtchn,
  11.110 -                   unsigned long *store_mfn,
  11.111 -                   unsigned int pae, unsigned int apic)
  11.112 +    int xc_hvm_restore(int xc_handle, int io_fd, uint32_t dom,
  11.113 +                       unsigned long max_pfn, unsigned int store_evtchn,
  11.114 +                       unsigned long *store_mfn,
  11.115 +                       unsigned int pae, unsigned int apic)
  11.116  {
  11.117      errno = ENOSYS;
  11.118      return -1;
  11.119 @@ -228,3 +228,13 @@ int xc_hvm_restore(int xc_handle, int io
  11.120  {
  11.121      return -ENOSYS;
  11.122  }
  11.123 +
  11.124 +/*
  11.125 + * Local variables:
  11.126 + * mode: C
  11.127 + * c-set-style: "BSD"
  11.128 + * c-basic-offset: 4
  11.129 + * tab-width: 4
  11.130 + * indent-tabs-mode: nil
  11.131 + * End:
  11.132 + */