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-next>] [day] [month] [year] [list]
Message-ID: <20250904023753.494147-1-marek.vasut+renesas@mailbox.org>
Date: Thu,  4 Sep 2025 04:37:39 +0200
From: Marek Vasut <marek.vasut+renesas@...lbox.org>
To: linux-pci@...r.kernel.org
Cc: Marek Vasut <marek.vasut+renesas@...lbox.org>,
	Krzysztof Wilczyński <kwilczynski@...nel.org>,
	Bjorn Helgaas <bhelgaas@...gle.com>,
	Damien Le Moal <dlemoal@...nel.org>,
	Frank Li <Frank.Li@....com>,
	Kishon Vijay Abraham I <kishon@...nel.org>,
	Manivannan Sadhasivam <mani@...nel.org>,
	Niklas Cassel <cassel@...nel.org>,
	Wang Jiang <jiangwang@...inos.cn>,
	linux-kernel@...r.kernel.org,
	linux-renesas-soc@...r.kernel.org
Subject: [PATCH] PCI: endpoint: pci-epf-test: Limit PCIe BAR size for fixed BARs

Currently, the test allocates BAR sizes according to fixed table
bar_size[] = { 512, 512, 1024, 16384, 131072, 1048576 } . This
does not work with controllers which have fixed size BARs, like
Renesas R-Car V4H PCIe controller, which has BAR4 size limited
to 256 Bytes, which is much less than 131072 currently requested
by this test.

Adjust the test such, that in case a fixed size BAR is detected
on a controller, minimum of requested size and fixed size BAR
size is used during the test instead.

This helps with test failures reported as follows:
"
pci_epf_test pci_epf_test.0: requested BAR size is larger than fixed size
pci_epf_test pci_epf_test.0: Failed to allocate space for BAR4
"

Signed-off-by: Marek Vasut <marek.vasut+renesas@...lbox.org>
---
Cc: "Krzysztof Wilczyński" <kwilczynski@...nel.org>
Cc: Bjorn Helgaas <bhelgaas@...gle.com>
Cc: Damien Le Moal <dlemoal@...nel.org>
Cc: Frank Li <Frank.Li@....com>
Cc: Kishon Vijay Abraham I <kishon@...nel.org>
Cc: Manivannan Sadhasivam <mani@...nel.org>
Cc: Niklas Cassel <cassel@...nel.org>
Cc: Wang Jiang <jiangwang@...inos.cn>
Cc: linux-kernel@...r.kernel.org
Cc: linux-pci@...r.kernel.org
Cc: linux-renesas-soc@...r.kernel.org
---
 drivers/pci/endpoint/functions/pci-epf-test.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c
index e091193bd8a8a..d9c950d4c9a9e 100644
--- a/drivers/pci/endpoint/functions/pci-epf-test.c
+++ b/drivers/pci/endpoint/functions/pci-epf-test.c
@@ -1022,7 +1022,8 @@ static int pci_epf_test_alloc_space(struct pci_epf *epf)
 	enum pci_barno test_reg_bar = epf_test->test_reg_bar;
 	enum pci_barno bar;
 	const struct pci_epc_features *epc_features = epf_test->epc_features;
-	size_t test_reg_size;
+	size_t test_reg_size, test_bar_size;
+	u64 bar_fixed_size;
 
 	test_reg_bar_size = ALIGN(sizeof(struct pci_epf_test_reg), 128);
 
@@ -1050,7 +1051,13 @@ static int pci_epf_test_alloc_space(struct pci_epf *epf)
 		if (bar == test_reg_bar)
 			continue;
 
-		base = pci_epf_alloc_space(epf, bar_size[bar], bar,
+		test_bar_size = bar_size[bar];
+
+		bar_fixed_size = epc_features->bar[bar].fixed_size;
+		if (epc_features->bar[bar].type == BAR_FIXED && bar_fixed_size)
+			test_bar_size = min(bar_size[bar], bar_fixed_size);
+
+		base = pci_epf_alloc_space(epf, test_bar_size, bar,
 					   epc_features, PRIMARY_INTERFACE);
 		if (!base)
 			dev_err(dev, "Failed to allocate space for BAR%d\n",
-- 
2.50.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ