From nobody Wed May 1 02:59:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587141257; cv=none; d=zohomail.com; s=zohoarc; b=XYiTdHzO7GSPJla71TYNhkkDi4aQPF1OYZJHHWv2fWGmjFxGpxAhi5QwM7h+kiJu4v8YdjFroJZ8mxcWw4HsxdWOLWv3qCla5ckXBELpJKric3LSeYAXne0+gjF+vq3qcN384G+vJYVAPznuFd1iniPAZ39M8ICCK1D2rs5U1/Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587141257; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=T6hawlBrCPno0iZPoldPkUAX2qEz8wEBxbooJrK9/pA=; b=Qtc8Agr67ciecY2FlErHdbyrzpuyd1uftL1eO/oCEzDNXpMo0d1gtJDY7LkvPYbWATAiDIDYZpujZW83A69fK+JZEk2XsEY6EAA846crBuZg8kqhI1s3K2osa60BKtFXxM1Yq9SDRE5nCqrVeMZ31cnOivuaTqImKq8veZuViS4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 158714125709630.060742336776002; Fri, 17 Apr 2020 09:34:17 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-285-CygthgEBM6KAhZPqPwFZXQ-1; Fri, 17 Apr 2020 12:34:13 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6E9DC1005509; Fri, 17 Apr 2020 16:34:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F066660BF7; Fri, 17 Apr 2020 16:34:06 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 021DC93516; Fri, 17 Apr 2020 16:34:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03HGY3rt012775 for ; Fri, 17 Apr 2020 12:34:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id AA8532166B2F; Fri, 17 Apr 2020 16:34:03 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A63242166B2C for ; Fri, 17 Apr 2020 16:34:00 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A4E758007D4 for ; Fri, 17 Apr 2020 16:34:00 +0000 (UTC) Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-6-GyEkqRatOJGC_ZsGyuIFLg-1; Fri, 17 Apr 2020 12:33:58 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id A76515C008E; Fri, 17 Apr 2020 12:33:57 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Fri, 17 Apr 2020 12:33:57 -0400 Received: from localhost.localdomain (ip5b412221.dynamic.kabel-deutschland.de [91.65.34.33]) by mail.messagingengine.com (Postfix) with ESMTPA id D3A183280068; Fri, 17 Apr 2020 12:33:56 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587141255; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=T6hawlBrCPno0iZPoldPkUAX2qEz8wEBxbooJrK9/pA=; b=KXmVfb2BEJ2U550ErTpfn3/JT74N+xevTqNM8KXT0eAKuiAgmhsfwL/SoA8L5rcHAhxkdB EDU4wbRe96+CTiT1m+geh0ub3D9bQpJcjrU4JSFoSSIO5pbq59RobsnDKen7g8Fi/bvHyl fY1k+qsFp1+w+Y+ij3+lcE2xmEAxpdI= X-MC-Unique: CygthgEBM6KAhZPqPwFZXQ-1 X-MC-Unique: GyEkqRatOJGC_ZsGyuIFLg-1 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrfeejgddutddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffogggtohfgsehtkeertdertdejnecuhfhrohhmpeforghrvghk ucforghrtgiihihkohifshhkihdqifpkrhgvtghkihcuoehmrghrmhgrrhgvkhesihhnvh hishhisghlvghthhhinhhgshhlrggsrdgtohhmqeenucffohhmrghinhephhhtmhhlrdhi nhenucfkphepledurdeihedrfeegrdeffeenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehmrghrmhgrrhgvkhesihhnvhhishhisghlvghthhhi nhhgshhlrggsrdgtohhm X-ME-Proxy: From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= To: libvir-list@redhat.com Subject: [PATCH] Add 'permissive' option for PCI devices Date: Fri, 17 Apr 2020 18:33:45 +0200 Message-Id: <20200417163345.1314-1-marmarek@invisiblethingslab.com> MIME-Version: 1.0 Organization: Invisible Things Lab X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 03HGY3rt012775 X-loop: libvir-list@redhat.com Cc: Simon Gaiser X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Simon Gaiser By setting the permissive flag the guest access to the PCI config space is not filtered. This might be a security risk, but it's required for some devices and the IOMMU and interrupt remapping should (mostly?) contain it. Signed-off-by: Simon Gaiser Signed-off-by: Marek Marczykowski-G=C3=B3recki --- docs/formatdomain.html.in | 3 +++ docs/schemas/domaincommon.rng | 5 +++++ src/conf/domain_conf.c | 12 ++++++++++++ src/conf/domain_conf.h | 1 + src/libxl/libxl_conf.c | 1 + 5 files changed, 22 insertions(+) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 6f43976815..79a5176ccd 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5051,6 +5051,9 @@ or hot-plugging the device and virNodeDeviceReAttach (or virsh nodedev-reattach) after hot-unplug or stopping the guest. + When permissive is "yes" the pci config space acc= ess + will not be filtered. This might be a security issue. The defa= ult + is "no".
scsi
For SCSI devices, user is responsible to make sure the device diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 65d6580434..9389eec3d8 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3064,6 +3064,11 @@ + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8e8146374c..607cae61d4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8419,6 +8419,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, virDomainHostdevSubsysSCSIVHostPtr scsihostsrc =3D &def->source.subsys= .u.scsi_host; virDomainHostdevSubsysMediatedDevPtr mdevsrc =3D &def->source.subsys.u= .mdev; g_autofree char *managed =3D NULL; + g_autofree char *permissive =3D NULL; g_autofree char *sgio =3D NULL; g_autofree char *rawio =3D NULL; g_autofree char *backendStr =3D NULL; @@ -8434,6 +8435,11 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, if ((managed =3D virXMLPropString(node, "managed")) !=3D NULL) ignore_value(virStringParseYesNo(managed, &def->managed)); =20 + if ((permissive =3D virXMLPropString(node, "permissive")) !=3D NULL) { + if (STREQ(permissive, "yes")) + def->permissive =3D true; + } + sgio =3D virXMLPropString(node, "sgio"); rawio =3D virXMLPropString(node, "rawio"); model =3D virXMLPropString(node, "model"); @@ -25942,6 +25948,8 @@ virDomainActualNetDefFormat(virBufferPtr buf, virDomainHostdevDefPtr hostdef =3D virDomainNetGetActualHostdev(de= f); if (hostdef && hostdef->managed) virBufferAddLit(buf, " managed=3D'yes'"); + if (hostdef && hostdef->permissive) + virBufferAddLit(buf, " permissive=3D'yes'"); } if (def->trustGuestRxFilters) virBufferAsprintf(buf, " trustGuestRxFilters=3D'%s'", @@ -26130,6 +26138,8 @@ virDomainNetDefFormat(virBufferPtr buf, virBufferAsprintf(buf, "managed) virBufferAddLit(buf, " managed=3D'yes'"); + if (hostdef && hostdef->permissive) + virBufferAddLit(buf, " permissive=3D'yes'"); if (def->trustGuestRxFilters) virBufferAsprintf(buf, " trustGuestRxFilters=3D'%s'", virTristateBoolTypeToString(def->trustGuestRxFil= ters)); @@ -27914,6 +27924,8 @@ virDomainHostdevDefFormat(virBufferPtr buf, if (def->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) { virBufferAsprintf(buf, " managed=3D'%s'", def->managed ? "yes" : "no"); + if (def->permissive) + virBufferAddLit(buf, " permissive=3D'yes'"); =20 if (def->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_= SCSI && scsisrc->sgio) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index aad3f82db7..b81a3ce901 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -345,6 +345,7 @@ struct _virDomainHostdevDef { bool missing; bool readonly; bool shareable; + bool permissive; union { virDomainHostdevSubsys subsys; virDomainHostdevCaps caps; diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index b3f67f817a..55f2a09e3e 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -2249,6 +2249,7 @@ libxlMakePCI(virDomainHostdevDefPtr hostdev, libxl_de= vice_pci *pcidev) pcidev->bus =3D pcisrc->addr.bus; pcidev->dev =3D pcisrc->addr.slot; pcidev->func =3D pcisrc->addr.function; + pcidev->permissive =3D hostdev->permissive; =20 return 0; } --=20 2.21.1