[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v5 04/10] domain: update GADDR based runstate guest area


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx, henry.wang@xxxxxxx
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Mon, 2 Oct 2023 17:11:21 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sqQYB5GprqLA6zNhgwV+4qSeIntPqXWXOOafhMdSkF4=; b=XUhBx5jMh1BJPB+0WTjXYUFwzM0C+hl6CdLbT7ceo91W+eMd9JTSzp3EAFOWafErb2FcprhjXV8kLYCL9mr4CBrOGyI+blmAFRH4aMEq8Ir/nvRbTMjlNw2gIRTRYzpm5ZW94UQx4CBqOAyjGPjBP/3dsHCHBNTgEAhhLIhiAs5U5WQASK96a0aEOrIh44B3HeMNGvSTd9zhtbIKuGgsLMw9sdKe7be1qfgEWzU9gAdTHr6h1nkM44ULlfzPnbTeBTVuo46XCniRjGwCFFJwh0MonSG/kRmSTRBACcVrfiZQR2dqhuQX/pts4KepUklgoKQDiCKj4S/y0RZKkvfTpg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Un6Ea+ZZWP8TXe+RIm+H/mvs6bU8JCsdkppb+w3vS3YyhtNpfqkBXzLCac03thqvPYWdbKm+eKjyGd7Q/vuI/YICRkTjjP++0UI+j5E5PoZvx97ZseeWkzQUmlX/Dx2+OEwRO4OefCSzFLyC0uEs0q4vnkS1ayXe0SQ5AgUFGXfPaUDuNmCOaZneLzrMpKJttqDdMOOR7Q9jgqOFHCMXb2zRRxvWpAiMqNjY2hypwCJRxXHzps+6OEVVuLtj+MGDNJZqf+w+3qDlR3hFzWLPM/W2Cx5J7YrId9At0InkHhDPFFWnfTABuOcPgTaqXUKKEAjPnjrpKLXmWxuDAZgvzQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Julien Grall <jgrall@xxxxxxxxxx>
  • Delivery-date: Mon, 02 Oct 2023 15:12:16 +0000
  • Ironport-data: A9a23:qv5rd6BeKLXiiBVW/97iw5YqxClBgxIJ4kV8jS/XYbTApDongz0Cx jQbDW6BOK7fZzP9e9l2aI+y8x4CvsOBx9JqQQY4rX1jcSlH+JHPbTi7wuUcHAvJd5GeExg3h yk6QoOdRCzhZiaE/n9BCpC48D8kk/nOH+KgYAL9EngZbRd+Tys8gg5Ulec8g4p56fC0GArIs t7pyyHlEAbNNwVcbCRMsMpvlDs15K6p4WtA5ARnDRx2lAS2e0c9Xcp3yZ6ZdxMUcqEMdsamS uDKyq2O/2+x13/B3fv8z94X2mVTKlLjFVDmZkh+AsBOsTAbzsAG6Y4pNeJ0VKtio27hc+ada jl6ncfYpQ8BZsUgkQmGOvVSO3kW0aZuoNcrLZUj2CA6IoKvn3bEmp1T4E8K0YIw5MZoPH0e+ uciFhM2cVeRjdzp7rGpVbw57igjBJGD0II3nFhFlGicIdN4BJfJTuPN+MNS2yo2ioZWB/HCa sEFaD1pKhPdfxlIPVRRA5U79AuqriCnL3sE9xTI+uxuvDC7IA9ZidABNPLPfdOHX4NNl1uwr WPa5WXpRBodMbRzzBLcqC7837Gewn2TtIQ6H5vjqttIuAWqyTY9Fj9NZF24rPrlhRvrMz5YA wlOksY0loAi+UruQtTjUhmQpH+fogVaS9dWC/c96gyG1uzT+QnxLmgJSCRQLsMvssAeTCYvk FSOmrvBBzZirbmUQnK17aqPoHW5Pi19BW0fYS4JSyMV7t+lp5s85jrUVcpqGqOxitzzGBnzz iqMoSx4gK8c5eYU042r8FaBhCijzrDLQRQ84gH/V2es/AR/IoWiYuSVBUPz6P9BKMOVSweHt X1dwsyGtrlRVdeKiTCHR/gLEPex/fGZPTbAgFlpWZ486zCq/H3ldodViN1jGHpU3g8/UWeBS CfuVcl5vve/4FPCgXdLXr+M
  • Ironport-hdrordr: A9a23:KFtoU6DWkioI2PflHemo55DYdb4zR+YMi2TDtnocdfUxSKelfq +V88jzuSWbtN9yYhEdcKG7WZVoKEm0nfQZ3WB7B8bAYOCJghrNEKhSqafk3j38C2nf24dmpM BdmnFFeb/N5I5B/KPH3DU=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

From: Jan Beulich <jbeulich@xxxxxxxx>

Before adding a new vCPU operation to register the runstate area by
guest-physical address, add code to actually keep such areas up-to-date.

Note that updating of the area will be done exclusively following the
model enabled by VMASST_TYPE_runstate_update_flag for virtual-address
based registered areas.

Note further that pages aren't marked dirty when written to (matching
the handling of space mapped by map_vcpu_info()), on the basis that the
registrations are lost anyway across migration (or would need re-
populating at the target for transparent migration). Plus the contents
of the areas in question have to be deemed volatile in the first place
(so saving a "most recent" value is pretty meaningless even for e.g.
snapshotting).

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
Reviewed-by: Julien Grall <jgrall@xxxxxxxxxx>
---
 xen/common/domain.c     | 43 ++++++++++++++++++++++++++++++++++++++---
 xen/include/xen/sched.h |  2 ++
 2 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/xen/common/domain.c b/xen/common/domain.c
index 76a4c2072e10..d4958ec5e149 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -1644,15 +1644,52 @@ bool update_runstate_area(struct vcpu *v)
     bool rc;
     struct guest_memory_policy policy = { };
     void __user *guest_handle = NULL;
-    struct vcpu_runstate_info runstate;
+    struct vcpu_runstate_info runstate = v->runstate;
+    struct vcpu_runstate_info *map = v->runstate_guest_area.map;
+
+    if ( map )
+    {
+        uint64_t *pset;
+#ifdef CONFIG_COMPAT
+        struct compat_vcpu_runstate_info *cmap = NULL;
+
+        if ( v->runstate_guest_area_compat )
+            cmap = (void *)map;
+#endif
+
+        /*
+         * NB: No VM_ASSIST(v->domain, runstate_update_flag) check here.
+         *     Always using that updating model.
+         */
+#ifdef CONFIG_COMPAT
+        if ( cmap )
+            pset = &cmap->state_entry_time;
+        else
+#endif
+            pset = &map->state_entry_time;
+        runstate.state_entry_time |= XEN_RUNSTATE_UPDATE;
+        write_atomic(pset, runstate.state_entry_time);
+        smp_wmb();
+
+#ifdef CONFIG_COMPAT
+        if ( cmap )
+            XLAT_vcpu_runstate_info(cmap, &runstate);
+        else
+#endif
+            *map = runstate;
+
+        smp_wmb();
+        runstate.state_entry_time &= ~XEN_RUNSTATE_UPDATE;
+        write_atomic(pset, runstate.state_entry_time);
+
+        return true;
+    }
 
     if ( guest_handle_is_null(runstate_guest(v)) )
         return true;
 
     update_guest_memory_policy(v, &policy);
 
-    memcpy(&runstate, &v->runstate, sizeof(runstate));
-
     if ( VM_ASSIST(v->domain, runstate_update_flag) )
     {
 #ifdef CONFIG_COMPAT
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index f30f3b0ebeab..6e1028785d8c 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -232,6 +232,8 @@ struct vcpu
 #ifdef CONFIG_COMPAT
     /* A hypercall is using the compat ABI? */
     bool             hcall_compat;
+    /* Physical runstate area registered via compat ABI? */
+    bool             runstate_guest_area_compat;
 #endif
 
 #ifdef CONFIG_IOREQ_SERVER
-- 
2.42.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.