From nobody Thu May 2 21:41:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1598279375; cv=none; d=zohomail.com; s=zohoarc; b=ZFfc2PGVQsNja4jXRLjTq3o2gf/FSikUdnQixaHR60P2qFh0cIonKpiJcw7qLu8SHkrc986uvx05YDbKvp36SqgVZh2+Idr5H88stITuZIUUGatZPZv8xJ5SBztBQqPYJq9i29AupKgpqvs7mzikaDRDaFPMJDiJF/a6N9+O/N0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598279375; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=a4VLlGZoxxdcHk9SHKmo4LOmMGhED3ieIovOZsdK35s=; b=F/Y6efMOEMufdZa7uhZl7ySH+9i1i1WtPC/5QkLjkadwNf3nF2q154HK4VMkVbJ3TNW6axTBJDz0YSj1Yxi2Ix5cjhef2nPU0q9Gyaix1C4OsB3KjknD+//RPcWLTRMIvXP40FrtR01hClO/e+nKwJLB4MP+GyowzdpHOXfpzEQ= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1598279375833600.366156589919; Mon, 24 Aug 2020 07:29:35 -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-327-WLcV3O7GMg2XrVpEm507DQ-1; Mon, 24 Aug 2020 10:29:30 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7E63310ABDAD; Mon, 24 Aug 2020 14:29:24 +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 5939F1055A45; Mon, 24 Aug 2020 14:29:24 +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 C4709668F7; Mon, 24 Aug 2020 14:29:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 07OERatx018153 for ; Mon, 24 Aug 2020 10:27:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 607E9202279A; Mon, 24 Aug 2020 14:27:36 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5AB41203B867 for ; Mon, 24 Aug 2020 14:27:32 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (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 7C5F31815DCA for ; Mon, 24 Aug 2020 14:27:32 +0000 (UTC) Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [51.163.158.102]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-301-0vXyTThVN9Wjg799_NXiGQ-1; Mon, 24 Aug 2020 10:27:30 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2112.outbound.protection.outlook.com [104.47.18.112]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-17-YonpYdUyOR6MrWJw4n2r6Q-1; Mon, 24 Aug 2020 16:27:28 +0200 Received: from VI1PR0401MB2429.eurprd04.prod.outlook.com (2603:10a6:800:2c::13) by VI1PR0402MB3662.eurprd04.prod.outlook.com (2603:10a6:803:1c::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.26; Mon, 24 Aug 2020 14:27:27 +0000 Received: from VI1PR0401MB2429.eurprd04.prod.outlook.com ([fe80::a0ba:4965:e484:d014]) by VI1PR0401MB2429.eurprd04.prod.outlook.com ([fe80::a0ba:4965:e484:d014%9]) with mapi id 15.20.3305.026; Mon, 24 Aug 2020 14:27:27 +0000 Received: from linux-tbji.devlab.prv.suse.com (192.150.153.236) by AM0PR06CA0144.eurprd06.prod.outlook.com (2603:10a6:208:ab::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.25 via Frontend Transport; Mon, 24 Aug 2020 14:27:24 +0000 X-MC-Unique: WLcV3O7GMg2XrVpEm507DQ-1 X-MC-Unique: 0vXyTThVN9Wjg799_NXiGQ-1 X-MC-Unique: YonpYdUyOR6MrWJw4n2r6Q-1 From: Jim Fehlig To: libvir-list@redhat.com Subject: [PATCH V4 1/3] Xen: Add writeFiltering option for PCI devices Date: Mon, 24 Aug 2020 08:26:55 -0600 Message-ID: <20200824142657.16682-2-jfehlig@suse.com> In-Reply-To: <20200824142657.16682-1-jfehlig@suse.com> References: <20200824142657.16682-1-jfehlig@suse.com> X-ClientProxiedBy: AM0PR06CA0144.eurprd06.prod.outlook.com (2603:10a6:208:ab::49) To VI1PR0401MB2429.eurprd04.prod.outlook.com (2603:10a6:800:2c::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Originating-IP: [192.150.153.236] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5b036b08-2f76-4253-fb51-08d84839d2ca X-MS-TrafficTypeDiagnostic: VI1PR0402MB3662: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:983; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DLQTj5VB2hnHrSXl7Utd1b0W3y7th7QgWR8OgWL30F6lxSWKcEhkakLgRHp7zoYpGDJy775wq9i5uwtaioGxQF+br1yZ1ZTRdvkH+WWHzg4FqQkBR71lZ80K9R2VrNeV0YLwPJqeXr0A8Bm91hSdtAGDq4Afc3F13IQAS/GwzFspWNh/Dtm3ZaJ/fElrZGk1rImaim94nTR0WDAd+UvIUeL2PYESJE0RLdIxoF2PjlTgGw4whh7JGo3FvaHu/6g7Ri3aizjOmHOf8CfzhSaEvSfOvk53vhX5ncK2eyXhOXr6/7sBJ+NCcWx/kTZ11TUJ X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR0401MB2429.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(376002)(366004)(346002)(396003)(136003)(36756003)(66574015)(5660300002)(86362001)(83380400001)(4326008)(52116002)(7696005)(8676002)(6916009)(2616005)(26005)(186003)(956004)(66946007)(66476007)(66556008)(1076003)(8936002)(6666004)(54906003)(6486002)(478600001)(2906002)(316002)(16526019); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 1r736PT7JhX9ABfajvJkPOxDzPncryKJISXH2MLvK3fr2hNdqgz+eBnKJbNJ9kWVT/S1T5Dw8QBuWKx7xQAISVYA/YQd55YYUNGg0mhToWBUffKzyAqLWgd2UDnVGkpH7ymbfBAGv/MS3qRvJm4w4RJ68sEufVOUfnKQm7BfHeY8DIlb7sc8Bz2fcbSp4iS1TYucKQNDfB9A0nHg4KjE0pURgPAENPFv/fdXajy2AIqWmd1QuZaeRvkBZF72eL0Klzcrpg7x56fcQMq3a43Bs457B4OKte59W40O2CFOkMM2TZz4+aL57UL7RAMunuPNs4/cnUukC5uPnUrC2V7UHadhm9ivqFaEzJl6MQwQstTNrq7f3fmkbhHqD35T9ujJVOB+hK0cQhUCQa0Ny4gLB9iKri95NDQjY2HzK1HMC+uIeZZVPTRwZstj0dRqWvO550mzrbqrGT8fKBb87YTzcOjWawnS3HO2va3S18qJl7bnUgM+Zyxx7x38dqFlSIZe1mHKOWUv9VHm5N3NY+n2xmML7TiK7k7JOw/HOJ8hNDv0yQOj4REJzVQRSd770cwu3KhoAzv8K10O05W1a4TabPjgYCoSrTgwPALD1wbugmtOA+LiTaxcUHOjJda2iiSupDJsMQsE/2JSZBRUsCpeIQ== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b036b08-2f76-4253-fb51-08d84839d2ca X-MS-Exchange-CrossTenant-AuthSource: VI1PR0401MB2429.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2020 14:27:27.1673 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Pua2dtyszPVUDeCSZovxtzxKvlilErMelPVlwJOqns5wdKiBNdvw2ORJwpcqLwHnOA6lxMgEf4XWRheWIhWyKA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3662 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false; X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 07OERatx018153 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.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.004 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable By default Xen only allows guests to write "known safe" values into PCI configuration space, yet many devices require writes to other areas of the configuration space in order to operate properly. To allow writing any values Xen supports the 'permissive' setting, see xl.cfg(5) man page. This change models Xen's permissive setting by adding a writeFiltering attribute on the element of a PCI hostdev. When writeFiltering is set to 'no', the Xen permissive setting will be enabled and guests will be able to write any values into the device's configuration space. The permissive setting remains disabled in the absense of the writeFiltering attribute, of if it is explicitly set to 'yes'. Signed-off-by: Jim Fehlig Signed-off-by: Simon Gaiser Signed-off-by: Marek Marczykowski-G=C3=B3recki Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/formatdomain.rst | 7 ++++++- docs/schemas/domaincommon.rng | 5 +++++ src/conf/domain_conf.c | 14 ++++++++++++++ src/conf/domain_conf.h | 1 + src/libxl/libxl_conf.c | 1 + src/qemu/qemu_validate.c | 7 +++++++ tests/libxlxml2domconfigdata/moredevs-hvm.json | 6 ++++++ tests/libxlxml2domconfigdata/moredevs-hvm.xml | 5 +++++ 8 files changed, 45 insertions(+), 1 deletion(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 8365fc8bbb..a7ab690b96 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -3733,7 +3733,7 @@ or: ... - +
@@ -3899,6 +3899,11 @@ or: =20 ``pci`` PCI devices can only be described by their ``address``. + :since:`Since 6.7.0 (Xen only)` , the ``source`` element of a PCI de= vice + may contain the ``writeFiltering`` attribute to control write access= to + the PCI configuration space. By default Xen only allows writes of kn= own + safe values to the configuration space. Setting ``writeFiltering=3D'= no'`` + will allow all writes to the device's PCI configuration space. ``scsi`` SCSI devices are described by both the ``adapter`` and ``address`` elements. The ``address`` element includes a ``bus`` attribute (a 2-= digit diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 0d0dcbc5ce..b4eb7486b9 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4982,6 +4982,11 @@ + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8e7981bf25..bba31cfddb 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8095,8 +8095,18 @@ virDomainHostdevSubsysPCIDefParseXML(xmlNodePtr node, virDomainHostdevDefPtr def, unsigned int flags) { + g_autofree char *filtering =3D NULL; xmlNodePtr cur; =20 + if ((filtering =3D virXMLPropString(node, "writeFiltering"))) { + if ((def->writeFiltering =3D virTristateBoolTypeFromString(filteri= ng)) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("unknown pci writeFiltering setting '%s'"), + filtering); + return -1; + } + } + cur =3D node->children; while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE) { @@ -26119,6 +26129,10 @@ virDomainHostdevDefFormatSubsysPCI(virBufferPtr bu= f, g_auto(virBuffer) origstatesChildBuf =3D VIR_BUFFER_INIT_CHILD(&source= ChildBuf); virDomainHostdevSubsysPCIPtr pcisrc =3D &def->source.subsys.u.pci; =20 + if (def->writeFiltering !=3D VIR_TRISTATE_BOOL_ABSENT) + virBufferAsprintf(&sourceAttrBuf, " writeFiltering=3D'%s'", + virTristateBoolTypeToString(def->writeFilter= ing)); + if (pcisrc->backend !=3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT) { const char *backend =3D virDomainHostdevSubsysPCIBackendTypeToStri= ng(pcisrc->backend); =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 68be32614c..2f17053198 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; + virTristateBool writeFiltering; union { virDomainHostdevSubsys subsys; virDomainHostdevCaps caps; diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 7c2c015015..0056f6fe66 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -2279,6 +2279,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->writeFiltering =3D=3D VIR_TRISTATE_BOO= L_NO; =20 return 0; } diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 488f258d00..97a9d25570 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -1833,6 +1833,13 @@ qemuValidateDomainDeviceDefHostdev(const virDomainHo= stdevDef *hostdev, return -1; } } + + if (hostdev->writeFiltering !=3D VIR_TRISTATE_BOOL_ABSENT) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Write filtering of PCI device configurat= ion " + "space is not supported by qemu")); + return -1; + } break; =20 case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST: diff --git a/tests/libxlxml2domconfigdata/moredevs-hvm.json b/tests/libxlxm= l2domconfigdata/moredevs-hvm.json index 7bfd68bd67..474aa2cef6 100644 --- a/tests/libxlxml2domconfigdata/moredevs-hvm.json +++ b/tests/libxlxml2domconfigdata/moredevs-hvm.json @@ -88,6 +88,12 @@ "dev": 16, "bus": 10, "rdm_policy": "invalid" + }, + { + "dev": 8, + "bus": 10, + "permissive": true, + "rdm_policy": "invalid" } ], "vfbs": [ diff --git a/tests/libxlxml2domconfigdata/moredevs-hvm.xml b/tests/libxlxml= 2domconfigdata/moredevs-hvm.xml index f7eb09fa3b..89ad80631d 100644 --- a/tests/libxlxml2domconfigdata/moredevs-hvm.xml +++ b/tests/libxlxml2domconfigdata/moredevs-hvm.xml @@ -48,6 +48,11 @@
+ + +
+ +