[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: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Thu, 23 Mar 2023 11:43:53 +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=sp53R9mfqA+z4/1nbloJSlzT4BHVq8APQQXPq6ejMFo=; b=eUfP9C20UQtJgN/DlbNH5FYIS7SaeEGDbGmdiErGIcoUC2z786hcESKbvDgNqzjZnKZbYT470LPrCaghrp/ypPdQZCS5qJhkX3xPO/1+jcIXlzhVd08mnAl1cgVsDGF10WapojxSkzvb2eAfzjxEr/1YDYRi19qX+oL/KUH3vU200Wc3mlkpOSEeqaEc/djOB4uKrQ4V8kkBpcxhzXZuu8L/FSgeVB70cDZecT0fcQ4ESCERyVe7aan4uh41ku0NZs5W36xqdcsEq9hg0iaL7qsrUtd5fIxFpXZkXYl1z23PkaUtl0/yajNlAZr087lpRJ+u36ETnnXCjU1v/IAOjA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xhy2M5cOrQJatl8EXVRkip0B/nTId2ZZdrwc6je5fZ8Q2txZHZDELgKqqMpiD+vfR7XfZN64hN9OVUJi2+sCxFpepZkJJHEJqrBGWQyMgDNyS+Vclg2lvdBywtXin+xsPPPFeNGXGjEJkg4N7ibvPx6qh7L+uzUuVOnUTpzEUYGrFSJBnyg93FOiaew3kbfVrW1aI4mlNQqqANzZpSJhHkP/FBCxBJRmVMR7gqlqDQoYYTBwaI1Rg4mAAmN2v1V4qMqQ6FbpISNYMcy4pDoSx3924zf9SUUaDX0h0muHwJOkQVgdpUONFLjMOuixSbDlrMb64/n6m+gBEq5H3dACvw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Huang Rui <ray.huang@xxxxxxx>, "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 10:44:21 +0000
  • Ironport-data: A9a23:rP5g5qIQsmMBpkesFE+Rv5UlxSXFcZb7ZxGr2PjKsXjdYENS0DdSn GccUGrTM6vbYzSgeYp/YN7n90wDvpLUnNUyTwJlqX01Q3x08seUXt7xwmUcnc+xBpaaEB84t ZV2hv3odp1coqr0/0/1WlTZhSAgk/rOHvykU7Ss1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpJrfPTwP9TlK6q4mhA5QZlPakjUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVaPpIAHOgdcS9qZwChxLid/ jnvWauYEm/FNoWU8AgUvoIx/ytWZcWq85efSZSzXFD6I+QrvBIAzt03ZHzaM7H09c5tKE8e+ /snDwkAdxuCrLqs7PXncNFz05FLwMnDZOvzu1lG5BSB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5ic twriqknqsSKSmFsDX25tDOWR0vvk2ooUA6mepWq3BES4MRZJJYsIRa1kJIF5UrGj789ekcYa BTJfCZwMwTXUKRbnjfsGUq6NuwXk4rFhPDeUQGstz96UkioFlJi28jgOAPlHYJ85wwD7Ne4f 7fD6hunLZSCucLcKNUHo46MIWKI12IZSiJHHOZIFzhGq1CEWnKsYTL7LI84/zvUIAUzaE1hI /KXDpjxCEPknrVeI2zNaBwg1PwqD3XZ0Wu9ige3ek0hlTEfsurDcXZI2pe1vdJoJ0kc7/msr iISdZr6sTYXBrT8LZyrnLDsqZpWAcjue0uy6IGsgG107X2A7yvkNDnW9DuA5eoOQoYewrEcw g+tX7IVYh90nw=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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.

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, Roger.



 


Rackspace

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