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: <20250210093641.0be242ae.alex.williamson@redhat.com>
Date: Mon, 10 Feb 2025 09:36:41 -0700
From: Alex Williamson <alex.williamson@...hat.com>
To: Oleg Nesterov <oleg@...hat.com>
Cc: bhelgaas@...gle.com, linux-pci@...r.kernel.org,
 linux-kernel@...r.kernel.org, mitchell.augustin@...onical.com,
 ilpo.jarvinen@...ux.intel.com
Subject: Re: [PATCH v2] PCI: Batch BAR sizing operations

On Sun, 9 Feb 2025 16:45:12 +0100
Oleg Nesterov <oleg@...hat.com> wrote:

> On 01/20, Alex Williamson wrote:
> >
> >  static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
> >  {
> > +	u32 rombar, stdbars[PCI_STD_NUM_BARS];
> >  	unsigned int pos, reg;
> > +	u16 orig_cmd;
> > +
> > +	BUILD_BUG_ON(howmany > PCI_STD_NUM_BARS);  
> 
> FYI, I can't build the kernel after this patch:
> 
> 	$ make drivers/pci/probe.o
> 	  UPD     include/config/kernel.release
> 	  UPD     include/generated/utsrelease.h
> 	  CALL    scripts/checksyscalls.sh
> 	  DESCEND objtool
> 	  INSTALL libsubcmd_headers
> 	  CC      drivers/pci/probe.o
> 	In file included from <command-line>:0:0:
> 	drivers/pci/probe.c: In function ‘pci_read_bases’:
> 	././include/linux/compiler_types.h:542:38: error: call to ‘__compiletime_assert_338’ declared with attribute error: BUILD_BUG_ON failed: howmany > PCI_STD_NUM_BARS
> 	  _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
> 					      ^
> 	././include/linux/compiler_types.h:523:4: note: in definition of macro ‘__compiletime_assert’
> 	    prefix ## suffix();    \
> 	    ^
> 	././include/linux/compiler_types.h:542:2: note: in expansion of macro ‘_compiletime_assert’
> 	  _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
> 	  ^
> 	./include/linux/build_bug.h:39:37: note: in expansion of macro ‘compiletime_assert’
> 	 #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
> 					     ^
> 	./include/linux/build_bug.h:50:2: note: in expansion of macro ‘BUILD_BUG_ON_MSG’
> 	  BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
> 	  ^
> 	drivers/pci/probe.c:348:2: note: in expansion of macro ‘BUILD_BUG_ON’
> 	  BUILD_BUG_ON(howmany > PCI_STD_NUM_BARS);
> 
> Yes, my gcc version 5.3.1 is very old, but according to Documentation/process/changes.rst
> it should still be supported, the minimal version is 5.1.

While I try to setup an environment with an old gcc, can we do something
with __builtin_constant_p() to only evaluate this on versions of gcc
that can determine howmany is constant?  Ex.

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index b6536ed599c3..c70cb480125e 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -345,7 +345,8 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
 	unsigned int pos, reg;
 	u16 orig_cmd;
 
-	BUILD_BUG_ON(howmany > PCI_STD_NUM_BARS);
+	if (__builtin_constant_p(howmany))
+		BUILD_BUG_ON(howmany > PCI_STD_NUM_BARS);
 
 	if (dev->non_compliant_bars)
 		return;

I welcome other suggestions too.  Thanks,

Alex


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ