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

Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.


  • To: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Fri, 15 Oct 2021 12:19:48 +0200
  • 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=7MNC1a91rpq7DUgy3k6U5HtOdN4y858cGx50d5cboIg=; b=Eb39JKwWNVv+aBMhJwDE/KcdsiX61rXoCk3GPT41kqLrD29cjN/Cf962ikQnjpxMo5Xr8VYKt8yKYxd8qT0916e483IkU8clhDcsNuU4SuQjaZwKklUjqaf1glU1gxADnRXoUQvBflfBwUJr8RnhfTU9EjHSzvkXodL1Q7wUbH25Z4QS5hLoq0XHx7rP9/w5eppg92f75koyHyNwuLfakrzJFfTZKLp4eWIBjCQwaFgaxYVjzQ3Eo7Bznk5XOAmJJZeq3Z7a/meVM97BS11QVzgMPuJKSVpoWjuHJ1KkqIJ1ZtmOGNSXZvp7sIqsUZF6fy4jnmHgxSXm5t0S201z+Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YX9LFIxx5zscLhPM1odE3bXgND9SDwQuOfdz0NcsIe+3CQtS1yeYUveP199Vz9srrL8n0TVIwRam3pYR/UAZPNCjuRgHYsWxzvQxD+yeIu/8j7DtjgNuxDVJko8krM9Bcwt6cdV1nRF+76WxKRQqZvV8XJuTDXim/+/Tz46dewZ9TiorMTHmH7sAZtMYPupcld1VkeGp110arOTXhOtM7GWT6oJ3D9zSLeC6YCvAmoWNsEac7ia1aItJb+3FOY80vejHLE16TVh6zP6Iv3yY5pWhFoxLgNDZ/i6dnQbvsJeibgeBioVmsEvxs51juxVPf+O/Xtp57k6+Duq5+Liw5w==
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Rahul Singh <Rahul.Singh@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Wei Liu <wl@xxxxxxx>, Paul Durrant <paul@xxxxxxx>, Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • Delivery-date: Fri, 15 Oct 2021 10:20:16 +0000
  • Ironport-data: A9a23:OTabFa5BBVbLd2cIstuCGAxRtCjBchMFZxGqfqrLsTDasY5as4F+v mIfUGjSPq2LYTfxKY1/Odmz9U0Bu8LWmN81SwZo+yBgHi5G8cbLO4+Ufxz6V8+wwmwvb67FA +E2MISowBUcFyeEzvuV3zyIQUBUjclkfJKlYAL/En03FVIMpBsJ00o5wrdh29Mw2LBVPivW0 T/Mi5yHULOa82Yc3lI8s8pvfzs24ZweEBtB1rAPTagjUG32zhH5P7pGTU2FFFPqQ5E8IwKPb 72rIIdVXI/u10xF5tuNyt4Xe6CRK1LYFVDmZnF+A8BOjvXez8CbP2lS2Pc0MC9qZzu1c99Z8 MsUn7G0bAIVOO71srsfFDR3MnhiBPgTkFPHCSDXXc27ykTHdz3nwul0DVFwNoodkgp1KTgQr 7pCcmlLN03dwbLtqF64YrAEasALNs7kMZlZonh95TrYEew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/9HENAQRD24 mC+RVYPne0pjEkoDIS2F5LOmFX88im4eumvEupuuxHKjkTx9dG1Ui6s5jgXt5ClVHukworYtWm Vj+fg+yDqSUmHf6EDcNWUYwjAhpeOUtcYeYpta3CnOwtfoZ+ywZWaguwNWC+KtL4TSMepLDK2c P46n6DfwffI6MSODs5t2ud5bPvu/E5YnLClDBulOpipb1u4sfiGcuU+EZWkzTP7y4VQtBkb28R 4D5e9IiSjC6IXlUDhHNzrfMF
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Fri, Oct 15, 2021 at 09:52:28AM +0000, Bertrand Marquis wrote:
> Hi Roger,
> 
> > On 15 Oct 2021, at 09:32, Roger Pau Monné <roger.pau@xxxxxxxxxx> wrote:
> > 
> > On Thu, Oct 14, 2021 at 03:49:50PM +0100, Bertrand Marquis wrote:
> >> From: Rahul Singh <rahul.singh@xxxxxxx>
> >> diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
> >> index 3aa8c3175f..8cc529ecec 100644
> >> --- a/xen/drivers/passthrough/pci.c
> >> +++ b/xen/drivers/passthrough/pci.c
> >> @@ -658,7 +658,7 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,
> >>                    const struct pci_dev_info *info, nodeid_t node)
> >> {
> >>     struct pci_seg *pseg;
> >> -    struct pci_dev *pdev;
> >> +    struct pci_dev *pdev = NULL;
> >>     unsigned int slot = PCI_SLOT(devfn), func = PCI_FUNC(devfn);
> >>     const char *pdev_type;
> >>     int ret;
> >> @@ -752,6 +752,19 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,
> >> 
> >>     check_pdev(pdev);
> >> 
> >> +#ifdef CONFIG_ARM
> >> +    /*
> >> +     * On ARM PCI devices discovery will be done by Dom0. Add vpci 
> >> handler when
> >> +     * Dom0 inform XEN to add the PCI devices in XEN.
> >> +     */
> >> +    ret = vpci_add_handlers(pdev);
> >> +    if ( ret )
> >> +    {
> >> +        printk(XENLOG_ERR "Setup of vPCI failed: %d\n", ret);
> >> +        goto out;
> >> +    }
> >> +#endif
> > 
> > I think vpci_add_handlers should be called after checking that
> > pdev->domain is != NULL, so I would move this chunk a bit below.
> 
> On arm this would prevent the dom0less use case or to have the PCI
> bus enumerated from an other domain.

vpci_add_handlers will try to access pdev->domain, so passing a pdev
without domain being set is wrong.

> @oleksandr: can you comment on this one, you might have a better
> answer than me on this ?
> 
> > 
> >> +
> >>     ret = 0;
> >>     if ( !pdev->domain )
> >>     {
> >> @@ -784,6 +797,9 @@ out:
> >>                    &PCI_SBDF(seg, bus, slot, func));
> >>         }
> >>     }
> >> +    else if ( pdev )
> >> +        pci_cleanup_msi(pdev);
> > 
> > I'm slightly lost at why you add this chunk, is this strictly related
> > to the patch?
> 
> This was discussed a lot in previous version of the patch and
> requested by Stefano. The idea here is that as soon as handlers
> are added some bits might be modified in the PCI config space
> leading possibly to msi interrupts. So it is safer to cleanup on the
> error path. For references please see discussion on v4 and v5 where
> this was actually added (to much references as the discussion was
> long so here [1] and [2] are the patchwork thread).

pci_add_device being solely used by trusted domains, I think it would
be fine to require that the domain doesn't poke the PCI config space
until the call to pci_add_device has finished. Else it's likely to get
inconsistent results, or mess up with the device state.

In any case, such addition needs some kind of reasoning added to the
commit message if it's really required.

Thanks, Roger.



 


Rackspace

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