[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH for-4.16 2/2] xen: Report grant table v1/v2 capabilities to the toolstack
In order to let the toolstack be able to set the gnttab version on a per-domain basis, it needs to know which ABIs Xen supports. Introduce XEN_SYSCTL_PHYSCAP_gnttab_v{1,2} for the purpose, and plumb in down into userspace. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- CC: George Dunlap <George.Dunlap@xxxxxxxxxxxxx> CC: Ian Jackson <iwj@xxxxxxxxxxxxxx> CC: Jan Beulich <JBeulich@xxxxxxxx> CC: Stefano Stabellini <sstabellini@xxxxxxxxxx> CC: Wei Liu <wl@xxxxxxx> CC: Roger Pau Monné <roger.pau@xxxxxxxxxx> CC: Julien Grall <julien@xxxxxxx> CC: Christian Lindig <christian.lindig@xxxxxxxxxx> CC: Edwin Török <edvin.torok@xxxxxxxxxx> For 4.16. This is useful information: xl info virt_caps | grep -q gnttab-v2 is far more coherent for the admin than having to root around in the Xen build time configuraiton, or command line settings. Furthermore, it is information necessary for the toolstack to be able to choose the gnttab version on a per-domain basis (a feature under consideration for 4.16). Risks are largely at build time, but adding new PHYSCAPs is formulaic. In this case, just using 2 bits in an already existing hypercall. golang was generated automatically, while Ocaml has build time ABI checks issues. --- tools/golang/xenlight/helpers.gen.go | 4 ++++ tools/golang/xenlight/types.gen.go | 2 ++ tools/include/libxl.h | 6 ++++++ tools/libs/light/libxl.c | 4 ++++ tools/libs/light/libxl_types.idl | 2 ++ tools/ocaml/libs/xc/xenctrl.ml | 2 ++ tools/ocaml/libs/xc/xenctrl.mli | 2 ++ tools/xl/xl_info.c | 6 ++++-- xen/common/grant_table.c | 2 +- xen/common/sysctl.c | 6 ++++++ xen/include/public/sysctl.h | 6 +++++- xen/include/xen/grant_table.h | 2 ++ 12 files changed, 40 insertions(+), 4 deletions(-) diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/helpers.gen.go index c010f2d3a47f..afa44a857a6c 100644 --- a/tools/golang/xenlight/helpers.gen.go +++ b/tools/golang/xenlight/helpers.gen.go @@ -3369,6 +3369,8 @@ x.CapShadow = bool(xc.cap_shadow) x.CapIommuHapPtShare = bool(xc.cap_iommu_hap_pt_share) x.CapVmtrace = bool(xc.cap_vmtrace) x.CapVpmu = bool(xc.cap_vpmu) +x.CapGnttabV1 = bool(xc.cap_gnttab_v1) +x.CapGnttabV2 = bool(xc.cap_gnttab_v2) return nil} @@ -3401,6 +3403,8 @@ xc.cap_shadow = C.bool(x.CapShadow) xc.cap_iommu_hap_pt_share = C.bool(x.CapIommuHapPtShare) xc.cap_vmtrace = C.bool(x.CapVmtrace) xc.cap_vpmu = C.bool(x.CapVpmu) +xc.cap_gnttab_v1 = C.bool(x.CapGnttabV1) +xc.cap_gnttab_v2 = C.bool(x.CapGnttabV2) return nil } diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/types.gen.go index 8c8c481b86f6..31b5af0777d5 100644 --- a/tools/golang/xenlight/types.gen.go +++ b/tools/golang/xenlight/types.gen.go @@ -1011,6 +1011,8 @@ CapShadow bool CapIommuHapPtShare bool CapVmtrace bool CapVpmu bool +CapGnttabV1 bool +CapGnttabV2 bool } type Connectorinfo struct { diff --git a/tools/include/libxl.h b/tools/include/libxl.h index 2e8679dbcb21..54c10f6efe23 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -515,6 +515,12 @@ #define LIBXL_HAVE_VPMU 1 /* + * LIBXL_HAVE_PHYSINFO_CAP_GNTTAB indicates that libxl_physinfo has a + * cap_gnttab_v1/2 fields, which indicates the available grant table ABIs. + */ +#define LIBXL_HAVE_PHYSINFO_CAP_GNTTAB 1 + +/* * libxl ABI compatibility * * The only guarantee which libxl makes regarding ABI compatibility diff --git a/tools/libs/light/libxl.c b/tools/libs/light/libxl.c index a032723fdecb..a77aa856fdd6 100644 --- a/tools/libs/light/libxl.c +++ b/tools/libs/light/libxl.c @@ -405,6 +405,10 @@ int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo) physinfo->cap_vmtrace = !!(xcphysinfo.capabilities & XEN_SYSCTL_PHYSCAP_vmtrace); physinfo->cap_vpmu = !!(xcphysinfo.capabilities & XEN_SYSCTL_PHYSCAP_vpmu); + physinfo->cap_gnttab_v1 = + !!(xcphysinfo.capabilities & XEN_SYSCTL_PHYSCAP_gnttab_v1); + physinfo->cap_gnttab_v2 = + !!(xcphysinfo.capabilities & XEN_SYSCTL_PHYSCAP_gnttab_v2); GC_FREE; return 0; diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_types.idl index 608d55a4568d..573bba68ee3a 100644 --- a/tools/libs/light/libxl_types.idl +++ b/tools/libs/light/libxl_types.idl @@ -1065,6 +1065,8 @@ libxl_physinfo = Struct("physinfo", [ ("cap_iommu_hap_pt_share", bool), ("cap_vmtrace", bool), ("cap_vpmu", bool), + ("cap_gnttab_v1", bool), + ("cap_gnttab_v2", 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 addcf4cc593d..ed2924a2b34a 100644 --- a/tools/ocaml/libs/xc/xenctrl.ml +++ b/tools/ocaml/libs/xc/xenctrl.ml @@ -123,6 +123,8 @@ type physinfo_cap_flag = | CAP_IOMMU_HAP_PT_SHARE | CAP_Vmtrace | CAP_Vpmu + | CAP_Gnttab_v1 + | CAP_Gnttab_v2 type physinfo = { diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.mli index 0a5ce529e951..d20dc0108dce 100644 --- a/tools/ocaml/libs/xc/xenctrl.mli +++ b/tools/ocaml/libs/xc/xenctrl.mli @@ -108,6 +108,8 @@ type physinfo_cap_flag = | CAP_IOMMU_HAP_PT_SHARE | CAP_Vmtrace | CAP_Vpmu + | CAP_Gnttab_v1 + | CAP_Gnttab_v2 type physinfo = { threads_per_core : int; diff --git a/tools/xl/xl_info.c b/tools/xl/xl_info.c index 2c86b317b702..712b7638b013 100644 --- a/tools/xl/xl_info.c +++ b/tools/xl/xl_info.c @@ -210,7 +210,7 @@ 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%s%s%s%s\n", + maybe_printf("virt_caps :%s%s%s%s%s%s%s%s%s%s%s\n", info.cap_pv ? " pv" : "", info.cap_hvm ? " hvm" : "", info.cap_hvm && info.cap_hvm_directio ? " hvm_directio" : "", @@ -219,7 +219,9 @@ static void output_physinfo(void) info.cap_shadow ? " shadow" : "", info.cap_iommu_hap_pt_share ? " iommu_hap_pt_share" : "", info.cap_vmtrace ? " vmtrace" : "", - info.cap_vpmu ? " vpmu" : "" + info.cap_vpmu ? " vpmu" : "", + info.cap_gnttab_v1 ? " gnttab-v1" : "", + info.cap_gnttab_v2 ? " gnttab-v2" : "" ); vinfo = libxl_get_version_info(ctx); diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index e510395d088e..a20319b22abc 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -178,7 +178,7 @@ static int parse_gnttab_max_maptrack_frames(const char *arg) #define GNTTAB_MAX_VERSION 2 #endif -static unsigned int __read_mostly opt_gnttab_max_version = GNTTAB_MAX_VERSION; +unsigned int __read_mostly opt_gnttab_max_version = GNTTAB_MAX_VERSION; static bool __read_mostly opt_transitive_grants = true; static int __init parse_gnttab(const char *s) diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c index f2dab722b683..1ad3c29351db 100644 --- a/xen/common/sysctl.c +++ b/xen/common/sysctl.c @@ -12,6 +12,7 @@ #include <xen/sched.h> #include <xen/domain.h> #include <xen/event.h> +#include <xen/grant_table.h> #include <xen/domain_page.h> #include <xen/trace.h> #include <xen/console.h> @@ -283,6 +284,11 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) if ( vpmu_is_available ) pi->capabilities |= XEN_SYSCTL_PHYSCAP_vpmu; + if ( opt_gnttab_max_version >= 1 ) + pi->capabilities |= XEN_SYSCTL_PHYSCAP_gnttab_v1; + if ( opt_gnttab_max_version >= 2 ) + pi->capabilities |= XEN_SYSCTL_PHYSCAP_gnttab_v2; + if ( copy_to_guest(u_sysctl, op, 1) ) ret = -EFAULT; } diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index 3e53681b4368..55252e97f230 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -104,8 +104,12 @@ struct xen_sysctl_tbuf_op { /* The platform supports vPMU. */ #define XEN_SYSCTL_PHYSCAP_vpmu (1u << 7) +/* Xen supports the Grant v1 and/or v2 ABIs. */ +#define XEN_SYSCTL_PHYSCAP_gnttab_v1 (1u << 8) +#define XEN_SYSCTL_PHYSCAP_gnttab_v2 (1u << 9) + /* Max XEN_SYSCTL_PHYSCAP_* constant. Used for ABI checking. */ -#define XEN_SYSCTL_PHYSCAP_MAX XEN_SYSCTL_PHYSCAP_vpmu +#define XEN_SYSCTL_PHYSCAP_MAX XEN_SYSCTL_PHYSCAP_gnttab_v2 struct xen_sysctl_physinfo { uint32_t threads_per_core; diff --git a/xen/include/xen/grant_table.h b/xen/include/xen/grant_table.h index 41713e2726e9..9ee830cfd0ab 100644 --- a/xen/include/xen/grant_table.h +++ b/xen/include/xen/grant_table.h @@ -32,6 +32,7 @@ struct grant_table; #ifdef CONFIG_GRANT_TABLE +extern unsigned int opt_gnttab_max_version; extern unsigned int opt_max_grant_frames; /* Create/destroy per-domain grant table context. */ @@ -63,6 +64,7 @@ int gnttab_acquire_resource( #else +#define opt_gnttab_max_version 0 #define opt_max_grant_frames 0 static inline int grant_table_init(struct domain *d, -- 2.11.0
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |