lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c1c437a9a2a146b302e1904d7af113e6ef4b0ac6.1759312886.git.epetron@amazon.de>
Date: Fri, 3 Oct 2025 09:00:45 +0000
From: Evangelos Petrongonas <epetron@...zon.de>
To: Bjorn Helgaas <bhelgaas@...gle.com>, Alex Williamson
	<alex.williamson@...hat.com>, "Rafael J . Wysocki" <rafael@...nel.org>, "Len
 Brown" <lenb@...nel.org>
CC: Evangelos Petrongonas <epetron@...zon.de>, Pasha Tatashin
	<pasha.tatashin@...een.com>, David Matlack <dmatlack@...gle.com>, "Vipin
 Sharma" <vipinsh@...gle.com>, Chris Li <chrisl@...nel.org>, Jason Miu
	<jasonmiu@...gle.com>, Pratyush Yadav <pratyush@...nel.org>, "Stanislav
 Spassov" <stanspas@...zon.de>, <linux-pci@...r.kernel.org>,
	<linux-acpi@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
	<nh-open-source@...zon.com>
Subject: [RFC PATCH 09/13] vfio: pci: Fill only spec-defined configuration space regions

Ammend VFIO PCI configuration space initialization by filling only
the regions defined by the PCI specification, avoiding unnecessary
reads from undefined or reserved areas.

The current implementation reads the entire configuration space during
initialization, including reserved regions that may not be implemented
by the device or may have side effects when accessed. This change
modifies vfio_fill_vconfig_bytes() skips reserved regions in the
standard configuration space header.

This benefits the PCSC hit rate, as 4byte access to a region where only
2 bytes are cacheable and 2 are undefined, therefore uncached, will lead
to a HW access instead.

Signed-off-by: Evangelos Petrongonas <epetron@...zon.de>
---
 drivers/vfio/pci/vfio_pci_config.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c
index 8f02f236b5b4..4fc7156a77d1 100644
--- a/drivers/vfio/pci/vfio_pci_config.c
+++ b/drivers/vfio/pci/vfio_pci_config.c
@@ -1485,7 +1485,18 @@ static int vfio_fill_vconfig_bytes(struct vfio_pci_core_device *vdev,
 	while (size) {
 		int filled;
 
-		if (size >= 4 && !(offset % 4)) {
+		if (offset == PCI_CAPABILITY_LIST) {
+			u8 *byte = &vdev->vconfig[offset];
+
+			ret = pci_read_config_byte(pdev, offset, byte);
+			if (ret)
+				return ret;
+			/* Skip the reserved area */
+			filled = 4;
+		} else if (offset == 0x38) {
+			/* Skip the reserved area */
+			filled = 4;
+		} else if (size >= 4 && !(offset % 4)) {
 			__le32 *dwordp = (__le32 *)&vdev->vconfig[offset];
 			u32 dword;
 
-- 
2.47.3




Amazon Web Services Development Center Germany GmbH
Tamara-Danz-Str. 13
10243 Berlin
Geschaeftsfuehrung: Christian Schlaeger
Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B
Sitz: Berlin
Ust-ID: DE 365 538 597


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ