]> xenbits.xensource.com Git - people/andrewcoop/hwloc.git/commitdiff
CPUID-based detection with Xen. hwloc-xen-topology-v4
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 13 Feb 2014 01:02:02 +0000 (01:02 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 13 Feb 2014 01:32:25 +0000 (01:32 +0000)
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 <andrew.cooper3@citrix.com>
src/topology-xen.c
tests/ports/include/xen/xenctrl.h

index bb0a9955ede8b064a9a1fc8b7a3140bff06b2ba6..d959061a05078e907dead8e9edd8cbd65855dd0e 100644 (file)
@@ -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;
index 1fc9ad874547a11bc6fa81b58b45a7ec0958213c..22e887d757ded09b48be0e2f85c4a4ce128a8c95 100644 (file)
@@ -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 */