From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vitaly Kuznetsov Subject: [PATCH v2 1/1] evtchn: make EVTCHNOP_reset suitable for kexec Date: Wed, 30 Jul 2014 15:26:50 +0200 Message-ID: <1406726810-2557-2-git-send-email-vkuznets@redhat.com> References: <1406726810-2557-1-git-send-email-vkuznets@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XCTuL-0004QC-IO for xen-devel@lists.xenproject.org; Wed, 30 Jul 2014 13:27:05 +0000 In-Reply-To: <1406726810-2557-1-git-send-email-vkuznets@redhat.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Andrew Jones , Ian Campbell , Andrew Cooper , David Vrabel , Jan Beulich List-Id: xen-devel@lists.xenproject.org It would be nice to allow guests to close all event channels in ABI-agnostic way in case of kexec/kdump. EVTCHNOP_reset looks suitable for this purpose. However control blocks for vcpus and event array need cleanup when FIFO ABI is being used. With this change a guest can simply do EVTCHNOP_reset before kexec in both 2-level and FIFO cases. It is also important to perform store/console channel remapping after such call. The issue can also be solved by introducing a new EVTCHNOP operation but it seems that EVTCHNOP_reset can be reused. [The idea was suggested by Ian Campbell, Andrew Cooper, and David Vrabel] Changes from v1: - Change EVTCHNOP_reset behavior when it is being called by the guest with DOMID_SELF only [Andrew Cooper, Jan Beulich]. - Do not skip interdomain store/console channels, let the guest rebind them [David Vrabel]. - Do evtchn_2l_init() after evtchn_fifo_destroy() so the guest can perform e.g. EVTCHNOP_bind_interdomain operations after EVTCHNOP_reset. Signed-off-by: Vitaly Kuznetsov --- xen/common/event_channel.c | 11 +++++++++++ xen/common/event_fifo.c | 1 + 2 files changed, 12 insertions(+) diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index db952af..0dad08d 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -957,6 +957,17 @@ static long evtchn_reset(evtchn_reset_t *r) for ( i = 0; port_is_valid(d, i); i++ ) (void)__evtchn_close(d, i); + if ( (d == current->domain) && d->evtchn_fifo ) + { + /* + * Guest domain called EVTCHNOP_reset with DOMID_SELF, destroying + * FIFO event array and control blocks, resetting evtchn_port_ops to + * evtchn_port_ops_2l. + */ + evtchn_fifo_destroy(d); + evtchn_2l_init(d); + } + rc = 0; out: 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) -- 1.9.3