* [PATCH] libxc: use vcpu_guest_context_either_t instead of vcpu_guest_context_t
@ 2008-06-19 14:03 Jean Guyader
2008-06-19 14:58 ` Jean Guyader
0 siblings, 1 reply; 4+ messages in thread
From: Jean Guyader @ 2008-06-19 14:03 UTC (permalink / raw)
To: xen-devel
[-- Attachment #1: Type: text/plain, Size: 1013 bytes --]
Hi,
There is some problem on libxc when we try to get the vcpu context.
This is happen with a 64 bits xen and a 32 bits dom0 when we try to get
the vcpu context of a 64 bits guest.
libxc uses the structure vcpu_guest_context_t which has been compiled in
32 bits, but in the hypervisor use the same structure compiled in 64 bits.
- vcpu_guest_context_t in libxc : 2800
- vcpu_guest_context_t in xen : 5168
We do a mlock of a right size (sizeof(vcpu_guest_context_either_t))
before doing the domctl so in the hypervisor when we copy the 64 bits
guest context there is an overflow inside the dom0 memory.
I know that this patch is a little bit intrusive because that changes
the libxc interface. May be there is smarter solution? I am waiting for
your suggestion.
libxc: The following patch replace the libxc interface to use
vcpu_guest_context_either_t (which is both 32 and 64 bits) instead of
vcpu_guest_context_t.
Signed-off-by: Jean Guyader <jean.guyader@eu.citrix.com>
--
Jean Guyader
[-- Attachment #2: vcpu_guest_context_either_t.patch --]
[-- Type: text/plain, Size: 15553 bytes --]
diff -r 3da148fb7d9b tools/libxc/xc_core.c
--- a/tools/libxc/xc_core.c Thu Jun 19 11:09:10 2008 +0100
+++ b/tools/libxc/xc_core.c Thu Jun 19 14:59:57 2008 +0100
@@ -407,7 +407,7 @@ xc_domain_dumpcore_via_callback(int xc_h
int nr_vcpus = 0;
char *dump_mem, *dump_mem_start = NULL;
- vcpu_guest_context_t ctxt[MAX_VIRT_CPUS];
+ vcpu_guest_context_either_t ctxt[MAX_VIRT_CPUS];
struct xc_core_arch_context arch_ctxt;
char dummy[PAGE_SIZE];
int dummy_len;
diff -r 3da148fb7d9b tools/libxc/xc_domain.c
--- a/tools/libxc/xc_domain.c Thu Jun 19 11:09:10 2008 +0100
+++ b/tools/libxc/xc_domain.c Thu Jun 19 14:59:57 2008 +0100
@@ -298,7 +298,7 @@ int xc_vcpu_getcontext(int xc_handle,
int xc_vcpu_getcontext(int xc_handle,
uint32_t domid,
uint32_t vcpu,
- vcpu_guest_context_t *ctxt)
+ vcpu_guest_context_either_t *ctxt)
{
int rc;
DECLARE_DOMCTL;
@@ -307,7 +307,7 @@ int xc_vcpu_getcontext(int xc_handle,
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
@@ -626,7 +626,7 @@ int xc_vcpu_setcontext(int xc_handle,
int xc_vcpu_setcontext(int xc_handle,
uint32_t domid,
uint32_t vcpu,
- vcpu_guest_context_t *ctxt)
+ vcpu_guest_context_either_t *ctxt)
{
DECLARE_DOMCTL;
int rc;
@@ -635,7 +635,7 @@ int xc_vcpu_setcontext(int xc_handle,
domctl.cmd = XEN_DOMCTL_setvcpucontext;
domctl.domain = domid;
domctl.u.vcpucontext.vcpu = 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
diff -r 3da148fb7d9b tools/libxc/xc_domain_save.c
--- a/tools/libxc/xc_domain_save.c Thu Jun 19 11:09:10 2008 +0100
+++ b/tools/libxc/xc_domain_save.c Thu Jun 19 14:59:57 2008 +0100
@@ -735,7 +735,7 @@ static xen_pfn_t *map_and_save_p2m_table
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;
@@ -1536,7 +1536,7 @@ int xc_domain_save(int xc_handle, int io
}
}
- 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
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;
diff -r 3da148fb7d9b tools/libxc/xc_pagetab.c
--- a/tools/libxc/xc_pagetab.c Thu Jun 19 11:09:10 2008 +0100
+++ b/tools/libxc/xc_pagetab.c Thu Jun 19 14:59:57 2008 +0100
@@ -48,7 +48,7 @@ unsigned long xc_translate_foreign_addre
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_either_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_addre
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 */
diff -r 3da148fb7d9b tools/libxc/xc_private.h
--- a/tools/libxc/xc_private.h Thu Jun 19 11:09:10 2008 +0100
+++ b/tools/libxc/xc_private.h Thu Jun 19 14:59:57 2008 +0100
@@ -188,9 +188,9 @@ int xc_map_foreign_ranges(int xc_handle,
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_either_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_either_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);
diff -r 3da148fb7d9b tools/libxc/xc_ptrace.c
--- a/tools/libxc/xc_ptrace.c Thu Jun 19 11:09:10 2008 +0100
+++ b/tools/libxc/xc_ptrace.c Thu Jun 19 14:59:57 2008 +0100
@@ -40,9 +40,9 @@ static int current_isfile;
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_either_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
}
static inline int
-paging_enabled(vcpu_guest_context_t *v)
+paging_enabled(vcpu_guest_context_either_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;
diff -r 3da148fb7d9b tools/libxc/xc_ptrace_core.c
--- a/tools/libxc/xc_ptrace_core.c Thu Jun 19 11:09:10 2008 +0100
+++ b/tools/libxc/xc_ptrace_core.c Thu Jun 19 14:59:57 2008 +0100
@@ -641,24 +641,24 @@ static const struct xc_core_format_type*
void *
map_domain_va_core(unsigned long domfd, int cpu, void *guest_va,
- vcpu_guest_context_t *ctxt)
+ vcpu_guest_context_either_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_either_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;
diff -r 3da148fb7d9b tools/libxc/xc_resume.c
--- a/tools/libxc/xc_resume.c Thu Jun 19 11:09:10 2008 +0100
+++ b/tools/libxc/xc_resume.c Thu Jun 19 14:59:57 2008 +0100
@@ -39,7 +39,7 @@ static int modify_returncode(int xc_hand
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_hand
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_h
int i, rc = -1;
#if defined(__i386__) || defined(__x86_64__)
unsigned long mfn, p2m_size = 0;
- vcpu_guest_context_t ctxt;
+ vcpu_guest_context_either_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_h
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);
diff -r 3da148fb7d9b tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h Thu Jun 19 11:09:10 2008 +0100
+++ b/tools/libxc/xenctrl.h Thu Jun 19 14:59:57 2008 +0100
@@ -30,6 +30,11 @@
#include <xen/xsm/acm.h>
#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
@@ -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_either_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_either_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_either_t;
+
+
int xc_domain_create(int xc_handle,
uint32_t ssidref,
xen_domain_handle_t handle,
@@ -307,7 +341,7 @@ int xc_vcpu_setcontext(int xc_handle,
int xc_vcpu_setcontext(int xc_handle,
uint32_t domid,
uint32_t vcpu,
- vcpu_guest_context_t *ctxt);
+ vcpu_guest_context_either_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_vcpu_getcontext(int xc_handle,
int xc_vcpu_getcontext(int xc_handle,
uint32_t domid,
uint32_t vcpu,
- vcpu_guest_context_t *ctxt);
+ vcpu_guest_context_either_t *ctxt);
typedef xen_domctl_getvcpuinfo_t xc_vcpuinfo_t;
int xc_vcpu_getinfo(int xc_handle,
diff -r 3da148fb7d9b tools/libxc/xg_save_restore.h
--- a/tools/libxc/xg_save_restore.h Thu Jun 19 11:09:10 2008 +0100
+++ b/tools/libxc/xg_save_restore.h Thu Jun 19 14:59:57 2008 +0100
@@ -112,28 +112,6 @@ static inline int get_platform_info(int
#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 { \
diff -r 3da148fb7d9b tools/xentrace/xenctx.c
--- a/tools/xentrace/xenctx.c Thu Jun 19 11:09:10 2008 +0100
+++ b/tools/xentrace/xenctx.c Thu Jun 19 14:59:57 2008 +0100
@@ -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 dump_ctx(int vcpu)
void dump_ctx(int vcpu)
{
int ret;
- vcpu_guest_context_t ctx;
+ vcpu_guest_context_either_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) {
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] libxc: use vcpu_guest_context_either_t instead of vcpu_guest_context_t 2008-06-19 14:03 [PATCH] libxc: use vcpu_guest_context_either_t instead of vcpu_guest_context_t Jean Guyader @ 2008-06-19 14:58 ` Jean Guyader 2008-06-20 3:25 ` [PATCH] compilation fix caused by 17880:d3a87899985d (was Re: [PATCH] libxc: use vcpu_guest_context_either_t instead of vcpu_guest_context_t) Isaku Yamahata 2008-06-20 10:01 ` [PATCH] compilation fix for x86_64 caused by 17880:d3a87899985d Jean Guyader 0 siblings, 2 replies; 4+ messages in thread From: Jean Guyader @ 2008-06-19 14:58 UTC (permalink / raw) To: xen-devel [-- Attachment #1: Type: text/plain, Size: 81 bytes --] This is a new version without falling back for the domctl. -- Jean Guyader [-- Attachment #2: vcpu_guest_context_either_t_2.patch --] [-- Type: text/plain, Size: 17367 bytes --] diff -r 3da148fb7d9b tools/libxc/xc_core.c --- a/tools/libxc/xc_core.c Thu Jun 19 11:09:10 2008 +0100 +++ b/tools/libxc/xc_core.c Thu Jun 19 15:51:59 2008 +0100 @@ -407,7 +407,7 @@ xc_domain_dumpcore_via_callback(int xc_h int nr_vcpus = 0; char *dump_mem, *dump_mem_start = NULL; - vcpu_guest_context_t ctxt[MAX_VIRT_CPUS]; + vcpu_guest_context_either_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_h 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_h 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; diff -r 3da148fb7d9b tools/libxc/xc_domain.c --- a/tools/libxc/xc_domain.c Thu Jun 19 11:09:10 2008 +0100 +++ b/tools/libxc/xc_domain.c Thu Jun 19 15:51:59 2008 +0100 @@ -298,7 +298,7 @@ int xc_vcpu_getcontext(int xc_handle, int xc_vcpu_getcontext(int xc_handle, uint32_t domid, uint32_t vcpu, - vcpu_guest_context_t *ctxt) + vcpu_guest_context_either_t *ctxt) { int rc; DECLARE_DOMCTL; @@ -307,21 +307,12 @@ int xc_vcpu_getcontext(int xc_handle, 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_vcpu_setcontext(int xc_handle, int xc_vcpu_setcontext(int xc_handle, uint32_t domid, uint32_t vcpu, - vcpu_guest_context_t *ctxt) + vcpu_guest_context_either_t *ctxt) { DECLARE_DOMCTL; int rc; size_t sz = sizeof(vcpu_guest_context_either_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); + 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 ( (ctxt != NULL) && (rc = lock_pages(ctxt, sz)) != 0 ) - { - sz = sizeof(*ctxt); - if ( (rc = lock_pages(ctxt, sz)) != 0 ) - return rc; - } - + 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; } diff -r 3da148fb7d9b tools/libxc/xc_domain_save.c --- a/tools/libxc/xc_domain_save.c Thu Jun 19 11:09:10 2008 +0100 +++ b/tools/libxc/xc_domain_save.c Thu Jun 19 15:51:59 2008 +0100 @@ -735,7 +735,7 @@ static xen_pfn_t *map_and_save_p2m_table 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; @@ -1536,7 +1536,7 @@ int xc_domain_save(int xc_handle, int io } } - 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 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; diff -r 3da148fb7d9b tools/libxc/xc_pagetab.c --- a/tools/libxc/xc_pagetab.c Thu Jun 19 11:09:10 2008 +0100 +++ b/tools/libxc/xc_pagetab.c Thu Jun 19 15:51:59 2008 +0100 @@ -48,7 +48,7 @@ unsigned long xc_translate_foreign_addre 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_either_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_addre 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 */ diff -r 3da148fb7d9b tools/libxc/xc_private.h --- a/tools/libxc/xc_private.h Thu Jun 19 11:09:10 2008 +0100 +++ b/tools/libxc/xc_private.h Thu Jun 19 15:51:59 2008 +0100 @@ -188,9 +188,9 @@ int xc_map_foreign_ranges(int xc_handle, 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_either_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_either_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); diff -r 3da148fb7d9b tools/libxc/xc_ptrace.c --- a/tools/libxc/xc_ptrace.c Thu Jun 19 11:09:10 2008 +0100 +++ b/tools/libxc/xc_ptrace.c Thu Jun 19 15:51:59 2008 +0100 @@ -40,9 +40,9 @@ static int current_isfile; 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_either_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 } static inline int -paging_enabled(vcpu_guest_context_t *v) +paging_enabled(vcpu_guest_context_either_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; diff -r 3da148fb7d9b tools/libxc/xc_ptrace_core.c --- a/tools/libxc/xc_ptrace_core.c Thu Jun 19 11:09:10 2008 +0100 +++ b/tools/libxc/xc_ptrace_core.c Thu Jun 19 15:51:59 2008 +0100 @@ -641,24 +641,24 @@ static const struct xc_core_format_type* void * map_domain_va_core(unsigned long domfd, int cpu, void *guest_va, - vcpu_guest_context_t *ctxt) + vcpu_guest_context_either_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_either_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; diff -r 3da148fb7d9b tools/libxc/xc_resume.c --- a/tools/libxc/xc_resume.c Thu Jun 19 11:09:10 2008 +0100 +++ b/tools/libxc/xc_resume.c Thu Jun 19 15:51:59 2008 +0100 @@ -39,7 +39,7 @@ static int modify_returncode(int xc_hand 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_hand 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_h int i, rc = -1; #if defined(__i386__) || defined(__x86_64__) unsigned long mfn, p2m_size = 0; - vcpu_guest_context_t ctxt; + vcpu_guest_context_either_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_h 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); diff -r 3da148fb7d9b tools/libxc/xenctrl.h --- a/tools/libxc/xenctrl.h Thu Jun 19 11:09:10 2008 +0100 +++ b/tools/libxc/xenctrl.h Thu Jun 19 15:51:59 2008 +0100 @@ -30,6 +30,11 @@ #include <xen/xsm/acm.h> #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 @@ -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_either_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_either_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_either_t; + + int xc_domain_create(int xc_handle, uint32_t ssidref, xen_domain_handle_t handle, @@ -307,7 +341,7 @@ int xc_vcpu_setcontext(int xc_handle, int xc_vcpu_setcontext(int xc_handle, uint32_t domid, uint32_t vcpu, - vcpu_guest_context_t *ctxt); + vcpu_guest_context_either_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_vcpu_getcontext(int xc_handle, int xc_vcpu_getcontext(int xc_handle, uint32_t domid, uint32_t vcpu, - vcpu_guest_context_t *ctxt); + vcpu_guest_context_either_t *ctxt); typedef xen_domctl_getvcpuinfo_t xc_vcpuinfo_t; int xc_vcpu_getinfo(int xc_handle, diff -r 3da148fb7d9b tools/libxc/xg_save_restore.h --- a/tools/libxc/xg_save_restore.h Thu Jun 19 11:09:10 2008 +0100 +++ b/tools/libxc/xg_save_restore.h Thu Jun 19 15:51:59 2008 +0100 @@ -112,28 +112,6 @@ static inline int get_platform_info(int #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 { \ diff -r 3da148fb7d9b tools/xentrace/xenctx.c --- a/tools/xentrace/xenctx.c Thu Jun 19 11:09:10 2008 +0100 +++ b/tools/xentrace/xenctx.c Thu Jun 19 15:51:59 2008 +0100 @@ -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 dump_ctx(int vcpu) void dump_ctx(int vcpu) { int ret; - vcpu_guest_context_t ctx; + vcpu_guest_context_either_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) { [-- Attachment #3: Type: text/plain, Size: 138 bytes --] _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] compilation fix caused by 17880:d3a87899985d (was Re: [PATCH] libxc: use vcpu_guest_context_either_t instead of vcpu_guest_context_t) 2008-06-19 14:58 ` Jean Guyader @ 2008-06-20 3:25 ` Isaku Yamahata 2008-06-20 10:01 ` [PATCH] compilation fix for x86_64 caused by 17880:d3a87899985d Jean Guyader 1 sibling, 0 replies; 4+ messages in thread From: Isaku Yamahata @ 2008-06-20 3:25 UTC (permalink / raw) To: xen-devel; +Cc: Jean Guyader # HG changeset patch # User Isaku Yamahata <yamahata@valinux.co.jp> # Date 1213932168 -32400 # Node ID 97de6df3fddc2747ff159df0ed091bac909765a6 # Parent d3a87899985d8f0c91aed55ff05451aee3f973b9 [IA64] compilation fix caused by 17880:d3a87899985d Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> diff --git a/tools/debugger/xenitp/xenitp.c b/tools/debugger/xenitp/xenitp.c --- a/tools/debugger/xenitp/xenitp.c +++ b/tools/debugger/xenitp/xenitp.c @@ -57,6 +57,16 @@ static int cur_vcpu; #define CFM_SOF_MASK 0x3f int virt_to_phys (int is_inst, unsigned long vaddr, unsigned long *paddr); + +/* wrapper for vcpu_gest_context_any_t */ +static int xc_ia64_vcpu_getcontext(int xc_handle, + uint32_t domid, + uint32_t vcpu, + vcpu_guest_context_t *ctxt) +{ + return xc_vcpu_getcontext(xc_handle, domid, vcpu, + (vcpu_guest_context_any_t *)ctxt); +} static inline unsigned int ctx_slot (vcpu_guest_context_t *ctx) { @@ -729,7 +739,7 @@ int wait_domain (int vcpu, vcpu_guest_co fflush (stdout); nanosleep (&ts, NULL); } - return xc_vcpu_getcontext (xc_handle, domid, vcpu, ctx); + return xc_ia64_vcpu_getcontext (xc_handle, domid, vcpu, ctx); } int virt_to_phys (int is_inst, unsigned long vaddr, unsigned long *paddr) @@ -945,13 +955,13 @@ char *parse_arg (char **buf) return res; } -vcpu_guest_context_t vcpu_ctx[MAX_VIRT_CPUS]; +vcpu_guest_context_any_t vcpu_ctx_any[MAX_VIRT_CPUS]; int vcpu_setcontext (int vcpu) { int ret; - ret = xc_vcpu_setcontext (xc_handle, domid, vcpu, &vcpu_ctx[vcpu]); + ret = xc_vcpu_setcontext (xc_handle, domid, vcpu, &vcpu_ctx_any[vcpu]); if (ret < 0) perror ("xc_vcpu_setcontext"); @@ -1518,7 +1528,7 @@ enum cmd_status do_command (int vcpu, ch int flag_ambiguous; cur_vcpu = vcpu; - cur_ctx = &vcpu_ctx[vcpu]; + cur_ctx = &vcpu_ctx_any[vcpu].c; /* Handle repeat last-command. */ if (*line == 0) { @@ -1575,7 +1585,7 @@ void xenitp (int vcpu) int ret; struct sigaction sa; - cur_ctx = &vcpu_ctx[vcpu]; + cur_ctx = &vcpu_ctx_any[vcpu].c; xc_handle = xc_interface_open (); /* for accessing control interface */ @@ -1588,9 +1598,9 @@ void xenitp (int vcpu) exit (-1); } - ret = xc_vcpu_getcontext (xc_handle, domid, vcpu, cur_ctx); + ret = xc_ia64_vcpu_getcontext (xc_handle, domid, vcpu, cur_ctx); if (ret < 0) { - perror ("xc_vcpu_getcontext"); + perror ("xc_ia64_vcpu_getcontext"); exit (-1); } diff --git a/tools/libxc/ia64/xc_ia64_hvm_build.c b/tools/libxc/ia64/xc_ia64_hvm_build.c --- a/tools/libxc/ia64/xc_ia64_hvm_build.c +++ b/tools/libxc/ia64/xc_ia64_hvm_build.c @@ -1052,7 +1052,8 @@ int int xc_hvm_build(int xc_handle, uint32_t domid, int memsize, const char *image_name) { - vcpu_guest_context_t st_ctxt, *ctxt = &st_ctxt; + vcpu_guest_context_any_t st_ctxt_any; + vcpu_guest_context_t *ctxt = &st_ctxt_any.c; char *image = NULL; unsigned long image_size; unsigned long nr_pages; @@ -1079,14 +1080,14 @@ xc_hvm_build(int xc_handle, uint32_t dom free(image); - memset(ctxt, 0, sizeof(*ctxt)); + memset(&st_ctxt_any, 0, sizeof(st_ctxt_any)); ctxt->regs.ip = 0x80000000ffffffb0UL; ctxt->regs.ar.fpsr = xc_ia64_fpsr_default(); ctxt->regs.cr.itir = 14 << 2; ctxt->regs.psr = IA64_PSR_AC | IA64_PSR_BN; ctxt->regs.cr.dcr = 0; ctxt->regs.cr.pta = 15 << 2; - return xc_vcpu_setcontext(xc_handle, domid, 0, ctxt); + return xc_vcpu_setcontext(xc_handle, domid, 0, &st_ctxt_any); error_out: free(image); diff --git a/tools/libxc/ia64/xc_ia64_linux_restore.c b/tools/libxc/ia64/xc_ia64_linux_restore.c --- a/tools/libxc/ia64/xc_ia64_linux_restore.c +++ b/tools/libxc/ia64/xc_ia64_linux_restore.c @@ -117,8 +117,9 @@ xc_ia64_recv_unallocated_list(int xc_han static int xc_ia64_recv_vcpu_context(int xc_handle, int io_fd, uint32_t dom, - uint32_t vcpu, vcpu_guest_context_t *ctxt) + uint32_t vcpu, vcpu_guest_context_any_t *ctxt_any) { + vcpu_guest_context_t *ctxt = &ctxt_any->c; if (read_exact(io_fd, ctxt, sizeof(*ctxt))) { ERROR("Error when reading ctxt"); return -1; @@ -128,14 +129,14 @@ xc_ia64_recv_vcpu_context(int xc_handle, /* Initialize and set registers. */ ctxt->flags = VGCF_EXTRA_REGS | VGCF_SET_CR_IRR; - if (xc_vcpu_setcontext(xc_handle, dom, vcpu, ctxt) != 0) { + if (xc_vcpu_setcontext(xc_handle, dom, vcpu, ctxt_any) != 0) { ERROR("Couldn't set vcpu context"); return -1; } /* Just a check. */ ctxt->flags = 0; - if (xc_vcpu_getcontext(xc_handle, dom, vcpu, ctxt)) { + if (xc_vcpu_getcontext(xc_handle, dom, vcpu, ctxt_any)) { ERROR("Could not get vcpu context"); return -1; } @@ -195,22 +196,23 @@ xc_ia64_pv_recv_context(int xc_handle, i unsigned long gmfn; /* A copy of the CPU context of the guest. */ - vcpu_guest_context_t ctxt; + vcpu_guest_context_any_t ctxt_any; + vcpu_guest_context_t *ctxt = &ctxt_any.c; /* A temporary mapping of the guest's start_info page. */ start_info_t *start_info; - if (lock_pages(&ctxt, sizeof(ctxt))) { + if (lock_pages(&ctxt_any, sizeof(ctxt_any))) { /* needed for build domctl, but might as well do early */ ERROR("Unable to lock_pages ctxt"); return -1; } - if (xc_ia64_recv_vcpu_context(xc_handle, io_fd, dom, 0, &ctxt)) + if (xc_ia64_recv_vcpu_context(xc_handle, io_fd, dom, 0, &ctxt_any)) goto out; /* Then get privreg page. */ - if (read_page(xc_handle, io_fd, dom, ctxt.privregs_pfn) < 0) { + if (read_page(xc_handle, io_fd, dom, ctxt->privregs_pfn) < 0) { ERROR("Could not read vcpu privregs"); goto out; } @@ -243,7 +245,7 @@ xc_ia64_pv_recv_context(int xc_handle, i rc = 0; out: - unlock_pages(&ctxt, sizeof(ctxt)); + unlock_pages(&ctxt_any, sizeof(ctxt_any)); return rc; } @@ -314,12 +316,12 @@ xc_ia64_hvm_recv_context(int xc_handle, /* vcpu context */ for (i = 0; i <= info.max_vcpu_id; i++) { /* A copy of the CPU context of the guest. */ - vcpu_guest_context_t ctxt; + vcpu_guest_context_any_t ctxt_any; if (!__test_bit(i, vcpumap)) continue; - if (xc_ia64_recv_vcpu_context(xc_handle, io_fd, dom, i, &ctxt)) + if (xc_ia64_recv_vcpu_context(xc_handle, io_fd, dom, i, &ctxt_any)) goto out; // system context of vcpu is recieved as hvm context. diff --git a/tools/libxc/ia64/xc_ia64_linux_save.c b/tools/libxc/ia64/xc_ia64_linux_save.c --- a/tools/libxc/ia64/xc_ia64_linux_save.c +++ b/tools/libxc/ia64/xc_ia64_linux_save.c @@ -180,9 +180,10 @@ xc_ia64_send_unallocated_list(int xc_han static int xc_ia64_send_vcpu_context(int xc_handle, int io_fd, uint32_t dom, - uint32_t vcpu, vcpu_guest_context_t *ctxt) + uint32_t vcpu, vcpu_guest_context_any_t *ctxt_any) { - if (xc_vcpu_getcontext(xc_handle, dom, vcpu, ctxt)) { + vcpu_guest_context_t *ctxt = &ctxt_any->c; + if (xc_vcpu_getcontext(xc_handle, dom, vcpu, ctxt_any)) { ERROR("Could not get vcpu context"); return -1; } @@ -211,14 +212,15 @@ xc_ia64_pv_send_context(int xc_handle, i shared_info_t *live_shinfo) { /* A copy of the CPU context of the guest. */ - vcpu_guest_context_t ctxt; + vcpu_guest_context_any_t ctxt_any; + vcpu_guest_context_t *ctxt = &ctxt_any.c; char *mem; - if (xc_ia64_send_vcpu_context(xc_handle, io_fd, dom, 0, &ctxt)) + if (xc_ia64_send_vcpu_context(xc_handle, io_fd, dom, 0, &ctxt_any)) return -1; mem = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, - PROT_READ|PROT_WRITE, ctxt.privregs_pfn); + PROT_READ|PROT_WRITE, ctxt->privregs_pfn); if (mem == NULL) { ERROR("cannot map privreg page"); return -1; @@ -297,12 +299,12 @@ xc_ia64_hvm_send_context(int xc_handle, /* vcpu context */ for (i = 0; i <= info->max_vcpu_id; i++) { /* A copy of the CPU context of the guest. */ - vcpu_guest_context_t ctxt; + vcpu_guest_context_any_t ctxt_any; if (!__test_bit(i, vcpumap)) continue; - if (xc_ia64_send_vcpu_context(xc_handle, io_fd, dom, i, &ctxt)) + if (xc_ia64_send_vcpu_context(xc_handle, io_fd, dom, i, &ctxt_any)) goto out; // system context of vcpu is sent as hvm context. diff --git a/tools/libxc/xc_core_ia64.c b/tools/libxc/xc_core_ia64.c --- a/tools/libxc/xc_core_ia64.c +++ b/tools/libxc/xc_core_ia64.c @@ -308,9 +308,10 @@ xc_core_arch_context_free(struct xc_core int xc_core_arch_context_get(struct xc_core_arch_context* arch_ctxt, - vcpu_guest_context_t* ctxt, + vcpu_guest_context_any_t* ctxt_any, int xc_handle, uint32_t domid) { + vcpu_guest_context_t *ctxt = &ctxt_any->c; mapped_regs_t* mapped_regs; if ( ctxt->privregs_pfn == VGC_PRIVREGS_HVM ) diff --git a/tools/libxc/xc_core_ia64.h b/tools/libxc/xc_core_ia64.h --- a/tools/libxc/xc_core_ia64.h +++ b/tools/libxc/xc_core_ia64.h @@ -40,7 +40,7 @@ xc_core_arch_context_free(struct xc_core xc_core_arch_context_free(struct xc_core_arch_context* arch_ctxt); int xc_core_arch_context_get(struct xc_core_arch_context* arch_ctxt, - vcpu_guest_context_t* ctxt, + vcpu_guest_context_any_t* ctxt, int xc_handle, uint32_t domid); int xc_core_arch_context_get_shdr(struct xc_core_arch_context* arch_ctxt, -- yamahata ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] compilation fix for x86_64 caused by 17880:d3a87899985d 2008-06-19 14:58 ` Jean Guyader 2008-06-20 3:25 ` [PATCH] compilation fix caused by 17880:d3a87899985d (was Re: [PATCH] libxc: use vcpu_guest_context_either_t instead of vcpu_guest_context_t) Isaku Yamahata @ 2008-06-20 10:01 ` Jean Guyader 1 sibling, 0 replies; 4+ messages in thread From: Jean Guyader @ 2008-06-20 10:01 UTC (permalink / raw) To: xen-devel [-- Attachment #1: Type: text/plain, Size: 79 bytes --] Signed-off-by: Jean Guyader <jean.guyader@eu.citrix.com> -- Jean Guyader [-- Attachment #2: vcpu_guest_context_any_t_x86_64.patch --] [-- Type: text/plain, Size: 1063 bytes --] diff -r d3a87899985d tools/libxc/xc_ptrace.c --- a/tools/libxc/xc_ptrace.c Thu Jun 19 16:15:05 2008 +0100 +++ b/tools/libxc/xc_ptrace.c Fri Jun 20 10:59:17 2008 +0100 @@ -264,12 +264,12 @@ map_domain_va_64( uint64_t *l4, *l3, *l2, *l1; static void *v[MAX_VIRT_CPUS]; - if ((ctxt[cpu].ctrlreg[4] & 0x20) == 0 ) /* legacy ia32 mode */ + if ((ctxt[cpu].c.ctrlreg[4] & 0x20) == 0 ) /* legacy ia32 mode */ return map_domain_va_32(xc_handle, cpu, guest_va, perm); l4 = 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 ( l4 == NULL ) return NULL; diff -r d3a87899985d tools/xentrace/xenctx.c --- a/tools/xentrace/xenctx.c Thu Jun 19 16:15:05 2008 +0100 +++ b/tools/xentrace/xenctx.c Fri Jun 20 10:59:17 2008 +0100 @@ -22,8 +22,6 @@ #include <string.h> #include <inttypes.h> #include <getopt.h> -#include <xen/foreign/x86_64.h> -#include <xen/foreign/x86_32.h> #include "xenctrl.h" [-- Attachment #3: Type: text/plain, Size: 138 bytes --] _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-06-20 10:01 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-06-19 14:03 [PATCH] libxc: use vcpu_guest_context_either_t instead of vcpu_guest_context_t Jean Guyader 2008-06-19 14:58 ` Jean Guyader 2008-06-20 3:25 ` [PATCH] compilation fix caused by 17880:d3a87899985d (was Re: [PATCH] libxc: use vcpu_guest_context_either_t instead of vcpu_guest_context_t) Isaku Yamahata 2008-06-20 10:01 ` [PATCH] compilation fix for x86_64 caused by 17880:d3a87899985d Jean Guyader
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.