From patchwork Wed Aug 7 11:20:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eslam Elnikety X-Patchwork-Id: 11081917 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7461E112C for ; Wed, 7 Aug 2019 11:22:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60BE4289CC for ; Wed, 7 Aug 2019 11:22:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54553289D1; Wed, 7 Aug 2019 11:22:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A40C0289CC for ; Wed, 7 Aug 2019 11:22:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hvK0A-0001EE-B7; Wed, 07 Aug 2019 11:21:06 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hvK09-0001E9-01 for xen-devel@lists.xenproject.org; Wed, 07 Aug 2019 11:21:05 +0000 X-Inumbo-ID: 70ed02b1-b905-11e9-8980-bc764e045a96 Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 70ed02b1-b905-11e9-8980-bc764e045a96; Wed, 07 Aug 2019 11:21:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1565176863; x=1596712863; h=from:to:cc:subject:date:message-id:mime-version; bh=k4YL87HzFOSD+QSCuRst/miLz+7AMsh1ervn8DZjP/8=; b=YyDLP+84+xWuBD/DpWxSqMr6PjBebtys5xjKQX62PaItW89kAx9rZSjo URB7MQIdYWUBUdL2DGGj46SZ1tdMZA2EyuNMe289GBDU3dnk89xmdg9Rq +fyKGY1uZpKmtvJGLR5cu0NXPQX1NYzEDFsRL8IfsXdqpcPtkDEJRvSCN s=; X-IronPort-AV: E=Sophos;i="5.64,357,1559520000"; d="scan'208";a="745590219" Received: from iad6-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-2b-a7fdc47a.us-west-2.amazon.com) ([10.124.125.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 07 Aug 2019 11:21:00 +0000 Received: from EX13MTAUEA001.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan2.pdx.amazon.com [10.170.41.162]) by email-inbound-relay-2b-a7fdc47a.us-west-2.amazon.com (Postfix) with ESMTPS id 29B94C5C77; Wed, 7 Aug 2019 11:21:00 +0000 (UTC) Received: from EX13D08UEE001.ant.amazon.com (10.43.62.126) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 7 Aug 2019 11:20:59 +0000 Received: from EX13MTAUWB001.ant.amazon.com (10.43.161.207) by EX13D08UEE001.ant.amazon.com (10.43.62.126) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 7 Aug 2019 11:20:59 +0000 Received: from dev-dsk-elnikety-1c-28a13cba.eu-west-1.amazon.com (10.15.5.186) by mail-relay.amazon.com (10.43.161.249) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Wed, 7 Aug 2019 11:20:58 +0000 Received: by dev-dsk-elnikety-1c-28a13cba.eu-west-1.amazon.com (Postfix, from userid 6438462) id 24956465CD; Wed, 7 Aug 2019 11:20:58 +0000 (UTC) From: Eslam Elnikety To: Date: Wed, 7 Aug 2019 11:20:24 +0000 Message-ID: <20190807112024.19480-1-elnikety@amazon.com> X-Mailer: git-send-email 2.15.3.AMZN MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH] evtchn: make support for different ABIs tunable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Eslam Elnikety , Tim Deegan , Julien Grall , Jan Beulich , Anthony PERARD , David Woodhouse Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Adding support for FIFO event channel ABI was first introduced in Xen 4.4 (see 88910061ec6). Make this support tunable, since the choice of which event channel ABI has implications for hibernation. Consider resuming a pre Xen 4.4 hibernated Linux guest. The guest boot kernel defaults to FIFO ABI, whereas the resume kernel assumes 2L. This, in turn, results in Xen and the resumed kernel talking past each other (due to different protocols FIFO vs 2L). In order to announce to guests that the event channel ABI does not support FIFO, the hypervisor returns ENOSYS on init_control operation. When this operation fails, the guest should continue to use the 2L event channel ABI. For example, in Linux drivers/xen/events/events_base.c: if (fifo_events) ret = xen_evtchn_fifo_init(); if (ret < 0) xen_evtchn_2l_init(); and xen_evtchn_fifo_init fails when EVTCHNOP_init_control fails. This commit does not change the current default behaviour: announce FIFO event channels ABI support for guests unless explicitly stated otherwise at domaincreate. Signed-off-by: Eslam Elnikety --- docs/man/xl.cfg.5.pod.in | 5 +++++ tools/libxl/libxl.h | 8 ++++++++ tools/libxl/libxl_create.c | 5 +++++ tools/libxl/libxl_types.idl | 1 + tools/xl/xl_parse.c | 2 ++ tools/xl/xl_sxp.c | 2 ++ xen/common/domain.c | 3 +++ xen/common/event_channel.c | 5 +++++ xen/include/public/domctl.h | 3 +++ xen/include/xen/sched.h | 1 + 10 files changed, 35 insertions(+) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index c99d40307e..f204d8b4f0 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -1262,6 +1262,11 @@ FIFO-based event channel ABI support up to 131,071 event channels. Other guests are limited to 4095 (64-bit x86 and ARM) or 1023 (32-bit x86). +=item B + +Indicates if support for FIFO event channel ABI is disabled. The default +is false (0). + =item B Specifies the virtual display devices to be provided to the guest. diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 9bacfb97f0..75b2ee3d1b 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -169,6 +169,14 @@ */ #define LIBXL_HAVE_BUILDINFO_EVENT_CHANNELS 1 +/* + * LIBXL_HAVE_BUILDINFO_DISABLE_EVTCHN_FIFO indicates that the + * libxl_domain_build_info structure contains a boolean + * disable_evtchn_fifo which instructs libxl to enable/disable + * support for FIFO event channel ABI at create time. + */ +#define LIBXL_HAVE_BUILDINFO_DISABLE_EVTCHN_FIFO 1 + /* * libxl_domain_build_info has the u.hvm.ms_vm_genid field. */ diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 03ce166f4f..aa87e45643 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -217,6 +217,8 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, if (!b_info->event_channels) b_info->event_channels = 1023; + libxl_defbool_setdefault(&b_info->disable_evtchn_fifo, false); + libxl__arch_domain_build_info_setdefault(gc, b_info); libxl_defbool_setdefault(&b_info->dm_restrict, false); @@ -564,6 +566,9 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config, libxl_defbool_val(info->oos) ? 0 : XEN_DOMCTL_CDF_oos_off; } + if (libxl_defbool_val(b_info->disable_evtchn_fifo)) + create.flags |= XEN_DOMCTL_CDF_disable_fifo; + /* Ultimately, handle is an array of 16 uint8_t, same as uuid */ libxl_uuid_copy(ctx, (libxl_uuid *)&create.handle, &info->uuid); diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index b61399ce36..5f30570443 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -521,6 +521,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("iomem", Array(libxl_iomem_range, "num_iomem")), ("claim_mode", libxl_defbool), ("event_channels", uint32), + ("disable_evtchn_fifo", libxl_defbool), ("kernel", string), ("cmdline", string), ("ramdisk", string), diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index e105bda2bb..bcf16c31d4 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -1496,6 +1496,8 @@ void parse_config_data(const char *config_source, if (!xlu_cfg_get_long(config, "max_event_channels", &l, 0)) b_info->event_channels = l; + xlu_cfg_get_defbool(config, "disable_evtchn_fifo", + &b_info->disable_evtchn_fifo, 0); xlu_cfg_replace_string (config, "kernel", &b_info->kernel, 0); xlu_cfg_replace_string (config, "ramdisk", &b_info->ramdisk, 0); xlu_cfg_replace_string (config, "device_tree", &b_info->device_tree, 0); diff --git a/tools/xl/xl_sxp.c b/tools/xl/xl_sxp.c index 359a001570..52e98c6c61 100644 --- a/tools/xl/xl_sxp.c +++ b/tools/xl/xl_sxp.c @@ -71,6 +71,8 @@ void printf_info_sexp(int domid, libxl_domain_config *d_config, FILE *fh) fprintf(fh, "\t(target_memkb %"PRId64")\n", b_info->target_memkb); fprintf(fh, "\t(nomigrate %s)\n", libxl_defbool_to_string(b_info->disable_migrate)); + fprintf(fh, "\t(disable_evtchn_fifo %s)\n", + libxl_defbool_to_string(b_info->disable_evtchn_fifo)); if (c_info->type == LIBXL_DOMAIN_TYPE_PV && b_info->bootloader) { fprintf(fh, "\t(bootloader %s)\n", b_info->bootloader); diff --git a/xen/common/domain.c b/xen/common/domain.c index 744b572195..d54674e28c 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -444,6 +444,9 @@ struct domain *domain_create(domid_t domid, d->controller_pause_count = 1; atomic_inc(&d->pause_count); + if ( d->options & XEN_DOMCTL_CDF_disable_fifo ) + d->disable_evtchn_fifo = 1; + if ( (err = evtchn_init(d, config->max_evtchn_port)) != 0 ) goto fail; init_status |= INIT_evtchn; diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index e86e2bfab0..ce3dbb90ab 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -1170,6 +1170,11 @@ long do_event_channel_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) case EVTCHNOP_init_control: { struct evtchn_init_control init_control; + + /* Fail init_control for domains that must use 2l ABI */ + if ( current->domain->disable_evtchn_fifo ) + return -ENOSYS; + if ( copy_from_guest(&init_control, arg, 1) != 0 ) return -EFAULT; rc = evtchn_fifo_init_control(&init_control); diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index 19486d5e32..654b4fdd22 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -64,6 +64,9 @@ struct xen_domctl_createdomain { /* Is this a xenstore domain? */ #define _XEN_DOMCTL_CDF_xs_domain 4 #define XEN_DOMCTL_CDF_xs_domain (1U<<_XEN_DOMCTL_CDF_xs_domain) + /* Disable FIFO event channels? */ +#define _XEN_DOMCTL_CDF_disable_fifo 5 +#define XEN_DOMCTL_CDF_disable_fifo (1U<<_XEN_DOMCTL_CDF_disable_fifo) uint32_t flags; /* diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 2e6e0d3488..fcdd802665 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -338,6 +338,7 @@ struct domain struct evtchn **evtchn_group[NR_EVTCHN_GROUPS]; /* all other buckets */ unsigned int max_evtchns; /* number supported by ABI */ unsigned int max_evtchn_port; /* max permitted port number */ + bool disable_evtchn_fifo; /* force 2l ABI */ unsigned int valid_evtchns; /* number of allocated event channels */ spinlock_t event_lock; const struct evtchn_port_ops *evtchn_port_ops;