]> xenbits.xensource.com Git - people/liuw/xen.git/commitdiff
sysctl: report shadow paging capability
authorRoger Pau Monne <roger.pau@citrix.com>
Tue, 10 Sep 2019 15:25:38 +0000 (17:25 +0200)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 12 Sep 2019 11:27:45 +0000 (12:27 +0100)
Report whether shadow paging is supported by the hypervisor, since it
can be disabled at build time.

Reuse and tweak LIBXL_HAVE_PHYSINFO_CAP_HAP as it hasn't appeared in a
released version of Xen yet.

Requested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/libxl/libxl.c
tools/libxl/libxl.h
tools/libxl/libxl_create.c
tools/libxl/libxl_types.idl
tools/ocaml/libs/xc/xenctrl.ml
tools/ocaml/libs/xc/xenctrl.mli
tools/xl/xl_info.c
xen/arch/x86/sysctl.c
xen/include/public/sysctl.h

index 5c0fcf320e23c6d4523c2de66c6ae0c5856e9d3c..57073c06d5da4b1ba75a65233ed87a85e20eb2d3 100644 (file)
@@ -400,6 +400,8 @@ int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo)
     physinfo->cap_hvm_directio =
         !!(xcphysinfo.capabilities & XEN_SYSCTL_PHYSCAP_directio);
     physinfo->cap_hap = !!(xcphysinfo.capabilities & XEN_SYSCTL_PHYSCAP_hap);
+    physinfo->cap_shadow =
+        !!(xcphysinfo.capabilities & XEN_SYSCTL_PHYSCAP_shadow);
 
     GC_FREE;
     return 0;
index 3ff67792a7c401b3a965f4059a983103dcd0a6fb..466df2cdf55bd9c6f2c988268e6b5b20c2a6b44d 100644 (file)
 #define LIBXL_HAVE_EXTENDED_VKB 1
 
 /*
- * LIBXL_HAVE_PHYSINFO_CAP_HAP indicates that libxl_physinfo has a cap_hap
- * field that indicates whether the hardware supports Hardware Assisted
- * Paging.
+ * LIBXL_HAVE_PHYSINFO_CAP_HAP_SHADOW indicates that libxl_physinfo has
+ * cap_hap and cap_shadow fields reflecting the hardware and Xen availability
+ * of Hardware Assisted, and Shadow paging support.
  */
-#define LIBXL_HAVE_PHYSINFO_CAP_HAP 1
+#define LIBXL_HAVE_PHYSINFO_CAP_HAP_SHADOW 1
 
 /*
  * libxl ABI compatibility
index 3b45065597f15cfac4a1e3a97799ebf2dc014db5..59dbcb50a086bca2b89ea05feca02a782acc6948 100644 (file)
@@ -44,7 +44,15 @@ int libxl__domain_create_info_setdefault(libxl__gc *gc,
         if (rc)
             return rc;
 
-        libxl_defbool_setdefault(&c_info->hap, info.cap_hap);
+        if (info.cap_hap)
+            libxl_defbool_setdefault(&c_info->hap, true);
+        else if (info.cap_shadow)
+            libxl_defbool_setdefault(&c_info->hap, false);
+        else {
+            LOG(ERROR, "neither hap nor shadow paging available");
+            return ERROR_INVAL;
+        }
+
         libxl_defbool_setdefault(&c_info->oos, true);
     }
 
index 9e1f8515d3b3dd88b780ec899a1fd3d6a5cce9cf..6f431baec24bdfe6ccd30053430e1d5b43210b05 100644 (file)
@@ -1026,6 +1026,7 @@ libxl_physinfo = Struct("physinfo", [
     ("cap_pv", bool),
     ("cap_hvm_directio", bool), # No longer HVM specific
     ("cap_hap", bool),
+    ("cap_shadow", bool),
     ], dir=DIR_OUT)
 
 libxl_connectorinfo = Struct("connectorinfo", [
index bfb3d8e18166b21dfadcf4ee4416e44d85fcdae1..43aafa7e22b3250a60b8a2df1e38bf708aee2258 100644 (file)
@@ -108,6 +108,7 @@ type physinfo_cap_flag =
        | CAP_PV
        | CAP_DirectIO
        | CAP_HAP
+       | CAP_Shadow
 
 type physinfo =
 {
index 8bc36ec8f6f136268b0dc76989e80698a1f9c32a..1bcfa3f83977694b8b864fb92b96c5ca8fa5b45a 100644 (file)
@@ -93,6 +93,7 @@ type physinfo_cap_flag =
   | CAP_PV
   | CAP_DirectIO
   | CAP_HAP
+  | CAP_Shadow
 type physinfo = {
   threads_per_core : int;
   cores_per_socket : int;
index aa6724bc7f6b6eedcda5296b6eec686c393fc3ec..148c4740ae61fb73fe42a0940e6d7a9633fe8cf7 100644 (file)
@@ -210,12 +210,13 @@ static void output_physinfo(void)
          info.hw_cap[4], info.hw_cap[5], info.hw_cap[6], info.hw_cap[7]
         );
 
-    maybe_printf("virt_caps              :%s%s%s%s%s\n",
+    maybe_printf("virt_caps              :%s%s%s%s%s%s\n",
          info.cap_pv ? " pv" : "",
          info.cap_hvm ? " hvm" : "",
          info.cap_hvm && info.cap_hvm_directio ? " hvm_directio" : "",
          info.cap_pv && info.cap_hvm_directio ? " pv_directio" : "",
-         info.cap_hap ? " hap" : ""
+         info.cap_hap ? " hap" : "",
+         info.cap_shadow ? " shadow" : ""
         );
 
     vinfo = libxl_get_version_info(ctx);
index 5777a05ffcc1eed25503e4e00ee032eb2cc3a1a5..50be0c722aaae968ea9a927f69066c47a1e464bf 100644 (file)
@@ -165,6 +165,8 @@ void arch_do_physinfo(struct xen_sysctl_physinfo *pi)
         pi->capabilities |= XEN_SYSCTL_PHYSCAP_pv;
     if ( hvm_hap_supported() )
         pi->capabilities |= XEN_SYSCTL_PHYSCAP_hap;
+    if ( IS_ENABLED(CONFIG_SHADOW_PAGING) )
+        pi->capabilities |= XEN_SYSCTL_PHYSCAP_shadow;
 }
 
 long arch_do_sysctl(
index d4b455619c761ea9d68db017645f2d7c76e25162..e324442f925195ba9fb86df7c397f600f47470f8 100644 (file)
@@ -93,9 +93,12 @@ struct xen_sysctl_tbuf_op {
 /* The platform supports Hardware Assisted Paging. */
 #define _XEN_SYSCTL_PHYSCAP_hap          3
 #define XEN_SYSCTL_PHYSCAP_hap           (1u<<_XEN_SYSCTL_PHYSCAP_hap)
+/* The platform supports software paging. */
+#define _XEN_SYSCTL_PHYSCAP_shadow       4
+#define XEN_SYSCTL_PHYSCAP_shadow        (1u<<_XEN_SYSCTL_PHYSCAP_shadow)
 
 /* Max XEN_SYSCTL_PHYSCAP_* constant.  Used for ABI checking. */
-#define XEN_SYSCTL_PHYSCAP_MAX XEN_SYSCTL_PHYSCAP_hap
+#define XEN_SYSCTL_PHYSCAP_MAX XEN_SYSCTL_PHYSCAP_shadow
 
 struct xen_sysctl_physinfo {
     uint32_t threads_per_core;