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

Re: [PATCH v5 05/14] vpci: add hooks for PCI device assign/de-assign


  • To: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Tue, 1 Feb 2022 11:23:46 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=fjmKXC02a46b0N4agfLPjg7mRyM64QzovMyqMf83574=; b=Vmon9T6SkCCcGP6j0qgZYUvoctVC6iHfB8ImRMA2+1jBPwtLzLMHwVIpRq7q0HUpI43OyHslywl2WmdMEQdon8hp7EK9nosIvXWl/ywBO2e3/x+ITjVU+n4CgFMJUhksnq24mXsQvsktP4wlKbYqCqU6DL+fSrXKDEJOQUMobqWYdZJ/XERq0nITe+VRqmGO1o5pOr0iYhBG6GOjsLn1w2hoOA4RkVQhRJyHy9RYq5REyqLl9tbXakr4T+U1k03k0a+ovBBUHCshil7hQs7Lht5PUfRye6nPfFtPF5qQ+HzfxLuHzjSxDNTy33E+/w1mJX2Zpe9SoFbYD15sYqxXzw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c5d2DQbZJGtPiMrb01XcPPFvczQNYSZzxLyXgElN9kdvMY1IFKcOvtbqYZ5m7xWr71Gu46nSFVFbtUrU9+Kynl1k+ujt9aLRCcebA9ckWdvamHgciKun0Muu5T7ngy6lpEhNQ4ANjGP1JxWaKlaMrin8S6o0eawrwXIOio2MxoU+T3VufCGHtXVAZ1Gw99Koc35IFTDZeTQ7WIh+6/hJ67hk+NXK31d1RwzR7OhIIDdHKUlWk9aA9juXrl2E//lsRRUg2P7gxqieIToC01+3XBdJxJXgn8uzddvmYgSVIzGjkkOe58ArRIzspLTGlZw8GzQAVyQE1YW+/6GX/r85Xg==
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "julien@xxxxxxx" <julien@xxxxxxx>, "sstabellini@xxxxxxxxxx" <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Artem Mygaiev <Artem_Mygaiev@xxxxxxxx>, "jbeulich@xxxxxxxx" <jbeulich@xxxxxxxx>, "andrew.cooper3@xxxxxxxxxx" <andrew.cooper3@xxxxxxxxxx>, "george.dunlap@xxxxxxxxxx" <george.dunlap@xxxxxxxxxx>, "paul@xxxxxxx" <paul@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Rahul Singh <rahul.singh@xxxxxxx>
  • Delivery-date: Tue, 01 Feb 2022 10:24:06 +0000
  • Ironport-data: A9a23:nrrY5627PuDK6CB/UPbD5ed3kn2cJEfYwER7XKvMYLTBsI5bp2ADz mAeWW+AafveYzH0e4wiO96w9h5UsMLUy9VhQAVvpC1hF35El5HIVI+TRqvS04J+DSFhoGZPt Zh2hgzodZhsJpPkS5PE3oHJ9RGQ74nRLlbHILOCanAZqTNMEn9700o5w7dh2+aEvPDia++zk YKqyyHgEAfNNw5cagr4PIra9XuDFNyr0N8plgRWicJj5TcypFFMZH4rHomjLmOQf2VhNrXSq 9Avbl2O1jixEx8FUrtJm1tgG6EAaua60QOm0hK6V0U+6/TrS+NbPqsTbZIhhUlrZzqhsNdK+ OtCmsKKdSQiYaP+qs8HQQdaHHQrVUFG0OevzXmXtMWSywvNcmf2wuUoB0YzVWEa0r8pWycU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GthrERWm7UDz3jttT/Jh0oPn9Q6D3OSqIRBQvnqKb0oUi6w3gKo CO0b5tco3exFrVaPF0NlfFKudvwFElIb4ohuo=
  • Ironport-sdr: vVc4Uv59KrjVwq98irhOKRHGp3JjtRgyjxJJokmtOKIazOS2JHbqw6zXp9qx9F4dh9Srzi8dBS AKMdx88DRt7eDVXdklEDtrQEnL9CnC99tJPWSRooEA6hZqeoLM/dUW5hgn9gXdaZe8qUiyaXN+ HKEOeWovXr7KTW2PxFKel5QVmIKpI6g85minSPNFTfjTuDbTRx28eM9BuZntU98dFV2g2nrTGP rBqgpXJUHCE2aVJxBuVpaiQZURdkmre31KHXnYIfDdAhJgZnWEExDISeOoBjdWyOfj1dDISIkS Z5i27vEU1VDgO/Tqx4DT4GUX
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Tue, Feb 01, 2022 at 08:56:49AM +0000, Oleksandr Andrushchenko wrote:
> Hi, Roger!
> 
> On 31.01.22 10:45, Oleksandr Andrushchenko wrote:
> > Hi, Roger!
> >
> > On 13.01.22 13:40, Roger Pau Monné wrote:
> >> On Thu, Nov 25, 2021 at 01:02:42PM +0200, Oleksandr Andrushchenko wrote:
> >>> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>
> >>> +#ifdef CONFIG_HAS_VPCI_GUEST_SUPPORT
> >>> +/* Notify vPCI that device is assigned to guest. */
> >>> +int vpci_assign_device(struct domain *d, struct pci_dev *pdev)
> >>> +{
> >>> +    int rc;
> >>> +
> >>> +    /* It only makes sense to assign for hwdom or guest domain. */
> >>> +    if ( is_system_domain(d) || !has_vpci(d) )
> >>> +        return 0;
> >>> +
> >>> +    spin_lock(&pdev->vpci_lock);
> >>> +    rc = run_vpci_init(pdev);
> >> Following my comment below, this will likely need to call
> >> vpci_add_handlers in order to allocate the pdev->vpci field.
> >>
> >> It's not OK to carry the contents of pdev->vpci across domain
> >> assignations, as the device should be reset, and thus the content of
> >> pdev->vpci would be stale.
> >>
> >>> +    spin_unlock(&pdev->vpci_lock);
> >>> +    if ( rc )
> >>> +        vpci_deassign_device(d, pdev);
> >>> +
> >>> +    return rc;
> >>> +}
> >>> +
> >>> +/* Notify vPCI that device is de-assigned from guest. */
> >>> +int vpci_deassign_device(struct domain *d, struct pci_dev *pdev)
> >>> +{
> >>> +    /* It only makes sense to de-assign from hwdom or guest domain. */
> >>> +    if ( is_system_domain(d) || !has_vpci(d) )
> >>> +        return 0;
> >>> +
> >>> +    spin_lock(&pdev->vpci_lock);
> >>> +    vpci_remove_device_handlers_locked(pdev);
> >> You need to free the pdev->vpci structure on deassign. I would expect
> >> the device to be reset on deassign, so keeping the pdev->vpci contents
> >> would be wrong.
> > Sure, I will re-allocate pdev->vpci then
> After thinking a bit more on this I have realized that we cannot free
> pdev->vpci on de-assign. The reason for that is the fact that vpci
> structure contains vital data which is collected and managed at different
> stages: for example, BAR types are collected while we run for the
> hardware domain and in init_bars we collect the types of the BARS etc.
> This is then used while assigning device to construct guest's representation
> of the device. Freeing vpci will lead to that data is lost and the required
> data is not populated into vpci.
> So, it is no possible to free vpci structure and I am about to leave the
> approach as it is.

We discussed this on IRC, and we have agreed that it's possible to
free pdev->vpci on deassign since in any case we need to call
init_bars (and other capability init functions) when the device is
assigned to setup the register traps and fetch the required
information in order to fill pdev->vpci.

Roger.



 


Rackspace

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