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

Re: [PATCH v5 11/14] vpci: add initial support for virtual PCI bus topology


  • To: Oleksandr Andrushchenko <andr2000@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 12 Jan 2022 16:39:12 +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=uuaw4pm64S8+1bi66QUmMLszgHEtQ4lMfAZnq59p/vU=; b=LrUiwrTutSkGPoZFVzhdNXy4HoEQSWpd4ZAM9pYMIYOrdqSniiCPc4EVlWpNj0cfJ/RbqOI+dobaECePfEAbkywXSoBriBqnOG80YtyVXLhgm5tZxfXbUX1t+lg8zm3p2b4sFcv/bLFLh0waVHGsKEu6zuf0R0HzajdyULIsCN9UM5hb7GXPqYyuLP/oLRk3nW17wo0zonyGiLPQqWYhGhOSq45Gej3FMXsf0TJ/vMXgcpYSm3l7q3rn6wKPWpNR6Ck+XrZLpfTsxNrbiKgSPrMF1AL4JL4j7F6EAyT3OmRbtY1Nn5hDV4jONabPwGMKJimtbdrEfUosgNIy93mA6g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QG8Q4o4EPXxjCRXigM7CK2vX9Om3Bkqhdq8osJZXlbM/6hiBAwOGpLNY/7U56KYuZ5ocVKw/cYj1cEV2LnWVL/mKIGtXL5Z1CYY5GUfhUV8IW7oseyTasas0mygjizku2JZ38Qq8jSn6B7aRhpPDB7+QVX+d3kEF9+ISnXc5reEzGcNi1RRhtgsWj9NzAI+cTBY0JjRC/S26bGjSB3a6yF9QtfFGxTK9JRZCs1Aa9zY6F7LXjhN9M9twW4dTbH2mwoBhUIqfa80209fPS6EVbq3olYE2VdwPPkOHDNKvDTINP4VyyAEWNu6w9sz4MgzfbW77hRWpkEeNU9eP38aTMw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: julien@xxxxxxx, sstabellini@xxxxxxxxxx, oleksandr_tyshchenko@xxxxxxxx, volodymyr_babchuk@xxxxxxxx, Artem_Mygaiev@xxxxxxxx, roger.pau@xxxxxxxxxx, andrew.cooper3@xxxxxxxxxx, george.dunlap@xxxxxxxxxx, paul@xxxxxxx, bertrand.marquis@xxxxxxx, rahul.singh@xxxxxxx, Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 12 Jan 2022 15:39:35 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 25.11.2021 12:02, Oleksandr Andrushchenko wrote:
> @@ -145,6 +148,53 @@ int vpci_add_handlers(struct pci_dev *pdev)
>  }
>  
>  #ifdef CONFIG_HAS_VPCI_GUEST_SUPPORT
> +int vpci_add_virtual_device(struct pci_dev *pdev)
> +{
> +    struct domain *d = pdev->domain;
> +    pci_sbdf_t sbdf = { 0 };
> +    unsigned long new_dev_number;
> +
> +    /*
> +     * Each PCI bus supports 32 devices/slots at max or up to 256 when
> +     * there are multi-function ones which are not yet supported.
> +     */
> +    if ( pdev->info.is_extfn )
> +    {
> +        gdprintk(XENLOG_ERR, "%pp: only function 0 passthrough supported\n",
> +                 &pdev->sbdf);
> +        return -EOPNOTSUPP;
> +    }
> +
> +    new_dev_number = find_first_zero_bit(&d->vpci_dev_assigned_map,
> +                                         VPCI_MAX_VIRT_DEV);
> +    if ( new_dev_number >= VPCI_MAX_VIRT_DEV )
> +        return -ENOSPC;
> +
> +    __set_bit(new_dev_number, &d->vpci_dev_assigned_map);
> +
> +    /*
> +     * Both segment and bus number are 0:
> +     *  - we emulate a single host bridge for the guest, e.g. segment 0
> +     *  - with bus 0 the virtual devices are seen as embedded
> +     *    endpoints behind the root complex
> +     *
> +     * TODO: add support for multi-function devices.
> +     */
> +    sbdf.devfn = PCI_DEVFN(new_dev_number, 0);
> +    pdev->vpci->guest_sbdf = sbdf;
> +
> +    return 0;
> +
> +}
> +REGISTER_VPCI_INIT(vpci_add_virtual_device, VPCI_PRIORITY_MIDDLE);

Is this function guaranteed to always be invoked ahead of ...

> +static void vpci_remove_virtual_device(struct domain *d,
> +                                       const struct pci_dev *pdev)
> +{
> +    __clear_bit(pdev->vpci->guest_sbdf.dev, &d->vpci_dev_assigned_map);
> +    pdev->vpci->guest_sbdf.sbdf = ~0;
> +}

... this one, even when considering error paths? Otherwise you may
wrongly clear bit 31 here afaict.

Jan




 


Rackspace

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