All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christopher Clark <christopher.w.clark@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Wei Liu <wei.liu2@citrix.com>,
	Ross Philipson <ross.philipson@gmail.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Jason Andryuk <jandryuk@gmail.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Rich Persaud <persaur@gmail.com>, Tim Deegan <tim@xen.org>,
	Daniel Smith <dpsmith@apertussolutions.com>,
	Julien Grall <julien.grall@arm.com>,
	Paul Durrant <paul.durrant@citrix.com>,
	Jan Beulich <jbeulich@suse.com>,
	James McKenzie <james@bromium.com>,
	Eric Chanudet <eric.chanudet@gmail.com>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH v2 18/18] argo: unmap rings on suspend; signal ring-owners on resume
Date: Wed, 19 Dec 2018 22:39:15 -0800	[thread overview]
Message-ID: <1545287955-27684-19-git-send-email-christopher.w.clark@gmail.com> (raw)
In-Reply-To: <1545287955-27684-1-git-send-email-christopher.w.clark@gmail.com>

The hypervisor data structures for the argo rings are populated with mfns
which cannot be assumed to map to the same guest frame numbers across entry
to and exit from host power state S4 (hibernate to disk).

Tear down all the rings during suspend to stop argo operations from
performing any further writes into the registered set of mfns for the rings.

In order to support guests reestablishing their registered rings on resume,
signal each guest that has a registered ring so that the guest may
re-register each ring with the current mappings for its guest frame numbers.

Signed-off-by: Christopher Clark <christopher.clark6@baesystems.com>
---
Changes since v1:

v1. feedback #15 Jan: make i unsigned
v1. self: fix indentation and blank lines
v1. feedback #25 Jan: add rationale to commit message

re: v1 feedback #25 Jan: soft-reset is now not a problem for the resume logic
in this commit since handling of soft reset was added to an earlier commit in
this version 2 series.

 xen/common/argo.c      | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++
 xen/common/domain.c    |  9 +++++++
 xen/include/xen/argo.h |  2 ++
 3 files changed, 83 insertions(+)

diff --git a/xen/common/argo.c b/xen/common/argo.c
index 921aaf3..624ed8a 100644
--- a/xen/common/argo.c
+++ b/xen/common/argo.c
@@ -1076,6 +1076,16 @@ static void argo_ring_remove_mfns(const struct domain *d,
 }
 
 static void
+argo_ring_reset(struct domain *d, struct argo_ring_info *ring_info)
+{
+    ASSERT(rw_is_write_locked(&d->argo->lock));
+
+    argo_ring_remove_mfns(d, ring_info);
+    ring_info->len = 0;
+    ring_info->tx_ptr = 0;
+}
+
+static void
 argo_ring_remove_info(struct domain *d, struct argo_ring_info *ring_info)
 {
     ASSERT(rw_is_write_locked(&d->argo->lock));
@@ -2222,3 +2232,65 @@ argo_soft_reset(struct domain *d)
 
     write_unlock(&argo_lock);
 }
+
+void
+argo_shutdown_for_suspend(struct domain *d)
+{
+    unsigned int i;
+
+    if ( !d )
+        return;
+
+    if ( get_domain(d) )
+    {
+        read_lock(&argo_lock);
+
+        if ( d->argo )
+        {
+            write_lock(&d->argo->lock);
+
+            for ( i = 0; i < ARGO_HTABLE_SIZE; i++ )
+            {
+                struct hlist_node *node, *next;
+                struct argo_ring_info *ring_info;
+
+                hlist_for_each_entry_safe(ring_info, node,
+                                          next, &d->argo->ring_hash[i], node)
+                    argo_ring_reset(d, ring_info);
+            }
+
+            write_unlock(&d->argo->lock);
+        }
+
+        read_unlock(&argo_lock);
+
+        put_domain(d);
+    }
+}
+
+void
+argo_resume(struct domain *d)
+{
+    bool send_wakeup;
+
+    if ( !d )
+        return;
+
+    if ( !get_domain(d) )
+        return;
+
+    read_lock(&argo_lock);
+
+    read_lock(&d->argo->lock);
+
+    send_wakeup = ( d->argo->ring_count > 0 );
+
+    read_unlock(&d->argo->lock);
+
+    if ( send_wakeup )
+        argo_signal_domain(d);
+
+    read_unlock(&argo_lock);
+
+    put_domain(d);
+}
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 601c663..e194a42 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -89,6 +89,11 @@ static void __domain_finalise_shutdown(struct domain *d)
         if ( !v->paused_for_shutdown )
             return;
 
+#ifdef CONFIG_ARGO
+    if ( d->shutdown_code == SHUTDOWN_suspend )
+        argo_shutdown_for_suspend(d);
+#endif
+
     d->is_shut_down = 1;
     if ( (d->shutdown_code == SHUTDOWN_suspend) && d->suspend_evtchn )
         evtchn_send(d, d->suspend_evtchn);
@@ -857,6 +862,10 @@ void domain_resume(struct domain *d)
     spin_unlock(&d->shutdown_lock);
 
     domain_unpause(d);
+
+#ifdef CONFIG_ARGO
+    argo_resume(d);
+#endif
 }
 
 int vcpu_start_shutdown_deferral(struct vcpu *v)
diff --git a/xen/include/xen/argo.h b/xen/include/xen/argo.h
index 29d32a9..e3dc19b 100644
--- a/xen/include/xen/argo.h
+++ b/xen/include/xen/argo.h
@@ -18,6 +18,8 @@
 
 int argo_init(struct domain *d);
 void argo_destroy(struct domain *d);
+void argo_shutdown_for_suspend(struct domain *d);
+void argo_resume(struct domain *d);
 void argo_soft_reset(struct domain *d);
 
 #endif
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

      parent reply	other threads:[~2018-12-20  6:40 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-20  6:38 [PATCH v2 00/18] Argo: hypervisor-mediated interdomain communication Christopher Clark
2018-12-20  6:38 ` [PATCH v2 01/18] argo: Introduce the Kconfig option to govern inclusion of Argo Christopher Clark
2018-12-20  9:00   ` Jan Beulich
2018-12-20  6:38 ` [PATCH v2 02/18] argo: introduce the argo_message_op hypercall boilerplate Christopher Clark
2018-12-20 15:18   ` Jan Beulich
2018-12-20  6:39 ` [PATCH v2 03/18] argo: define argo_dprintk for subsystem debugging Christopher Clark
2018-12-20 15:20   ` Jan Beulich
2018-12-20  6:39 ` [PATCH v2 04/18] argo: init, destroy and soft-reset, with enable command line opt Christopher Clark
2018-12-20 14:41   ` Lars Kurth
2018-12-20  6:39 ` [PATCH v2 05/18] xen: add simple errno-returning macros for copy from guest Christopher Clark
2018-12-20  6:39 ` [PATCH v2 06/18] xen: add XEN_GUEST_HANDLE_NULL macros for null XEN_GUEST_HANDLE Christopher Clark
2018-12-20  6:39 ` [PATCH v2 07/18] errno: add POSIX error codes EMSGSIZE, ECONNREFUSED to the ABI Christopher Clark
2018-12-20 15:22   ` Jan Beulich
2018-12-20  6:39 ` [PATCH v2 08/18] xen/arm: introduce guest_handle_for_field() Christopher Clark
2018-12-20  6:39 ` [PATCH v2 09/18] xsm, argo: XSM control for argo register; add argo_mac bootparam Christopher Clark
2018-12-20 15:29   ` Jan Beulich
2018-12-20  6:39 ` [PATCH v2 10/18] xsm, argo: XSM control for argo message send operation Christopher Clark
2018-12-20  6:39 ` [PATCH v2 11/18] argo: implement the register op Christopher Clark
2018-12-20 11:20   ` Julien Grall
2018-12-21  1:17     ` Christopher Clark
2018-12-21 12:21       ` Julien Grall
2018-12-20  6:39 ` [PATCH v2 12/18] argo: implement the unregister op Christopher Clark
2018-12-20  6:39 ` [PATCH v2 13/18] argo: implement the sendv op; evtchn: expose send_guest_global_virq Christopher Clark
2018-12-20  6:39 ` [PATCH v2 14/18] argo: implement the notify op Christopher Clark
2018-12-20  6:39 ` [PATCH v2 15/18] xsm, argo: XSM control for any access to argo by a domain Christopher Clark
2018-12-20  6:39 ` [PATCH v2 16/18] xsm, argo: notify: don't describe rings that cannot be sent to Christopher Clark
2018-12-20  6:39 ` [PATCH v2 17/18] argo: validate hypercall arg structures via compat machinery Christopher Clark
2018-12-20  6:39 ` Christopher Clark [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1545287955-27684-19-git-send-email-christopher.w.clark@gmail.com \
    --to=christopher.w.clark@gmail.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=dpsmith@apertussolutions.com \
    --cc=eric.chanudet@gmail.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=james@bromium.com \
    --cc=jandryuk@gmail.com \
    --cc=jbeulich@suse.com \
    --cc=julien.grall@arm.com \
    --cc=konrad.wilk@oracle.com \
    --cc=paul.durrant@citrix.com \
    --cc=persaur@gmail.com \
    --cc=roger.pau@citrix.com \
    --cc=ross.philipson@gmail.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.