From nobody Sun May 5 11:29:16 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=1597441455; cv=none; d=zohomail.com; s=zohoarc; b=aZx3B518AwOPL1OfeiBAsGZFL2d3F/z/Bv+BMU+jKQgnxpk2jAXVG7Ft1T/ogx2n6AU6LcmHTdm4L19XhTvz3RoxKbtnqck81yPgMO2/TOVwH7NPzbsK53N0yWLZJ79DNsf0UAZApMLkryOPjftjaZL3mIxyV21XzbM8XerbHIw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597441455; 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=SwxYmyipu7ZqF1pbZwiEYTb2Esd2stgmPhGrN3fWfTA=; b=lFGo6GhfDei2AHCAeAdqxCYd5hpLsg8LyUzPDh1XYmQ1vKiX1EwSfDHSfl93H8Y4zVwjNGZf+NwOLjgpQjqDQ53OlcrPaeLHktrsGsVEXySq9plcWZkud+UgsQ0jIbp7J1V2Qt81wWqa0oU0gd84r1kGIvnNG+P4jONV5k6wRHg= 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 1597441455478133.99790187473172; Fri, 14 Aug 2020 14:44:15 -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-523-mhSM6QPbNca6MaYyz5RzNw-1; Fri, 14 Aug 2020 17:44:12 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9D424108E; Fri, 14 Aug 2020 21:44:05 +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 4BF411992D; Fri, 14 Aug 2020 21:44:05 +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 2A9984EDB7; Fri, 14 Aug 2020 21:44:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 07ELhw5W002228 for ; Fri, 14 Aug 2020 17:43:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id C87F1100335C; Fri, 14 Aug 2020 21:43:58 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C359B100402A for ; Fri, 14 Aug 2020 21:43:55 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.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 7DBEF101A53F for ; Fri, 14 Aug 2020 21:43:55 +0000 (UTC) Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [62.140.7.102]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-135-6JR76x78P9awcVwigmPIlA-1; Fri, 14 Aug 2020 17:43:53 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2176.outbound.protection.outlook.com [104.47.17.176]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-14-u0fIGREOPzC9-UGu9Q8NDQ-2; Fri, 14 Aug 2020 23:43:51 +0200 Received: from VI1PR0401MB2429.eurprd04.prod.outlook.com (2603:10a6:800:2c::13) by VI1PR0402MB3456.eurprd04.prod.outlook.com (2603:10a6:803:7::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.18; Fri, 14 Aug 2020 21:43:50 +0000 Received: from VI1PR0401MB2429.eurprd04.prod.outlook.com ([fe80::c13d:6e8a:85f9:1bf5]) by VI1PR0401MB2429.eurprd04.prod.outlook.com ([fe80::c13d:6e8a:85f9:1bf5%6]) with mapi id 15.20.3283.015; Fri, 14 Aug 2020 21:43:50 +0000 Received: from linux-tbji.devlab.prv.suse.com (192.150.153.236) by AM0PR01CA0137.eurprd01.prod.exchangelabs.com (2603:10a6:208:168::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.16 via Frontend Transport; Fri, 14 Aug 2020 21:43:48 +0000 X-MC-Unique: mhSM6QPbNca6MaYyz5RzNw-1 X-MC-Unique: 6JR76x78P9awcVwigmPIlA-1 X-MC-Unique: u0fIGREOPzC9-UGu9Q8NDQ-2 From: Jim Fehlig To: libvir-list@redhat.com Subject: [PATCH V3 1/3] Xen: Add writeFiltering option for PCI devices Date: Fri, 14 Aug 2020 15:43:27 -0600 Message-ID: <20200814214329.32535-2-jfehlig@suse.com> In-Reply-To: <20200814214329.32535-1-jfehlig@suse.com> References: <20200814214329.32535-1-jfehlig@suse.com> X-ClientProxiedBy: AM0PR01CA0137.eurprd01.prod.exchangelabs.com (2603:10a6:208:168::42) 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: ee8d4623-79d9-4048-b6f0-08d8409b2130 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3456: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:849; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: goGIY5Qun6cCtkfaqWx5u1UMy4AjR7lxWzRjDyDUXOBrw8LbqZEMSL1NEpQ11QSh2LLrM8jnHpC0JKtmQez6kd6tr5cbScj+AMh/28a1CiRdAAHVvI37xKtkOD86uJaXpNap/yl1/Oz0JVuBOb0TMgeteyVh1TlXAkVLZuIPT54Swka618OuIdXzMhkYPQwkX17fbFK2kVsdinPGA34Qic7Oj5lCKziXGXgoOAb2khgWkTxps2g9+TTqVCs4wRImNAi7IV70v8KPyW5uB6BFPoNjHXx19osJ1Z7+kwEVxllB8aAgT4hxzUHBdTiuU9mO 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:(346002)(396003)(136003)(376002)(39860400002)(366004)(2616005)(4326008)(478600001)(83380400001)(186003)(956004)(1076003)(8676002)(6486002)(52116002)(7696005)(36756003)(66574015)(66476007)(66556008)(6666004)(86362001)(26005)(66946007)(316002)(16526019)(2906002)(5660300002)(54906003)(8936002)(6916009); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: YFibnW6hCWqTf78X2xzhruZQUPXzlvSwoTC8qwW9Cc9EgfzNwDPvxQxmgjPC86qvP9Ug1U0PCrRqCyH290bgHKEq/93vC3IfbzDHNBf04OBH5KcWmRPuq1WSVPkHtj+jqOpx+Hnj3sMVKUhPnrsrZVMannEtEkd9JoJGoP2jlWKE1ibG4KHBBkky+rv6nH0Um0kTtjd4KwsR0l1nDWvAcOg76gbqaIytCXiOAiEt4qkKL7x0wuKMBQXRKsu1tcDpg8QyCOj6s9QYkWDESVfs92xNmahJJZdfSdKd6pHOD5xUv6pdNFNWeePqF1W/uoq3MMQw9vrehvNhhGy4OnAm0sMQvTNPsO45ZLGx8Xzlt7iPHAJTPQ2G507kyRErdafLJbHrvgZF7wy49KCnJ8Zn8ECtX1WHqYdbWg9lb/MK3u4kSmNi9q7wnXK2kACDSPbOYsOkmA4le6WxVbH8lrvTVDxK00Shb0oJYMORdlSBm1mt2NsccchugG270Gdv0cCVph0i/QkcA7VHp8iT2ccVnAOw8GM9PdFXQt6DuU/nAAa+0BtjpMbD8VABF4nyF2Mzg+WFmMXiAduyKbFo8cjKbg3P05rE//O+3EOg3mjpMs2Y3eBi1DJdIiFcPjpgWBSuTPg6YO7vpR3lgPA8Fz+6lA== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee8d4623-79d9-4048-b6f0-08d8409b2130 X-MS-Exchange-CrossTenant-AuthSource: VI1PR0401MB2429.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Aug 2020 21:43:50.0001 (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: dmQq+//Qoj7wZ3nvj5DxqHjTcwlbdgjDj7qZLsfwK4ZpzwOP/82k2FrrMicgxrdwSlYAoYVp9t37PqH25TcA8w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3456 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.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 07ELhw5W002228 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.23 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 --- 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 + tests/libxlxml2domconfigdata/moredevs-hvm.json | 6 ++++++ tests/libxlxml2domconfigdata/moredevs-hvm.xml | 5 +++++ 7 files changed, 38 insertions(+), 1 deletion(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 218f0c1718..e1bd35fd53 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/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 @@
+ + +
+ +