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

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


  • To: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 8 Mar 2022 09:31:34 +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=WO6qL/gJgZYfOTZOELUFOkFkuLMC5VouXnJW0Cjp0To=; b=c+sVn34hNbHiqcVQSQxjIFjG1QIkgAJYgzTZf6A+1uBRlvkCmbOsVqL0fK6votlX7H8K//GLrd6qeb7+WsqihWjusgqEb6KxKrJPCPGISt69xR1wLKa4f+4gyXQZW08wEKJ/z9hugmwq5MF09nqIugyBl46JWc41gukPQ99mRUwIslz9wWtKb29jQLdEytZRA7CT0ZlDV31uTyjhcUpIz624Alikn7CSl2q2/eh7Fj6CCKGFc3odI/ctUDpn2Hzn6hvWZRkbLc2KJwF2eC+ATF1drt3zS+1QRRGsogXe3mgcO9byE9fUSbUfjyAAG4C9MGnzAqrRC5GswOyL4LnG3A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gSK9nD6jqL95zM7KS5UmqlZiUMlGnhNe84roSTA5Q0/F7Kw5fbwzPwEPNZ7/QubAEvk61U8FIzlHBdG1JlzpHWlOPUlsHRo/8n1rwo1qlGV4nd/0D4KtGfQXjb5xpbqClml/DD2wedPLBjd58yRJq0oHPvWuyUjAdg36yCp+J6efB3suDpPt+FPoIYwuxpVb6/EgjKoVCLsmqJJ0+J0uGIvH/Q3qm817EIIUFakkV/IBjnYjYZQsu5jW5diIeNyh2RX+Vqezt4/My8ZhsODyqgDh9eSkgeLLPj9yen0Vbav+d7iCnWnzaWtnTf6z2dPQnL5l9NiXKS/0GtzjAemfBQ==
  • 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: Tue, 08 Mar 2022 08:31:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 07.03.2022 17:37, Roger Pau Monne wrote:
> Map the PBA in order to access it from the MSI-X read and write
> handlers. Note that previously the handlers would pass the physical
> host address into the {read,write}{l,q} handlers, which is wrong as
> those expect a linear address.
> 
> Map the PBA using ioremap when the first access is performed. Note
> that 32bit arches might want to abstract the call to ioremap into a
> vPCI arch handler, so they can use a fixmap range to map the PBA.
> 
> Reported-by: Jan Beulich <jbeulich@xxxxxxxx>
> Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>

> Cc: Alex Olson <this.is.a0lson@xxxxxxxxx>

I'll wait a little with committing, in the hope for Alex to re-provide
a Tested-by.

> --- a/xen/drivers/vpci/msix.c
> +++ b/xen/drivers/vpci/msix.c
> @@ -182,6 +182,38 @@ 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;
> +    /*
> +     * PBA will only be unmapped when the device is deassigned, so access it
> +     * without holding the vpci lock.
> +     */
> +    void __iomem *pba = read_atomic(&msix->pba);
> +
> +    if ( likely(pba) )
> +        return pba;
> +
> +    pba = ioremap(vmsix_table_addr(vpci, VPCI_MSIX_PBA),
> +                  vmsix_table_size(vpci, VPCI_MSIX_PBA));
> +    if ( !pba )
> +        return read_atomic(&msix->pba);
> +
> +    spin_lock(&vpci->lock);
> +    if ( !msix->pba )
> +    {
> +        write_atomic(&msix->pba, pba);
> +        spin_unlock(&vpci->lock);
> +    }
> +    else
> +    {
> +        spin_unlock(&vpci->lock);
> +        iounmap(pba);
> +    }

TBH I had been hoping for just a single spin_unlock(), but you're
the maintainer of this code ...

Jan




 


Rackspace

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