[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v4 1/3] domctl: introduce a new domain create flag, XEN_DOMCTL_CDF_disable_fifo, ...
From: Paul Durrant <pdurrant@xxxxxxxxxx> ...to control the visibility of the FIFO event channel operations (EVTCHNOP_init_control, EVTCHNOP_expand_array, and EVTCHNOP_set_priority) to the guest. These operations were added to the public header in commit d2d50c2f308f ("evtchn: add FIFO-based event channel ABI") and the first implementation appeared in the two subsequent commits: edc8872aeb4a ("evtchn: implement EVTCHNOP_set_priority and add the set_priority hook") and 88910061ec61 ("evtchn: add FIFO-based event channel hypercalls and port ops"). Prior to that, a guest issuing those operations would receive a return value of -ENOSYS (not implemented) from Xen. Guests aware of the FIFO operations but running on an older (pre-4.4) Xen would fall back to using the 2-level event channel interface upon seeing this return value. Unfortunately the uncontrolable appearance of these new operations in Xen 4.4 onwards has implications for hibernation of some Linux guests. During resume from hibernation, there are two kernels involved: the "boot" kernel and the "resume" kernel. The guest boot kernel may default to use FIFO operations and instruct Xen via EVTCHNOP_init_control to switch from 2-level to FIFO. On the other hand, the resume kernel keeps assuming 2-level, because it was hibernated on a version of Xen that did not support the FIFO operations. To maintain compatibility it is necessary to make Xen behave as it did before the new operations were added and hence the code in this patch ensures that, if XEN_DOMCTL_CDF_disable_fifo is set, the FIFO event channel operations will again result in -ENOSYS being returned to the guest. Signed-off-by: Paul Durrant <pdurrant@xxxxxxxxxx> Signed-off-by: Eslam Elnikety <elnikety@xxxxxxxxxx> --- Cc: Christian Lindig <christian.lindig@xxxxxxxxxx> Cc: David Scott <dave@xxxxxxxxxx> Cc: Ian Jackson <iwj@xxxxxxxxxxxxxx> Cc: Wei Liu <wl@xxxxxxx> Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Cc: George Dunlap <george.dunlap@xxxxxxxxxx> Cc: Jan Beulich <jbeulich@xxxxxxxx> Cc: Julien Grall <julien@xxxxxxx> Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx> v4: - New in v4 --- tools/ocaml/libs/xc/xenctrl.ml | 1 + tools/ocaml/libs/xc/xenctrl.mli | 1 + xen/common/domain.c | 2 +- xen/common/event_channel.c | 17 +++++++++++++++++ xen/include/public/domctl.h | 4 +++- 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml index e878699b0a1a..9ccad9aece8c 100644 --- a/tools/ocaml/libs/xc/xenctrl.ml +++ b/tools/ocaml/libs/xc/xenctrl.ml @@ -65,6 +65,7 @@ type domain_create_flag = | CDF_XS_DOMAIN | CDF_IOMMU | CDF_NESTED_VIRT + | CDF_DISABLE_FIFO type domain_create_iommu_opts = | IOMMU_NO_SHAREPT diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.mli index e64907df8e7e..8bb0f9e14b8e 100644 --- a/tools/ocaml/libs/xc/xenctrl.mli +++ b/tools/ocaml/libs/xc/xenctrl.mli @@ -58,6 +58,7 @@ type domain_create_flag = | CDF_XS_DOMAIN | CDF_IOMMU | CDF_NESTED_VIRT + | CDF_DISABLE_FIFO type domain_create_iommu_opts = | IOMMU_NO_SHAREPT diff --git a/xen/common/domain.c b/xen/common/domain.c index f748806a450b..75aed7fd5b01 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -307,7 +307,7 @@ static int sanitise_domain_config(struct xen_domctl_createdomain *config) ~(XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap | XEN_DOMCTL_CDF_s3_integrity | XEN_DOMCTL_CDF_oos_off | XEN_DOMCTL_CDF_xs_domain | XEN_DOMCTL_CDF_iommu | - XEN_DOMCTL_CDF_nested_virt) ) + XEN_DOMCTL_CDF_nested_virt | XEN_DOMCTL_CDF_disable_fifo) ) { dprintk(XENLOG_INFO, "Unknown CDF flags %#x\n", config->flags); return -EINVAL; diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index 54b2e2550e93..6a96ccf56c3a 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -1193,10 +1193,27 @@ static long evtchn_set_priority(const struct evtchn_set_priority *set_priority) return ret; } +static bool is_fifo_op(int cmd) +{ + switch ( cmd ) + { + case EVTCHNOP_init_control: + case EVTCHNOP_expand_array: + case EVTCHNOP_set_priority: + return true; + default: + return false; + } +} + long do_event_channel_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) { long rc; + if ( (current->domain->options & XEN_DOMCTL_CDF_disable_fifo) && + is_fifo_op(cmd) ) + return -ENOSYS; + switch ( cmd ) { case EVTCHNOP_alloc_unbound: { diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index 666aeb71bf1b..70701c59d053 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -70,9 +70,11 @@ struct xen_domctl_createdomain { #define XEN_DOMCTL_CDF_iommu (1U<<_XEN_DOMCTL_CDF_iommu) #define _XEN_DOMCTL_CDF_nested_virt 6 #define XEN_DOMCTL_CDF_nested_virt (1U << _XEN_DOMCTL_CDF_nested_virt) +#define _XEN_DOMCTL_CDF_disable_fifo 7 +#define XEN_DOMCTL_CDF_disable_fifo (1U << _XEN_DOMCTL_CDF_disable_fifo) /* Max XEN_DOMCTL_CDF_* constant. Used for ABI checking. */ -#define XEN_DOMCTL_CDF_MAX XEN_DOMCTL_CDF_nested_virt +#define XEN_DOMCTL_CDF_MAX XEN_DOMCTL_CDF_disable_fifo uint32_t flags; -- 2.20.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |