libxc: The following patch replace the libxc interface to use
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 19 Jun 2008 15:15:05 +0000 (16:15 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 19 Jun 2008 15:15:05 +0000 (16:15 +0100)
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>
12 files changed:
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

index 864380d03d566881d05070e99cd833f45be7b5d0..9ee39810409be150753e2b3d1035886137a972e8 100644 (file)
@@ -407,7 +407,7 @@ xc_domain_dumpcore_via_callback(int xc_handle,
 
     int nr_vcpus = 0;
     char *dump_mem, *dump_mem_start = NULL;
-    vcpu_guest_context_t  ctxt[MAX_VIRT_CPUS];
+    vcpu_guest_context_any_t  ctxt[MAX_VIRT_CPUS];
     struct xc_core_arch_context arch_ctxt;
     char dummy[PAGE_SIZE];
     int dummy_len;
@@ -581,10 +581,10 @@ xc_domain_dumpcore_via_callback(int xc_handle,
         PERROR("Could not get section header for .xen_prstatus");
         goto out;
     }
-    filesz = sizeof(ctxt[0]) * nr_vcpus;
+    filesz = sizeof(ctxt[0].c) * nr_vcpus;
     sts = xc_core_shdr_set(shdr, strtab, XEN_DUMPCORE_SEC_PRSTATUS,
                            SHT_PROGBITS, offset, filesz,
-                           __alignof__(ctxt[0]), sizeof(ctxt[0]));
+                           __alignof__(ctxt[0].c), sizeof(ctxt[0].c));
     if ( sts != 0 )
         goto out;
     offset += filesz;
@@ -707,7 +707,7 @@ xc_domain_dumpcore_via_callback(int xc_handle,
         goto out;
 
     /* prstatus: .xen_prstatus */
-    sts = dump_rtn(args, (char *)&ctxt, sizeof(ctxt[0]) * nr_vcpus);
+    sts = dump_rtn(args, (char *)&ctxt[0].c, sizeof(ctxt[0].c) * nr_vcpus);
     if ( sts != 0 )
         goto out;
 
index d212c7d020b771c6ea7747a6dd9b354898cbb08a..4afec53bd5580cfb82046830fb63bb4a8d4a11c9 100644 (file)
@@ -298,30 +298,21 @@ int xc_domain_hvm_setcontext(int xc_handle,
 int xc_vcpu_getcontext(int xc_handle,
                        uint32_t domid,
                        uint32_t vcpu,
-                       vcpu_guest_context_t *ctxt)
+                       vcpu_guest_context_any_t *ctxt)
 {
     int rc;
     DECLARE_DOMCTL;
-    size_t sz = sizeof(vcpu_guest_context_either_t);
+    size_t sz = sizeof(vcpu_guest_context_any_t);
 
     domctl.cmd = XEN_DOMCTL_getvcpucontext;
     domctl.domain = (domid_t)domid;
     domctl.u.vcpucontext.vcpu   = (uint16_t)vcpu;
-    set_xen_guest_handle(domctl.u.vcpucontext.ctxt, ctxt);
+    set_xen_guest_handle(domctl.u.vcpucontext.ctxt, &ctxt->c);
 
-    /*
-     * We may be asked to lock either a 32-bit or a 64-bit context. Lock the
-     * larger of the two if possible, otherwise fall back to native size.
-     */
+    
     if ( (rc = lock_pages(ctxt, sz)) != 0 )
-    {
-        sz = sizeof(*ctxt);
-        if ( (rc = lock_pages(ctxt, sz)) != 0 )
-            return rc;
-    }
-
+        return rc;
     rc = do_domctl(xc_handle, &domctl);
-
     unlock_pages(ctxt, sz);
 
     return rc;
@@ -626,32 +617,28 @@ int xc_availheap(int xc_handle,
 int xc_vcpu_setcontext(int xc_handle,
                        uint32_t domid,
                        uint32_t vcpu,
-                       vcpu_guest_context_t *ctxt)
+                       vcpu_guest_context_any_t *ctxt)
 {
     DECLARE_DOMCTL;
     int rc;
-    size_t sz = sizeof(vcpu_guest_context_either_t);
+    size_t sz = sizeof(vcpu_guest_context_any_t);
+
+    if (ctxt == NULL)
+    {
+        errno = EINVAL;
+        return -1;
+    }
 
     domctl.cmd = XEN_DOMCTL_setvcpucontext;
     domctl.domain = domid;
     domctl.u.vcpucontext.vcpu = vcpu;
-    set_xen_guest_handle(domctl.u.vcpucontext.ctxt, ctxt);
-
-    /*
-     * We may be asked to lock either a 32-bit or a 64-bit context. Lock the
-     * larger of the two if possible, otherwise fall back to native size.
-     */
-    if ( (ctxt != NULL) && (rc = lock_pages(ctxt, sz)) != 0 )
-    {
-        sz = sizeof(*ctxt);
-        if ( (rc = lock_pages(ctxt, sz)) != 0 )
-            return rc;
-    }
+    set_xen_guest_handle(domctl.u.vcpucontext.ctxt, &ctxt->c);
 
+    if ( (rc = lock_pages(ctxt, sz)) != 0 )
+        return rc;
     rc = do_domctl(xc_handle, &domctl);
-
-    if ( ctxt != NULL )
-        unlock_pages(ctxt, sz);
+    
+    unlock_pages(ctxt, sz);
 
     return rc;
 }
index 46859f63cfa1a6907212604b65f3d52c42516ebd..b69a15c7853966c3e1700270180f39e6f13ec345 100644 (file)
@@ -153,7 +153,7 @@ static xen_pfn_t *load_p2m_frame_list(
     int io_fd, int *pae_extended_cr3, int *ext_vcpucontext)
 {
     xen_pfn_t *p2m_frame_list;
-    vcpu_guest_context_either_t ctxt;
+    vcpu_guest_context_any_t ctxt;
     xen_pfn_t p2m_fl_zero;
 
     /* Read first entry of P2M list, or extended-info signature (~0UL). */
@@ -284,12 +284,12 @@ int xc_domain_restore(int xc_handle, int io_fd, uint32_t dom,
     /* The new domain's shared-info frame number. */
     unsigned long shared_info_frame;
     unsigned char shared_info_page[PAGE_SIZE]; /* saved contents from file */
-    shared_info_either_t *old_shared_info = 
-        (shared_info_either_t *)shared_info_page;
-    shared_info_either_t *new_shared_info;
+    shared_info_any_t *old_shared_info = 
+        (shared_info_any_t *)shared_info_page;
+    shared_info_any_t *new_shared_info;
 
     /* A copy of the CPU context of the guest. */
-    vcpu_guest_context_either_t ctxt;
+    vcpu_guest_context_any_t ctxt;
 
     /* A table containing the type of each PFN (/not/ MFN!). */
     unsigned long *pfn_type = NULL;
@@ -304,7 +304,7 @@ int xc_domain_restore(int xc_handle, int io_fd, uint32_t dom,
     xen_pfn_t *p2m_frame_list = NULL;
     
     /* A temporary mapping of the guest's start_info page. */
-    start_info_either_t *start_info;
+    start_info_any_t *start_info;
 
     /* Our mapping of the current region (batch) */
     char *region_base;
index 7b8a1317a49d6facab6f344a5d6358324188d89f..8a16b928bc22e5d3a9a02d002d6dfb19a3cd0653 100644 (file)
@@ -412,7 +412,7 @@ static int suspend_and_state(int (*suspend)(int), int xc_handle, int io_fd,
 ** it to update the MFN to a reasonable value.
 */
 static void *map_frame_list_list(int xc_handle, uint32_t dom,
-                                 shared_info_either_t *shinfo)
+                                 shared_info_any_t *shinfo)
 {
     int count = 100;
     void *p;
@@ -628,9 +628,9 @@ static xen_pfn_t *map_and_save_p2m_table(int xc_handle,
                                          int io_fd, 
                                          uint32_t dom,
                                          unsigned long p2m_size,
-                                         shared_info_either_t *live_shinfo)
+                                         shared_info_any_t *live_shinfo)
 {
-    vcpu_guest_context_either_t ctxt;
+    vcpu_guest_context_any_t ctxt;
 
     /* Double and single indirect references to the live P2M table */
     void *live_p2m_frame_list_list = NULL;
@@ -735,7 +735,7 @@ static xen_pfn_t *map_and_save_p2m_table(int xc_handle,
         p2m_frame_list[i/FPP] = mfn_to_pfn(p2m_frame_list[i/FPP]);
     }
 
-    if ( xc_vcpu_getcontext(xc_handle, dom, 0, &ctxt.c) )
+    if ( xc_vcpu_getcontext(xc_handle, dom, 0, &ctxt) )
     {
         ERROR("Could not get vcpu context");
         goto out;
@@ -814,7 +814,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
     unsigned long shared_info_frame;
 
     /* A copy of the CPU context of the guest. */
-    vcpu_guest_context_either_t ctxt;
+    vcpu_guest_context_any_t ctxt;
 
     /* A table containing the type of each PFN (/not/ MFN!). */
     unsigned long *pfn_type = NULL;
@@ -824,7 +824,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
     char page[PAGE_SIZE];
 
     /* Live mapping of shared info structure */
-    shared_info_either_t *live_shinfo = NULL;
+    shared_info_any_t *live_shinfo = NULL;
 
     /* base of the region in which domain memory is mapped */
     unsigned char *region_base = NULL;
@@ -1536,7 +1536,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
         }
     }
 
-    if ( xc_vcpu_getcontext(xc_handle, dom, 0, &ctxt.c) )
+    if ( xc_vcpu_getcontext(xc_handle, dom, 0, &ctxt) )
     {
         ERROR("Could not get vcpu context");
         goto out;
@@ -1556,7 +1556,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
         if ( !(vcpumap & (1ULL << i)) )
             continue;
 
-        if ( (i != 0) && xc_vcpu_getcontext(xc_handle, dom, i, &ctxt.c) )
+        if ( (i != 0) && xc_vcpu_getcontext(xc_handle, dom, i, &ctxt) )
         {
             ERROR("No context for VCPU%d", i);
             goto out;
@@ -1624,7 +1624,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
      * Reset the MFN to be a known-invalid value. See map_frame_list_list().
      */
     memcpy(page, live_shinfo, PAGE_SIZE);
-    SET_FIELD(((shared_info_either_t *)page), 
+    SET_FIELD(((shared_info_any_t *)page), 
               arch.pfn_to_mfn_frame_list_list, 0);
     if ( write_exact(io_fd, page, PAGE_SIZE) )
     {
index 4682bb7f0428f6143dba9130fb90387c76574382..ac8035bf41a867cdac0a246a2cad5b945b1e65ad 100644 (file)
@@ -48,7 +48,7 @@
 unsigned long xc_translate_foreign_address(int xc_handle, uint32_t dom,
                                            int vcpu, unsigned long long virt )
 {
-    vcpu_guest_context_t ctx;
+    vcpu_guest_context_any_t ctx;
     unsigned long long cr3;
     void *pd, *pt, *pdppage = NULL, *pdp, *pml = NULL;
     unsigned long long pde, pte, pdpe, pmle;
@@ -78,7 +78,7 @@ unsigned long xc_translate_foreign_address(int xc_handle, uint32_t dom,
         DPRINTF("failed to retreive vcpu context\n");
         goto out;
     }
-    cr3 = ((unsigned long long)xen_cr3_to_pfn(ctx.ctrlreg[3])) << PAGE_SHIFT;
+    cr3 = ((unsigned long long)xen_cr3_to_pfn(ctx.c.ctrlreg[3])) << PAGE_SHIFT;
 
     /* Page Map Level 4 */
 
index 0570e62dfb91fd81dc1d66522a4ae8c880844666..2916903aef351d8d0ab5487d2fa40ea177b6f591 100644 (file)
@@ -188,9 +188,9 @@ int xc_map_foreign_ranges(int xc_handle, uint32_t dom,
                           privcmd_mmap_entry_t *entries, int nr);
 
 void *map_domain_va_core(unsigned long domfd, int cpu, void *guest_va,
-                         vcpu_guest_context_t *ctxt);
+                         vcpu_guest_context_any_t *ctxt);
 int xc_waitdomain_core(int xc_handle, int domain, int *status,
-    int options, vcpu_guest_context_t *ctxt);
+    int options, vcpu_guest_context_any_t *ctxt);
 
 void bitmap_64_to_byte(uint8_t *bp, const uint64_t *lp, int nbits);
 void bitmap_byte_to_64(uint64_t *lp, const uint8_t *bp, int nbits);
index f3cf2d79d8a309d43990f4da8861e360c8cd4be4..b2f3e55a0c3d747a569dc8f07c82fa710c3a15b6 100644 (file)
@@ -40,9 +40,9 @@ static int current_domid = -1;
 static int current_isfile;
 static int current_is_hvm;
 
-static uint64_t                 online_cpumap;
-static uint64_t                 regs_valid;
-static vcpu_guest_context_t     ctxt[MAX_VIRT_CPUS];
+static uint64_t                         online_cpumap;
+static uint64_t                         regs_valid;
+static vcpu_guest_context_any_t      ctxt[MAX_VIRT_CPUS];
 
 extern int ffsll(long long int);
 #define FOREACH_CPU(cpumap, i)  for ( cpumap = online_cpumap; (i = ffsll(cpumap)); cpumap &= ~(1 << (index - 1)) )
@@ -96,9 +96,9 @@ xc_register_event_handler(thr_ev_handler_t h,
 }
 
 static inline int
-paging_enabled(vcpu_guest_context_t *v)
+paging_enabled(vcpu_guest_context_any_t *v)
 {
-    unsigned long cr0 = v->ctrlreg[0];
+    unsigned long cr0 = v->c.ctrlreg[0];
     return (cr0 & X86_CR0_PE) && (cr0 & X86_CR0_PG);
 }
 
@@ -174,7 +174,7 @@ map_domain_va_32(
 
     l2 = xc_map_foreign_range(
          xc_handle, current_domid, PAGE_SIZE, PROT_READ,
-         xen_cr3_to_pfn(ctxt[cpu].ctrlreg[3]));
+         xen_cr3_to_pfn(ctxt[cpu].c.ctrlreg[3]));
     if ( l2 == NULL )
         return NULL;
 
@@ -216,7 +216,7 @@ map_domain_va_pae(
 
     l3 = xc_map_foreign_range(
         xc_handle, current_domid, PAGE_SIZE, PROT_READ,
-        xen_cr3_to_pfn(ctxt[cpu].ctrlreg[3]));
+        xen_cr3_to_pfn(ctxt[cpu].c.ctrlreg[3]));
     if ( l3 == NULL )
         return NULL;
 
@@ -494,26 +494,26 @@ xc_ptrace(
     case PTRACE_GETREGS:
         if (!current_isfile && fetch_regs(xc_handle, cpu, NULL))
             goto out_error;
-        SET_PT_REGS(pt, ctxt[cpu].user_regs);
+        SET_PT_REGS(pt, ctxt[cpu].c.user_regs);
         memcpy(data, &pt, sizeof(struct gdb_regs));
         break;
 
     case PTRACE_GETFPREGS:
         if (!current_isfile && fetch_regs(xc_handle, cpu, NULL)) 
                 goto out_error;
-        memcpy(data, &ctxt[cpu].fpu_ctxt, sizeof (elf_fpregset_t));
+        memcpy(data, &ctxt[cpu].c.fpu_ctxt, sizeof (elf_fpregset_t));
         break;
 
     case PTRACE_GETFPXREGS:
         if (!current_isfile && fetch_regs(xc_handle, cpu, NULL))
                 goto out_error;
-        memcpy(data, &ctxt[cpu].fpu_ctxt, sizeof(ctxt[cpu].fpu_ctxt));
+        memcpy(data, &ctxt[cpu].c.fpu_ctxt, sizeof(ctxt[cpu].c.fpu_ctxt));
         break;
 
     case PTRACE_SETREGS:
         if (current_isfile)
                 goto out_unsupported; /* XXX not yet supported */
-        SET_XC_REGS(((struct gdb_regs *)data), ctxt[cpu].user_regs);
+        SET_XC_REGS(((struct gdb_regs *)data), ctxt[cpu].c.user_regs);
         if ((retval = xc_vcpu_setcontext(xc_handle, current_domid, cpu,
                                 &ctxt[cpu])))
             goto out_error_domctl;
@@ -525,7 +525,7 @@ xc_ptrace(
         /*  XXX we can still have problems if the user switches threads
          *  during single-stepping - but that just seems retarded
          */
-        ctxt[cpu].user_regs.eflags |= PSL_T;
+        ctxt[cpu].c.user_regs.eflags |= PSL_T;
         if ((retval = xc_vcpu_setcontext(xc_handle, current_domid, cpu,
                                 &ctxt[cpu])))
             goto out_error_domctl;
@@ -542,9 +542,9 @@ xc_ptrace(
                 if (fetch_regs(xc_handle, cpu, NULL))
                     goto out_error;
                 /* Clear trace flag */
-                if ( ctxt[cpu].user_regs.eflags & PSL_T )
+                if ( ctxt[cpu].c.user_regs.eflags & PSL_T )
                 {
-                    ctxt[cpu].user_regs.eflags &= ~PSL_T;
+                    ctxt[cpu].c.user_regs.eflags &= ~PSL_T;
                     if ((retval = xc_vcpu_setcontext(xc_handle, current_domid,
                                                 cpu, &ctxt[cpu])))
                         goto out_error_domctl;
index 42d49cfcb787eacafdf35693785130670181a031..d4bd6bcb1566e9109e10d5af71aa5efc37ba6a78 100644 (file)
@@ -641,24 +641,24 @@ static const struct xc_core_format_type* current_format_type = NULL;
 
 void *
 map_domain_va_core(unsigned long domfd, int cpu, void *guest_va,
-                   vcpu_guest_context_t *ctxt)
+                   vcpu_guest_context_any_t *ctxt)
 {
     if (current_format_type == NULL)
         return NULL;
     return (current_format_type->map_domain_va_core)(domfd, cpu, guest_va,
-                                                     ctxt);
+                                                     &ctxt->c);
 }
 
 int
 xc_waitdomain_core(int xc_handle, int domfd, int *status, int options,
-                   vcpu_guest_context_t *ctxt)
+                   vcpu_guest_context_any_t *ctxt)
 {
     int ret;
     int i;
 
     for (i = 0; i < NR_FORMAT_TYPE; i++) {
         ret = (format_type[i].waitdomain_core)(xc_handle, domfd, status,
-                                               options, ctxt);
+                                               options, &ctxt->c);
         if (ret == 0) {
             current_format_type = &format_type[i];
             break;
index 3ce213e1f71ee57737f0b6e13b1fe71f313ffc14..73c2904053e922f7c229ba6947fe5b7aea58c8c4 100644 (file)
@@ -13,7 +13,7 @@
 
 static int modify_returncode(int xc_handle, uint32_t domid)
 {
-    vcpu_guest_context_either_t ctxt;
+    vcpu_guest_context_any_t ctxt;
     xc_dominfo_t info;
     xen_capabilities_info_t caps;
     int rc;
@@ -39,7 +39,7 @@ static int modify_returncode(int xc_handle, uint32_t domid)
         return -1;
     }
 
-    if ( (rc = xc_vcpu_getcontext(xc_handle, domid, 0, &ctxt.c)) != 0 )
+    if ( (rc = xc_vcpu_getcontext(xc_handle, domid, 0, &ctxt)) != 0 )
         return rc;
 
     if ( !info.hvm )
@@ -49,7 +49,7 @@ static int modify_returncode(int xc_handle, uint32_t domid)
     else
         ctxt.x32.user_regs.eax = 1;
 
-    if ( (rc = xc_vcpu_setcontext(xc_handle, domid, 0, &ctxt.c)) != 0 )
+    if ( (rc = xc_vcpu_setcontext(xc_handle, domid, 0, &ctxt)) != 0 )
         return rc;
 
     return 0;
@@ -89,7 +89,7 @@ static int xc_domain_resume_any(int xc_handle, uint32_t domid)
     int i, rc = -1;
 #if defined(__i386__) || defined(__x86_64__)
     unsigned long mfn, p2m_size = 0;
-    vcpu_guest_context_t ctxt;
+    vcpu_guest_context_any_t ctxt;
     start_info_t *start_info;
     shared_info_t *shinfo = NULL;
     xen_pfn_t *p2m_frame_list_list = NULL;
@@ -167,7 +167,7 @@ static int xc_domain_resume_any(int xc_handle, uint32_t domid)
         goto out;
     }
 
-    mfn = ctxt.user_regs.edx;
+    mfn = ctxt.c.user_regs.edx;
 
     start_info = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
                                       PROT_READ | PROT_WRITE, mfn);
index 77dba6ae2d5c542609ce94e780441776fa3399f8..ed782b49f0990186c0528cb161192b219ebd01bc 100644 (file)
 #include <xen/xsm/acm_ops.h>
 #include <xen/xsm/flask_op.h>
 
+#if defined(__i386__) || defined(__x86_64__)
+#include <xen/foreign/x86_32.h>
+#include <xen/foreign/x86_64.h>
+#endif
+
 #ifdef __ia64__
 #define XC_PAGE_SHIFT           14
 #else
@@ -162,6 +167,35 @@ typedef struct xc_dominfo {
 } xc_dominfo_t;
 
 typedef xen_domctl_getdomaininfo_t xc_domaininfo_t;
+
+typedef union 
+{
+#if defined(__i386__) || defined(__x86_64__)
+    vcpu_guest_context_x86_64_t x64;
+    vcpu_guest_context_x86_32_t x32;   
+#endif
+    vcpu_guest_context_t c;
+} vcpu_guest_context_any_t;
+
+typedef union
+{
+#if defined(__i386__) || defined(__x86_64__)
+    shared_info_x86_64_t x64;
+    shared_info_x86_32_t x32;
+#endif
+    shared_info_t s;
+} shared_info_any_t;
+
+typedef union
+{
+#if defined(__i386__) || defined(__x86_64__)
+    start_info_x86_64_t x64;
+    start_info_x86_32_t x32;
+#endif
+    start_info_t s;
+} start_info_any_t;
+
+
 int xc_domain_create(int xc_handle,
                      uint32_t ssidref,
                      xen_domain_handle_t handle,
@@ -307,7 +341,7 @@ int xc_domain_getinfo(int xc_handle,
 int xc_vcpu_setcontext(int xc_handle,
                        uint32_t domid,
                        uint32_t vcpu,
-                       vcpu_guest_context_t *ctxt);
+                       vcpu_guest_context_any_t *ctxt);
 /**
  * This function will return information about one or more domains, using a
  * single hypercall.  The domain information will be stored into the supplied
@@ -368,7 +402,7 @@ int xc_domain_hvm_setcontext(int xc_handle,
 int xc_vcpu_getcontext(int xc_handle,
                        uint32_t domid,
                        uint32_t vcpu,
-                       vcpu_guest_context_t *ctxt);
+                       vcpu_guest_context_any_t *ctxt);
 
 typedef xen_domctl_getvcpuinfo_t xc_vcpuinfo_t;
 int xc_vcpu_getinfo(int xc_handle,
index 2da1e2090dce8892482740e8fbb71c67d00d8aac..5d39982c000ac27eecd6205c132c43ab3dfaf069 100644 (file)
@@ -112,28 +112,6 @@ static inline int get_platform_info(int xc_handle, uint32_t dom,
 #define is_mapped(pfn_type) (!((pfn_type) & 0x80000000UL))
 
 
-/* 32-on-64 support: saving 32bit guests from 64bit tools and vice versa */
-typedef union 
-{
-    vcpu_guest_context_x86_64_t x64;
-    vcpu_guest_context_x86_32_t x32;   
-    vcpu_guest_context_t c;
-} vcpu_guest_context_either_t;
-
-typedef union 
-{
-    shared_info_x86_64_t x64;
-    shared_info_x86_32_t x32;   
-    shared_info_t s;
-} shared_info_either_t;
-
-typedef union 
-{
-    start_info_x86_64_t x64;
-    start_info_x86_32_t x32;   
-    start_info_t s;
-} start_info_either_t;
-
 #define GET_FIELD(_p, _f) ((guest_width==8) ? ((_p)->x64._f) : ((_p)->x32._f))
 
 #define SET_FIELD(_p, _f, _v) do {              \
index 59b631d74a18783d4d794a223833528c9aecb133..e6d10db356a6cc0af051575edd249a6e6e762422 100644 (file)
@@ -22,6 +22,8 @@
 #include <string.h>
 #include <inttypes.h>
 #include <getopt.h>
+#include <xen/foreign/x86_64.h>
+#include <xen/foreign/x86_32.h>
 
 #include "xenctrl.h"
 
@@ -702,7 +704,7 @@ void print_stack(vcpu_guest_context_t *ctx, int vcpu)
 void dump_ctx(int vcpu)
 {
     int ret;
-    vcpu_guest_context_t ctx;
+    vcpu_guest_context_any_t ctx;
     xc_dominfo_t dominfo;
 
     xc_handle = xc_interface_open(); /* for accessing control interface */
@@ -727,10 +729,10 @@ void dump_ctx(int vcpu)
         exit(-1);
     }
 
-    print_ctx(&ctx);
+    print_ctx(&ctx.c);
 #ifndef NO_TRANSLATION
-    if (is_kernel_text(INSTR_POINTER((&ctx.user_regs))))
-        print_stack(&ctx, vcpu);
+    if (is_kernel_text(INSTR_POINTER((&ctx.c.user_regs))))
+        print_stack(&ctx.c, vcpu);
 #endif
 
     if (!dominfo.paused) {