[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH RFC 07/31] xen/x86: Export host featureset via SYSCTL
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- CC: Jan Beulich <JBeulich@xxxxxxxx> CC: Tim Deegan <tim@xxxxxxx> CC: Ian Campbell <Ian.Campbell@xxxxxxxxxx> --- xen/arch/x86/sysctl.c | 51 +++++++++++++++++++++++++++++++++++++++++++++ xen/include/public/sysctl.h | 20 ++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c index 38b5dcb..1f483b8 100644 --- a/xen/arch/x86/sysctl.c +++ b/xen/arch/x86/sysctl.c @@ -29,6 +29,7 @@ #include <xen/cpu.h> #include <xsm/xsm.h> #include <asm/psr.h> +#include <asm/cpuid.h> #define get_xen_guest_handle(val, hnd) do { val = (hnd).p; } while (0) @@ -190,6 +191,56 @@ long arch_do_sysctl( } break; + case XEN_SYSCTL_get_featureset: + { + uint32_t *featureset; + unsigned int nr; + + /* Request for maximum number of features? */ + if ( guest_handle_is_null(sysctl->u.featureset.features) ) + { + sysctl->u.featureset.nr_features = XEN_NR_FEATURESET_ENTRIES; + if ( __copy_to_guest(u_sysctl, sysctl, 1) ) + ret = -EFAULT; + break; + } + + /* Clip the number of entries. */ + nr = min_t(unsigned int, sysctl->u.featureset.nr_features, + XEN_NR_FEATURESET_ENTRIES); + + switch ( sysctl->u.featureset.index ) + { + case XEN_SYSCTL_featureset_host: + featureset = host_featureset; + break; + + default: + featureset = NULL; + break; + } + + /* Bad featureset index? */ + if ( !ret && !featureset ) + ret = -EINVAL; + + /* Copy the requested featureset into place. */ + if ( !ret && copy_to_guest(sysctl->u.featureset.features, + featureset, nr) ) + ret = -EFAULT; + + /* Inform the caller of how many features we wrote. */ + sysctl->u.featureset.nr_features = nr; + if ( !ret && __copy_to_guest(u_sysctl, sysctl, 1) ) + ret = -EFAULT; + + /* Inform the caller if there was more data to provide. */ + if ( !ret && nr < XEN_NR_FEATURESET_ENTRIES ) + ret = -ENOBUFS; + + break; + } + default: ret = -ENOSYS; break; diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index 0cacacc..dfde433 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -764,6 +764,24 @@ struct xen_sysctl_tmem_op { typedef struct xen_sysctl_tmem_op xen_sysctl_tmem_op_t; DEFINE_XEN_GUEST_HANDLE(xen_sysctl_tmem_op_t); +/* + * XEN_SYSCTL_get_featureset (x86 specific) + * + * Return information about the maximum sets of features which can be offered + * to different types of guests. This is all strictly information as found in + * `cpuid` feature leaves with no synthetic alterations. + */ +struct xen_sysctl_featureset { +#define XEN_SYSCTL_featureset_host 0 + uint32_t index; /* IN: Which featureset to query? */ + uint32_t nr_features; /* IN/OUT: Number of entries in/written to + * 'features', or the maximum number of features if + * the guest handle is NULL. */ + XEN_GUEST_HANDLE_64(uint32) features; /* OUT: */ +}; +typedef struct xen_sysctl_featureset xen_sysctl_featureset_t; +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_featureset_t); + struct xen_sysctl { uint32_t cmd; #define XEN_SYSCTL_readconsole 1 @@ -789,6 +807,7 @@ struct xen_sysctl { #define XEN_SYSCTL_pcitopoinfo 22 #define XEN_SYSCTL_psr_cat_op 23 #define XEN_SYSCTL_tmem_op 24 +#define XEN_SYSCTL_get_featureset 25 uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */ union { struct xen_sysctl_readconsole readconsole; @@ -814,6 +833,7 @@ struct xen_sysctl { struct xen_sysctl_psr_cmt_op psr_cmt_op; struct xen_sysctl_psr_cat_op psr_cat_op; struct xen_sysctl_tmem_op tmem_op; + struct xen_sysctl_featureset featureset; uint8_t pad[128]; } u; }; -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |