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: <20250319170932.GA1046398@bhelgaas>
Date: Wed, 19 Mar 2025 12:09:32 -0500
From: Bjorn Helgaas <helgaas@...nel.org>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: LKML <linux-kernel@...r.kernel.org>, Marc Zyngier <maz@...nel.org>,
	Peter Zijlstra <peterz@...radead.org>,
	Jonathan Cameron <Jonathan.Cameron@...wei.com>,
	Nishanth Menon <nm@...com>, Dhruva Gole <d-gole@...com>,
	Tero Kristo <kristo@...nel.org>,
	Santosh Shilimkar <ssantosh@...nel.org>,
	Logan Gunthorpe <logang@...tatee.com>,
	Dave Jiang <dave.jiang@...el.com>, Jon Mason <jdmason@...zu.us>,
	Allen Hubbe <allenbh@...il.com>, ntb@...ts.linux.dev,
	Michael Kelley <mhklinux@...look.com>, Wei Liu <wei.liu@...nel.org>,
	Bjorn Helgaas <bhelgaas@...gle.com>,
	Haiyang Zhang <haiyangz@...rosoft.com>,
	linux-hyperv@...r.kernel.org, linux-pci@...r.kernel.org,
	Wei Huang <wei.huang2@....com>,
	Manivannan Sadhasivam <manivannan.sadhasivam@...aro.org>,
	"James E.J. Bottomley" <James.Bottomley@...senpartnership.com>,
	"Martin K. Petersen" <martin.petersen@...cle.com>,
	linux-scsi@...r.kernel.org,
	Jonathan Cameron <Jonathan.Cameron@...ei.com>
Subject: Re: [patch V4 09/14] PCI/MSI: Switch msix_capability_init() to
 guard(msi_desc_lock)

On Wed, Mar 19, 2025 at 11:56:54AM +0100, Thomas Gleixner wrote:
> Split the lock protected functionality of msix_capability_init() out into a
> helper function and use guard(msi_desc_lock) to replace the lock/unlock
> pair.
> 
> Simplify the error path in the helper function by utilizing a custom
> cleanup to get rid of the remaining gotos.
> 
> No functional change intended.
> 
> Signed-off-by: Thomas Gleixner <tglx@...utronix.de>

Acked-by: Bjorn Helgaas <bhelgaas@...gle.com>

> ---
> V4: Split out from the previous combo patch
> ---
>  drivers/pci/msi/msi.c |   36 ++++++++++++++++++++----------------
>  1 file changed, 20 insertions(+), 16 deletions(-)
> 
> --- a/drivers/pci/msi/msi.c
> +++ b/drivers/pci/msi/msi.c
> @@ -663,35 +663,39 @@ static void msix_mask_all(void __iomem *
>  		writel(ctrl, base + PCI_MSIX_ENTRY_VECTOR_CTRL);
>  }
>  
> -static int msix_setup_interrupts(struct pci_dev *dev, struct msix_entry *entries,
> -				 int nvec, struct irq_affinity *affd)
> +DEFINE_FREE(free_msi_irqs, struct pci_dev *, if (_T) pci_free_msi_irqs(_T));
> +
> +static int __msix_setup_interrupts(struct pci_dev *__dev, struct msix_entry *entries,
> +				   int nvec, struct irq_affinity_desc *masks)
>  {
> -	struct irq_affinity_desc *masks __free(kfree) =
> -		affd ? irq_create_affinity_masks(nvec, affd) : NULL;
> -	int ret;
> +	struct pci_dev *dev __free(free_msi_irqs) = __dev;
>  
> -	msi_lock_descs(&dev->dev);
> -	ret = msix_setup_msi_descs(dev, entries, nvec, masks);
> +	int ret = msix_setup_msi_descs(dev, entries, nvec, masks);
>  	if (ret)
> -		goto out_free;
> +		return ret;
>  
>  	ret = pci_msi_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSIX);
>  	if (ret)
> -		goto out_free;
> +		return ret;
>  
>  	/* Check if all MSI entries honor device restrictions */
>  	ret = msi_verify_entries(dev);
>  	if (ret)
> -		goto out_free;
> +		return ret;
>  
> +	retain_ptr(dev);
>  	msix_update_entries(dev, entries);
> -	goto out_unlock;
> +	return 0;
> +}
> +
> +static int msix_setup_interrupts(struct pci_dev *dev, struct msix_entry *entries,
> +				 int nvec, struct irq_affinity *affd)
> +{
> +	struct irq_affinity_desc *masks __free(kfree) =
> +		affd ? irq_create_affinity_masks(nvec, affd) : NULL;
>  
> -out_free:
> -	pci_free_msi_irqs(dev);
> -out_unlock:
> -	msi_unlock_descs(&dev->dev);
> -	return ret;
> +	guard(msi_descs_lock)(&dev->dev);
> +	return __msix_setup_interrupts(dev, entries, nvec, masks);
>  }
>  
>  /**
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ