ia64/xen-unstable

changeset 10632:c14f26a7b0bc

Allow 32-bit libxc to load 64-bit ELF files.
- use 64-bit integral types for addresses in struct domain_start_info
- use stroull() to parse 64-bit values
- remove redundant _p(a) definition and add a comment
- printf format changes for the new types

Signed-off-by: Jimi Xenidis <jimix@watson.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Jun 30 22:18:01 2006 +0100 (2006-06-30)
parents 130a5badf2b7
children 461fc0bf91f5
files tools/libxc/xc_hvm_build.c tools/libxc/xc_linux_build.c tools/libxc/xc_load_elf.c tools/libxc/xg_private.h
line diff
     1.1 --- a/tools/libxc/xc_hvm_build.c	Fri Jun 30 22:02:58 2006 +0100
     1.2 +++ b/tools/libxc/xc_hvm_build.c	Fri Jun 30 22:18:01 2006 +0100
     1.3 @@ -208,11 +208,11 @@ static int setup_guest(int xc_handle,
     1.4      v_end = (unsigned long long)memsize << 20;
     1.5  
     1.6      IPRINTF("VIRTUAL MEMORY ARRANGEMENT:\n"
     1.7 -           "  Loaded HVM loader:    %08lx->%08lx\n"
     1.8 -           "  TOTAL:                %08lx->%016llx\n",
     1.9 +           "  Loaded HVM loader:    %016llx->%016llx\n"
    1.10 +           "  TOTAL:                %016llx->%016llx\n",
    1.11             dsi.v_kernstart, dsi.v_kernend,
    1.12             dsi.v_start, v_end);
    1.13 -    IPRINTF("  ENTRY ADDRESS:        %08lx\n", dsi.v_kernentry);
    1.14 +    IPRINTF("  ENTRY ADDRESS:        %016llx\n", dsi.v_kernentry);
    1.15  
    1.16      if ( (v_end - dsi.v_start) > ((unsigned long long)nr_pages << PAGE_SHIFT) )
    1.17      {
     2.1 --- a/tools/libxc/xc_linux_build.c	Fri Jun 30 22:02:58 2006 +0100
     2.2 +++ b/tools/libxc/xc_linux_build.c	Fri Jun 30 22:18:01 2006 +0100
     2.3 @@ -12,6 +12,9 @@
     2.4  #include <inttypes.h>
     2.5  #include <zlib.h>
     2.6  
     2.7 +/* Handy for printing out '0' prepended values at native pointer size */
     2.8 +#define _p(a) ((void *) ((ulong)a))
     2.9 +
    2.10  #if defined(__i386__)
    2.11  #define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED)
    2.12  #define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
    2.13 @@ -502,8 +505,6 @@ static int setup_guest(int xc_handle,
    2.14          goto error_out;
    2.15      }
    2.16  
    2.17 -#define _p(a) ((void *) (a))
    2.18 -
    2.19      IPRINTF("VIRTUAL MEMORY ARRANGEMENT:\n"
    2.20             " Loaded kernel: %p->%p\n"
    2.21             " Init. ramdisk: %p->%p\n"
    2.22 @@ -766,9 +767,9 @@ static int setup_guest(int xc_handle,
    2.23                  goto error_out;
    2.24          }
    2.25  
    2.26 -#define NR(_l,_h,_s) \
    2.27 -    (((((_h) + ((1UL<<(_s))-1)) & ~((1UL<<(_s))-1)) - \
    2.28 -    ((_l) & ~((1UL<<(_s))-1))) >> (_s))
    2.29 +#define NR(_l,_h,_s)                                                    \
    2.30 +    (((((unsigned long)(_h) + ((1UL<<(_s))-1)) & ~((1UL<<(_s))-1)) -    \
    2.31 +    ((unsigned long)(_l) & ~((1UL<<(_s))-1))) >> (_s))
    2.32  #if defined(__i386__)
    2.33          if ( dsi.pae_kernel != PAEKERN_no )
    2.34          {
    2.35 @@ -797,8 +798,6 @@ static int setup_guest(int xc_handle,
    2.36  #endif
    2.37      }
    2.38  
    2.39 -#define _p(a) ((void *) (a))
    2.40 -
    2.41      IPRINTF("VIRTUAL MEMORY ARRANGEMENT:\n");
    2.42      IPRINTF(" Loaded kernel:    %p->%p\n", _p(dsi.v_kernstart),
    2.43             _p(dsi.v_kernend));
    2.44 @@ -819,8 +818,8 @@ static int setup_guest(int xc_handle,
    2.45      if ( ((v_end - dsi.v_start)>>PAGE_SHIFT) > nr_pages )
    2.46      {
    2.47          PERROR("Initial guest OS requires too much space\n"
    2.48 -               "(%luMB is greater than %luMB limit)\n",
    2.49 -               (v_end-dsi.v_start)>>20, nr_pages>>(20-PAGE_SHIFT));
    2.50 +               "(%pMB is greater than %luMB limit)\n",
    2.51 +               _p((v_end-dsi.v_start)>>20), nr_pages>>(20-PAGE_SHIFT));
    2.52          goto error_out;
    2.53      }
    2.54  
     3.1 --- a/tools/libxc/xc_load_elf.c	Fri Jun 30 22:02:58 2006 +0100
     3.2 +++ b/tools/libxc/xc_load_elf.c	Fri Jun 30 22:18:01 2006 +0100
     3.3 @@ -162,12 +162,12 @@ static int parseelfimage(const char *ima
     3.4      /* Initial guess for virt_base is 0 if it is not explicitly defined. */
     3.5      p = strstr(guestinfo, "VIRT_BASE=");
     3.6      virt_base_defined = (p != NULL);
     3.7 -    virt_base = virt_base_defined ? strtoul(p+10, &p, 0) : 0;
     3.8 +    virt_base = virt_base_defined ? strtoull(p+10, &p, 0) : 0;
     3.9  
    3.10      /* Initial guess for elf_pa_off is virt_base if not explicitly defined. */
    3.11      p = strstr(guestinfo, "ELF_PADDR_OFFSET=");
    3.12      elf_pa_off_defined = (p != NULL);
    3.13 -    elf_pa_off = elf_pa_off_defined ? strtoul(p+17, &p, 0) : virt_base;
    3.14 +    elf_pa_off = elf_pa_off_defined ? strtoull(p+17, &p, 0) : virt_base;
    3.15  
    3.16      if ( elf_pa_off_defined && !virt_base_defined )
    3.17          goto bad_image;
    3.18 @@ -196,7 +196,7 @@ static int parseelfimage(const char *ima
    3.19  
    3.20      dsi->v_kernentry = ehdr->e_entry;
    3.21      if ( (p = strstr(guestinfo, "VIRT_ENTRY=")) != NULL )
    3.22 -        dsi->v_kernentry = strtoul(p+11, &p, 0);
    3.23 +        dsi->v_kernentry = strtoull(p+11, &p, 0);
    3.24  
    3.25      if ( (kernstart > kernend) ||
    3.26           (dsi->v_kernentry < kernstart) ||
     4.1 --- a/tools/libxc/xg_private.h	Fri Jun 30 22:02:58 2006 +0100
     4.2 +++ b/tools/libxc/xg_private.h	Fri Jun 30 22:18:01 2006 +0100
     4.3 @@ -132,13 +132,13 @@ typedef unsigned long l4_pgentry_t;
     4.4  
     4.5  struct domain_setup_info
     4.6  {
     4.7 -    unsigned long v_start;
     4.8 -    unsigned long v_end;
     4.9 -    unsigned long v_kernstart;
    4.10 -    unsigned long v_kernend;
    4.11 -    unsigned long v_kernentry;
    4.12 +    uint64_t v_start;
    4.13 +    uint64_t v_end;
    4.14 +    uint64_t v_kernstart;
    4.15 +    uint64_t v_kernend;
    4.16 +    uint64_t v_kernentry;
    4.17  
    4.18 -    unsigned long elf_paddr_offset;
    4.19 +    uint64_t elf_paddr_offset;
    4.20  
    4.21  #define PAEKERN_no           0
    4.22  #define PAEKERN_yes          1