From nobody Thu May 2 05:50:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1606999349; cv=none; d=zohomail.com; s=zohoarc; b=jCvZod5B/VXrIejhklj7bN0NmLmZ3FXU0JGw5y3G22dLy4gm/NaFSxQmUByYjnTKUuNj3DhomnMC7MdOmxPgijzVwebfreI8LIG9BdfUr8apUIl9ZmHxJvJrxEZwc+LwVAW4HkCnx0+xNIvPEaKH2KvHd4kvT9X0XD8G3gNm6X4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606999349; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TkS/3Nu1RBKiO2GK1mYbF+lmLCDon9ThVaW6ItHos8g=; b=MyDZpAl1cHAyfDC5PXPVzrF/VOM8LyDI8U5CzGgGT+FjsllAA5WCiKmsbSRnel7OTndIwEZ1j7CqL7G7o4nd/FFLcafxdfaOo6frn2lsdzgJRB+GqtzYicx8Sle/GAJmbjMy1/9Pwt5CplZd4d2CMsiyUPH8D3Tt29zell6tQts= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1606999349182800.3848634780502; Thu, 3 Dec 2020 04:42:29 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.43406.78022 (Exim 4.92) (envelope-from ) id 1kknvz-0005wD-1J; Thu, 03 Dec 2020 12:42:07 +0000 Received: by outflank-mailman (output) from mailman id 43406.78022; Thu, 03 Dec 2020 12:42:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kknvy-0005w6-UY; Thu, 03 Dec 2020 12:42:06 +0000 Received: by outflank-mailman (input) for mailman id 43406; Thu, 03 Dec 2020 12:42:05 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kknvx-0005v7-G6 for xen-devel@lists.xenproject.org; Thu, 03 Dec 2020 12:42:05 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kknvv-00045z-VV; Thu, 03 Dec 2020 12:42:03 +0000 Received: from host86-183-162-145.range86-183.btcentralplus.com ([86.183.162.145] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kknvv-00015A-Lq; Thu, 03 Dec 2020 12:42:03 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=TkS/3Nu1RBKiO2GK1mYbF+lmLCDon9ThVaW6ItHos8g=; b=0ZcGMieUH5oylchv/0Q1N6RoT+ chFubiScjuIJhbbcCo/zH4WpyG1MAPRGvKytPqFMxAXYDiWVI2owoeHrLy6Zhe3NHUwrK1ksDqxOq ZJmyj7jwwqXjFT+MuYmyk72O9yZCWarv59e4IUXr7esdcEvqK3FWX2feEPvKmI6nO4HA=; From: Paul Durrant To: xen-devel@lists.xenproject.org Cc: Paul Durrant , Eslam Elnikety , Ian Jackson , Wei Liu , Anthony PERARD , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Christian Lindig , David Scott , Volodymyr Babchuk , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v5 1/4] domctl: introduce a new domain create flag, XEN_DOMCTL_CDF_evtchn_fifo, ... Date: Thu, 3 Dec 2020 12:41:56 +0000 Message-Id: <20201203124159.3688-2-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201203124159.3688-1-paul@xen.org> References: <20201203124159.3688-1-paul@xen.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) From: Paul Durrant ...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 a= nd instruct Xen via EVTCHNOP_init_control to switch from 2-level to FIFO. On t= he other hand, the resume kernel keeps assuming 2-level, because it was hibern= ated 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 ensur= es that, if XEN_DOMCTL_CDF_evtchn_fifo is not set, the FIFO event channel operations will again result in -ENOSYS being returned to the guest. This patch also adds an extra log line into the 'e' key handler output to call out which event channel ABI is in use by a domain. NOTE: To maintain current behavior, until a tool-stack option is added to control the flag, it is unconditionally set for all domains. A subsequent patch will introduce such tool-stack control. Signed-off-by: Paul Durrant Signed-off-by: Eslam Elnikety --- Cc: Ian Jackson Cc: Wei Liu Cc: Anthony PERARD Cc: Andrew Cooper Cc: George Dunlap Cc: Jan Beulich Cc: Julien Grall Cc: Stefano Stabellini Cc: Christian Lindig Cc: David Scott Cc: Volodymyr Babchuk Cc: "Roger Pau Monn=C3=A9" v5: - Flip the sense of the flag from disabling to enabling, as requested by Andrew v4: - New in v4 --- tools/libs/light/libxl_create.c | 1 + tools/ocaml/libs/xc/xenctrl.ml | 1 + tools/ocaml/libs/xc/xenctrl.mli | 1 + xen/arch/arm/domain.c | 3 ++- xen/arch/arm/domain_build.c | 3 ++- xen/arch/arm/setup.c | 3 ++- xen/arch/x86/setup.c | 3 ++- xen/common/domain.c | 2 +- xen/common/event_channel.c | 24 +++++++++++++++++++++--- xen/include/public/domctl.h | 4 +++- 10 files changed, 36 insertions(+), 9 deletions(-) diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_creat= e.c index 321a13e519b5..3ca9f00d6d83 100644 --- a/tools/libs/light/libxl_create.c +++ b/tools/libs/light/libxl_create.c @@ -607,6 +607,7 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_conf= ig *d_config, .max_evtchn_port =3D b_info->event_channels, .max_grant_frames =3D b_info->max_grant_frames, .max_maptrack_frames =3D b_info->max_maptrack_frames, + .flags =3D XEN_DOMCTL_CDF_evtchn_fifo, }; =20 if (info->type !=3D LIBXL_DOMAIN_TYPE_PV) { diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml index e878699b0a1a..fa5c7b7eb0a2 100644 --- a/tools/ocaml/libs/xc/xenctrl.ml +++ b/tools/ocaml/libs/xc/xenctrl.ml @@ -65,6 +65,7 @@ type domain_create_flag =3D | CDF_XS_DOMAIN | CDF_IOMMU | CDF_NESTED_VIRT + | CDF_EVTCHN_FIFO =20 type domain_create_iommu_opts =3D | IOMMU_NO_SHAREPT diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.= mli index e64907df8e7e..a872002d90cc 100644 --- a/tools/ocaml/libs/xc/xenctrl.mli +++ b/tools/ocaml/libs/xc/xenctrl.mli @@ -58,6 +58,7 @@ type domain_create_flag =3D | CDF_XS_DOMAIN | CDF_IOMMU | CDF_NESTED_VIRT + | CDF_EVTCHN_FIFO =20 type domain_create_iommu_opts =3D | IOMMU_NO_SHAREPT diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 18cafcdda7b1..59f947370053 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -622,7 +622,8 @@ int arch_sanitise_domain_config(struct xen_domctl_creat= edomain *config) unsigned int max_vcpus; =20 /* HVM and HAP must be set. IOMMU may or may not be */ - if ( (config->flags & ~XEN_DOMCTL_CDF_iommu) !=3D + if ( (config->flags & + ~(XEN_DOMCTL_CDF_iommu | XEN_DOMCTL_CDF_evtchn_fifo) !=3D (XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap) ) { dprintk(XENLOG_INFO, "Unsupported configuration %#x\n", diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index e824ba34b012..13d1e79f1463 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -2478,7 +2478,8 @@ void __init create_domUs(void) struct domain *d; struct xen_domctl_createdomain d_cfg =3D { .arch.gic_version =3D XEN_DOMCTL_CONFIG_GIC_NATIVE, - .flags =3D XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap, + .flags =3D XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap | + XEN_DOMCTL_CDF_evtchn_fifo, .max_evtchn_port =3D -1, .max_grant_frames =3D 64, .max_maptrack_frames =3D 1024, diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 7fcff9af2a7e..0267acfca16e 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -805,7 +805,8 @@ void __init start_xen(unsigned long boot_phys_offset, struct bootmodule *xen_bootmodule; struct domain *dom0; struct xen_domctl_createdomain dom0_cfg =3D { - .flags =3D XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap, + .flags =3D XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap | + XEN_DOMCTL_CDF_evtchn_fifo, .max_evtchn_port =3D -1, .max_grant_frames =3D gnttab_dom0_frames(), .max_maptrack_frames =3D -1, diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 30d6f375a3af..e558241c73da 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -738,7 +738,8 @@ static struct domain *__init create_dom0(const module_t= *image, const char *loader) { struct xen_domctl_createdomain dom0_cfg =3D { - .flags =3D IS_ENABLED(CONFIG_TBOOT) ? XEN_DOMCTL_CDF_s3_integrity = : 0, + .flags =3D XEN_DOMCTL_CDF_evtchn_fifo | + (IS_ENABLED(CONFIG_TBOOT) ? XEN_DOMCTL_CDF_s3_integrity := 0), .max_evtchn_port =3D -1, .max_grant_frames =3D -1, .max_maptrack_frames =3D -1, diff --git a/xen/common/domain.c b/xen/common/domain.c index f748806a450b..28592c7c8486 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -307,7 +307,7 @@ static int sanitise_domain_config(struct xen_domctl_cre= atedomain *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_evtchn_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 dbfba62a4934..91133bf3c263 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -1188,10 +1188,27 @@ static long evtchn_set_priority(const struct evtchn= _set_priority *set_priority) return ret; } =20 +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; =20 + if ( !(current->domain->options & XEN_DOMCTL_CDF_evtchn_fifo) && + is_fifo_op(cmd) ) + return -ENOSYS; + switch ( cmd ) { case EVTCHNOP_alloc_unbound: { @@ -1568,9 +1585,10 @@ static void domain_dump_evtchn_info(struct domain *d) unsigned int port; int irq; =20 - printk("Event channel information for domain %d:\n" - "Polling vCPUs: {%*pbl}\n" - " port [p/m/s]\n", d->domain_id, d->max_vcpus, d->poll_mask); + printk("Event channel information for %pd:\n", d); + printk("ABI: %s\n", d->evtchn_fifo ? "FIFO" : "2-level"); + printk("Polling vCPUs: {%*pbl}\n" + " port [p/m/s]\n", d->max_vcpus, d->poll_mask); =20 spin_lock(&d->event_lock); =20 diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index 666aeb71bf1b..f7149c81a7c2 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_evtchn_fifo 7 +#define XEN_DOMCTL_CDF_evtchn_fifo (1U << _XEN_DOMCTL_CDF_evtchn_fifo) =20 /* 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_evtchn_fifo =20 uint32_t flags; =20 --=20 2.20.1 From nobody Thu May 2 05:50:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1606999348; cv=none; d=zohomail.com; s=zohoarc; b=Aol830E8rLAH2VHv51aMywapJBMGLpR5l00NVUKI4Mv0gYoYayP3Q+fXriYCeAJGvPq7duoGcDGLrfR+wHTjzbzS2WlS+4Hg2HV0FUdlI5yz9N7DFAmRNr6wLVY95mPKVa9thKw3TqqLSaOWn3EU6lxH6bEhwQv2Zx1Emp0B8PY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606999348; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lmkdn59hshdmAjDQmfZLDVWbGtLlFRpvq2lkuaCfgJY=; b=AtxT5k22cd8Uol6NMPUHe4gt7Ej2XRVNDYW80JQ/MvHuxxtEE7d6glBP8JGD+orueTjlcPULPNbbS8qDFdBgICH84jze9pIYvS1v1Ktq2J8EkKYyPT7oUFM0qtFV8C4ztcpVY2RkeCFHswuBBbfu5RbsGXpJbuCs8pVCrT5TBKE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1606999348585517.1523962340547; Thu, 3 Dec 2020 04:42:28 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.43407.78034 (Exim 4.92) (envelope-from ) id 1kknw0-0005xn-B1; Thu, 03 Dec 2020 12:42:08 +0000 Received: by outflank-mailman (output) from mailman id 43407.78034; Thu, 03 Dec 2020 12:42:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kknw0-0005xg-6x; Thu, 03 Dec 2020 12:42:08 +0000 Received: by outflank-mailman (input) for mailman id 43407; Thu, 03 Dec 2020 12:42:07 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kknvz-0005wR-5p for xen-devel@lists.xenproject.org; Thu, 03 Dec 2020 12:42:07 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kknvx-000469-PG; Thu, 03 Dec 2020 12:42:05 +0000 Received: from host86-183-162-145.range86-183.btcentralplus.com ([86.183.162.145] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kknvx-00015A-FJ; Thu, 03 Dec 2020 12:42:05 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=lmkdn59hshdmAjDQmfZLDVWbGtLlFRpvq2lkuaCfgJY=; b=lnfsOqa1+UyaBlTlxXau6pCzBV Cmfflqq2/JrDMV/gHL2vnO6Hd1dVp7LZHeKXBThMnOcj1mAmAgP3xe3TMgUCcihcaPefdpoPRNw9p SmtW9xPEAtzVbf1g8Umd5YTlCiEMcCC7IPjBBVQgOMwbLbqeGf0NDkpGveQglSpOkft8=; From: Paul Durrant To: xen-devel@lists.xenproject.org Cc: Paul Durrant , Ian Jackson , Wei Liu , Anthony PERARD , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Christian Lindig , David Scott , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v5 2/4] domctl: introduce a new domain create flag, XEN_DOMCTL_CDF_evtchn_upcall, ... Date: Thu, 3 Dec 2020 12:41:57 +0000 Message-Id: <20201203124159.3688-3-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201203124159.3688-1-paul@xen.org> References: <20201203124159.3688-1-paul@xen.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) From: Paul Durrant ...to control the visibility of the per-vCPU upcall feature for HVM guests. Commit 04447f4453c0 ("x86/hvm: add per-vcpu evtchn upcalls") added a mechan= ism by which x86 HVM guests can register a vector for each vCPU which will be u= sed by Xen to signal event channels on that vCPU. This facility (an HVMOP hypercall) appeared in a uncontrolled fashion which has implications for the behaviour of OS when moving from an older Xen to a newer Xen. For instance, the OS may be aware of the per-vCPU upcall feature but support for it is buggy. In this case the OS will function perfectly we= ll on the older Xen, but fail (in a potentially non-obvious way) on the newer Xen. To maintain compatibility it is necessary to make Xen behave as it did before the new hypercall was added and hence the code in this patch ensures that, if XEN_DOMCTL_CDF_evtchn_upcall is not set, the hypercall will again result in -ENOSYS being returned to the guest. NOTE: To maintain current behavior, until a tool-stack option is added to control the flag, it is unconditionally set for x86 HVM domains. A subsequent patch will introduce such tool-stack control. Signed-off-by: Paul Durrant --- Cc: Ian Jackson Cc: Wei Liu Cc: Anthony PERARD Cc: Andrew Cooper Cc: George Dunlap Cc: Jan Beulich Cc: Julien Grall Cc: Stefano Stabellini Cc: Christian Lindig Cc: David Scott Cc: "Roger Pau Monn=C3=A9" v5: - New in v5 --- tools/libs/light/libxl_x86.c | 7 ++++++- tools/ocaml/libs/xc/xenctrl.ml | 1 + tools/ocaml/libs/xc/xenctrl.mli | 1 + xen/arch/x86/domain.c | 8 ++++++++ xen/arch/x86/hvm/hvm.c | 3 +++ xen/arch/x86/setup.c | 1 + xen/common/domain.c | 3 ++- xen/include/public/domctl.h | 4 +++- 8 files changed, 25 insertions(+), 3 deletions(-) diff --git a/tools/libs/light/libxl_x86.c b/tools/libs/light/libxl_x86.c index 86d272999d67..f7217b422404 100644 --- a/tools/libs/light/libxl_x86.c +++ b/tools/libs/light/libxl_x86.c @@ -5,7 +5,12 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, libxl_domain_config *d_config, struct xen_domctl_createdomain *conf= ig) { - switch(d_config->c_info.type) { + libxl_domain_create_info *info =3D &d_config->c_info; + + if (info->type =3D=3D LIBXL_DOMAIN_TYPE_HVM) + config->flags |=3D XEN_DOMCTL_CDF_evtchn_upcall; + + switch(info->type) { case LIBXL_DOMAIN_TYPE_HVM: config->arch.emulation_flags =3D (XEN_X86_EMU_ALL & ~XEN_X86_EMU_V= PCI); break; diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml index fa5c7b7eb0a2..04284c364108 100644 --- a/tools/ocaml/libs/xc/xenctrl.ml +++ b/tools/ocaml/libs/xc/xenctrl.ml @@ -66,6 +66,7 @@ type domain_create_flag =3D | CDF_IOMMU | CDF_NESTED_VIRT | CDF_EVTCHN_FIFO + | CDF_EVTCHN_UPCALL =20 type domain_create_iommu_opts =3D | IOMMU_NO_SHAREPT diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.= mli index a872002d90cc..e40759464ae5 100644 --- a/tools/ocaml/libs/xc/xenctrl.mli +++ b/tools/ocaml/libs/xc/xenctrl.mli @@ -59,6 +59,7 @@ type domain_create_flag =3D | CDF_IOMMU | CDF_NESTED_VIRT | CDF_EVTCHN_FIFO + | CDF_EVTCHN_UPCALL =20 type domain_create_iommu_opts =3D | IOMMU_NO_SHAREPT diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 1b894d0124d7..e7f83880219d 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -662,11 +662,19 @@ int arch_sanitise_domain_config(struct xen_domctl_cre= atedomain *config) } =20 if ( !hvm ) + { + if ( config->flags & XEN_DOMCTL_CDF_evtchn_upcall ) + { + dprintk(XENLOG_INFO, "Per-vCPU event channel vector only suppo= rted for HVM guests\n"); + return -EINVAL; + } + /* * It is only meaningful for XEN_DOMCTL_CDF_oos_off to be clear * for HVM guests. */ config->flags |=3D XEN_DOMCTL_CDF_oos_off; + } =20 if ( nested_virt && !hap ) { diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 54e32e4fe85c..7ffc42a7282e 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4037,6 +4037,9 @@ static int hvmop_set_evtchn_upcall_vector( struct domain *d =3D current->domain; struct vcpu *v; =20 + if ( !(d->options & XEN_DOMCTL_CDF_evtchn_upcall) ) + return -ENOSYS; + if ( !is_hvm_domain(d) ) return -EINVAL; =20 diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index e558241c73da..3ff9a25eede6 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -751,6 +751,7 @@ static struct domain *__init create_dom0(const module_t= *image, if ( opt_dom0_pvh ) { dom0_cfg.flags |=3D (XEN_DOMCTL_CDF_hvm | + XEN_DOMCTL_CDF_evtchn_upcall | ((hvm_hap_supported() && !opt_dom0_shadow) ? XEN_DOMCTL_CDF_hap : 0)); =20 diff --git a/xen/common/domain.c b/xen/common/domain.c index 28592c7c8486..1ff2603425a3 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -307,7 +307,8 @@ static int sanitise_domain_config(struct xen_domctl_cre= atedomain *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_evtchn_fifo) ) + XEN_DOMCTL_CDF_nested_virt | XEN_DOMCTL_CDF_evtchn_fifo | + XEN_DOMCTL_CDF_evtchn_upcall ) ) { dprintk(XENLOG_INFO, "Unknown CDF flags %#x\n", config->flags); return -EINVAL; diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index f7149c81a7c2..f5fe43a55662 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -72,9 +72,11 @@ struct xen_domctl_createdomain { #define XEN_DOMCTL_CDF_nested_virt (1U << _XEN_DOMCTL_CDF_nested_virt) #define _XEN_DOMCTL_CDF_evtchn_fifo 7 #define XEN_DOMCTL_CDF_evtchn_fifo (1U << _XEN_DOMCTL_CDF_evtchn_fifo) +#define _XEN_DOMCTL_CDF_evtchn_upcall 8 +#define XEN_DOMCTL_CDF_evtchn_upcall (1U << _XEN_DOMCTL_CDF_evtchn_upcall) =20 /* Max XEN_DOMCTL_CDF_* constant. Used for ABI checking. */ -#define XEN_DOMCTL_CDF_MAX XEN_DOMCTL_CDF_evtchn_fifo +#define XEN_DOMCTL_CDF_MAX XEN_DOMCTL_CDF_evtchn_upcall =20 uint32_t flags; =20 --=20 2.20.1 From nobody Thu May 2 05:50:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1606999349; cv=none; d=zohomail.com; s=zohoarc; b=Tj/GTcEDNvz6oPsKkWAm0hJYYQJfpCgR4F5x8EF+SeqRsi8+hYc5gz00OdZXU39jKr94hTI2qngj50+rJ/ExJfSljdEsHRIpRiGtClomvrL6OYeTM3mXSkIRvG445bhLOMXGxclfqr96RpAMtfB22TXJFxlIUmkmpN8ILSO2p60= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606999349; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yJbK+YZtuE0HTqrQU4QFK2ag5uh4t73qAq6ThSOAdyw=; b=ERPQQkN2+iNOwtmfDNAlBvaAR2t18Y7beQqvNJX6Y/XtgvqICdrJgdGnfu0cYAoH9k85hlvu4qyJmTWlsvi9XmHpFwvPGF5YKiYoE0OKBR3tuJ7JDxb+A0T00i66tjBZ184XlAVXFKH26vq4nfXLpUs/oUZ++AkxtItdOTaAA00= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1606999349148666.3844453503876; Thu, 3 Dec 2020 04:42:29 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.43408.78043 (Exim 4.92) (envelope-from ) id 1kknw0-0005yr-W2; Thu, 03 Dec 2020 12:42:09 +0000 Received: by outflank-mailman (output) from mailman id 43408.78043; Thu, 03 Dec 2020 12:42:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kknw0-0005yN-Ja; Thu, 03 Dec 2020 12:42:08 +0000 Received: by outflank-mailman (input) for mailman id 43408; Thu, 03 Dec 2020 12:42:07 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kknvz-0005xT-Qp for xen-devel@lists.xenproject.org; Thu, 03 Dec 2020 12:42:07 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kknvy-00046E-NK; Thu, 03 Dec 2020 12:42:06 +0000 Received: from host86-183-162-145.range86-183.btcentralplus.com ([86.183.162.145] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kknvy-00015A-FT; Thu, 03 Dec 2020 12:42:06 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=yJbK+YZtuE0HTqrQU4QFK2ag5uh4t73qAq6ThSOAdyw=; b=eKUdkgqtJyfjtmonjYjyorCeu3 ABafYeN9MyRFS86S/K/zCCiqsIOQHiW6P/sAbg9E8Ovb0INx+5rtUK53pwHL41yo1/a57jsil11lL GDMQxLmvXId8JpTBXBGj+p9nglTAedkLaKTk5ha/KP2dr/O3CnwMLgLXpoNkFRdfWy9k=; From: Paul Durrant To: xen-devel@lists.xenproject.org Cc: Paul Durrant , Ian Jackson , Wei Liu , Anthony PERARD Subject: [PATCH v5 3/4] libxl: introduce a 'libxl_xen_abi_features' enumeration... Date: Thu, 3 Dec 2020 12:41:58 +0000 Message-Id: <20201203124159.3688-4-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201203124159.3688-1-paul@xen.org> References: <20201203124159.3688-1-paul@xen.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) Content-Type: text/plain; charset="utf-8" From: Paul Durrant ... and bitmaps to enable or disable fetaures. This patch adds a new 'libxl_xen_abi_features' enumeration into the IDL whi= ch specifies features of the Xen ABI which may be optionally enabled or disabl= ed via new 'feature_enable' and 'feature_disable' bitaps added into 'libxl_domain_build_info'. The initially defined features are enabled by default (for relevant architectures) and so the corresponding flags in 'struct xen_domctl_createdomain' are set if they are missing from 'disable_features' rather than if they are present in 'enable_features'. Checks are, however, added to make sure that features are not specifically enabled in cases where they are not supported. NOTE: A subsequent patch will add an option into xl.cfg(5) to control wheth= er Xen ABI features are enabled or disabled. Signed-off-by: Paul Durrant --- Cc: Ian Jackson Cc: Wei Liu Cc: Anthony PERARD v5: - New in v5 --- tools/include/libxl.h | 10 ++++++++++ tools/libs/light/libxl_arm.c | 22 +++++++++++++++------- tools/libs/light/libxl_create.c | 32 +++++++++++++++++++++++++++++++- tools/libs/light/libxl_types.idl | 7 +++++++ tools/libs/light/libxl_x86.c | 14 ++++++++++++-- 5 files changed, 75 insertions(+), 10 deletions(-) diff --git a/tools/include/libxl.h b/tools/include/libxl.h index eaffccb30f37..b328a5621e6f 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -451,6 +451,16 @@ */ #define LIBXL_HAVE_VIRIDIAN_EX_PROCESSOR_MASKS 1 =20 +/* + * LIBXL_HAVE_BUILDINFO_XEN_ABI_FEATURE indicates that the + * libxl_xen_abi_feature enumeration is defined and that + * libxl_domain_build_info has feature_enable and _disable bitmaps + * of the specified width. These bitmaps are used to enable or disable + * features of the Xen ABI (enumerated by the new type) for a domain. + */ +#define LIBXL_HAVE_BUILDINFO_XEN_ABI_FEATURE 1 +#define LIBXL_BUILDINFO_FEATURE_ENABLE_DISABLE_WIDTH 64 + /* * libxl ABI compatibility * diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c index 66e8a065fe67..69676340a661 100644 --- a/tools/libs/light/libxl_arm.c +++ b/tools/libs/light/libxl_arm.c @@ -28,19 +28,27 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, unsigned int i; uint32_t vuart_irq; bool vuart_enabled =3D false; + libxl_domain_build_info *b_info =3D &d_config->b_info; + libxl_xen_abi_feature f =3D LIBXL_XEN_ABI_FEATURE_EVTCHN_UPCALL; + + if (libxl_bitmap_test(&b_info->feature_enable, f)) { + LOG(ERROR, "unsupported Xen ABI feature '%s'", + libxl_xen_abi_feature_to_string(f)); + return ERROR_FAIL; + } =20 /* * If pl011 vuart is enabled then increment the nr_spis to allow alloc= ation * of SPI VIRQ for pl011. */ - if (d_config->b_info.arch_arm.vuart =3D=3D LIBXL_VUART_TYPE_SBSA_UART)= { + if (b_info->arch_arm.vuart =3D=3D LIBXL_VUART_TYPE_SBSA_UART) { nr_spis +=3D (GUEST_VPL011_SPI - 32) + 1; vuart_irq =3D GUEST_VPL011_SPI; vuart_enabled =3D true; } =20 - for (i =3D 0; i < d_config->b_info.num_irqs; i++) { - uint32_t irq =3D d_config->b_info.irqs[i]; + for (i =3D 0; i < b_info->num_irqs; i++) { + uint32_t irq =3D b_info->irqs[i]; uint32_t spi; =20 /* @@ -72,7 +80,7 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, config->arch.nr_spis =3D nr_spis; LOG(DEBUG, " - Allocate %u SPIs", nr_spis); =20 - switch (d_config->b_info.arch_arm.gic_version) { + switch (b_info->arch_arm.gic_version) { case LIBXL_GIC_VERSION_DEFAULT: config->arch.gic_version =3D XEN_DOMCTL_CONFIG_GIC_NATIVE; break; @@ -84,11 +92,11 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, break; default: LOG(ERROR, "Unknown GIC version %d", - d_config->b_info.arch_arm.gic_version); + b_info->arch_arm.gic_version); return ERROR_FAIL; } =20 - switch (d_config->b_info.tee) { + switch (b_info->tee) { case LIBXL_TEE_TYPE_NONE: config->arch.tee_type =3D XEN_DOMCTL_CONFIG_TEE_NONE; break; @@ -97,7 +105,7 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, break; default: LOG(ERROR, "Unknown TEE type %d", - d_config->b_info.tee); + b_info->tee); return ERROR_FAIL; } =20 diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_creat= e.c index 3ca9f00d6d83..8cf7fd5f6d1b 100644 --- a/tools/libs/light/libxl_create.c +++ b/tools/libs/light/libxl_create.c @@ -587,6 +587,7 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_conf= ig *d_config, struct xs_permissions noperm[1]; xs_transaction_t t =3D 0; libxl_vminfo *vm_list; + libxl_xen_abi_feature f; =20 /* convenience aliases */ libxl_domain_create_info *info =3D &d_config->c_info; @@ -607,9 +608,38 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_con= fig *d_config, .max_evtchn_port =3D b_info->event_channels, .max_grant_frames =3D b_info->max_grant_frames, .max_maptrack_frames =3D b_info->max_maptrack_frames, - .flags =3D XEN_DOMCTL_CDF_evtchn_fifo, }; =20 + libxl_for_each_set_bit(f, b_info->feature_enable) { + if (!libxl_xen_abi_feature_to_string(f)) { /* check validity */ + LOGED(ERROR, *domid, "unknown Xen ABI feature enabled"); + rc =3D ERROR_FAIL; + goto out; + } + if (libxl_bitmap_test(&b_info->feature_disable, f)) { + LOGED(ERROR, *domid, "Xen ABI feature '%s' both enabled an= d disabled", + libxl_xen_abi_feature_to_string(f)); + rc =3D ERROR_FAIL; + goto out; + } + LOGD(DETAIL, *domid, "enable feature: '%s'", + libxl_xen_abi_feature_to_string(f)); + } + + libxl_for_each_set_bit(f, b_info->feature_disable) { + if (!libxl_xen_abi_feature_to_string(f)) { /* check validity */ + LOGED(ERROR, *domid, "unknown Xen ABI feature disabled"); + rc =3D ERROR_FAIL; + goto out; + } + LOGD(DETAIL, *domid, "disable feature: '%s'", + libxl_xen_abi_feature_to_string(f)); + } + + if (!libxl_bitmap_test(&b_info->feature_disable, + LIBXL_XEN_ABI_FEATURE_EVTCHN_FIFO)) + create.flags |=3D XEN_DOMCTL_CDF_evtchn_fifo; + if (info->type !=3D LIBXL_DOMAIN_TYPE_PV) { create.flags |=3D XEN_DOMCTL_CDF_hvm; =20 diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_type= s.idl index 05324736b744..3c50724b64cd 100644 --- a/tools/libs/light/libxl_types.idl +++ b/tools/libs/light/libxl_types.idl @@ -477,6 +477,11 @@ libxl_tee_type =3D Enumeration("tee_type", [ (1, "optee") ], init_val =3D "LIBXL_TEE_TYPE_NONE") =20 +libxl_xen_abi_feature =3D Enumeration("xen_abi_feature", [ + (0, "evtchn_fifo"), + (1, "evtchn_upcall") + ]) + libxl_rdm_reserve =3D Struct("rdm_reserve", [ ("strategy", libxl_rdm_reserve_strategy), ("policy", libxl_rdm_reserve_policy), @@ -559,6 +564,8 @@ libxl_domain_build_info =3D Struct("domain_build_info",[ ("apic", libxl_defbool), ("dm_restrict", libxl_defbool), ("tee", libxl_tee_type), + ("feature_enable", libxl_bitmap), + ("feature_disable", libxl_bitmap), ("u", KeyedUnion(None, libxl_domain_type, "type", [("hvm", Struct(None, [("firmware", string), ("bios", libxl_bios_typ= e), diff --git a/tools/libs/light/libxl_x86.c b/tools/libs/light/libxl_x86.c index f7217b422404..39a9d3cbf9f8 100644 --- a/tools/libs/light/libxl_x86.c +++ b/tools/libs/light/libxl_x86.c @@ -6,9 +6,19 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, struct xen_domctl_createdomain *conf= ig) { libxl_domain_create_info *info =3D &d_config->c_info; + libxl_domain_build_info *b_info =3D &d_config->b_info; + libxl_xen_abi_feature f =3D LIBXL_XEN_ABI_FEATURE_EVTCHN_UPCALL; =20 - if (info->type =3D=3D LIBXL_DOMAIN_TYPE_HVM) - config->flags |=3D XEN_DOMCTL_CDF_evtchn_upcall; + if (info->type !=3D LIBXL_DOMAIN_TYPE_HVM && + libxl_bitmap_test(&b_info->feature_enable, f)) { + LOG(ERROR, "unsupported Xen ABI feature '%s'", + libxl_xen_abi_feature_to_string(f)); + return ERROR_FAIL; + } + + if (info->type =3D=3D LIBXL_DOMAIN_TYPE_HVM && + !libxl_bitmap_test(&b_info->feature_disable, f)) + config->flags |=3D XEN_DOMCTL_CDF_evtchn_upcall; =20 switch(info->type) { case LIBXL_DOMAIN_TYPE_HVM: --=20 2.20.1 From nobody Thu May 2 05:50:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1606999348; cv=none; d=zohomail.com; s=zohoarc; b=KOUBDpb/x2FqCbKULPrQtE1TSM+B6w1xhIUnhMLuY5+rDqlgohJydvUxx1Dl+NZW8lx2gi7rn12XhUS6BZ/m50H8hxI2t71a8PH7uiB/hVlhM6WGqdihzP9R2n1L1uBoykytpQS7hQewKF7Vc+IhFYQ5q6pjxN9mN5Deud73ZIE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606999348; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CGl8BZR/+SpIqigLmobGcANzj6zAGuP+UKJDCJC+Ltg=; b=b5zrIC4PLGX9YzDh+SiyErK9tVuapD0MzrBPfjkTXlChH96SK7OXkZldN1pGzM0yOsDO7WG5it6orM4L+PQXHeGo3v5wXxPb72dY3nkGP8wrx6TbNPGjjxolossb553Tpp3uHULfM1WA0HvNxk72iAdfp1Ysw8yQqqtgaC4chIA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1606999348398222.88869461962258; Thu, 3 Dec 2020 04:42:28 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.43409.78058 (Exim 4.92) (envelope-from ) id 1kknw2-00062D-B8; Thu, 03 Dec 2020 12:42:10 +0000 Received: by outflank-mailman (output) from mailman id 43409.78058; Thu, 03 Dec 2020 12:42:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kknw2-000621-7d; Thu, 03 Dec 2020 12:42:10 +0000 Received: by outflank-mailman (input) for mailman id 43409; Thu, 03 Dec 2020 12:42:08 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kknw0-0005yS-JC for xen-devel@lists.xenproject.org; Thu, 03 Dec 2020 12:42:08 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kknvz-00046M-Nc; Thu, 03 Dec 2020 12:42:07 +0000 Received: from host86-183-162-145.range86-183.btcentralplus.com ([86.183.162.145] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kknvz-00015A-Fm; Thu, 03 Dec 2020 12:42:07 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=CGl8BZR/+SpIqigLmobGcANzj6zAGuP+UKJDCJC+Ltg=; b=SbbI6XX5sX2gwuUxhWLZLT1pAX 4ZL8iL+x0MoLHveAY1p0FQnICSlV/ZcM/nIq3r996pGP3fUHPfGg0mJ7ieDkLcD8k9KmOrqQi6zyN I4gxHGQd/gRl5BZpvbYI+vxBZKnK8rPcIE4sGGTHyZI5PEaumxUs1Gt4GFyU53cZHGhs=; From: Paul Durrant To: xen-devel@lists.xenproject.org Cc: Paul Durrant , Ian Jackson , Wei Liu , Anthony PERARD Subject: [PATCH v5 4/4] xl: introduce a 'xen-abi-features' option... Date: Thu, 3 Dec 2020 12:41:59 +0000 Message-Id: <20201203124159.3688-5-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201203124159.3688-1-paul@xen.org> References: <20201203124159.3688-1-paul@xen.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) Content-Type: text/plain; charset="utf-8" From: Paul Durrant ... to control which features of the Xen ABI are enabled in 'libxl_domain_build_info', and hence exposed to the guest. Signed-off-by: Paul Durrant --- Cc: Ian Jackson Cc: Wei Liu Cc: Anthony PERARD v5: - New in v5 --- docs/man/xl.cfg.5.pod.in | 50 ++++++++++++++++++++++++++++++++++++++++ tools/xl/xl_parse.c | 50 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 98 insertions(+), 2 deletions(-) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index 3f0f8de1e988..b42ab8ba9f60 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -1649,6 +1649,56 @@ This feature is a B. =20 =3Dback =20 +=3Ditem B + +The features of the Xen ABI exposed to the guest. The following features +may be specified: + +=3Dover 4 + +=3Ditem B + +A new event channel ABI was introduced in Xen 4.4. Moving a guest from an +earlier Xen to Xen 4.4 onwards may expose bugs in the guest support for +this ABI. Disabling this feature hides the ABI from the guest and hence +may be used as a workaround for such bugs. + +The festure is enabled by default. + +=3Ditem B + +B. A new hypercall to specify per-VCPU interrupt vectors to = use +for event channel upcalls in HVM guests was added in Xen 4.6. Moving a gue= st +from an earlier Xen to Xen 4.6 onwards may expose bugs in the guest support +for this hypercall. Disabling this feature hides the hypercall from the +guest and hence may be used as a workaround for such bugs. + +The festure is enabled by default for B guests. Note that it is +considered an error to enable this feature for B or B guests. + +=3Ditem B + +This is a special value that enables all available features. + +=3Dback + +Features can be disabled by prefixing the name with '!'. So, for example, +to enable all features except B, specify: + +=3Dover 4 + +B + +=3Dback + +Or, to simply enable default features except B, specify: + +=3Dover 4 + +B + +=3Dback + =3Dback =20 =3Dhead2 Paravirtualised (PV) Guest Specific Options diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index cae8eb679c5a..566e09f938f4 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -1216,8 +1216,9 @@ void parse_config_data(const char *config_source, XLU_ConfigList *cpus, *vbds, *nics, *pcis, *cvfbs, *cpuids, *vtpms, *usbctrls, *usbdevs, *p9devs, *vdispls, *pvcallsifs_dev= s; XLU_ConfigList *channels, *ioports, *irqs, *iomem, *viridian, *dtdevs, - *mca_caps; - int num_ioports, num_irqs, num_iomem, num_cpus, num_viridian, num_mca_= caps; + *mca_caps, *features; + int num_ioports, num_irqs, num_iomem, num_cpus, num_viridian, num_mca_= caps, + num_features; int pci_power_mgmt =3D 0; int pci_msitranslate =3D 0; int pci_permissive =3D 0; @@ -2737,6 +2738,51 @@ skip_usbdev: xlu_cfg_get_defbool(config, "xend_suspend_evtchn_compat", &c_info->xend_suspend_evtchn_compat, 0); =20 + switch (xlu_cfg_get_list(config, "xen_abi_features", + &features, &num_features, 1)) + { + case 0: /* Success */ + if (num_features) { + libxl_bitmap_alloc(ctx, &b_info->feature_enable, + LIBXL_BUILDINFO_FEATURE_ENABLE_DISABLE_WIDT= H); + libxl_bitmap_alloc(ctx, &b_info->feature_disable, + LIBXL_BUILDINFO_FEATURE_ENABLE_DISABLE_WIDT= H); + } + for (i =3D 0; i < num_features; i++) { + if (strcmp(buf, "all") =3D=3D 0) + libxl_bitmap_set_any(&b_info->feature_enable); + else { + libxl_bitmap *s =3D &b_info->feature_enable; + libxl_bitmap *r =3D &b_info->feature_disable; + libxl_xen_abi_feature f; + + buf =3D xlu_cfg_get_listitem(features, i); + + if (*buf =3D=3D '!') { + s =3D &b_info->feature_disable; + r =3D &b_info->feature_enable; + buf++; + } + + e =3D libxl_xen_abi_feature_from_string(buf, &f); + if (e) { + fprintf(stderr, + "xl: Unknown Xen ABI feature '%s'\n", + buf); + exit(-ERROR_FAIL); + } + + libxl_bitmap_set(s, f); + libxl_bitmap_reset(r, f); + } + } + break; + case ESRCH: break; /* Option not present */ + default: + fprintf(stderr,"xl: Unable to parse Xen ABI features.\n"); + exit(-ERROR_FAIL); + } + xlu_cfg_destroy(config); } =20 --=20 2.20.1