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

[xen master] domain: update GADDR based runstate guest area



commit e1ddb822ca2e3c332d42d508e2a5fbd7be018815
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Mon Oct 2 17:11:21 2023 +0200
Commit:     Julien Grall <jgrall@xxxxxxxxxx>
CommitDate: Thu Oct 5 14:08:50 2023 +0100

    domain: update GADDR based runstate guest area
    
    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>
    Release-acked-by: Henry Wang <Henry.Wang@xxxxxxx>
---
 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 76a4c2072e..d4958ec5e1 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 f30f3b0ebe..6e1028785d 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
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

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