From nobody Tue Apr 30 12:43:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1567505753; cv=none; d=zoho.com; s=zohoarc; b=JZWB+4ybQaZoh56cZB2+jnJn/kHlLnkZkNrOaCb+qKRzNaZ6oSSGJ2PuM2qve1u7W2xn6P53W6uvD0MWCc2N/SQzsmIGPS3GEV0uhAdpwzcl2mBB12DSFPi4UPN3EY1IVxyVcs2UOAgqnLtfE8vDpEeQsqvIZS+VQnkI5+7edN0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567505753; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=f1YndpwSdUdElmVsveWJPFEz5g37JD/Pt3FboPSOwfE=; b=aef5ReTaztTIwnPEF1a2o9e5GBZbva36RUmEbetFETzZsVcu8inaTkRf/uOy4nZmSWYWXUEoU/WtpxO2KE2uljq7mlS1uQyJxKI2EP4HHEhCe2OYi+JLKagrHdphglQWHbFSYLAtthDvkKpK3BM6WNlxrUAW5U8TScBvyFR8v/g= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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 156750575357059.56584438207915; Tue, 3 Sep 2019 03:15:53 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i55pc-0001ZS-LW; Tue, 03 Sep 2019 10:14:36 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i55pb-0001ZN-CO for xen-devel@lists.xenproject.org; Tue, 03 Sep 2019 10:14:35 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id a071b7bc-ce33-11e9-8980-bc764e2007e4; Tue, 03 Sep 2019 10:14:34 +0000 (UTC) X-Inumbo-ID: a071b7bc-ce33-11e9-8980-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1567505674; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=59moLgxvlTYcqNj97DGqae1abT6c0gdxKKQe6oNiY+E=; b=D8NI26Q5ZINNn1Ji3pNvLijDOZktsiO+p/k/nkKPuX134czXNgBh+G4b 4xckJpI/PsF9MRjWClVquvRuhef5nTH7TnICYYYCS71YAWd4hhCyRnNPU wI+MZbt+DWXEqKovszp5/ZAcqXAAtxE+HaGa1imd/Ol+oF1tjbRPKLZTl w=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=roger.pau@citrix.com; spf=Pass smtp.mailfrom=roger.pau@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of roger.pau@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.hc3370-68.iphmx.com: domain of roger.pau@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: Zh/M9lNQGB/8IPG9orLrYYNJrMRXhwTHh1L8CxUvlrNURv6xXF7rocUa5aesPjelc54wR+6BLg IgQmTRFgygSrrJXo9fXmAqA3qvz1rxy2YlZ9AcWT0cE3bWpNh6A5zq6ulgxcPQQVSTSsXv2qUi 5PJNDVhD0hC/DuYFetnWs5FH28hWHwjNCphkgAFasB4OHd334fALHxLzqMTBStIITmylAYUNDc PZ0B6tB2eveG5UZLB+1OaQ8Rae5sgsQtXNnBqeTSFuVKoR+1P3nYCaatfKRV0emFGYTG6d26NI 2fI= X-SBRS: 2.7 X-MesageID: 5271139 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,462,1559534400"; d="scan'208";a="5271139" From: Roger Pau Monne To: Date: Tue, 3 Sep 2019 12:14:28 +0200 Message-ID: <20190903101428.3543-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3] vpci: honor read-only devices X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Roger Pau Monne Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Don't allow the hardware domain write access the PCI config space of devices marked as read-only. Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Jan Beulich --- Changes since v2: - Fix test harness. - Do the RO check before the ownership one. Changes since v1: - Change the approach and allow full read access, while limiting write access to devices marked RO. --- tools/tests/vpci/emul.h | 3 +++ xen/drivers/vpci/vpci.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/tools/tests/vpci/emul.h b/tools/tests/vpci/emul.h index 5d47544bf7..2e1d3057c9 100644 --- a/tools/tests/vpci/emul.h +++ b/tools/tests/vpci/emul.h @@ -92,6 +92,9 @@ typedef union { #define xfree(p) free(p) =20 #define pci_get_pdev_by_domain(...) &test_pdev +#define pci_get_ro_map(...) NULL + +#define test_bit(...) false =20 /* Dummy native helpers. Writes are ignored, reads return 1's. */ #define pci_conf_read8(...) 0xff diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c index 758d9420e7..cbd1bac7fc 100644 --- a/xen/drivers/vpci/vpci.c +++ b/xen/drivers/vpci/vpci.c @@ -411,6 +411,7 @@ void vpci_write(pci_sbdf_t sbdf, unsigned int reg, unsi= gned int size, const struct pci_dev *pdev; const struct vpci_register *r; unsigned int data_offset =3D 0; + const unsigned long *ro_map =3D pci_get_ro_map(sbdf.seg); =20 if ( !size ) { @@ -418,6 +419,10 @@ void vpci_write(pci_sbdf_t sbdf, unsigned int reg, uns= igned int size, return; } =20 + if ( ro_map && test_bit(sbdf.bdf, ro_map) ) + /* Ignore writes to read-only devices. */ + return; + /* * Find the PCI dev matching the address. * Passthrough everything that's not trapped. --=20 2.22.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel