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

Re: [BUG]Add PCIE devie to SMMUv3 fail


  • To: sisyphean <sisyphean@zlw.email>
  • From: Rahul Singh <Rahul.Singh@xxxxxxx>
  • Date: Mon, 12 Dec 2022 16:30:47 +0000
  • Accept-language: 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=A7v0H9dM0cYnw02ADRWPxuNzWqTPlELM43gCakoW97A=; b=GCvbOF6WPmjNFSAmpzMrRM/YnT8wulbGml3avoKV/UNzMqoJKgjOhs+Urm68SLjFCPi94AMJJo+8pbQ4bDVJe4N4zADyluXDoIr8UqidV7s7wNDXHTIqfMVHLwKf0ZnT8Ajszi2u240LOzW8j9GzTOB9/q43zfvNk3o6Z0+mWfUDM6eviIZwNwbUq6TUqwzTCV92kc54SyJIUKsn5uQa1J43Y/gNnNKROvYda1B9JcGlN8n1QfUH88pHcQ/sIy1NVf/tQnKqIdbSpIxoqGC2Vc98C/p1IpK8Lz/8JtWxQn2aFNbUUpuV9G74X+DkGy1qmh8dH0PtLEkQrrrBlz7tYA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SFJIhIiV9RK/9Xz/q/rL8KXz3EwjssS7U+vDYnzh14z9hkimmzfxcnyhEfb0RK1khgzYJ+JwrnFK0EQhDu5jGPxVeZLGk6C6tNaBIChSxzpvSGzR/wrDmUXliHgJXdHEgUqgmNHhKV+nFeumoTFKAo1s2O3V+bvHsi5n6K+vgPEoJ6o6nesAoFKbDX7okR4gbAyWZCZ6Tyo65dVd4H0HuO4uKtK5CChzfQjHbnvsIkEZvv/ESf9TTRM9ukwD1CIs1cwzcXOp2FHLzMs7S7ttWeFLq9ExtU8hWbsGGPRSIzOWIbUTynqsXmf4cwdFfeSPK+rG2dnCYpgBdOE55VYmHw==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 12 Dec 2022 16:31:10 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHZC5XCObk04ipFEE+2cKVjhEnU1a5lUAQAgARztoCAALM7gA==
  • Thread-topic: [BUG]Add PCIE devie to SMMUv3 fail

Hi Sisyphean,

> On 12 Dec 2022, at 5:49 am, sisyphean <sisyphean@zlw.email> wrote:
> 
> Hi,
> 在 2022/12/9 17:50, Rahul Singh 写道:
>> Hi Sisyphean,
>> 
>> > On 9 Dec 2022, at 6:15 am, sisyphean <sisyphean@zlw.email> wrote:
>> > 
>> > Hi,
>> > 
>> > I try to run XEN on my ARM board(Sorry, for some commercial reasons, I 
>> > can't tell you
>> > on which platform I run XEN)  and add PCIE device passthrough to DomU.But 
>> > an error
>> > occurred while adding the PCIE device to SMMUv3.
>> 
>> PCI passthrough support is not fully upstream to Xen on ARM. We have working
>> PCI passthrough branch that you can use to test it. 
>> 
>> https://gitlab.com/xen-project/fusa/xen-integration/-/commits/integration/pci-passthrough
>> 
>> > 
>> > Through reading the code and tracing debugging, the error is found in the 
>> > function
>> > arm_smmu_add_device, which will obtain and determine whether the fwspec of 
>> > the
>> > device to be added to SMMU exists.But for the XEN of arm, the fwspec of 
>> > the device is
>> > created and added by judging whether the iommu field exists in the device 
>> > node when
>> > XEN parses the device tree.However, the PCIE device does not appear in the 
>> > device tree,
>> > so there will be no fwspec for all PCIE devices. When attempting to add a 
>> > PCIE device to
>> > SMMU, a ENODEV error will be returned.
>> 
>> As of now Xen doesn’t support to add PCI device to IOMMU on ARM. 
>> > 
>> > In addition, the code at xen/drivers/passthrough/pci.c also verifies the 
>> > above view.
>> > For PCIE devices, pdev is alloc in function pci_add_device by 
>> > alloc_pdev.However,
>> > the function alloc_pdev does not create and add fwspec to the PCIE 
>> > device.Therefore,
>> > when function pci_add_device executes to iommu_add_device,it will get the 
>> > error
>> > return of ENODEV.
>> > 
>> > How can I resolve the above errors?
>> 
>> If you want to test the PCI passthrough please follow below steps.
>> 
>> Xen setup:
>>     • A checkout of the “integration/pci-passthrough” branch from the  
>> gitlab 
>> https://gitlab.com/xen-project/fusa/xen-integration/-/commits/integration/pci-passthrough
>>     • Pass iommu=yes  and pci-passthrough=on to Xen command line to enable 
>> PCI passthrough.
>> 
>>  Linux Kernel setup:
>>  
>>     • Some changes are required for the kernel to work with PCI passthrough. 
>> First are some configuration options, enable them in kernel config.
>>          CONFIG_XEN=y
>>          CONFIG_XEN_BACKEND=y
>>          CONFIG_XEN_PCIDEV_BACKEND=y
>>     • Then a patch needs to be applied for enabling the pciback driver. 
>> Patch is attached in this email.
>>  
>> Using PCI passthrough:
>>  
>>     • In order to pass a device to a guest, you first need its PCI 
>> address(SBDF). You can either get it from a bare-metal
>>       Linux running on the platform or by having pciutils  installed (if you 
>> are using a yocto-based dom0 or have apt available), which provides lspci.
>>  
>>      For example, let's pass one ethernet interface to the guest. Running 
>> lspci gives us this output (truncated) :
>>        0000:00:00.0 Host bridge: Ampere Computing, LLC Device e100
>>        0000:00:01.0 PCI bridge: Ampere Computing, LLC Device e101 (rev 04)
>>        0000:01:00.0 Ethernet controller: Intel Corporation Ethernet 
>> Controller X710/X557-AT 10GBASE-T (rev 01)
>>                [...]
>>  
>>      We will pass one of the ethernet from the PCI network card : 
>> 0000:01:00.0 .
>>  
>>     • Add the following line to the guest configuration file :
>>           pci = ['0000:01:00.0']
>>  
>>     • Run the following command before starting the guest :
>>            xl pci-assignable-add 0000:01:00.0
>>     • Start the guest. The network interface should appear as 00:00.0  in 
>> the guest and be usable.
>>  
>> Please let me know if you need more info.
>> 
>> 
>> 
>> Regards,
>> Rahul
>> 
> Thank you for your reply.
> After setting XEN and kernel as above, I tried the following two methods to 
> add a PCIE device passthrough:
> 1. According to your suggestion, use the command xl pci-assignable-add 
> 0002:21:00.0 to set in the Dom0. But in function
> iommu_do_pci_domctl,  after device_assigned is called, ENODEV error is 
> obtained.
> 2. Add xen-pciback.hide=(0002:21:00.0) to dom0-bootargs in the device tree, I 
> encountered the same problem as before 
> when initializing the kernel. In function pci_add_device, PCIE devices cannot 
> be added to SMMUv3.

It is hard to find what is happening without logs. Could you please share the 
Xen and Linux boot logs so that I can
check what is the root cause of this issue.

> The kernel version I use is 5.10. Does this have an impact?

I am using the Linux version 5.15.44 but I don’t think is because of Linux.

Regards,
Rahul


 


Rackspace

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