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

Re: [PATCH v4 11/11] xen/arm: translate virtual PCI bus topology for guests


  • To: Oleksandr Andrushchenko <andr2000@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 8 Nov 2021 12:10:39 +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=jvAGoe391StPaIngK1M3IcM1yPYh80+GCkggRfZspwo=; b=fyiJEuu6BL+1ZLWXRGXxrXusW+ISOtgficsv2pZ2h+AmsYWqXITHDKQ0nmMf4AAG3A1aGM2MdW/+dfx+Y7dpA7Dxp+PkOVnBfOA70VdiiUB0+QNPCB95RXUms9zSFg+S+koLnxIP6Ygv4ariAEghvP1OfImd0J2FBlD43zXedu8WadT6umdLOMaO9HnCLMqfM/RWCbbKAt+E5FlMBikKPj01ANLupLwQzNyY5m/xgUuNhi7HaR1T6iQPOQmD83Pm3IaIdGiCpQ45kfpWlgW68g1bqXDXDDzNiLCuAm7cJPbcd9CcR2S7CD5lVRc+qzHbxFxi2FwdExfqfA7mwRTOug==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n74x934Qf9YyCl2P1lfTc7JDpWuPjlbTgyzSE2DX55jwXTMkPwYm8c/5YKJoTzOJ8S1g7ugKAlIeH8LzcICJUiKM1l5ostKHnZ/N40iicTGwlBPhb4QrPRQwGq1T8EOMrWcJnqa0zGx2PaWoNs0uNMLXJwB7txHQyOOUNphPRvDUbvEuwByXsHFE5CdpLAZIeMnerFl5n57L5+aZ03XLP8nTxreaOFu4GylStg7w6BWRXG8F6rzrS6da0ENWkyGXom2V8XewaQ5jhstfDhoZPLSLvLPZVS7TyPyE+hA1Izuog9Se1wOoUuqSkbavc1eabjnjIjDqGu/9l8wg7iLg6w==
  • 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: Mon, 08 Nov 2021 11:11:00 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 05.11.2021 07:56, Oleksandr Andrushchenko wrote:
> --- a/xen/arch/arm/vpci.c
> +++ b/xen/arch/arm/vpci.c
> @@ -41,6 +41,15 @@ static int vpci_mmio_read(struct vcpu *v, mmio_info_t 
> *info,
>      /* data is needed to prevent a pointer cast on 32bit */
>      unsigned long data;
>  
> +#ifdef CONFIG_HAS_VPCI_GUEST_SUPPORT
> +    /*
> +     * For the passed through devices we need to map their virtual SBDF
> +     * to the physical PCI device being passed through.
> +     */
> +    if ( !bridge && !vpci_translate_virtual_device(v->domain, &sbdf) )
> +            return 1;

Nit: Indentation.

> @@ -59,6 +68,15 @@ static int vpci_mmio_write(struct vcpu *v, mmio_info_t 
> *info,
>      struct pci_host_bridge *bridge = p;
>      pci_sbdf_t sbdf = vpci_sbdf_from_gpa(bridge, info->gpa);
>  
> +#ifdef CONFIG_HAS_VPCI_GUEST_SUPPORT
> +    /*
> +     * For the passed through devices we need to map their virtual SBDF
> +     * to the physical PCI device being passed through.
> +     */
> +    if ( !bridge && !vpci_translate_virtual_device(v->domain, &sbdf) )
> +            return 1;

Again.

> @@ -172,10 +175,37 @@ REGISTER_VPCI_INIT(vpci_add_virtual_device, 
> VPCI_PRIORITY_MIDDLE);
>  static void vpci_remove_virtual_device(struct domain *d,
>                                         const struct pci_dev *pdev)
>  {
> +    ASSERT(pcidevs_locked());
> +
>      clear_bit(pdev->vpci->guest_sbdf.dev, &d->vpci_dev_assigned_map);
>      pdev->vpci->guest_sbdf.sbdf = ~0;
>  }
>  
> +/*
> + * Find the physical device which is mapped to the virtual device
> + * and translate virtual SBDF to the physical one.
> + */
> +bool vpci_translate_virtual_device(struct domain *d, pci_sbdf_t *sbdf)

const struct domain *d ?

> +{
> +    const struct pci_dev *pdev;
> +    bool found = false;
> +
> +    pcidevs_lock();
> +    for_each_pdev( d, pdev )
> +    {
> +        if ( pdev->vpci->guest_sbdf.sbdf == sbdf->sbdf )
> +        {
> +            /* Replace virtual SBDF with the physical one. */
> +            *sbdf = pdev->sbdf;
> +            found = true;
> +            break;
> +        }
> +    }
> +    pcidevs_unlock();

I think the description wants to at least mention that in principle
this is too coarse grained a lock, providing justification for why
it is deemed good enough nevertheless. (Personally, as expressed
before, I don't think the lock should be used here, but as long as
Roger agrees with you, you're fine.)

Jan




 


Rackspace

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