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

Re: [PATCH v8 2/5] xen/arm: Enable the existing x86 virtual PCI support for ARM


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Mon, 18 Oct 2021 10:03:55 +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=xCGL8SNFNpLLM3D06NxF5xSBXoQ1UwrVW4z556ysmOc=; b=dLPtfRVqJwYBZd1Tl2ILdqPR9cg4H2Z87wvnAQS6HeX8422956K08uK1B/8ii63im4dCDwX8kfwW52sSM4ocSYFfO9X0nwUMU8AOwmkIVRbWwlcsVSFefIYI3lUaHs2pGN6wHK7Ur3M9xN4AocH37d+QqVedR6meMH8OP5r1fZAbHN47WrpOZv36U5fPIsgT4RlCstWHR50h6TK2BquoosSxaUxJglZtctuA/9Uz6jKmvpt5WhLUu4OPGs7ZdxyZdmRy6hl1uzDG+/+rShMr+IaZNYmP068GSOJJZXARuw4U2l4VF3Z9KKly18uz4Vf+9rjgqjZDxeQQXCH/xDMKKA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ipjy7lTwiboGV1RDAak9wUnT6AhRK/sKSIedEIB6ugIQIR6rLLiCUeLlKYpeIibFSsH1jO+AWK9wzNBaSz8z9WceO5lC9DpirmWF7IMFE0lJotxGSrwfwD+cP8xPnEWiFPEdmMq/xfks6lhxXTH8177903mN8VyWxKevlchF2niZrXuEbS7WAk+Hec5CUL1fdOPnyJwf8lNeLrp5bjyuCbLyD45DMcIbEPrI5hLZEoC5ps44faZaGe1KtF12YKKWTrAp/PDAaiGE0OcvJ0w5UmV76V5buMBvKymPNTRecV5bsEa2LEkgTEtF2hsYTyNVdgStr98dS5D5CY8V3OodfA==
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Bertrand Marquis <bertrand.marquis@xxxxxxx>, Rahul Singh <rahul.singh@xxxxxxx>, <iwj@xxxxxxxxxxxxxx>, <sstabellini@xxxxxxxxxx>, "Julien Grall" <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Paul Durrant <paul@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 18 Oct 2021 08:04:46 +0000
  • Ironport-data: A9a23:JNo7bqNY35FUdi3vrR3TkcFynXyQoLVcMsEvi/4bfWQNrUokhTxVz 2EaDWqBOP/ZNmCmeYh0atywoEgC657SyNdmTQto+SlhQUwRpJueD7x1DKtR0wB+jCHnZBg6h ynLQoCYdKjYdpJYz/uUGuCJQUNUjMlkfZKhTr6ZUsxNbVU8En540Uszw7dRbrNA2rBVPSvc4 bsenOWHULOV82Yc3rU8sv/rRLtH5ZweiRtA1rAMTakjUGz2zhH5OKk3N6CpR0YUd6EPdgKMq 0Qv+5nilo/R109F5tpICd8XeGVSKlLZFVDmZna7x8FOK/WNz8A/+v9TCRYSVatYoz6moP18z c1wjLubUixqOrH+28gCYSANRkmSPYUekFPGCX22sMjVxEzaaXr8hf5pCSnaP6VBpLwxWzsXs 6VFdnZdNXhvhMrvqF6/YvNrick5atHiIasUu216zCGfBvEjKXzGa/iXvo4IjG1v7ixINfSFT I1JNiBMVwjrPgNJI3VLWL0yovj90xETdBUH8QnI9MLb+VP78gt117T8N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VpFe5HdVHP7ucndd9VWP0A2C TaIn66e1a9Ez0/PfndvR3jA2e1R2cYHtBxQlQJQIl2InpzOh+Mt3Q0X+jMyF1wHwhJC2uN1G 25qK0wqevneo2Y23JBODzK2BgVMJByF4UigmVIGmVrQQ1SsSmGQfnY2PvyA/RxB/m9RFtSBE Gp0FIoxve7WQfzM
  • Ironport-hdrordr: A9a23:9ygcMqDq9+3IlnHlHemZ55DYdb4zR+YMi2TDgXoBMCC9Afb5qy nOppomPHDP5wr5NEtMpTnEAtjjfZq+z/RICOsqTNSftWDd0QOVxcNZnO7fKlbbakvDH5tmpM Bdmt9FebnN5DZB4foTv2KDeOrJibO8kZxAL92ut0tQcQ==
  • Ironport-sdr: 1dyQevWT6WDJAjtQZP2ac+4+kqDQr2HeaiUFzb3+9xDq63nKGXZSfBizK+UlGCHTi9WOSU1VWR caQUvk7MNCscokGNyQ2yUwhJyTmUDe/PtQnby7cJxdjSHXx+X8CWsWJSH9C7PyYmLi2E/C58p2 +YLWvTQ0rkcLS/4HZ7Re2QvHKJqKvJtTx0Rh0Rph0it92wFEKLQrRXNeQ+5uQw5iFh3DC2jVpt UGIHmUpZz0TtiwpiLwCqEJmK841uxuNDUP5SpFN0XTCr2Sv8CPN9Og79IAYsnIYfO2PK2V2C1r FDRGjUO7tix9MTGz+kvvYC+H
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Mon, Oct 18, 2021 at 09:47:06AM +0200, Jan Beulich wrote:
> On 15.10.2021 18:51, Bertrand Marquis wrote:
> > --- /dev/null
> > +++ b/xen/arch/arm/vpci.c
> > @@ -0,0 +1,77 @@
> > +/*
> > + * xen/arch/arm/vpci.c
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License as published by
> > + * the Free Software Foundation; either version 2 of the License, or
> > + * (at your option) any later version.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + */
> > +#include <xen/sched.h>
> > +#include <xen/vpci.h>
> > +
> > +#include <asm/mmio.h>
> > +
> > +static int vpci_mmio_read(struct vcpu *v, mmio_info_t *info,
> > +                          register_t *r, void *p)
> > +{
> > +    pci_sbdf_t sbdf;
> > +    /* data is needed to prevent a pointer cast on 32bit */
> > +    unsigned long data;
> > +
> > +    /* We ignore segment part and always handle segment 0 */
> > +    sbdf.sbdf = VPCI_ECAM_BDF(info->gpa);
> > +
> > +    if ( vpci_ecam_read(sbdf, ECAM_REG_OFFSET(info->gpa),
> > +                        1U << info->dabt.size, &data) )
> > +    {
> 
> Here it is quite clear that the SBDF you pass into vpci_ecam_read() is
> the virtual one. The function then calls vpci_read(), which in turn
> will call vpci_read_hw() in a number of situations (first and foremost
> whenever pci_get_pdev_by_domain() returns NULL). That function as well
> as pci_get_pdev_by_domain() use the passed in SBDF as if it was a
> physical one; I'm unable to spot any translation. Yet I do recall
> seeing assignment of a virtual device and function number somewhere
> (perhaps another of the related series), so the model also doesn't
> look to assume 1:1 mapping of SBDF.
> 
> > --- a/xen/drivers/passthrough/pci.c
> > +++ b/xen/drivers/passthrough/pci.c
> > @@ -756,6 +756,19 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,
> >      if ( !pdev->domain )
> >      {
> >          pdev->domain = hardware_domain;
> > +#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);
> > +            pdev->domain = NULL;
> > +            goto out;
> > +        }
> > +#endif
> >          ret = iommu_add_device(pdev);
> >          if ( ret )
> >          {
> 
> Upon failure, vpci_add_handlers() will itself call vpci_remove_handlers().
> What about iommu_add_device() failure? The device will have ->domain
> zapped, but all vPCI handlers still in place. This aspect of insufficient
> error cleanup was pointed out already in review of v1.
> 
> Furthermore already in v1 I questioned why this would be Arm-specific: On
> x86 this code path is going to be taken for all devices Xen wasn't able
> to discover at boot (anything on segments we wouldn't consider config
> space access safe on without reassurance by Dom0 plus SR-IOV VFs, at the
> very least).

My original plans for SR-IOV VFs on PVH dom0 involved trapping
accesses to the SR-IOV capability and detecting the creation of VFs
without the need for dom0 to notify them to Xen. This would avoid dom0
having to call PHYSDEVOP_pci_device_add for that case.

I might be confused, but I think we also spoke about other (non SR-IOV
related) cases where PCI devices might appear after certain actions by
dom0, so I think we need to keep the PHYSDEVOP_pci_device_add for PVH
dom0.

> Hence it is my understanding that something along these
> lines is actually also needed for PVH Dom0. I've just checked, and
> according to my mailbox that comment was actually left unresponded to.
> 
> Roger, am I missing anything here as to PVH Dom0 getting handlers put in
> place?

No, I think we will need those, likewise for run-time reported MCFG
regions.

Thanks, Roger.



 


Rackspace

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