xen/arm: Introduce gpaddr_bits field to struct xen_domctl_getdomaininfo
authorOleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Thu, 14 Oct 2021 11:40:44 +0000 (14:40 +0300)
committerIan Jackson <iwj@xenproject.org>
Thu, 14 Oct 2021 14:18:32 +0000 (15:18 +0100)
We need to pass info about maximum supported guest physical
address space size to the toolstack on Arm in order to properly
calculate the base and size of the extended region (safe range)
for the guest. The extended region is unused address space which
could be safely used by domain for foreign/grant mappings on Arm.
The extended region itself will be handled by the subsequent
patch.

Currently the same guest physical address space size is used
for all guests (p2m_ipa_bits variable on Arm, the x86 equivalent
is hap_paddr_bits).

Add an explicit padding after "gpaddr_bits" field and also
(while at it) after "domain" field.

Also make sure that full structure is cleared in all cases by
moving the clearing into getdomaininfo(). Currently it is only
cleared by the sysctl caller (and only once).

Please note, we do not need to bump XEN_DOMCTL_INTERFACE_VERSION
as a bump has already occurred in this release cycle. But we do
need to bump XEN_SYSCTL_INTERFACE_VERSION as the structure is
re-used in a sysctl.

Suggested-by: Julien Grall <jgrall@amazon.com>
Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Reviewed-by: Ian Jackson <iwj@xenproject.org>
[hypervisor parts]
Reviewed-by: Jan Beulich <jbeulich@suse.com>
tools/include/libxl.h
tools/include/xenctrl.h
tools/libs/ctrl/xc_domain.c
tools/libs/light/libxl_domain.c
tools/libs/light/libxl_types.idl
xen/arch/arm/domctl.c
xen/arch/x86/domctl.c
xen/common/domctl.c
xen/common/sysctl.c
xen/include/public/domctl.h
xen/include/public/sysctl.h

index ee73eb06f13302e372afcec09e7cbc43535a34e0..2e8679dbcb21db394f7e86c89223bff9ebd745ff 100644 (file)
@@ -885,6 +885,14 @@ typedef struct libxl__ctx libxl_ctx;
  */
 #define LIBXL_HAVE_DOMINFO_NEVER_STOP 1
 
+/*
+ * LIBXL_HAVE_DOMINFO_GPADDR_BITS
+ *
+ * If this is defined, libxl_dominfo will contain an uint8 field called
+ * gpaddr_bits, containing the guest physical address space size.
+ */
+#define LIBXL_HAVE_DOMINFO_GPADDR_BITS 1
+
 /*
  * LIBXL_HAVE_QXL
  *
index a3063998e04771d74c12784828dc1aed21dbc84b..07b96e6671a53a0cea1b2da476d77073d8b6a90c 100644 (file)
@@ -462,6 +462,7 @@ typedef struct xc_dominfo {
     unsigned int  max_vcpu_id;
     xen_domain_handle_t handle;
     unsigned int  cpupool;
+    uint8_t       gpaddr_bits;
     struct xen_arch_domainconfig arch_config;
 } xc_dominfo_t;
 
index 23322b70b5a5a2ab72c1c514cdb04299beb947cb..b155d6afd2ef7e1c069d5280ceb0b9f2c2e76072 100644 (file)
@@ -396,6 +396,7 @@ int xc_domain_getinfo(xc_interface *xch,
         info->nr_online_vcpus = domctl.u.getdomaininfo.nr_online_vcpus;
         info->max_vcpu_id = domctl.u.getdomaininfo.max_vcpu_id;
         info->cpupool = domctl.u.getdomaininfo.cpupool;
+        info->gpaddr_bits = domctl.u.getdomaininfo.gpaddr_bits;
         info->arch_config = domctl.u.getdomaininfo.arch_config;
 
         memcpy(info->handle, domctl.u.getdomaininfo.handle,
index 51a6127552e9ee89f71f91a76ff3534ea48a2579..544a9bf59d2f21b8c84731922651b50ecbe553bd 100644 (file)
@@ -306,6 +306,7 @@ void libxl__xcinfo2xlinfo(libxl_ctx *ctx,
     xlinfo->vcpu_max_id = xcinfo->max_vcpu_id;
     xlinfo->vcpu_online = xcinfo->nr_online_vcpus;
     xlinfo->cpupool = xcinfo->cpupool;
+    xlinfo->gpaddr_bits = xcinfo->gpaddr_bits;
     xlinfo->domain_type = (xcinfo->flags & XEN_DOMINF_hvm_guest) ?
         LIBXL_DOMAIN_TYPE_HVM : LIBXL_DOMAIN_TYPE_PV;
 }
index b96fb5c47e7425bdf341dce595f4ad85aa9e55d2..608d55a4568db1d788be08f15e7b39d409cf81c5 100644 (file)
@@ -357,6 +357,7 @@ libxl_dominfo = Struct("dominfo",[
     ("vcpu_max_id", uint32),
     ("vcpu_online", uint32),
     ("cpupool",     uint32),
+    ("gpaddr_bits", uint8),
     ("domain_type", libxl_domain_type),
     ], dir=DIR_OUT)
 
index b7d27f37df8b0569b4ac0fd283fceaae3966f2b6..6245af6d0bab1775b5fb274532fd37040e2c0564 100644 (file)
@@ -20,6 +20,8 @@ void arch_get_domain_info(const struct domain *d,
 {
     /* All ARM domains use hardware assisted paging. */
     info->flags |= XEN_DOMINF_hap;
+
+    info->gpaddr_bits = p2m_ipa_bits;
 }
 
 static int handle_vuart_init(struct domain *d, 
index 26a76d2be99217bfe05b36e14531c71b7f435001..7d102e0647ec6d07127410b8ba34985efa4631ed 100644 (file)
@@ -151,6 +151,7 @@ void arch_get_domain_info(const struct domain *d,
         info->flags |= XEN_DOMINF_hap;
 
     info->arch_config.emulation_flags = d->arch.emulation_flags;
+    info->gpaddr_bits = hap_paddr_bits;
 }
 
 static int do_vmtrace_op(struct domain *d, struct xen_domctl_vmtrace_op *op,
index 12d6144d28960313c00e49f19f964397666eb7fd..271862ae587f669e05e2af2820cdc4c589f491b0 100644 (file)
@@ -69,10 +69,10 @@ void getdomaininfo(struct domain *d, struct xen_domctl_getdomaininfo *info)
     int flags = XEN_DOMINF_blocked;
     struct vcpu_runstate_info runstate;
 
+    memset(info, 0, sizeof(*info));
+
     info->domain = d->domain_id;
     info->max_vcpu_id = XEN_INVALID_MAX_VCPU_ID;
-    info->nr_online_vcpus = 0;
-    info->ssidref = 0;
 
     /*
      * - domain is marked as blocked only if all its vcpus are blocked
index 6e7189bb3c3bb297fc885d2d05e400bc4858c5ab..f2dab722b6833324035c44a63c5af6e50fe49d3c 100644 (file)
@@ -76,7 +76,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
     case XEN_SYSCTL_getdomaininfolist:
     { 
         struct domain *d;
-        struct xen_domctl_getdomaininfo info = { 0 };
+        struct xen_domctl_getdomaininfo info;
         u32 num_domains = 0;
 
         rcu_read_lock(&domlist_read_lock);
index 238384b5ae3b7adddf1c61e59b88e61d0fb59fe6..51017b47bc5d6bddb15c2b22e4c6589c969ed11c 100644 (file)
@@ -107,6 +107,7 @@ struct xen_domctl_createdomain {
 struct xen_domctl_getdomaininfo {
     /* OUT variables. */
     domid_t  domain;              /* Also echoed in domctl.domain */
+    uint16_t pad1;
  /* Domain is scheduled to die. */
 #define _XEN_DOMINF_dying     0
 #define XEN_DOMINF_dying      (1U<<_XEN_DOMINF_dying)
@@ -151,6 +152,8 @@ struct xen_domctl_getdomaininfo {
     uint32_t ssidref;
     xen_domain_handle_t handle;
     uint32_t cpupool;
+    uint8_t gpaddr_bits; /* Guest physical address space size. */
+    uint8_t pad2[7];
     struct xen_arch_domainconfig arch_config;
 };
 typedef struct xen_domctl_getdomaininfo xen_domctl_getdomaininfo_t;
index fead0e5b53a1792571b55b772224d607dbb3035b..3e53681b43680dbbe38c680e8f4eaab28f58dc6c 100644 (file)
@@ -35,7 +35,7 @@
 #include "domctl.h"
 #include "physdev.h"
 
-#define XEN_SYSCTL_INTERFACE_VERSION 0x00000013
+#define XEN_SYSCTL_INTERFACE_VERSION 0x00000014
 
 /*
  * Read console content from Xen buffer ring.