[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 <andr2000@xxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Thu, 13 Jan 2022 12:40:52 +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=Whnu4s4Kz3TznB2fQ1mDh5SGxRBCi6ctjNEfiolaOGo=; b=g15iX11cIb6BcMy3c1LHi/f0AVi1aqQHFOhq9rrrlWDOPE2HpDuX3SH5hRbwU0+oruGYkiIiorQDfMJJrzlHKZGTrnVosbI0I27Sbax1Ujxolcv9wjFyk7uY754ZGYbNiiOmL6eDL/3bZoQgViXhjnbsitNIFtn9QbkazYDPifeR74loQlDkU1njQ2xMZ2MZqdRuN/uRlXymThjOOczbeBX/NmC69f5n5+LFOHdM/YaAt0GRjzs6MJXQVBlw8H8gKmdIZpwjRA4WkTITH0BaQXgHcCWHRLCegbixDw6OmDWTTNHuPAfAvdlRTWtH2fUYR6mlQZtDxZLfHcwyzt8FMw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PwwKK8Kx/pOmaohb4HeR+Zy4CHtVXhIjoa1EDS+Vl89JY/HjnlBTs0kUl0L9H0WKHT9f2IM0sdBvhsDBudNEZ3UnZJnmaGQv+QSwgfQliju4Ok2Act16okSzOPkbWYEyX57D4VSzwPX7NqRyuPR8SgBeAlMw3dnZUX0YXTNpdmu+4aTWtYLQPhdRcdO9R4s0hw0NU/y2AOyXdUHTlM/XIIx21wt+AOp/5Wc+GHl5PaodOD4KX/FuR3BFZjDl4Y1pXr6q3dULQCGV19GN2RoPUyo1RScvagmmODaSENdwsvVuJ2rklBHg1k3PHOg3GSODBPpD/iveaM4kjaG5Q/WXJg==
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, <julien@xxxxxxx>, <sstabellini@xxxxxxxxxx>, <oleksandr_tyshchenko@xxxxxxxx>, <volodymyr_babchuk@xxxxxxxx>, <Artem_Mygaiev@xxxxxxxx>, <jbeulich@xxxxxxxx>, <andrew.cooper3@xxxxxxxxxx>, <george.dunlap@xxxxxxxxxx>, <paul@xxxxxxx>, <bertrand.marquis@xxxxxxx>, <rahul.singh@xxxxxxx>, Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>
  • Delivery-date: Thu, 13 Jan 2022 11:41:22 +0000
  • Ironport-data: A9a23:Fd7ZAqCyMJTSmxVW/+nlw5YqxClBgxIJ4kV8jS/XYbTApDgl1TxSz GccWj3VaavcNmX1c40nbYyzox8O6pfVyNdmQQY4rX1jcSlH+JHPbTi7wuYcHM8wwunrFh8PA xA2M4GYRCwMo/u1Si6FatANl1ElvU2zbue6WL6s1hxZH1c+En940Ek7wobVv6Yz6TSHK1LV0 T/Ni5W31G+Ng1aY5UpNtspvADs21BjDkGtwUm4WPJinj3eH/5UhN7oNJLnZEpfNatI88thW5 Qr05OrREmvxp3/BAz4++1rxWhVirrX6ZWBihpfKMkQLb9crSiEai84G2PQghUh/lyyluPN1j /53iKOOFlgYeYiXhr03XEwNe81+FfUuFL7vJHG+tYqYzlHccmuqyPJrZK00FdRGoKAtWzgIr KFGbmBWBvyAr7veLLaTUO5ji95lNMD2FIgepmth3XfSCvNOrZXrHfybvIYJhmtYasZmAq/Ud ZMpNhlVaFfZZhpiFFgvJMIitbL97pX4W2I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NoTypbVxJPHS1BYbU2IPNvpvNd84100iyoCPD/nM7rZd0OB Xqo2PnGsRM3mYKqkqDTCCgNW0euD0Gwz0j5E+UD6/6VqGJqIcyY82FRTx9aP9csr44jCJVi+7m LyHAzXyNgFkk6T+W0gyBZVtYETKQyzkkLPAbmUUgV8S7Y9hasG/vxT+9aQGsu3C7Pbw8Uqdqvj YrFD6/bCGIp9fkd5xXw8WYVE
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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.

Thanks, Roger.



 


Rackspace

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