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

Re: RFC: PCI devices passthrough on Arm design proposal

  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Fri, 17 Jul 2020 13:14:25 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.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-SenderADCheck; bh=fGlWvLunnNEPD3F17cNmd24B3IWMU6l8zKXPOJpOy4c=; b=ck3RF6traEq3h0MygKJ3UvUdoGZJC2Ic/XzmV9Qcnhv72GJ+1WPxA/Rkyr88d0SasUVlHvRCRMaBAuX9NlAa5wuNIyEefQe0Es+oM4KTgXX1TPiWOhDsViV3IrXwJXhMzwkMmeomWUuuPE2w8tzcl1dckiL90EH13xR0HiDmhV0XHZ38eZ8qPGk+6d4ptg+R0JU6f8HRFUsXBwqHs3R1jS5dq/qbgfp08zEkUWJ1IG3NqApnHIqGFrSbFJSL/p0dJOaPo6D4ySNbYwI9X2doD5ifDUonoJBVt4nZ3IrsMcyr/gnLKN4kyPfpD/lJDxBKxhTen8cmBJUdIF7TzfapGw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B4W89KzXozt+dp0K8D6k+A1VviZCAzLtsdeGYi0QclUukekfsnuNpoMu6husxI+k5KmmjEJ70fhlAuTGO99tx2tJ87XYlHqNW7gSXyA7OTwQq44sTbV0y7eSmr9reXLrf0Q3PdMCW2wIy/3WEWW1LAc2skqmHh2Lrc9XbPMGAVV1SNzAdyWv0wxyO1ClpV0irzrbd9kl1vNfqn8xu6MPn89fJ8aAh0AZJm1Qo1Jmc2LYNDcOBNq29gyk5zndChiG2qtWdjSASMXUy9bebE3mM9yO4vV/AVmukkBFdTL7jNNrrPp1faWnjQdA5daDROU7arh+7plb3tPWeTL0ryJEUw==
  • Authentication-results-original: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=arm.com;
  • Cc: Rahul Singh <Rahul.Singh@xxxxxxx>, Julien Grall <julien.grall.oss@xxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, nd <nd@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Fri, 17 Jul 2020 13:14:37 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=arm.com;
  • Thread-topic: RFC: PCI devices passthrough on Arm design proposal

> On 17 Jul 2020, at 10:10, Jan Beulich <jbeulich@xxxxxxxx> wrote:
> On 16.07.2020 19:10, Rahul Singh wrote:
>> # Discovering PCI devices:
>> PCI-PCIe enumeration is a process of detecting devices connected to its 
>> host. It is the responsibility of the hardware domain or boot firmware to do 
>> the PCI enumeration and configure the BAR, PCI capabilities, and MSI/MSI-X 
>> configuration.
>> PCI-PCIe enumeration in XEN is not feasible for the configuration part as it 
>> would require a lot of code inside Xen which would require a lot of 
>> maintenance. Added to this many platforms require some quirks in that part 
>> of the PCI code which would greatly improve Xen complexity. Once hardware 
>> domain enumerates the device then it will communicate to XEN via the below 
>> hypercall.
>> #define PHYSDEVOP_pci_device_add        25
>> struct physdev_pci_device_add {
>>    uint16_t seg;
>>    uint8_t bus;
>>    uint8_t devfn;
>>    uint32_t flags;
>>    struct {
>>      uint8_t bus;
>>      uint8_t devfn;
>>    } physfn;
>>    /*
>>    * Optional parameters array.
>>    * First element ([0]) is PXM domain associated with the device (if * 
>> XEN_PCI_DEV_PXM is set)
>>    */
>>    uint32_t optarr[XEN_FLEX_ARRAY_DIM];
>>    };
>> As the hypercall argument has the PCI segment number, XEN will access the 
>> PCI config space based on this segment number and find the host-bridge 
>> corresponding to this segment number. At this stage host bridge is fully 
>> initialized so there will be no issue to access the config space.
>> XEN will add the PCI devices in the linked list maintain in XEN using the 
>> function pci_add_device(). XEN will be aware of all the PCI devices on the 
>> system and all the device will be added to the hardware domain.
> Have you had any thoughts about Dom0 re-arranging the bus numbering?
> This is, afaict, a still open issue on x86 as well.

no that’s not something we looked into. But in theory if this is done by Linux 
before Xen enumeration this will work. If a domain is trying to do this we have 
to look if we can somehow support this in VPCI but that is something we did not 
consider so far. 

>> Limitations:
>> * When PCI devices are added to XEN, MSI capability is not initialized 
>> inside XEN and not supported as of now.
> I think this is a pretty severe limitation, as modern devices tend to
> not support pin based interrupts anymore.

Sorry this is not what we meant. We will add MSI support but as of now this is 
not implemented or designed. “Limitations” means currently not supported but we 
will work on it on a second step.

>> # Emulated PCI device tree node in libxl:
>> Libxl is creating a virtual PCI device tree node in the device tree to 
>> enable the guest OS to discover the virtual PCI during guest boot. We 
>> introduced the new config option [vpci="pci_ecam"] for guests. When this 
>> config option is enabled in a guest configuration, a PCI device tree node 
>> will be created in the guest device tree.
> I support Stefano's suggestion for this to be an optional thing, i.e.
> there to be no need for it when there are PCI devices assigned to the
> guest anyway. I also wonder about the pci_ prefix here - isn't
> vpci="ecam" as unambiguous?

This could be a problem as we need to know that this is required for a guest 
upfront so that PCI devices can be assigned after using xl. 
Regarding the naming, I agree. We will remove the pci_ prefix here. 
>> A new area has been reserved in the arm guest physical map at which the VPCI 
>> bus is declared in the device tree (reg and ranges parameters of the node). 
>> A trap handler for the PCI ECAM access from guest has been registered at the 
>> defined address and redirects requests to the VPCI driver in Xen.
>> Limitation:
>> * Only one PCI device tree node is supported as of now.
>> BAR value and IOMEM mapping:
>> Linux guest will do the PCI enumeration based on the area reserved for ECAM 
>> and IOMEM ranges in the VPCI device tree node. Once PCI  device is assigned 
>> to the guest, XEN will map the guest PCI IOMEM region to the real physical 
>> IOMEM region only for the assigned devices.
>> As of now we have not modified the existing VPCI code to map the guest PCI 
>> IOMEM region to the real physical IOMEM region. We used the existing guest 
>> “iomem” config option to map the region.
>> For example:
>>      Guest reserved IOMEM region:  0x04020000
>>      Real physical IOMEM region:0x50000000
>>      IOMEM size:128MB
>>      iomem config will be:   iomem = ["0x50000,0x8000@0x4020"]
> This surely is planned to go away before the code hits upstream? The
> ranges really should be read out of the BARs, as I see the
> "limitations" section further down suggests, but it's not clear
> whether "limitations" are items that you plan to take care of before
> submitting your code for review.

definitely yes. As said before the limitations are in the RFC we will submit 
but we will work on that and remove those limitations before submitting the 
final code for review. 

Bertrand and Rahul

> Jan



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