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

Re: [PATCH v5 03/14] vpci: move lock outside of struct vpci


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Thu, 13 Jan 2022 09:58:05 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=B+qhBTT7gxt0T6BkIeV794kwNlxY+fQEhIPLsg+FKjg=; b=Iykn2vef71H9yygn/T2OXVUX5Irmh1GZlkPRnYGiKVofUevHf4PLjc5ZnVZP5XMY1HJHas2MatoZ2CkYRHtm1j5jsE5iuI0NB4rQOC2J15Mv2/DrPynCEGZbD08/KS1MIp/+uJKAzKtH+nILMfnun2jIAR4e7HXRYc89LwFGu12KbkIa4kdvVaqX9/tCe0/4gfZErgvRXjLRGQ7x6I0/W/uU1JFx3/KOQWsdR//mhS2OtGKYrD/IbAFxT08cN+Rrp1t713FiO+hCYU3RYltn9YKzcz0G0wI+0+Cp/aAab26OBEUv9J2qBNUNuH9ItJ5U3Z1ZMKU+JC9BOa/fXWm+yw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m1LqlzRZj2DSWJL7fIKoPCi68RJSJYNUURkScMlp2Advtr66Sj4hNw4CkDtN6PAPUlxzfHhp44gKYJPVxmzR/6dbpoTWASoUqfpHSf0n7G1888oBUGANwU7kAXLQA8qzqgX8qdztifzCNk01bedEwjE1j7li+NKktJdqVA7vbSMPgqlul0sWmX3MD5RWJsLIZqrZZra7GGE6kE9t4rKdG5d0+Qz2XhonE3uzmwPoN6DDfhpPsDWoP+85X51QPY+ldtnGgMVk33Qa+bvJiaSXGChod6P96vsVKyDt9NNOVCwMov3pkALiwCkZ6vpmQug60qcbbRL3LvLjKC3snKUsMQ==
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Oleksandr Andrushchenko <andr2000@xxxxxxxxx>, <julien@xxxxxxx>, <sstabellini@xxxxxxxxxx>, <oleksandr_tyshchenko@xxxxxxxx>, <volodymyr_babchuk@xxxxxxxx>, <Artem_Mygaiev@xxxxxxxx>, <andrew.cooper3@xxxxxxxxxx>, <george.dunlap@xxxxxxxxxx>, <paul@xxxxxxx>, <bertrand.marquis@xxxxxxx>, <rahul.singh@xxxxxxx>, Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 13 Jan 2022 08:59:04 +0000
  • Ironport-data: A9a23:XQenuK/7HYV/qgCu58FHDrUDQHiTJUtcMsCJ2f8bNWPcYEJGY0x3n TEbWW6FPv6LMWb1ft5yYdjk/UhQv5Pdx4IxGVE//y48E34SpcT7XtnIdU2Y0wF+jyHgoOCLy +1EN7Es+ehtFie0Si9AttENlFEkvU2ybuOU5NXsZ2YhFWeIdA970Ug5w7dg2dYx6TSEK1jlV e3a8pW31GCNg1aYAkpMg05UgEoy1BhakGpwUm0WPZinjneH/5UmJMt3yZWKB2n5WuFp8tuSH I4v+l0bElTxpH/BAvv9+lryn9ZjrrT6ZWBigVIOM0Sub4QrSoXfHc/XOdJFAXq7hQllkPhW7 vxmmZueUD00GbaLxt0lA0lKPntHaPguFL/veRBTsOSWxkzCNXDt3+9vHAc9OohwFuRfWD8Us 6ZCcXZUM07F17neLLGTE4GAguw5K8bmJsUHs2xIxjDFF/c2B5vERs0m4PcGhWZo3ZgVQp4yY eIbWAVCUD3KSiZQZE0pM7Unp/rz1y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ZWbwxHH3RTB4fbA/hq2gIYdA/oJzimT3KVRmkPyfhJbzku82973FqbFjIf+WEjQvQQ+taLgxcj IVgH8azyV489+rLj+1SRXhzq0qN1QJX3gWNgCk5OcyUzmLNur94oGGRXyDVYNnXRox6w6yxuxW yCqAygC47sM0xLl4h9yYOFAmUk0b3dsbZyCYZqP7OHJt+ah7TuV1FhYxBs2KcgY21/U6TLBK1h +7gO7LxcfI03JRIiFTaWgtzv
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, Jan 12, 2022 at 04:52:51PM +0100, Jan Beulich wrote:
> On 12.01.2022 16:42, Roger Pau Monné wrote:
> > On Wed, Jan 12, 2022 at 03:57:36PM +0100, Jan Beulich wrote:
> >> On 25.11.2021 12:02, Oleksandr Andrushchenko wrote:
> >>> @@ -379,7 +396,6 @@ uint32_t vpci_read(pci_sbdf_t sbdf, unsigned int reg, 
> >>> unsigned int size)
> >>>  
> >>>          data = merge_result(data, tmp_data, size - data_offset, 
> >>> data_offset);
> >>>      }
> >>> -    spin_unlock(&pdev->vpci->lock);
> >>>  
> >>>      return data & (0xffffffff >> (32 - 8 * size));
> >>>  }
> >>
> >> Here and ...
> >>
> >>> @@ -475,13 +498,12 @@ void vpci_write(pci_sbdf_t sbdf, unsigned int reg, 
> >>> unsigned int size,
> >>>              break;
> >>>          ASSERT(data_offset < size);
> >>>      }
> >>> +    spin_unlock(&pdev->vpci_lock);
> >>>  
> >>>      if ( data_offset < size )
> >>>          /* Tailing gap, write the remaining. */
> >>>          vpci_write_hw(sbdf, reg + data_offset, size - data_offset,
> >>>                        data >> (data_offset * 8));
> >>> -
> >>> -    spin_unlock(&pdev->vpci->lock);
> >>>  }
> >>
> >> ... even more so here I'm not sure of the correctness of the moving
> >> you do: While pdev->vpci indeed doesn't get accessed, I wonder
> >> whether there wasn't an intention to avoid racing calls to
> >> vpci_{read,write}_hw() this way. In any event I think such movement
> >> would need justification in the description.
> > 
> > I agree about the need for justification in the commit message, or
> > even better this being split into a pre-patch, as it's not related to
> > the lock switching done here.
> > 
> > I do think this is fine however, as racing calls to
> > vpci_{read,write}_hw() shouldn't be a problem. Those are just wrappers
> > around pci_conf_{read,write} functions, and the required locking (in
> > case of using the IO ports) is already taken care in
> > pci_conf_{read,write}.
> 
> IOW you consider it acceptable for a guest (really: Dom0) read racing
> a write to read back only part of what was written (so far)? I would
> think individual multi-byte reads and writes should appear atomic to
> the guest.

We split 64bit writes into two 32bit ones without taking the lock for
the whole duration of the access, so it's already possible to see a
partially updated state as a result of a 64bit write.

I'm going over the PCI(e) spec but I don't seem to find anything about
whether the ECAM is allowed to split memory transactions into multiple
Configuration Requests, and whether those could then interleave with
requests from a different CPU.

Thanks, Roger.



 


Rackspace

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