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

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


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 7 Mar 2022 17:11: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=Dzk5JVDvy4W4k7HgRn24d7pkM2C+eKKhEv7oOeWeO8A=; b=BeyiFYdqEM6IhlhJfgN59BXdjR7yDVbb1UulOMGw48Vjmp+ebTvtv6XnnB4bNZkkjsevS7Ybb0DrNpFH+CIhiOmw8/vS7ZxsBdaQymtwufDuFUbnSXvD6VIySvF9lRXCWtJnFbQQuBOPa3LQq3tfcF+Y1iGDlv9FHCdKd5WEmORsk4KZIbjOg7K/6CoZK0Xg0ssetyu/gLHO39ciIho2qCFVoLp0ldA+7UR8Tjy++aYXPdjr1JovuxDL7BmbOt9zJYnXXd/Y1Ok/6zrENgKbS8fF20osT96ksgRsKtkY+CSa7pjt1PrKgvW3IE+SxoAs1MJauox5OZwZ4t2HLsyWpw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fhJRqMqJu4UdcPssRCQU4H/+1mtX8zjWM0G3ISSlBF0+rQ+GdTzFKY80EFd9B3JpRyO+ehmyTLUJhGFU6uRyVYH1Z1VwUzY0ltj6d8pCQPQG4fMHgAltHrXzNNbLKIPKJLSyup5hHCfjVnZNqTfIG7RUDNBSfqqWOJQ9yPEuHuzcjoFSCM2u6tY9UQgbEnJwyYNlhlQM/f2dNAIp6FAInWVjR9zHIN24jpxNHfPW1aoZDSXAEaNTI+qznJBCiOSwQqW/gYJCkawleH8Jou77oXAYPjKWfYpK6OzB4a4m0WfZo+/blDRbc0M0yZltDc5mVG4I90MDtQSXWC1Tkl5zUg==
  • 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 16:11:40 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 07.03.2022 17:06, Roger Pau Monné wrote:
> On Mon, Mar 07, 2022 at 03:12:32PM +0100, Jan Beulich wrote:
>> 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.
> 
> Hm, I think I've asked before, but we do assume that ACCESS_ONCE will
> generate a single instruction, or else we would have to use
> read_atomic.

Yeah, that looks to be the assumption. It has become my understanding
that ACCESS_ONCE() is generally favored over {read,write}_atomic().
Personally I prefer the latter when the goal is to have single insns.

Jan




 


Rackspace

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