From c4441ab1f1d506a942002ccc55fdde2fe30ef626 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Thu, 25 Feb 2021 15:46:10 +0000 Subject: dmop: Add XEN_DMOP_nr_vcpus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Curiously absent from the stable API/ABIs is an ability to query the number of vcpus which a domain has. Emulators need to know this information in particular to know how many stuct ioreq's live in the ioreq server mappings. In practice, this forces all userspace to link against libxenctrl to use xc_domain_getinfo(), which rather defeats the purpose of the stable libraries. Introduce a DMOP to retrieve this information and surface it in libxendevicemodel to help emulators shed their use of unstable interfaces. Signed-off-by: Andrew Cooper Reviewed-by: Ian Jackson Reviewed-by: Jan Beulich Release-Acked-by: Ian Jackson --- CC: Jan Beulich CC: Roger Pau Monné CC: Wei Liu CC: Paul Durrant CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk CC: Ian Jackson For 4.15. This was a surprise discovery in the massive ABI untangling effort I'm currently doing for XenServer's new build system. This is one new read-only op to obtain information which isn't otherwise available under a stable API/ABI. As such, its risk for 4.15 is very low, with a very real quality-of-life improvement for downstreams. I realise this is technically a new feature and we're long past feature freeze, but I'm hoping that "really lets some emulators move off the unstable libraries" is sufficiently convincing argument. It's not sufficient to let Qemu move off unstable libraries yet - at a minimum, the add_to_phymap hypercalls need stabilising to support PCI Passthrough and BAR remapping. I'd prefer not to duplicate the op handling between ARM and x86, and if this weren't a release window, I'd submit a prereq patch to dedup the common dmop handling. That can wait to 4.16 at this point. Also, this op ought to work against x86 PV guests, but fixing that up will also need this rearrangement into common code, so needs to wait. --- xen/include/public/hvm/dm_op.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'xen/include/public') diff --git a/xen/include/public/hvm/dm_op.h b/xen/include/public/hvm/dm_op.h index 1f70d58caa..ef7fbc0d3d 100644 --- a/xen/include/public/hvm/dm_op.h +++ b/xen/include/public/hvm/dm_op.h @@ -449,6 +449,21 @@ struct xen_dm_op_set_irq_level { }; typedef struct xen_dm_op_set_irq_level xen_dm_op_set_irq_level_t; +/* + * XEN_DMOP_nr_vcpus: Query the number of vCPUs a domain has. + * + * This is the number of vcpu objects allocated in Xen for the domain, and is + * fixed from creation time. This bound is applicable to e.g. the vcpuid + * parameter of XEN_DMOP_inject_event, or number of struct ioreq objects + * mapped via XENMEM_acquire_resource. + */ +#define XEN_DMOP_nr_vcpus 20 + +struct xen_dm_op_nr_vcpus { + uint32_t vcpus; /* OUT */ +}; +typedef struct xen_dm_op_nr_vcpus xen_dm_op_nr_vcpus_t; + struct xen_dm_op { uint32_t op; uint32_t pad; @@ -472,6 +487,7 @@ struct xen_dm_op { xen_dm_op_remote_shutdown_t remote_shutdown; xen_dm_op_relocate_memory_t relocate_memory; xen_dm_op_pin_memory_cacheattr_t pin_memory_cacheattr; + xen_dm_op_nr_vcpus_t nr_vcpus; } u; }; -- cgit v1.2.3