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

Re: [RFC XEN PATCH 2/6] vpci: accept BAR writes if dom0 is PVH


  • To: Huang Rui <ray.huang@xxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Thu, 23 Mar 2023 17:23:39 +0100
  • 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=RCHwupboOH9N1m5o0ohbhUSnk3qxbfrCdnvZ5qLCsno=; b=R+PVG9jZFsXYRGcFZuFo8yJmbrYE8vT1l9Jwk+n5JmLuCqStNB7M6yMKxlIqqI3VihWYgbUe7dlCtYpEPao6MDF80AW6X2fwEzkFoxqxnxIK4nnIq1yagsZULpWsmpg/jVH63ZQR+1bTaJMkU+2e4W975haSzemRo2YTWg0xsm32bsQ3YvFChGAvEaIETXSXNIn7k3NPiE7gUNID5uhaU72Tb2DtpudOALYgEHuJp0NipBo4+iDY/9Ppq14sIoEneNLfoEBpNU+X39Chqbkq/o5jbgtq5WJmIlyST65AUdAJoS7t21FzN1BCpFArb6/DihL5U9rpPhFtDfD5TgHJRg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XwG/PT5AXkb8vWcOVa0l+IJaBxMJE4nGs7Xo44AIRSmLQrUltmOJMwsUTe82nvPyqCpDzNtba28aUTj9l2wQweRWHIp+3o5WuDTmeMXYOhyIEuEkAUPbhjFilLhspVcEqVvGn4sqYse6ug7vsvkqSjI+5xlV6yZ2UU7nKSU8Xn4KyB4xtslNA/2p6r5yuhr+OjNoeda01ttVz/WVQo6wRCSyWKMqlqRrL1wG5aVVxkSVw8TJrn6LngxtQ1R+Ql987brCuAJqSNNNxzIbD/KIRWNXGCz16X8VhKu7+ifv1gXPyG1o8eNW2uvdLtISq2Gfo3rZX6IyBLs9pbed8ErpmQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, "Deucher, Alexander" <Alexander.Deucher@xxxxxxx>, "Koenig, Christian" <Christian.Koenig@xxxxxxx>, "Hildebrand, Stewart" <Stewart.Hildebrand@xxxxxxx>, Xenia Ragiadakou <burzalodowa@xxxxxxxxx>, "Huang, Honglei1" <Honglei1.Huang@xxxxxxx>, "Zhang, Julia" <Julia.Zhang@xxxxxxx>, "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 23 Mar 2023 16:24:28 +0000
  • Ironport-data: A9a23:ivcDX6/w6Y2MuaKmqHyHDrUD6X6TJUtcMsCJ2f8bNWPcYEJGY0x3m GMfW2uGafrcMzT8f9FyYI3l90lTscOBmIdgTVBppS88E34SpcT7XtnIdU2Y0wF+jCHgZBk+s 5hBMImowOQcFCK0SsKFa+C5xZVE/fjUAOG6UKicYXoZqTZMEE8JkQhkl/MynrlmiN24BxLlk d7pqojUNUTNNwRcawr40Ire7kI/1BjOkGlA5AdmPqoQ5AW2e0Q9V/rzG4ngdxMUfaEMdgKKb 76r5K20+Grf4yAsBruN+losWhRXKlJ6FVHmZkt+A8BOsDAbzsAB+v9T2M4nQVVWk120c+VZk 72hg3ASpTABZcUgkMxFO/VR/roX0aduoNcrKlDn2SCfItGvn9IBDJyCAWlvVbD09NqbDklJr MQ2MHMpVimfxPCnwbCERqpHtuIaeZyD0IM34hmMzBn/JNN/GNXvZvuP4tVVmjAtmspJAPDSI dIDbiZiZwjBZBsJPUoLDJU5n6GjgXyXnz9w8QrJ4/ZopTWMilUvgNABM/KMEjCObd9SkUuC4 HrP4kzyAw0ANczZwj2Amp6prraXwX+kAtNDSNVU8NZVkmWhgVERASQzRGbhraelqnaUB/1Af hl8Fi0G6PJaGFaQZsP0Tlu4vXeCsTYVXtYWGOo/gCmPwKfJ5weSBkAfUyVMLtchsacebDgnx laPk97zQxBirbaVRGi1/7KY6zi1PEA9Bm8YZDQYTAIDpfrkrYcygTrGS9olG6mw5vXOBTzvy iqW6gg/g7keh9QC0amT9FXLxTmro/DhRBMv9AzTWW6i8QpRa4usZoju4l/ehd5gK4CWSlSA5 T4khsGY48gHCJ3LnyuIKM0vAbWo7rC3MDTajnZmGpVn/DOok1aBfJlR6Tc4D0dkNO4NfDOva 0jW0StK/4NaNnauaa5xYqqyBt4swKymEs7qPtjEY9wLbpVveQuv+CB1eVXWz23riFIrk6w0J dGca8nEMJoBIaFuzT7zS+JD17Yun3k63TmKG8C9yAm7272DYnLTUa0CLFaFcuE+6uWDvRnR9 NFcccCNzn2zTdHDX8UeyqZLRXhiEJTxLcyeRxB/HgJbHjdbJQ==
  • Ironport-hdrordr: A9a23:vziC4aO6F35/vcBcTs+jsMiBIKoaSvp037BL7SxMoHluGfBw+P rAoB1273HJYVQqOE3I6OrgBEDoexq1n/NICOIqTNSftWfdyQ6VBbAnwYz+wyDxXw3Sn9QtsZ uIqpIOauHNMQ==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu, Mar 23, 2023 at 09:34:40PM +0800, Huang Rui wrote:
> On Thu, Mar 23, 2023 at 06:43:53PM +0800, Roger Pau Monné wrote:
> > On Wed, Mar 22, 2023 at 01:48:30PM +0100, Jan Beulich wrote:
> > > On 22.03.2023 13:33, Huang Rui wrote:
> > > > I traced that while we do pci-assignable-add, we will follow below 
> > > > trace to
> > > > bind the passthrough device.
> > > > 
> > > > pciassignable_add()->libxl_device_pci_assignable_add()->libxl__device_pci_assignable_add()->pciback_dev_assign()
> > > > 
> > > > Then kernel xen-pciback driver want to add virtual configuration 
> > > > spaces. In
> > > > this phase, the bar_write() in xen hypervisor will be called. I still 
> > > > need
> > > > a bit more time to figure the exact reason. May I know where the
> > > > xen-pciback driver would trigger a hvm_io_intercept to xen hypervisor?
> > > 
> > > Any config space access would. And I might guess ...
> > > 
> > > > [  309.719049] xen_pciback: wants to seize 0000:03:00.0
> > > > [  462.911251] pciback 0000:03:00.0: xen_pciback: probing...
> > > > [  462.911256] pciback 0000:03:00.0: xen_pciback: seizing device
> > > > [  462.911257] pciback 0000:03:00.0: xen_pciback: pcistub_device_alloc
> > > > [  462.911261] pciback 0000:03:00.0: xen_pciback: initializing...
> > > > [  462.911263] pciback 0000:03:00.0: xen_pciback: initializing config
> > > > [  462.911265] pciback 0000:03:00.0: xen-pciback: initializing virtual 
> > > > configuration space
> > > > [  462.911268] pciback 0000:03:00.0: xen-pciback: added config field at 
> > > > offset 0x00
> > > > [  462.911271] pciback 0000:03:00.0: xen-pciback: added config field at 
> > > > offset 0x02
> > > > [  462.911284] pciback 0000:03:00.0: xen-pciback: added config field at 
> > > > offset 0x04
> > > > [  462.911286] pciback 0000:03:00.0: xen-pciback: added config field at 
> > > > offset 0x3c
> > > > [  462.911289] pciback 0000:03:00.0: xen-pciback: added config field at 
> > > > offset 0x3d
> > > > [  462.911291] pciback 0000:03:00.0: xen-pciback: added config field at 
> > > > offset 0x0c
> > > > [  462.911294] pciback 0000:03:00.0: xen-pciback: added config field at 
> > > > offset 0x0d
> > > > [  462.911296] pciback 0000:03:00.0: xen-pciback: added config field at 
> > > > offset 0x0f
> > > > [  462.911301] pciback 0000:03:00.0: xen-pciback: added config field at 
> > > > offset 0x10
> > > > [  462.911306] pciback 0000:03:00.0: xen-pciback: added config field at 
> > > > offset 0x14
> > > > [  462.911309] pciback 0000:03:00.0: xen-pciback: added config field at 
> > > > offset 0x18
> > > > [  462.911313] pciback 0000:03:00.0: xen-pciback: added config field at 
> > > > offset 0x1c
> > > > [  462.911317] pciback 0000:03:00.0: xen-pciback: added config field at 
> > > > offset 0x20
> > > > [  462.911321] pciback 0000:03:00.0: xen-pciback: added config field at 
> > > > offset 0x24
> > > > [  462.911325] pciback 0000:03:00.0: xen-pciback: added config field at 
> > > > offset 0x30
> > > > [  462.911358] pciback 0000:03:00.0: Found capability 0x1 at 0x50
> > > > [  462.911361] pciback 0000:03:00.0: xen-pciback: added config field at 
> > > > offset 0x50
> > > > [  462.911363] pciback 0000:03:00.0: xen-pciback: added config field at 
> > > > offset 0x52
> > > > [  462.911368] pciback 0000:03:00.0: xen-pciback: added config field at 
> > > > offset 0x54
> > > > [  462.911371] pciback 0000:03:00.0: xen-pciback: added config field at 
> > > > offset 0x56
> > > > [  462.911373] pciback 0000:03:00.0: xen-pciback: added config field at 
> > > > offset 0x57
> > > > [  462.911386] pciback 0000:03:00.0: Found capability 0x5 at 0xa0
> > > > [  462.911388] pciback 0000:03:00.0: xen-pciback: added config field at 
> > > > offset 0xa0
> > > > [  462.911391] pciback 0000:03:00.0: xen-pciback: added config field at 
> > > > offset 0xa2
> > > > [  462.911405] pciback 0000:03:00.0: xen_pciback: enabling device
> > > > [  462.911412] pciback 0000:03:00.0: enabling device (0006 -> 0007)
> > > > [  462.911658] Already setup the GSI :28
> > > > [  462.911668] Already map the GSI :28 and IRQ: 115
> > > > [  462.911684] pciback 0000:03:00.0: xen_pciback: save state of device
> > > > [  462.912154] pciback 0000:03:00.0: xen_pciback: resetting (FLR, D3, 
> > > > etc) the device
> > > > [  463.954998] pciback 0000:03:00.0: xen_pciback: reset device
> > > 
> > > ... it is actually the reset here, saving and then restoring config space.
> > > If e.g. that restore was done "blindly" (i.e. simply writing fields low to
> > > high), then memory decode would be re-enabled before the BARs are written.
> > 
> > The problem is also that we don't tell vPCI that the device has been
> > reset, so the current cached state in pdev->vpci is all out of date
> > with the real device state.
> > 
> > I didn't hit this on my test because the device I was using had no
> > reset support.
> > 
> > I don't think it's feasible for Xen to detect all the possible reset
> > methods dom0 might use, as some of those are device specific for
> > example.
> 
> OK.
> 
> > 
> > We would have to introduce a new hypercall that clears all vPCI device
> > state, PHYSDEVOP_pci_device_reset for example.  This will involve
> > adding proper cleanup functions, as the current code in
> > vpci_remove_device() only deals with allocated memory (because so far
> > devices where not deassigned) but we now also need to make sure
> > MSI(-X) interrupts are torn down and freed, and will also require
> > removing any mappings of BARs into the dom0 physmap.
> > 
> 
> Thanks for the suggestion. Let me make the new PHYSDEVOP_pci_device_reset
> in the next version instead of current workaround.
> 
> The MSI(-X) interrupts doesn't work in our platform, I don't figure the
> root cause yet.

Do MSI-X interrupts work when the device is in use by dom0 (both Pv
and PVH)?

> Could you please elaborate where we should require removing
> any mappings of BARs into the dom0 physmap here?

I think you can just use `modify_bars(pdev, 0, 0)`, as that will
effectively remove any BARs from the memory map.  That should also
take care of preemption, so you should be good to go.

Regards, Roger.



 


Rackspace

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