return dump_rtn(xch, args, (char*)&format_version, sizeof(format_version));
}
-static int
-get_guest_width(xc_interface *xch,
- uint32_t domid,
- unsigned int *guest_width)
-{
- DECLARE_DOMCTL;
-
- memset(&domctl, 0, sizeof(domctl));
- domctl.domain = domid;
- domctl.cmd = XEN_DOMCTL_get_address_size;
-
- if ( do_domctl(xch, &domctl) != 0 )
- return 1;
-
- *guest_width = domctl.u.address_size.size / 8;
- return 0;
-}
-
int
xc_domain_dumpcore_via_callback(xc_interface *xch,
uint32_t domid,
struct xc_core_section_headers *sheaders = NULL;
Elf64_Shdr *shdr;
- if ( get_guest_width(xch, domid, &dinfo->guest_width) != 0 )
+ if ( xc_domain_get_guest_width(xch, domid, &dinfo->guest_width) != 0 )
{
PERROR("Could not get address size for domain");
return sts;
const unsigned int *input, unsigned int *regs)
{
DECLARE_DOMCTL;
+ unsigned int guest_width;
int guest_64bit, xen_64bit = hypervisor_is_64bit(xch);
char brand[13];
uint64_t xfeature_mask;
xc_cpuid_brand_get(brand);
- memset(&domctl, 0, sizeof(domctl));
- domctl.domain = domid;
- domctl.cmd = XEN_DOMCTL_get_address_size;
- do_domctl(xch, &domctl);
- guest_64bit = (domctl.u.address_size.size == 64);
+ xc_domain_get_guest_width(xch, domid, &guest_width);
+ guest_64bit = (guest_width == 8);
/* Detecting Xen's atitude towards XSAVE */
memset(&domctl, 0, sizeof(domctl));
int ret;
uint32_t guest_width;
const char *protocol;
- DECLARE_DOMCTL;
- memset(&domctl, 0, sizeof(domctl));
- domctl.domain = domid;
- domctl.cmd = XEN_DOMCTL_get_address_size;
-
- ret = do_domctl(xch, &domctl);
+ ret = xc_domain_get_guest_width(xch, domid, &guest_width);
if ( ret )
return NULL;
- guest_width = domctl.u.address_size.size;
-
switch (guest_width) {
- case 32: /* 32 bit guest */
+ case 4: /* 32 bit guest */
protocol = XEN_IO_PROTO_ABI_X86_32;
break;
- case 64: /* 64 bit guest */
+ case 8: /* 64 bit guest */
protocol = XEN_IO_PROTO_ABI_X86_64;
break;
default:
return ret;
}
+int xc_domain_get_guest_width(xc_interface *xch, uint32_t domid,
+ unsigned int *guest_width)
+{
+ DECLARE_DOMCTL;
+
+ memset(&domctl, 0, sizeof(domctl));
+ domctl.domain = domid;
+ domctl.cmd = XEN_DOMCTL_get_address_size;
+
+ if ( do_domctl(xch, &domctl) != 0 )
+ return 1;
+
+ /* We want the result in bytes */
+ *guest_width = domctl.u.address_size.size / 8;
+ return 0;
+}
int xc_domain_getinfo(xc_interface *xch,
uint32_t first_domid,
unsigned int *pt_level,
unsigned int *gwidth)
{
- DECLARE_DOMCTL;
xen_capabilities_info_t xen_caps = "";
if (xc_version(xch, XENVER_capabilities, &xen_caps) != 0)
return -1;
- memset(&domctl, 0, sizeof(domctl));
- domctl.domain = domid;
- domctl.cmd = XEN_DOMCTL_get_address_size;
-
- if ( do_domctl(xch, &domctl) != 0 )
+ if (xc_domain_get_guest_width(xch, domid, gwidth) != 0)
return -1;
- *gwidth = domctl.u.address_size.size / 8;
-
if (strstr(xen_caps, "xen-3.0-x86_64"))
/* Depends on whether it's a compat 32-on-64 guest */
*pt_level = ( (*gwidth == 8) ? 4 : 3 );
pt_levels = (ctx.msr_efer&EFER_LMA) ? 4 : (ctx.cr4&CR4_PAE) ? 3 : 2;
paddr = ctx.cr3 & ((pt_levels == 3) ? ~0x1full : ~0xfffull);
} else {
- DECLARE_DOMCTL;
+ unsigned int gwidth;
vcpu_guest_context_any_t ctx;
if (xc_vcpu_getcontext(xch, dom, vcpu, &ctx) != 0)
return 0;
- domctl.domain = dom;
- domctl.cmd = XEN_DOMCTL_get_address_size;
- if ( do_domctl(xch, &domctl) != 0 )
+ if (xc_domain_get_guest_width(xch, dom, &gwidth) != 0)
return 0;
- if (domctl.u.address_size.size == 64) {
+ if (gwidth == 8) {
pt_levels = 4;
paddr = (uint64_t)xen_cr3_to_pfn_x86_64(ctx.x64.ctrlreg[3])
<< PAGE_SHIFT;
#include <xen/foreign/x86_64.h>
#include <xen/hvm/params.h>
-static int pv_guest_width(xc_interface *xch, uint32_t domid)
-{
- DECLARE_DOMCTL;
- domctl.domain = domid;
- domctl.cmd = XEN_DOMCTL_get_address_size;
- if ( xc_domctl(xch, &domctl) != 0 )
- {
- PERROR("Could not get guest address size");
- return -1;
- }
- return domctl.u.address_size.size / 8;
-}
-
static int modify_returncode(xc_interface *xch, uint32_t domid)
{
vcpu_guest_context_any_t ctxt;
else
{
/* Probe PV guest address width. */
- dinfo->guest_width = pv_guest_width(xch, domid);
- if ( dinfo->guest_width < 0 )
+ if ( xc_domain_get_guest_width(xch, domid, &dinfo->guest_width) )
return -1;
}
xc_dominfo_t info;
int i, rc = -1;
#if defined(__i386__) || defined(__x86_64__)
- struct domain_info_context _dinfo = { .p2m_size = 0 };
+ struct domain_info_context _dinfo = { .guest_width = 0,
+ .p2m_size = 0 };
struct domain_info_context *dinfo = &_dinfo;
unsigned long mfn;
vcpu_guest_context_any_t ctxt;
return rc;
}
- dinfo->guest_width = pv_guest_width(xch, domid);
+ xc_domain_get_guest_width(xch, domid, &dinfo->guest_width);
if ( dinfo->guest_width != sizeof(long) )
{
ERROR("Cannot resume uncooperative cross-address-size guests");
int vcpu,
xc_cpumap_t cpumap);
+
+/**
+ * This function will return the guest_width (in bytes) for the
+ * specified domain.
+ *
+ * @param xch a handle to an open hypervisor interface.
+ * @param domid the domain id one wants the address size width of.
+ * @param addr_size the address size.
+ */
+int xc_domain_get_guest_width(xc_interface *xch, uint32_t domid,
+ unsigned int *guest_width);
+
+
/**
* This function will return information about one or more domains. It is
* designed to iterate over the list of domains. If a single domain is
{
xen_capabilities_info_t xen_caps = "";
xen_platform_parameters_t xen_params;
- DECLARE_DOMCTL;
if (xc_version(xch, XENVER_platform_parameters, &xen_params) != 0)
return 0;
*hvirt_start = xen_params.virt_start;
- memset(&domctl, 0, sizeof(domctl));
- domctl.domain = dom;
- domctl.cmd = XEN_DOMCTL_get_address_size;
-
- if ( do_domctl(xch, &domctl) != 0 )
+ if ( xc_domain_get_guest_width(xch, dom, guest_width) != 0)
return 0;
- *guest_width = domctl.u.address_size.size / 8;
-
/* 64-bit tools will see the 64-bit hvirt_start, but 32-bit guests
* will be using the compat one. */
if ( *guest_width < sizeof (unsigned long) )
}
ctxt_word_size = (strstr(xen_caps, "xen-3.0-x86_64")) ? 8 : 4;
} else {
- struct xen_domctl domctl;
- memset(&domctl, 0, sizeof domctl);
- domctl.domain = xenctx.domid;
- domctl.cmd = XEN_DOMCTL_get_address_size;
- if (xc_domctl(xenctx.xc_handle, &domctl) == 0)
- ctxt_word_size = guest_word_size = domctl.u.address_size.size / 8;
+ unsigned int gw;
+ if ( !xc_domain_get_guest_width(xenctx.xc_handle, xenctx.domid, &gw) )
+ ctxt_word_size = guest_word_size = gw;
}
}
#endif