xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: xen-devel@lists.xenproject.org
Cc: Andrew Jones <drjones@redhat.com>,
	David Vrabel <david.vrabel@citrix.com>
Subject: [PATCH RFC] evtchn: introduce EVTCHNOP_fifo_destroy hypercall
Date: Fri, 18 Jul 2014 17:42:38 +0200	[thread overview]
Message-ID: <1405698158-17096-1-git-send-email-vkuznets@redhat.com> (raw)

New hypercall is required to allow guest to perform kexec when FIFO-based
event channel ABI is being used. This hypercall simply exposes evtchn_fifo_destroy()
function which cleans up all control blocks for all vcpus and frees event array
for the domain.

With this hypercall guest can do something like:
       struct evtchn_destroy_fifo destroy;

       destroy.dom = DOMID_SELF;
       HYPERVISOR_event_channel_op(EVTCHNOP_destroy_fifo, &destroy);

before doing
       HYPERVISOR_event_channel_op(EVTCHNOP_init_control, &init_control);
for the first vcpu on init.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
 xen/common/event_channel.c         | 30 ++++++++++++++++++++++++++++++
 xen/common/event_fifo.c            |  1 +
 xen/include/public/event_channel.h |  7 +++++++
 3 files changed, 38 insertions(+)

diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c
index db952af..9bc18b2 100644
--- a/xen/common/event_channel.c
+++ b/xen/common/event_channel.c
@@ -939,6 +939,26 @@ int evtchn_unmask(unsigned int port)
     return 0;
 }
 
+static long evtchn_fifo_destroy_all(domid_t dom)
+{
+	struct domain *d;
+	int rc;
+
+	d = rcu_lock_domain_by_any_id(dom);
+	if ( d == NULL )
+		return -ESRCH;
+
+	rc = xsm_evtchn_reset(XSM_TARGET, current->domain, d);
+	if ( rc )
+		goto out;
+
+	evtchn_fifo_destroy(d);
+
+out:
+	rcu_unlock_domain(d);
+
+	return rc;
+}
 
 static long evtchn_reset(evtchn_reset_t *r)
 {
@@ -1121,6 +1141,16 @@ long do_event_channel_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
         break;
     }
 
+	case EVTCHNOP_fifo_destroy: {
+		struct evtchn_fifo_destroy destroy;
+		if ( copy_from_guest(&destroy, arg, 1) != 0 )
+			return -EFAULT;
+		if ( destroy.dom != DOMID_SELF )
+			return -EPERM;
+		rc = evtchn_fifo_destroy_all(destroy.dom);
+		break;
+	}
+
     default:
         rc = -ENOSYS;
         break;
diff --git a/xen/common/event_fifo.c b/xen/common/event_fifo.c
index 1fce3f1..51b4ff6 100644
--- a/xen/common/event_fifo.c
+++ b/xen/common/event_fifo.c
@@ -451,6 +451,7 @@ static void cleanup_event_array(struct domain *d)
     for ( i = 0; i < EVTCHN_FIFO_MAX_EVENT_ARRAY_PAGES; i++ )
         unmap_guest_page(d->evtchn_fifo->event_array[i]);
     xfree(d->evtchn_fifo);
+    d->evtchn_fifo = NULL;
 }
 
 static void setup_ports(struct domain *d)
diff --git a/xen/include/public/event_channel.h b/xen/include/public/event_channel.h
index 49ac8cc..79b6e86 100644
--- a/xen/include/public/event_channel.h
+++ b/xen/include/public/event_channel.h
@@ -74,6 +74,7 @@
 #define EVTCHNOP_init_control    11
 #define EVTCHNOP_expand_array    12
 #define EVTCHNOP_set_priority    13
+#define EVTCHNOP_fifo_destroy    14
 /* ` } */
 
 typedef uint32_t evtchn_port_t;
@@ -308,6 +309,12 @@ struct evtchn_set_priority {
 };
 typedef struct evtchn_set_priority evtchn_set_priority_t;
 
+struct evtchn_fifo_destroy {
+	/* IN parameters. */
+	domid_t dom;
+};
+typedef struct evtchn_fifo_destroy evtchn_fifo_destroy_t;
+
 /*
  * ` enum neg_errnoval
  * ` HYPERVISOR_event_channel_op_compat(struct evtchn_op *op)
-- 
1.9.3

             reply	other threads:[~2014-07-18 15:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-18 15:42 Vitaly Kuznetsov [this message]
2014-07-18 15:46 ` [PATCH RFC] evtchn: introduce EVTCHNOP_fifo_destroy hypercall Ian Campbell
2014-07-18 15:50 ` Andrew Cooper

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=1405698158-17096-1-git-send-email-vkuznets@redhat.com \
    --to=vkuznets@redhat.com \
    --cc=david.vrabel@citrix.com \
    --cc=drjones@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).