All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roger Pau Monne <roger.pau@citrix.com>
To: <xen-devel@lists.xenproject.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <Andrew.Cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>,
	Julien Grall <julien.grall@arm.com>,
	Christian Lindig <christian.lindig@citrix.com>,
	Jan Beulich <jbeulich@suse.com>, David Scott <dave@recoil.org>,
	Anthony PERARD <anthony.perard@citrix.com>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: [Xen-devel] [PATCH v4 2/2] sysctl: report shadow paging capability
Date: Tue, 10 Sep 2019 17:25:38 +0200	[thread overview]
Message-ID: <20190910152538.36921-2-roger.pau@citrix.com> (raw)
In-Reply-To: <20190910152538.36921-1-roger.pau@citrix.com>

Report whether shadow paging is supported by the hypervisor, since it
can be disabled at build time.

Requested-by: Andrew Cooper <Andrew.Cooper3@citrix.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
NB: I'm not sure the added check in
libxl__domain_create_info_setdefault is that useful, or if it could be
better placed somewhere else.
---
Changes since v3:
 - New in this version.
---
 tools/libxl/libxl.c             | 2 ++
 tools/libxl/libxl.h             | 6 ++++++
 tools/libxl/libxl_create.c      | 5 +++++
 tools/libxl/libxl_types.idl     | 1 +
 tools/ocaml/libs/xc/xenctrl.ml  | 1 +
 tools/ocaml/libs/xc/xenctrl.mli | 1 +
 tools/xl/xl_info.c              | 5 +++--
 xen/arch/x86/sysctl.c           | 2 ++
 xen/include/public/sysctl.h     | 5 ++++-
 9 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 5c0fcf320e..57073c06d5 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -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;
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 3ff67792a7..e8f5ebe929 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -401,6 +401,12 @@
  */
 #define LIBXL_HAVE_PHYSINFO_CAP_HAP 1
 
+/*
+ * LIBXL_HAVE_PHYSINFO_CAP_HAP indicates that libxl_physinfo has a cap_shadow
+ * field that indicates whether software implemented paging is supported.
+ */
+#define LIBXL_HAVE_PHYSINFO_CAP_SHADOW 1
+
 /*
  * libxl ABI compatibility
  *
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 3b45065597..47f10da465 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -44,6 +44,11 @@ int libxl__domain_create_info_setdefault(libxl__gc *gc,
         if (rc)
             return rc;
 
+        if (!info.cap_hap && !info.cap_shadow) {
+            LOG(ERROR, "neither hap nor shadow paging available");
+            return ERROR_INVAL;
+        }
+
         libxl_defbool_setdefault(&c_info->hap, info.cap_hap);
         libxl_defbool_setdefault(&c_info->oos, true);
     }
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 9e1f8515d3..6f431baec2 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -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", [
diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml
index a5e77c943a..9f56e1df1a 100644
--- a/tools/ocaml/libs/xc/xenctrl.ml
+++ b/tools/ocaml/libs/xc/xenctrl.ml
@@ -108,6 +108,7 @@ type physinfo_cap_flag =
 	| CAP_PV
 	| CAP_DirectIO
 	| CAP_hap
+	| CAP_shadow
 
 type physinfo =
 {
diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.mli
index e92256654b..e06c53d0fa 100644
--- a/tools/ocaml/libs/xc/xenctrl.mli
+++ b/tools/ocaml/libs/xc/xenctrl.mli
@@ -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;
diff --git a/tools/xl/xl_info.c b/tools/xl/xl_info.c
index aa6724bc7f..148c4740ae 100644
--- a/tools/xl/xl_info.c
+++ b/tools/xl/xl_info.c
@@ -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);
diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c
index 5777a05ffc..50be0c722a 100644
--- a/xen/arch/x86/sysctl.c
+++ b/xen/arch/x86/sysctl.c
@@ -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(
diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h
index d4b455619c..e324442f92 100644
--- a/xen/include/public/sysctl.h
+++ b/xen/include/public/sysctl.h
@@ -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;
-- 
2.22.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2019-09-10 15:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-10 15:25 [Xen-devel] [PATCH v4 1/2] sysctl/libxl: choose a sane default for HAP Roger Pau Monne
2019-09-10 15:25 ` Roger Pau Monne [this message]
2019-09-10 15:40   ` [Xen-devel] [PATCH v4 2/2] sysctl: report shadow paging capability Jan Beulich
2019-09-12  9:51   ` Andrew Cooper
2019-09-12 10:45   ` Ian Jackson
2019-09-10 15:27 ` [Xen-devel] [PATCH v4 1/2] sysctl/libxl: choose a sane default for HAP Christian Lindig
2019-09-10 15:40 ` Andrew Cooper
2019-09-10 15:44   ` Roger Pau Monné

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190910152538.36921-2-roger.pau@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=Andrew.Cooper3@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=anthony.perard@citrix.com \
    --cc=christian.lindig@citrix.com \
    --cc=dave@recoil.org \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien.grall@arm.com \
    --cc=konrad.wilk@oracle.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.