ia64/xen-unstable

changeset 17894:d3a87899985d

libxc: The following patch replace the libxc interface to use
vcpu_guest_context_any_t (which is both 32 and 64 bits) instead of
vcpu_guest_context_t.

Signed-off-by: Jean Guyader <jean.guyader@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jun 19 16:15:05 2008 +0100 (2008-06-19)
parents 3da148fb7d9b
children ec5717ac4815
files tools/libxc/xc_core.c tools/libxc/xc_domain.c tools/libxc/xc_domain_restore.c tools/libxc/xc_domain_save.c tools/libxc/xc_pagetab.c tools/libxc/xc_private.h tools/libxc/xc_ptrace.c tools/libxc/xc_ptrace_core.c tools/libxc/xc_resume.c tools/libxc/xenctrl.h tools/libxc/xg_save_restore.h tools/xentrace/xenctx.c
line diff
     1.1 --- a/tools/libxc/xc_core.c	Thu Jun 19 11:09:10 2008 +0100
     1.2 +++ b/tools/libxc/xc_core.c	Thu Jun 19 16:15:05 2008 +0100
     1.3 @@ -407,7 +407,7 @@ xc_domain_dumpcore_via_callback(int xc_h
     1.4  
     1.5      int nr_vcpus = 0;
     1.6      char *dump_mem, *dump_mem_start = NULL;
     1.7 -    vcpu_guest_context_t  ctxt[MAX_VIRT_CPUS];
     1.8 +    vcpu_guest_context_any_t  ctxt[MAX_VIRT_CPUS];
     1.9      struct xc_core_arch_context arch_ctxt;
    1.10      char dummy[PAGE_SIZE];
    1.11      int dummy_len;
    1.12 @@ -581,10 +581,10 @@ xc_domain_dumpcore_via_callback(int xc_h
    1.13          PERROR("Could not get section header for .xen_prstatus");
    1.14          goto out;
    1.15      }
    1.16 -    filesz = sizeof(ctxt[0]) * nr_vcpus;
    1.17 +    filesz = sizeof(ctxt[0].c) * nr_vcpus;
    1.18      sts = xc_core_shdr_set(shdr, strtab, XEN_DUMPCORE_SEC_PRSTATUS,
    1.19                             SHT_PROGBITS, offset, filesz,
    1.20 -                           __alignof__(ctxt[0]), sizeof(ctxt[0]));
    1.21 +                           __alignof__(ctxt[0].c), sizeof(ctxt[0].c));
    1.22      if ( sts != 0 )
    1.23          goto out;
    1.24      offset += filesz;
    1.25 @@ -707,7 +707,7 @@ xc_domain_dumpcore_via_callback(int xc_h
    1.26          goto out;
    1.27  
    1.28      /* prstatus: .xen_prstatus */
    1.29 -    sts = dump_rtn(args, (char *)&ctxt, sizeof(ctxt[0]) * nr_vcpus);
    1.30 +    sts = dump_rtn(args, (char *)&ctxt[0].c, sizeof(ctxt[0].c) * nr_vcpus);
    1.31      if ( sts != 0 )
    1.32          goto out;
    1.33  
     2.1 --- a/tools/libxc/xc_domain.c	Thu Jun 19 11:09:10 2008 +0100
     2.2 +++ b/tools/libxc/xc_domain.c	Thu Jun 19 16:15:05 2008 +0100
     2.3 @@ -298,30 +298,21 @@ int xc_domain_hvm_setcontext(int xc_hand
     2.4  int xc_vcpu_getcontext(int xc_handle,
     2.5                         uint32_t domid,
     2.6                         uint32_t vcpu,
     2.7 -                       vcpu_guest_context_t *ctxt)
     2.8 +                       vcpu_guest_context_any_t *ctxt)
     2.9  {
    2.10      int rc;
    2.11      DECLARE_DOMCTL;
    2.12 -    size_t sz = sizeof(vcpu_guest_context_either_t);
    2.13 +    size_t sz = sizeof(vcpu_guest_context_any_t);
    2.14  
    2.15      domctl.cmd = XEN_DOMCTL_getvcpucontext;
    2.16      domctl.domain = (domid_t)domid;
    2.17      domctl.u.vcpucontext.vcpu   = (uint16_t)vcpu;
    2.18 -    set_xen_guest_handle(domctl.u.vcpucontext.ctxt, ctxt);
    2.19 +    set_xen_guest_handle(domctl.u.vcpucontext.ctxt, &ctxt->c);
    2.20  
    2.21 -    /*
    2.22 -     * We may be asked to lock either a 32-bit or a 64-bit context. Lock the
    2.23 -     * larger of the two if possible, otherwise fall back to native size.
    2.24 -     */
    2.25 +    
    2.26      if ( (rc = lock_pages(ctxt, sz)) != 0 )
    2.27 -    {
    2.28 -        sz = sizeof(*ctxt);
    2.29 -        if ( (rc = lock_pages(ctxt, sz)) != 0 )
    2.30 -            return rc;
    2.31 -    }
    2.32 -
    2.33 +        return rc;
    2.34      rc = do_domctl(xc_handle, &domctl);
    2.35 -
    2.36      unlock_pages(ctxt, sz);
    2.37  
    2.38      return rc;
    2.39 @@ -626,32 +617,28 @@ int xc_availheap(int xc_handle,
    2.40  int xc_vcpu_setcontext(int xc_handle,
    2.41                         uint32_t domid,
    2.42                         uint32_t vcpu,
    2.43 -                       vcpu_guest_context_t *ctxt)
    2.44 +                       vcpu_guest_context_any_t *ctxt)
    2.45  {
    2.46      DECLARE_DOMCTL;
    2.47      int rc;
    2.48 -    size_t sz = sizeof(vcpu_guest_context_either_t);
    2.49 +    size_t sz = sizeof(vcpu_guest_context_any_t);
    2.50 +
    2.51 +    if (ctxt == NULL)
    2.52 +    {
    2.53 +        errno = EINVAL;
    2.54 +        return -1;
    2.55 +    }
    2.56  
    2.57      domctl.cmd = XEN_DOMCTL_setvcpucontext;
    2.58      domctl.domain = domid;
    2.59      domctl.u.vcpucontext.vcpu = vcpu;
    2.60 -    set_xen_guest_handle(domctl.u.vcpucontext.ctxt, ctxt);
    2.61 +    set_xen_guest_handle(domctl.u.vcpucontext.ctxt, &ctxt->c);
    2.62  
    2.63 -    /*
    2.64 -     * We may be asked to lock either a 32-bit or a 64-bit context. Lock the
    2.65 -     * larger of the two if possible, otherwise fall back to native size.
    2.66 -     */
    2.67 -    if ( (ctxt != NULL) && (rc = lock_pages(ctxt, sz)) != 0 )
    2.68 -    {
    2.69 -        sz = sizeof(*ctxt);
    2.70 -        if ( (rc = lock_pages(ctxt, sz)) != 0 )
    2.71 -            return rc;
    2.72 -    }
    2.73 -
    2.74 +    if ( (rc = lock_pages(ctxt, sz)) != 0 )
    2.75 +        return rc;
    2.76      rc = do_domctl(xc_handle, &domctl);
    2.77 -
    2.78 -    if ( ctxt != NULL )
    2.79 -        unlock_pages(ctxt, sz);
    2.80 +    
    2.81 +    unlock_pages(ctxt, sz);
    2.82  
    2.83      return rc;
    2.84  }
     3.1 --- a/tools/libxc/xc_domain_restore.c	Thu Jun 19 11:09:10 2008 +0100
     3.2 +++ b/tools/libxc/xc_domain_restore.c	Thu Jun 19 16:15:05 2008 +0100
     3.3 @@ -153,7 +153,7 @@ static xen_pfn_t *load_p2m_frame_list(
     3.4      int io_fd, int *pae_extended_cr3, int *ext_vcpucontext)
     3.5  {
     3.6      xen_pfn_t *p2m_frame_list;
     3.7 -    vcpu_guest_context_either_t ctxt;
     3.8 +    vcpu_guest_context_any_t ctxt;
     3.9      xen_pfn_t p2m_fl_zero;
    3.10  
    3.11      /* Read first entry of P2M list, or extended-info signature (~0UL). */
    3.12 @@ -284,12 +284,12 @@ int xc_domain_restore(int xc_handle, int
    3.13      /* The new domain's shared-info frame number. */
    3.14      unsigned long shared_info_frame;
    3.15      unsigned char shared_info_page[PAGE_SIZE]; /* saved contents from file */
    3.16 -    shared_info_either_t *old_shared_info = 
    3.17 -        (shared_info_either_t *)shared_info_page;
    3.18 -    shared_info_either_t *new_shared_info;
    3.19 +    shared_info_any_t *old_shared_info = 
    3.20 +        (shared_info_any_t *)shared_info_page;
    3.21 +    shared_info_any_t *new_shared_info;
    3.22  
    3.23      /* A copy of the CPU context of the guest. */
    3.24 -    vcpu_guest_context_either_t ctxt;
    3.25 +    vcpu_guest_context_any_t ctxt;
    3.26  
    3.27      /* A table containing the type of each PFN (/not/ MFN!). */
    3.28      unsigned long *pfn_type = NULL;
    3.29 @@ -304,7 +304,7 @@ int xc_domain_restore(int xc_handle, int
    3.30      xen_pfn_t *p2m_frame_list = NULL;
    3.31      
    3.32      /* A temporary mapping of the guest's start_info page. */
    3.33 -    start_info_either_t *start_info;
    3.34 +    start_info_any_t *start_info;
    3.35  
    3.36      /* Our mapping of the current region (batch) */
    3.37      char *region_base;
     4.1 --- a/tools/libxc/xc_domain_save.c	Thu Jun 19 11:09:10 2008 +0100
     4.2 +++ b/tools/libxc/xc_domain_save.c	Thu Jun 19 16:15:05 2008 +0100
     4.3 @@ -412,7 +412,7 @@ static int suspend_and_state(int (*suspe
     4.4  ** it to update the MFN to a reasonable value.
     4.5  */
     4.6  static void *map_frame_list_list(int xc_handle, uint32_t dom,
     4.7 -                                 shared_info_either_t *shinfo)
     4.8 +                                 shared_info_any_t *shinfo)
     4.9  {
    4.10      int count = 100;
    4.11      void *p;
    4.12 @@ -628,9 +628,9 @@ static xen_pfn_t *map_and_save_p2m_table
    4.13                                           int io_fd, 
    4.14                                           uint32_t dom,
    4.15                                           unsigned long p2m_size,
    4.16 -                                         shared_info_either_t *live_shinfo)
    4.17 +                                         shared_info_any_t *live_shinfo)
    4.18  {
    4.19 -    vcpu_guest_context_either_t ctxt;
    4.20 +    vcpu_guest_context_any_t ctxt;
    4.21  
    4.22      /* Double and single indirect references to the live P2M table */
    4.23      void *live_p2m_frame_list_list = NULL;
    4.24 @@ -735,7 +735,7 @@ static xen_pfn_t *map_and_save_p2m_table
    4.25          p2m_frame_list[i/FPP] = mfn_to_pfn(p2m_frame_list[i/FPP]);
    4.26      }
    4.27  
    4.28 -    if ( xc_vcpu_getcontext(xc_handle, dom, 0, &ctxt.c) )
    4.29 +    if ( xc_vcpu_getcontext(xc_handle, dom, 0, &ctxt) )
    4.30      {
    4.31          ERROR("Could not get vcpu context");
    4.32          goto out;
    4.33 @@ -814,7 +814,7 @@ int xc_domain_save(int xc_handle, int io
    4.34      unsigned long shared_info_frame;
    4.35  
    4.36      /* A copy of the CPU context of the guest. */
    4.37 -    vcpu_guest_context_either_t ctxt;
    4.38 +    vcpu_guest_context_any_t ctxt;
    4.39  
    4.40      /* A table containing the type of each PFN (/not/ MFN!). */
    4.41      unsigned long *pfn_type = NULL;
    4.42 @@ -824,7 +824,7 @@ int xc_domain_save(int xc_handle, int io
    4.43      char page[PAGE_SIZE];
    4.44  
    4.45      /* Live mapping of shared info structure */
    4.46 -    shared_info_either_t *live_shinfo = NULL;
    4.47 +    shared_info_any_t *live_shinfo = NULL;
    4.48  
    4.49      /* base of the region in which domain memory is mapped */
    4.50      unsigned char *region_base = NULL;
    4.51 @@ -1536,7 +1536,7 @@ int xc_domain_save(int xc_handle, int io
    4.52          }
    4.53      }
    4.54  
    4.55 -    if ( xc_vcpu_getcontext(xc_handle, dom, 0, &ctxt.c) )
    4.56 +    if ( xc_vcpu_getcontext(xc_handle, dom, 0, &ctxt) )
    4.57      {
    4.58          ERROR("Could not get vcpu context");
    4.59          goto out;
    4.60 @@ -1556,7 +1556,7 @@ int xc_domain_save(int xc_handle, int io
    4.61          if ( !(vcpumap & (1ULL << i)) )
    4.62              continue;
    4.63  
    4.64 -        if ( (i != 0) && xc_vcpu_getcontext(xc_handle, dom, i, &ctxt.c) )
    4.65 +        if ( (i != 0) && xc_vcpu_getcontext(xc_handle, dom, i, &ctxt) )
    4.66          {
    4.67              ERROR("No context for VCPU%d", i);
    4.68              goto out;
    4.69 @@ -1624,7 +1624,7 @@ int xc_domain_save(int xc_handle, int io
    4.70       * Reset the MFN to be a known-invalid value. See map_frame_list_list().
    4.71       */
    4.72      memcpy(page, live_shinfo, PAGE_SIZE);
    4.73 -    SET_FIELD(((shared_info_either_t *)page), 
    4.74 +    SET_FIELD(((shared_info_any_t *)page), 
    4.75                arch.pfn_to_mfn_frame_list_list, 0);
    4.76      if ( write_exact(io_fd, page, PAGE_SIZE) )
    4.77      {
     5.1 --- a/tools/libxc/xc_pagetab.c	Thu Jun 19 11:09:10 2008 +0100
     5.2 +++ b/tools/libxc/xc_pagetab.c	Thu Jun 19 16:15:05 2008 +0100
     5.3 @@ -48,7 +48,7 @@
     5.4  unsigned long xc_translate_foreign_address(int xc_handle, uint32_t dom,
     5.5                                             int vcpu, unsigned long long virt )
     5.6  {
     5.7 -    vcpu_guest_context_t ctx;
     5.8 +    vcpu_guest_context_any_t ctx;
     5.9      unsigned long long cr3;
    5.10      void *pd, *pt, *pdppage = NULL, *pdp, *pml = NULL;
    5.11      unsigned long long pde, pte, pdpe, pmle;
    5.12 @@ -78,7 +78,7 @@ unsigned long xc_translate_foreign_addre
    5.13          DPRINTF("failed to retreive vcpu context\n");
    5.14          goto out;
    5.15      }
    5.16 -    cr3 = ((unsigned long long)xen_cr3_to_pfn(ctx.ctrlreg[3])) << PAGE_SHIFT;
    5.17 +    cr3 = ((unsigned long long)xen_cr3_to_pfn(ctx.c.ctrlreg[3])) << PAGE_SHIFT;
    5.18  
    5.19      /* Page Map Level 4 */
    5.20  
     6.1 --- a/tools/libxc/xc_private.h	Thu Jun 19 11:09:10 2008 +0100
     6.2 +++ b/tools/libxc/xc_private.h	Thu Jun 19 16:15:05 2008 +0100
     6.3 @@ -188,9 +188,9 @@ int xc_map_foreign_ranges(int xc_handle,
     6.4                            privcmd_mmap_entry_t *entries, int nr);
     6.5  
     6.6  void *map_domain_va_core(unsigned long domfd, int cpu, void *guest_va,
     6.7 -                         vcpu_guest_context_t *ctxt);
     6.8 +                         vcpu_guest_context_any_t *ctxt);
     6.9  int xc_waitdomain_core(int xc_handle, int domain, int *status,
    6.10 -    int options, vcpu_guest_context_t *ctxt);
    6.11 +    int options, vcpu_guest_context_any_t *ctxt);
    6.12  
    6.13  void bitmap_64_to_byte(uint8_t *bp, const uint64_t *lp, int nbits);
    6.14  void bitmap_byte_to_64(uint64_t *lp, const uint8_t *bp, int nbits);
     7.1 --- a/tools/libxc/xc_ptrace.c	Thu Jun 19 11:09:10 2008 +0100
     7.2 +++ b/tools/libxc/xc_ptrace.c	Thu Jun 19 16:15:05 2008 +0100
     7.3 @@ -40,9 +40,9 @@ static int current_domid = -1;
     7.4  static int current_isfile;
     7.5  static int current_is_hvm;
     7.6  
     7.7 -static uint64_t                 online_cpumap;
     7.8 -static uint64_t                 regs_valid;
     7.9 -static vcpu_guest_context_t     ctxt[MAX_VIRT_CPUS];
    7.10 +static uint64_t                         online_cpumap;
    7.11 +static uint64_t                         regs_valid;
    7.12 +static vcpu_guest_context_any_t      ctxt[MAX_VIRT_CPUS];
    7.13  
    7.14  extern int ffsll(long long int);
    7.15  #define FOREACH_CPU(cpumap, i)  for ( cpumap = online_cpumap; (i = ffsll(cpumap)); cpumap &= ~(1 << (index - 1)) )
    7.16 @@ -96,9 +96,9 @@ xc_register_event_handler(thr_ev_handler
    7.17  }
    7.18  
    7.19  static inline int
    7.20 -paging_enabled(vcpu_guest_context_t *v)
    7.21 +paging_enabled(vcpu_guest_context_any_t *v)
    7.22  {
    7.23 -    unsigned long cr0 = v->ctrlreg[0];
    7.24 +    unsigned long cr0 = v->c.ctrlreg[0];
    7.25      return (cr0 & X86_CR0_PE) && (cr0 & X86_CR0_PG);
    7.26  }
    7.27  
    7.28 @@ -174,7 +174,7 @@ map_domain_va_32(
    7.29  
    7.30      l2 = xc_map_foreign_range(
    7.31           xc_handle, current_domid, PAGE_SIZE, PROT_READ,
    7.32 -         xen_cr3_to_pfn(ctxt[cpu].ctrlreg[3]));
    7.33 +         xen_cr3_to_pfn(ctxt[cpu].c.ctrlreg[3]));
    7.34      if ( l2 == NULL )
    7.35          return NULL;
    7.36  
    7.37 @@ -216,7 +216,7 @@ map_domain_va_pae(
    7.38  
    7.39      l3 = xc_map_foreign_range(
    7.40          xc_handle, current_domid, PAGE_SIZE, PROT_READ,
    7.41 -        xen_cr3_to_pfn(ctxt[cpu].ctrlreg[3]));
    7.42 +        xen_cr3_to_pfn(ctxt[cpu].c.ctrlreg[3]));
    7.43      if ( l3 == NULL )
    7.44          return NULL;
    7.45  
    7.46 @@ -494,26 +494,26 @@ xc_ptrace(
    7.47      case PTRACE_GETREGS:
    7.48          if (!current_isfile && fetch_regs(xc_handle, cpu, NULL))
    7.49              goto out_error;
    7.50 -        SET_PT_REGS(pt, ctxt[cpu].user_regs);
    7.51 +        SET_PT_REGS(pt, ctxt[cpu].c.user_regs);
    7.52          memcpy(data, &pt, sizeof(struct gdb_regs));
    7.53          break;
    7.54  
    7.55      case PTRACE_GETFPREGS:
    7.56          if (!current_isfile && fetch_regs(xc_handle, cpu, NULL)) 
    7.57                  goto out_error;
    7.58 -        memcpy(data, &ctxt[cpu].fpu_ctxt, sizeof (elf_fpregset_t));
    7.59 +        memcpy(data, &ctxt[cpu].c.fpu_ctxt, sizeof (elf_fpregset_t));
    7.60          break;
    7.61  
    7.62      case PTRACE_GETFPXREGS:
    7.63          if (!current_isfile && fetch_regs(xc_handle, cpu, NULL))
    7.64                  goto out_error;
    7.65 -        memcpy(data, &ctxt[cpu].fpu_ctxt, sizeof(ctxt[cpu].fpu_ctxt));
    7.66 +        memcpy(data, &ctxt[cpu].c.fpu_ctxt, sizeof(ctxt[cpu].c.fpu_ctxt));
    7.67          break;
    7.68  
    7.69      case PTRACE_SETREGS:
    7.70          if (current_isfile)
    7.71                  goto out_unsupported; /* XXX not yet supported */
    7.72 -        SET_XC_REGS(((struct gdb_regs *)data), ctxt[cpu].user_regs);
    7.73 +        SET_XC_REGS(((struct gdb_regs *)data), ctxt[cpu].c.user_regs);
    7.74          if ((retval = xc_vcpu_setcontext(xc_handle, current_domid, cpu,
    7.75                                  &ctxt[cpu])))
    7.76              goto out_error_domctl;
    7.77 @@ -525,7 +525,7 @@ xc_ptrace(
    7.78          /*  XXX we can still have problems if the user switches threads
    7.79           *  during single-stepping - but that just seems retarded
    7.80           */
    7.81 -        ctxt[cpu].user_regs.eflags |= PSL_T;
    7.82 +        ctxt[cpu].c.user_regs.eflags |= PSL_T;
    7.83          if ((retval = xc_vcpu_setcontext(xc_handle, current_domid, cpu,
    7.84                                  &ctxt[cpu])))
    7.85              goto out_error_domctl;
    7.86 @@ -542,9 +542,9 @@ xc_ptrace(
    7.87                  if (fetch_regs(xc_handle, cpu, NULL))
    7.88                      goto out_error;
    7.89                  /* Clear trace flag */
    7.90 -                if ( ctxt[cpu].user_regs.eflags & PSL_T )
    7.91 +                if ( ctxt[cpu].c.user_regs.eflags & PSL_T )
    7.92                  {
    7.93 -                    ctxt[cpu].user_regs.eflags &= ~PSL_T;
    7.94 +                    ctxt[cpu].c.user_regs.eflags &= ~PSL_T;
    7.95                      if ((retval = xc_vcpu_setcontext(xc_handle, current_domid,
    7.96                                                  cpu, &ctxt[cpu])))
    7.97                          goto out_error_domctl;
     8.1 --- a/tools/libxc/xc_ptrace_core.c	Thu Jun 19 11:09:10 2008 +0100
     8.2 +++ b/tools/libxc/xc_ptrace_core.c	Thu Jun 19 16:15:05 2008 +0100
     8.3 @@ -641,24 +641,24 @@ static const struct xc_core_format_type*
     8.4  
     8.5  void *
     8.6  map_domain_va_core(unsigned long domfd, int cpu, void *guest_va,
     8.7 -                   vcpu_guest_context_t *ctxt)
     8.8 +                   vcpu_guest_context_any_t *ctxt)
     8.9  {
    8.10      if (current_format_type == NULL)
    8.11          return NULL;
    8.12      return (current_format_type->map_domain_va_core)(domfd, cpu, guest_va,
    8.13 -                                                     ctxt);
    8.14 +                                                     &ctxt->c);
    8.15  }
    8.16  
    8.17  int
    8.18  xc_waitdomain_core(int xc_handle, int domfd, int *status, int options,
    8.19 -                   vcpu_guest_context_t *ctxt)
    8.20 +                   vcpu_guest_context_any_t *ctxt)
    8.21  {
    8.22      int ret;
    8.23      int i;
    8.24  
    8.25      for (i = 0; i < NR_FORMAT_TYPE; i++) {
    8.26          ret = (format_type[i].waitdomain_core)(xc_handle, domfd, status,
    8.27 -                                               options, ctxt);
    8.28 +                                               options, &ctxt->c);
    8.29          if (ret == 0) {
    8.30              current_format_type = &format_type[i];
    8.31              break;
     9.1 --- a/tools/libxc/xc_resume.c	Thu Jun 19 11:09:10 2008 +0100
     9.2 +++ b/tools/libxc/xc_resume.c	Thu Jun 19 16:15:05 2008 +0100
     9.3 @@ -13,7 +13,7 @@
     9.4  
     9.5  static int modify_returncode(int xc_handle, uint32_t domid)
     9.6  {
     9.7 -    vcpu_guest_context_either_t ctxt;
     9.8 +    vcpu_guest_context_any_t ctxt;
     9.9      xc_dominfo_t info;
    9.10      xen_capabilities_info_t caps;
    9.11      int rc;
    9.12 @@ -39,7 +39,7 @@ static int modify_returncode(int xc_hand
    9.13          return -1;
    9.14      }
    9.15  
    9.16 -    if ( (rc = xc_vcpu_getcontext(xc_handle, domid, 0, &ctxt.c)) != 0 )
    9.17 +    if ( (rc = xc_vcpu_getcontext(xc_handle, domid, 0, &ctxt)) != 0 )
    9.18          return rc;
    9.19  
    9.20      if ( !info.hvm )
    9.21 @@ -49,7 +49,7 @@ static int modify_returncode(int xc_hand
    9.22      else
    9.23          ctxt.x32.user_regs.eax = 1;
    9.24  
    9.25 -    if ( (rc = xc_vcpu_setcontext(xc_handle, domid, 0, &ctxt.c)) != 0 )
    9.26 +    if ( (rc = xc_vcpu_setcontext(xc_handle, domid, 0, &ctxt)) != 0 )
    9.27          return rc;
    9.28  
    9.29      return 0;
    9.30 @@ -89,7 +89,7 @@ static int xc_domain_resume_any(int xc_h
    9.31      int i, rc = -1;
    9.32  #if defined(__i386__) || defined(__x86_64__)
    9.33      unsigned long mfn, p2m_size = 0;
    9.34 -    vcpu_guest_context_t ctxt;
    9.35 +    vcpu_guest_context_any_t ctxt;
    9.36      start_info_t *start_info;
    9.37      shared_info_t *shinfo = NULL;
    9.38      xen_pfn_t *p2m_frame_list_list = NULL;
    9.39 @@ -167,7 +167,7 @@ static int xc_domain_resume_any(int xc_h
    9.40          goto out;
    9.41      }
    9.42  
    9.43 -    mfn = ctxt.user_regs.edx;
    9.44 +    mfn = ctxt.c.user_regs.edx;
    9.45  
    9.46      start_info = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
    9.47                                        PROT_READ | PROT_WRITE, mfn);
    10.1 --- a/tools/libxc/xenctrl.h	Thu Jun 19 11:09:10 2008 +0100
    10.2 +++ b/tools/libxc/xenctrl.h	Thu Jun 19 16:15:05 2008 +0100
    10.3 @@ -31,6 +31,11 @@
    10.4  #include <xen/xsm/acm_ops.h>
    10.5  #include <xen/xsm/flask_op.h>
    10.6  
    10.7 +#if defined(__i386__) || defined(__x86_64__)
    10.8 +#include <xen/foreign/x86_32.h>
    10.9 +#include <xen/foreign/x86_64.h>
   10.10 +#endif
   10.11 +
   10.12  #ifdef __ia64__
   10.13  #define XC_PAGE_SHIFT           14
   10.14  #else
   10.15 @@ -162,6 +167,35 @@ typedef struct xc_dominfo {
   10.16  } xc_dominfo_t;
   10.17  
   10.18  typedef xen_domctl_getdomaininfo_t xc_domaininfo_t;
   10.19 +
   10.20 +typedef union 
   10.21 +{
   10.22 +#if defined(__i386__) || defined(__x86_64__)
   10.23 +    vcpu_guest_context_x86_64_t x64;
   10.24 +    vcpu_guest_context_x86_32_t x32;   
   10.25 +#endif
   10.26 +    vcpu_guest_context_t c;
   10.27 +} vcpu_guest_context_any_t;
   10.28 +
   10.29 +typedef union
   10.30 +{
   10.31 +#if defined(__i386__) || defined(__x86_64__)
   10.32 +    shared_info_x86_64_t x64;
   10.33 +    shared_info_x86_32_t x32;
   10.34 +#endif
   10.35 +    shared_info_t s;
   10.36 +} shared_info_any_t;
   10.37 +
   10.38 +typedef union
   10.39 +{
   10.40 +#if defined(__i386__) || defined(__x86_64__)
   10.41 +    start_info_x86_64_t x64;
   10.42 +    start_info_x86_32_t x32;
   10.43 +#endif
   10.44 +    start_info_t s;
   10.45 +} start_info_any_t;
   10.46 +
   10.47 +
   10.48  int xc_domain_create(int xc_handle,
   10.49                       uint32_t ssidref,
   10.50                       xen_domain_handle_t handle,
   10.51 @@ -307,7 +341,7 @@ int xc_domain_getinfo(int xc_handle,
   10.52  int xc_vcpu_setcontext(int xc_handle,
   10.53                         uint32_t domid,
   10.54                         uint32_t vcpu,
   10.55 -                       vcpu_guest_context_t *ctxt);
   10.56 +                       vcpu_guest_context_any_t *ctxt);
   10.57  /**
   10.58   * This function will return information about one or more domains, using a
   10.59   * single hypercall.  The domain information will be stored into the supplied
   10.60 @@ -368,7 +402,7 @@ int xc_domain_hvm_setcontext(int xc_hand
   10.61  int xc_vcpu_getcontext(int xc_handle,
   10.62                         uint32_t domid,
   10.63                         uint32_t vcpu,
   10.64 -                       vcpu_guest_context_t *ctxt);
   10.65 +                       vcpu_guest_context_any_t *ctxt);
   10.66  
   10.67  typedef xen_domctl_getvcpuinfo_t xc_vcpuinfo_t;
   10.68  int xc_vcpu_getinfo(int xc_handle,
    11.1 --- a/tools/libxc/xg_save_restore.h	Thu Jun 19 11:09:10 2008 +0100
    11.2 +++ b/tools/libxc/xg_save_restore.h	Thu Jun 19 16:15:05 2008 +0100
    11.3 @@ -112,28 +112,6 @@ static inline int get_platform_info(int 
    11.4  #define is_mapped(pfn_type) (!((pfn_type) & 0x80000000UL))
    11.5  
    11.6  
    11.7 -/* 32-on-64 support: saving 32bit guests from 64bit tools and vice versa */
    11.8 -typedef union 
    11.9 -{
   11.10 -    vcpu_guest_context_x86_64_t x64;
   11.11 -    vcpu_guest_context_x86_32_t x32;   
   11.12 -    vcpu_guest_context_t c;
   11.13 -} vcpu_guest_context_either_t;
   11.14 -
   11.15 -typedef union 
   11.16 -{
   11.17 -    shared_info_x86_64_t x64;
   11.18 -    shared_info_x86_32_t x32;   
   11.19 -    shared_info_t s;
   11.20 -} shared_info_either_t;
   11.21 -
   11.22 -typedef union 
   11.23 -{
   11.24 -    start_info_x86_64_t x64;
   11.25 -    start_info_x86_32_t x32;   
   11.26 -    start_info_t s;
   11.27 -} start_info_either_t;
   11.28 -
   11.29  #define GET_FIELD(_p, _f) ((guest_width==8) ? ((_p)->x64._f) : ((_p)->x32._f))
   11.30  
   11.31  #define SET_FIELD(_p, _f, _v) do {              \
    12.1 --- a/tools/xentrace/xenctx.c	Thu Jun 19 11:09:10 2008 +0100
    12.2 +++ b/tools/xentrace/xenctx.c	Thu Jun 19 16:15:05 2008 +0100
    12.3 @@ -22,6 +22,8 @@
    12.4  #include <string.h>
    12.5  #include <inttypes.h>
    12.6  #include <getopt.h>
    12.7 +#include <xen/foreign/x86_64.h>
    12.8 +#include <xen/foreign/x86_32.h>
    12.9  
   12.10  #include "xenctrl.h"
   12.11  
   12.12 @@ -702,7 +704,7 @@ void print_stack(vcpu_guest_context_t *c
   12.13  void dump_ctx(int vcpu)
   12.14  {
   12.15      int ret;
   12.16 -    vcpu_guest_context_t ctx;
   12.17 +    vcpu_guest_context_any_t ctx;
   12.18      xc_dominfo_t dominfo;
   12.19  
   12.20      xc_handle = xc_interface_open(); /* for accessing control interface */
   12.21 @@ -727,10 +729,10 @@ void dump_ctx(int vcpu)
   12.22          exit(-1);
   12.23      }
   12.24  
   12.25 -    print_ctx(&ctx);
   12.26 +    print_ctx(&ctx.c);
   12.27  #ifndef NO_TRANSLATION
   12.28 -    if (is_kernel_text(INSTR_POINTER((&ctx.user_regs))))
   12.29 -        print_stack(&ctx, vcpu);
   12.30 +    if (is_kernel_text(INSTR_POINTER((&ctx.c.user_regs))))
   12.31 +        print_stack(&ctx.c, vcpu);
   12.32  #endif
   12.33  
   12.34      if (!dominfo.paused) {