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

Re: [PATCH] PCI/MSI: Fix masking MSI/MSI-X on Xen PV


  • To: David Woodhouse <dwmw2@xxxxxxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Mon, 25 Oct 2021 14:58:56 +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=u5HlCx1T4j1mLh8UL4lgbY+XWzMabz9h68wj0xoDXNg=; b=PzXDVuG7S2bjYvbNiGo097D+Tvw0A0F0ffKC70pVBcjTLXew7mf1z6xTMwDZyaAVcRmlACWnnpw+cDkI5N0LFgLN4L8Ho5CN2y5C81R4FUKkR0meolKvVaoRT31YrxYg0kSkz3hpQBkiL7DB76qgdjDoNmS9/CTTicP2kesiuCKAxaf6kIpRdkwbG9UJ9TIzeDJjL0xL5Q3C66Gb6Lt0RilJV1EyT1G/yeK1M9T135fKYTNXJTjz3w0q/KMwSELD/zT+mb4xSFFhSfpoKZWnWBloHwyuRYxUmitJ5WPAvN4iAh+m32I05Grzpr0gA+8WDIxw7oNyvp+ozloxX5iLgw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MfdX0Zuj8/Frnz7c5fhNQK/Vj4YPjxc9rRmK1C5xDKN8B03+CL3NyVE/p74rr5qSxj7lhLahVLq/9RN5VjrGbo/Qgw7o+3oU1FxtcWahaNh5fcZJYAZSTdtcjDRXZK4hH807fX/9FC1aPYlX5umBsTX+fgQ6NT9oWGRN8/bPo0VzF9QlreMNWVWHxbCtGlBf8EM+/LiDRMbgDbRbbNajuCXUSf1Box/YBFzr8bLH8ol08FRD48iKZ6KXLn2JxIRX7p6Z2aIsdvY9Vh7sx1QtmR4zpee1EIHpuHPXWZliLHr2x0V8MnGiWuiCj6YpXyzkA0vv9BEcNo43G3SzriNN6A==
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Jason Andryuk <jandryuk@xxxxxxxxx>, <josef@xxxxxxxxxxx>, <boris.ostrovsky@xxxxxxxxxx>, <helgaas@xxxxxxxxxx>, <jgross@xxxxxxxx>, <linux-pci@xxxxxxxxxxxxxxx>, <maz@xxxxxxxxxx>, <tglx@xxxxxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 25 Oct 2021 12:59:22 +0000
  • Ironport-data: A9a23:UVSf6a/leLbhi/WRURsoDrUD83iTJUtcMsCJ2f8bNWPcYEJGY0x3y WIYUWjQOf+PYTegeYoiYN61oxsFupOEn9NrHlFlry88E34SpcT7XtnIdU2Y0wF+jyHgoOCLy +1EN7Es+ehtFie0Si9AttENlFEkvU2ybuOU5NXsZ2YhGmeIdA970Ug6wrZj39Yx6TSEK1jlV e3a8pW31GCNg1aYAkpMg05UgEoy1BhakGpwUm0WPZinjneH/5UmJMt3yZWKB2n5WuFp8tuSH I4v+l0bElTxpH/BAvv9+lryn9ZjrrT6ZWBigVIOM0Sub4QrSoXfHc/XOdJFAXq7hQllkPgyy NNgnJmuRjskL6Dpg+YFfzdmEiZxaPguFL/veRBTsOSWxkzCNXDt3+9vHAc9OohwFuRfWD8Us 6ZCcXZUM07F17neLLGTE4GAguw5K8bmJsUHs2xIxjDFF/c2B5vERs0m4PcFgm9o3ZERRJ4yY eI6czk2ZwacbiYIeRAdWZgzsLysuHPWJmgwRFW9+vNsvjm7IBZK+LzsNsfFP8SBRO1LkUuC4 GHL5WL0BlcdLtP34TiK6HW3ncfUgDj2HokVE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sJYgFgLhs71sLcaqZ/Oa0r4xNvvWflvcnXH5KwIH+rl1uF/PrBPlopCLv0Fno DJoXSHoQUv2EcFOcmj5f/WirQF0WKS4AF7E8/KNtzbUP87zyAY+cTVtoZ6omXTESrS8a5JzW0t 4p1c+wdiy6Ey0ih4LPydoSMwekPze9ZRRB9XGwjgzNBE+c9+3x0cob3+m2s0onOBX65yFLkOKm GNoh+7pYkMpZ+G6GuXoGDn6z
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Mon, Oct 25, 2021 at 12:53:31PM +0100, David Woodhouse wrote:
> On Mon, 2021-10-25 at 13:43 +0200, Roger Pau Monné wrote:
> > It's kind of optional for HVM guests, as it depends on
> > XENFEAT_hvm_pirqs, which sadly gets unconditionally set for HVM
> > guests, thus dropping any benefits from having hardware assisted APIC
> > virtualization or posted interrupts support.
> 
> Indeed. After implementing PIRQ support for Xen guests running under
> KVM, I spent a "happy" couple of days swearing at it because it
> actually *worked* if something would just *unmask* the f***ing MSI, but
> the guest inexplicably (to me) didn't do that.
> 
> Took me a while to work out that Xen itself is *snooping* on the MSI
> table writes even while they are *masked*, to capture the magic MSI
> message (with vector==0) which means it's actually a PIRQ# in the
> destination ID bits, and then magically unmask the MSI when the guest
> binds that PIRQ to an event channel.
> 
> I did not enjoy implementing that part.

I can see that. It's even better because none of this is actually
documented.

> FWIW the *guest* could potentlaly be smarter here and elect not to use
> PIRQs when hardware assisted vAPIC is present. Aren't there some bits
> in the CPUID that Xen advertises, which indicate that? 

Yes, it's in leaf 0x40000x04. FWIW, I would also be fine with removing
XENFEAT_hvm_pirqs, as I don't think diverging from the hardware
specifications gives us much benefit. We avoid a couple of vm exits
for sure, but the cost of having all those modifications in guest
OSes is not worth it.

Roger.



 


Rackspace

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