[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3] vpci/msix: fix PBA accesses


  • To: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 7 Mar 2022 15:12:32 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LKUf4j+vtRwEuE8r7CIp+76QvTBHVqvnLlWbMSqE0Uc=; b=C8AZ8IrCsYuIcKIo1ebSm6H6H4Xt7UjcV+JbnaFjhbBd6qYdwyVVZJrO8wl816uwufguYYT5KthI4lBKWY5tOlyadfkGJQ32dXj2YisyGBilE6yFX9UhGfUio3I/6yNeu/FhPK2BOHPHwyqUIxyuaVzow1/ph3nn3HYKdR9wNHO+7FsRKWFNJZUCR7E5OKwIeFL2jDIKIcZPTLr1GW765A43W9/E49e/+2gA/oLX7Y7hxEtck7yxoaPRIO4c6PMwg7LBmoWZXgn7Nh5+xz0d6KOt0H5HUNIWyJdTRd++/H4nnoD0u2pspNAnRg9CeO2410oprZFxJDHIVC/0XbABew==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aWc9fTI5G+j5PXiAqTzteipMU6jOuKUEY5Y44jva43hricldkgNZeHzgbNwHv7VaY2PNFn+gKRT/Y0ISQN7FHDPQ6NfNS2OWp54Hi89R19vOI3CBwt8AZgHsO8dLGR1fSUFXGg0pn8eglTNkH61vWTSHvdSLckVMsnwiVuDuX+W5wh6Tra1bwgBM7g6xeFoO+r5Y8SZ94huQIhr2JHyu8yXAibyPNZTZboQCO8ohdvbnffkdm9Wibw63VxcZnVztZWyW0b8EOJokeataPApJvSb6tD8pJ49WR1FgD1KN3+TmjWCqWwd++Tl07ovZQkxSs9EC1a89UV2dJpWwVt+WCQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Alex Olson <this.is.a0lson@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Mon, 07 Mar 2022 14:12:41 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 07.03.2022 13:53, Roger Pau Monne wrote:
> --- a/xen/drivers/vpci/msix.c
> +++ b/xen/drivers/vpci/msix.c
> @@ -182,6 +182,33 @@ static struct vpci_msix_entry *get_entry(struct 
> vpci_msix *msix,
>      return &msix->entries[(addr - start) / PCI_MSIX_ENTRY_SIZE];
>  }
>  
> +static void __iomem *get_pba(struct vpci *vpci)
> +{
> +    struct vpci_msix *msix = vpci->msix;
> +    void __iomem *pba;
> +
> +    /*
> +     * PBA will only be unmapped when the device is deassigned, so access it
> +     * without holding the vpci lock.
> +     */
> +    if ( likely(msix->pba) )
> +        return msix->pba;
> +
> +    pba = ioremap(vmsix_table_addr(vpci, VPCI_MSIX_PBA),
> +                  vmsix_table_size(vpci, VPCI_MSIX_PBA));
> +    if ( !pba )
> +        return msix->pba;

For this particular purpose may want to consider using ACCESS_ONCE() for
all accesses to this field.

> +    spin_lock(&vpci->lock);
> +    if ( !msix->pba )
> +        msix->pba = pba;
> +    else
> +        iounmap(pba);
> +    spin_unlock(&vpci->lock);

Whenever possible I think we should try to do things, in particular ones
involving further locks, with as few locks held as possible. IOW I'd like
to ask that you pull out the iounmap().

> @@ -200,6 +227,10 @@ static int cf_check msix_read(
>  
>      if ( VMSIX_ADDR_IN_RANGE(addr, msix->pdev->vpci, VPCI_MSIX_PBA) )
>      {
> +        struct vpci *vpci = msix->pdev->vpci;
> +        unsigned int idx = addr - vmsix_table_addr(vpci, VPCI_MSIX_PBA);
> +        void __iomem *pba = get_pba(vpci);

const?

Jan




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.