Skip to contentSkip to conversation

xen: report PV capability in sysctl and use it in toolstack

PATCH Superseded Wei Liu 2 participants 4 messages Nov 8, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH 1/1 xen: report PV capability in sysctl and use it in toolstack

0e2c886ef ("xen: decouple HVM and IOMMU capabilities") provided a truth table for what xl info would report. In order to make the table work xen will need to report its PV capability.

Replace cap_directio with cap_pv in libxl IDL. It is safe to do so because cap_directio has never been released. Revert to use cap_hvm_directio to mark the availability of IOMMU, to save us from providing a compatibility layer.

Don't bump sysctl version number because we've already done so.

---
 tools/libxl/libxl.c         | 4 ++--
 tools/libxl/libxl.h         | 6 +++---
 tools/libxl/libxl_types.idl | 2 +-
 tools/xl/xl_info.c          | 4 ++--
 xen/arch/x86/sysctl.c       | 2 ++
 xen/include/public/sysctl.h | 5 ++++-
 6 files changed, 14 insertions(+), 9 deletions(-)
tools/libxl/libxl.c +2 -2
index a0d9f2bfe7..ec71574e99 100644
@@ -396,9 +396,9 @@ int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo)
     memcpy(physinfo->hw_cap,xcphysinfo.hw_cap, sizeof(physinfo->hw_cap));
 
     physinfo->cap_hvm = !!(xcphysinfo.capabilities & XEN_SYSCTL_PHYSCAP_hvm);
-    physinfo->cap_directio =
+    physinfo->cap_pv = !!(xcphysinfo.capabilities & XEN_SYSCTL_PHYSCAP_pv);
+    physinfo->cap_hvm_directio =
         !!(xcphysinfo.capabilities & XEN_SYSCTL_PHYSCAP_directio);
-    physinfo->cap_hvm_directio = physinfo->cap_hvm && physinfo->cap_directio;
 
     GC_FREE;
     return 0;
tools/libxl/libxl.h +3 -3
index 2cfc1b08ad..a38e5cdba2 100644
@@ -67,11 +67,11 @@
  * the same $(XEN_VERSION) (e.g. throughout a major release).
  */
 
-/* LIBXL_HAVE_PHYSINFO_CAP_DIRECTIO
+/* LIBXL_HAVE_PHYSINFO_CAP_PV
  *
- * If this is defined, libxl_physinfo has a "cap_directio" field.
+ * If this is defined, libxl_physinfo has a "cap_pv" field.
  */
-#define LIBXL_HAVE_PHYSINFO_CAP_DIRECTIO 1
+#define LIBXL_HAVE_PHYSINFO_CAP_PV 1
 
 /* LIBXL_HAVE_CONSOLE_NOTIFY_FD
  *
tools/libxl/libxl_types.idl +1 -1
index 3b8f967651..41babb329e 100644
@@ -1013,8 +1013,8 @@ libxl_physinfo = Struct("physinfo", [
     ("hw_cap", libxl_hwcap),
 
     ("cap_hvm", bool),
+    ("cap_pv", bool),
     ("cap_hvm_directio", bool),
-    ("cap_directio", bool),
     ], dir=DIR_OUT)
 
 libxl_connectorinfo = Struct("connectorinfo", [
tools/xl/xl_info.c +2 -2
index 93e2c5fa7d..19baf97d88 100644
@@ -212,8 +212,8 @@ static void output_physinfo(void)
 
     maybe_printf("virt_caps              :%s%s%s\n",
          info.cap_hvm ? " hvm" : "",
-         info.cap_hvm_directio ? " hvm_directio" : "",
-         info.cap_directio ? " directio" : ""
+         info.cap_hvm && info.cap_hvm_directio ? " hvm_directio" : "",
+         info.cap_pv && info.cap_hvm_directio ? " directio" : ""
         );
 
     vinfo = libxl_get_version_info(ctx);
xen/arch/x86/sysctl.c +2 -0
index 0bec7e5c3c..1916a3de1b 100644
@@ -120,6 +120,8 @@ void arch_do_physinfo(struct xen_sysctl_physinfo *pi)
            min(sizeof(pi->hw_cap), sizeof(boot_cpu_data.x86_capability)));
     if ( hvm_enabled )
         pi->capabilities |= XEN_SYSCTL_PHYSCAP_hvm;
+    if ( IS_ENABLED(CONFIG_PV) )
+        pi->capabilities |= XEN_SYSCTL_PHYSCAP_pv;
     if ( iommu_enabled )
         pi->capabilities |= XEN_SYSCTL_PHYSCAP_directio;
 }
xen/include/public/sysctl.h +4 -1
index e3a14dfcc9..1ccf20787a 100644
@@ -85,8 +85,11 @@ struct xen_sysctl_tbuf_op {
  /* (x86) The platform supports HVM guests. */
 #define _XEN_SYSCTL_PHYSCAP_hvm          0
 #define XEN_SYSCTL_PHYSCAP_hvm           (1u<<_XEN_SYSCTL_PHYSCAP_hvm)
+ /* (x86) The platform supports PV guests. */
+#define _XEN_SYSCTL_PHYSCAP_pv           1
+#define XEN_SYSCTL_PHYSCAP_pv            (1u<<_XEN_SYSCTL_PHYSCAP_pv)
  /* (x86) The platform supports direct access to I/O devices with IOMMU. */
-#define _XEN_SYSCTL_PHYSCAP_directio 1
+#define _XEN_SYSCTL_PHYSCAP_directio     2
 #define XEN_SYSCTL_PHYSCAP_directio  (1u<<_XEN_SYSCTL_PHYSCAP_directio)
 struct xen_sysctl_physinfo {
     uint32_t threads_per_core;
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 4 lines · Wei Liu

0e2c886ef ("xen: decouple HVM and IOMMU capabilities") provided a truth table for what xl info would report. In order to make the table work xen will need to report its PV capability.

Quoted 8 lines

Replace cap_directio with cap_pv in libxl IDL. It is safe to do so because cap_directio has never been released. Revert to use cap_hvm_directio to mark the availability of IOMMU, to save us from providing a compatibility layer.

Don't bump sysctl version number because we've already done so.

In principle, I think this is fine.  However, some observations.

Looking more closely at the matrix, we've got:

    pv      hvm     iommu           flags in xl info 0       0       x               n/a
    0       1       0               hvm
    0       1       1               hvm hvm_directio 1       0       0               NIL
    1       0       1               directio
    1       1       0               hvm
    1       1       1               hvm hvm_directio directio

Wouldn't it make more sense to have pv and pv_directio, even if only as the end user visible string?

tools/libxl/libxl_types.idl libxl_physinfo = Struct("physinfo", [ · line 1017

Quoted 10 lines
tools/libxl/libxl_types.idl +1 -0
index 3b8f967651..41babb329e 100644
@@ -1013,8 +1013,8 @@ libxl_physinfo = Struct("physinfo", [
     ("hw_cap", libxl_hwcap),
 
     ("cap_hvm", bool),
+    ("cap_pv", bool),
     ("cap_hvm_directio", bool),

Is it worth noting "# No longer HVM specific" here?

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#2 lore raw
Quoted 27 lines · Andrew Cooper
Quoted 4 lines · Wei Liu

0e2c886ef ("xen: decouple HVM and IOMMU capabilities") provided a truth table for what xl info would report. In order to make the table work xen will need to report its PV capability.

Quoted 8 lines

Replace cap_directio with cap_pv in libxl IDL. It is safe to do so because cap_directio has never been released. Revert to use cap_hvm_directio to mark the availability of IOMMU, to save us from providing a compatibility layer.

Don't bump sysctl version number because we've already done so.

In principle, I think this is fine.  However, some observations.

Looking more closely at the matrix, we've got:

    pv      hvm     iommu           flags in xl info 0       0       x               n/a
    0       1       0               hvm
    0       1       1               hvm hvm_directio 1       0       0               NIL
    1       0       1               directio
    1       1       0               hvm
    1       1       1               hvm hvm_directio directio

Quoted 2 lines

Wouldn't it make more sense to have pv and pv_directio, even if only as the end user visible string?

That would be fine by me. I didn't do it because I couldn't figure out the difference between virt_caps and xen_caps.

Quoted 8 lines
Quoted 8 lines
tools/libxl/libxl_types.idl +0 -0
index 3b8f967651..41babb329e 100644
@@ -1013,8 +1013,8 @@ libxl_physinfo = Struct("physinfo", [
     ("hw_cap", libxl_hwcap),
 
Quoted 5 lines

tools/libxl/libxl_types.idl libxl_physinfo = Struct("physinfo", [ · line 1017

Quoted 3 lines
tools/libxl/libxl_types.idl +1 -0
     ("cap_hvm", bool),
+    ("cap_pv", bool),
     ("cap_hvm_directio", bool),

Is it worth noting "# No longer HVM specific" here?

Sure.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
Quoted 27 lines · Wei Liu
Quoted 26 lines · Andrew Cooper
Quoted 4 lines · Wei Liu

0e2c886ef ("xen: decouple HVM and IOMMU capabilities") provided a truth table for what xl info would report. In order to make the table work xen will need to report its PV capability.

Quoted 8 lines

Replace cap_directio with cap_pv in libxl IDL. It is safe to do so because cap_directio has never been released. Revert to use cap_hvm_directio to mark the availability of IOMMU, to save us from providing a compatibility layer.

Don't bump sysctl version number because we've already done so.

In principle, I think this is fine.  However, some observations.

Looking more closely at the matrix, we've got:

    pv      hvm     iommu           flags in xl info 0       0       x               n/a
    0       1       0               hvm
    0       1       1               hvm hvm_directio 1       0       0               NIL
    1       0       1               directio
    1       1       0               hvm
    1       1       1               hvm hvm_directio directio

Quoted 4 lines
Quoted 2 lines

Wouldn't it make more sense to have pv and pv_directio, even if only as the end user visible string?

That would be fine by me. I didn't do it because I couldn't figure out the difference between virt_caps and xen_caps.

The answer is most probably "it grew organically and without any real design in the past".

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel