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: <c1ae8732-357a-fce7-8853-9ea7051d306d@linux.intel.com>
Date: Thu, 13 Jun 2024 19:57:24 +0300 (EEST)
From: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
To: Philipp Stanner <pstanner@...hat.com>
cc: Hans de Goede <hdegoede@...hat.com>, 
    Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>, 
    Maxime Ripard <mripard@...nel.org>, 
    Thomas Zimmermann <tzimmermann@...e.de>, David Airlie <airlied@...il.com>, 
    Daniel Vetter <daniel@...ll.ch>, Bjorn Helgaas <bhelgaas@...gle.com>, 
    Sam Ravnborg <sam@...nborg.org>, dakr@...hat.com, 
    dri-devel@...ts.freedesktop.org, LKML <linux-kernel@...r.kernel.org>, 
    linux-pci@...r.kernel.org
Subject: Re: [PATCH v7 01/13] PCI: Add and use devres helper for bit masks

On Wed, 5 Jun 2024, Philipp Stanner wrote:

> The current derves implementation uses manual shift operations to check
> whether a bit in a mask is set. The code can be made more readable by
> writing a small helper function for that.
> 
> Implement mask_contains_bar() and use it where applicable.
> 
> Signed-off-by: Philipp Stanner <pstanner@...hat.com>
> ---
>  drivers/pci/devres.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pci/devres.c b/drivers/pci/devres.c
> index 2c562b9eaf80..f13edd4a3873 100644
> --- a/drivers/pci/devres.c
> +++ b/drivers/pci/devres.c
> @@ -161,6 +161,10 @@ int pcim_set_mwi(struct pci_dev *dev)
>  }
>  EXPORT_SYMBOL(pcim_set_mwi);
>  
> +static inline bool mask_contains_bar(int mask, int bar)

Why these are signed? Using & for signed values is an indication that the 
types should have been unsigned. The typing change has ripple effects to 
caller-side typing.

> +{
> +	return mask & BIT(bar);
> +}

-- 
 i.

>  
>  static void pcim_release(struct device *gendev, void *res)
>  {
> @@ -169,7 +173,7 @@ static void pcim_release(struct device *gendev, void *res)
>  	int i;
>  
>  	for (i = 0; i < DEVICE_COUNT_RESOURCE; i++)
> -		if (this->region_mask & (1 << i))
> +		if (mask_contains_bar(this->region_mask, i))
>  			pci_release_region(dev, i);
>  
>  	if (this->mwi)
> @@ -363,7 +367,7 @@ int pcim_iomap_regions(struct pci_dev *pdev, int mask, const char *name)
>  	for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
>  		unsigned long len;
>  
> -		if (!(mask & (1 << i)))
> +		if (!mask_contains_bar(mask, i))
>  			continue;
>  
>  		rc = -EINVAL;
> @@ -386,7 +390,7 @@ int pcim_iomap_regions(struct pci_dev *pdev, int mask, const char *name)
>  	pci_release_region(pdev, i);
>   err_inval:
>  	while (--i >= 0) {
> -		if (!(mask & (1 << i)))
> +		if (!mask_contains_bar(mask, i))
>  			continue;
>  		pcim_iounmap(pdev, iomap[i]);
>  		pci_release_region(pdev, i);
> @@ -438,7 +442,7 @@ void pcim_iounmap_regions(struct pci_dev *pdev, int mask)
>  		return;
>  
>  	for (i = 0; i < PCIM_IOMAP_MAX; i++) {
> -		if (!(mask & (1 << i)))
> +		if (!mask_contains_bar(mask, i))
>  			continue;
>  
>  		pcim_iounmap(pdev, iomap[i]);
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ