From ef78fd528c84e69d0ca8caced9edf18df911b4e6 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Thu, 13 Feb 2014 01:02:02 +0000 Subject: [PATCH] CPUID-based detection with Xen. Use the brand new hwloc_x86_discovery() function to allow the common x86 code to enumerate cache information under Xen. The following patch is required http://xenbits.xen.org/gitweb/?p=people/andrewcoop/xen.git;a=commitdiff;h=51cfdf2dfd5fd905f136418810e250cd21c6643c which implements the xc_xen_cpuid() function in libxc and Xen. Signed-off-by: Andrew Cooper --- src/topology-xen.c | 19 +++++++++++++++++++ tests/ports/include/xen/xenctrl.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/src/topology-xen.c b/src/topology-xen.c index bb0a9955..d959061a 100644 --- a/src/topology-xen.c +++ b/src/topology-xen.c @@ -160,6 +160,20 @@ hwloc_get_xen_info(xc_interface *xch) return NULL; } +/* Ask Xen to execute CPUID on a specific PU on our behalf. */ +static int xen_cpuid_fn(void *_priv, unsigned pu, unsigned *eax, unsigned *ebx, + unsigned *ecx, unsigned *edx) +{ + struct hwloc_xen_priv *priv = _priv; + int ret = xc_xen_cpuid(priv->xch, pu, eax, ebx, ecx, edx); + + /* Possible failures are -EINVAL for bad PU or -EFAULT for problems moving + * hypercall parameters. */ + assert(!ret && "Something went very wrong with xc_xen_cpuid()\n"); + + return 0; +} + /* Enumerate the full Xen system and fill in appropriate objects into the * topology. */ static int @@ -288,6 +302,11 @@ hwloc_xen_discover(struct hwloc_backend *backend) hwloc_debug("All done discovering Xen topology\n\n"); hwloc_obj_add_info(hwloc_get_root_obj(topology), "Backend", "Xen"); + hwloc_debug("Using CPUID to find cache information\n\n"); + hwloc_x86_discovery(topology, data->max_cpu_id + 1, + HWLOC_X86_DISC_FLAG_CACHES | HWLOC_X86_DISC_FLAG_CPUINFO, + xen_cpuid_fn, priv); + free_xen_info(data); return 1; diff --git a/tests/ports/include/xen/xenctrl.h b/tests/ports/include/xen/xenctrl.h index 1fc9ad87..22e887d7 100644 --- a/tests/ports/include/xen/xenctrl.h +++ b/tests/ports/include/xen/xenctrl.h @@ -56,4 +56,6 @@ int xc_topologyinfo_bounced(xc_interface *, uint32_t *, uint32_t *, uint32_t *, int xc_numainfo_bounced(xc_interface *, uint32_t *, uint64_t *, uint64_t *, uint32_t *); +int xc_xen_cpuid(xc_interface *, uint32_t, uint32_t *, uint32_t *, uint32_t *, uint32_t *); + #endif /* HWLOC_PORT_XEN_XENCTRL_H */ -- 2.39.5