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

Re: [PATCH] x86/dpci: remove the dpci EOI timer


  • To: "Tian, Kevin" <kevin.tian@xxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Wed, 13 Jan 2021 14:11:00 +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-SenderADCheck; bh=H/AOWbh+OIpUw2RgLNucpUtTGLIMnXCQN7+S5oqLRaw=; b=OZSu7BWkuxEAyyiWGeoW6Jz/QPVBEyaOqRSuqEjm+h+lk2+k71YdqcMnrs/IJHJc0Ifg5BQ1PM1KdWB63BrrVmIWQF+BOCCkzaV/7yTxfymplDfmVqamut/Bw+EhN7XHUUsN3KjO2RiViMcKkOeL1pxQHWxNPzGeW1fN8gbuijs+pJECwp5Y9Xhvha7LcDtu5ibJb5/DpUOi/nJtmkFM0CqocqtdVPXyJUZU/kfFkn62zvbh42druLGKeGnHWXy3VdBUhO1lv6NlgKB+yK9nv2BfeAy2VV8C6NMGzkkCDNTwYEmCKY2Kl5RQv0eeXmiV8Y08nRTIw61FsKTMFTj7qA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EshERDNc3KoN89ar/cvufPTA8LPCre8nXIBd0UW8LJ/jSXRqLCN2Ru3ZTzL6EO+F1hmVxO+mHLZb1D5gbE4ZRXqRGx0PYkMRBzWWPalVk2nJkIO5VpnaX1dJYQBGxGG6EzRnKnQejGVEvjsHMyjikV96yHSIh6AYAQbDoAkARfkT9liVmzQZxea2MiuNghHdhoYKyh1DXSwsl8AAA6kLjL3L31oEG0zNrEShioDywBVvdokDhvFkDNJ72YR0YrrmxloHyACs/nca6Szd128BfIL8BEPRTDhhgOfuNn8ol06GZuaRmUobaxa5yV1wYoQ38wRNptvK/6+8NLrruEK0DA==
  • Authentication-results: esa5.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "Jan Beulich" <jbeulich@xxxxxxxx>, Paul Durrant <paul@xxxxxxx>, "Cooper, Andrew" <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Wed, 13 Jan 2021 13:11:18 +0000
  • Ironport-sdr: 52FpCBmqnwjHpmKdIcBfqijEASD613Qi6iHYgMTJCuEermEkPAQyQpfdR0KnKn2HBblpLmDjA/ Czw41dtGYpEvPd5nXBLtLvHD/zgP+H5CY+7HlB4zvknnabeV8higqvdXK6H/nj6XHDg28cWO4x a2f/pZ2T59b732IKjyWEFhIRheawpyd34h3nNSP0DjLiNmQq15OqgXEGhgtTBxB5+P6YKFxsBL iW0JvYMv8u75SgeflwSuLL0Hul92j80EdINrrP25QLh/I74rdWeofkmMHa4gXXvoAWyCD7LCZK 4uo=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, Jan 13, 2021 at 06:21:03AM +0000, Tian, Kevin wrote:
> > From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
> > Sent: Wednesday, January 13, 2021 1:33 AM
> > 
> > Current interrupt pass though code will setup a timer for each
> > interrupt injected to the guest that requires an EOI from the guest.
> > Such timer would perform two actions if the guest doesn't EOI the
> > interrupt before a given period of time. The first one is deasserting
> > the virtual line, the second is perform an EOI of the physical
> > interrupt source if it requires such.
> > 
> > The deasserting of the guest virtual line is wrong, since it messes
> > with the interrupt status of the guest. It's not clear why this was
> > odne in the first place, it should be the guest the one to EOI the
> > interrupt and thus deassert the line.
> > 
> > Performing an EOI of the physical interrupt source is redundant, since
> > there's already a timer that takes care of this for all interrupts,
> > not just the HVM dpci ones, see irq_guest_action_t struct eoi_timer
> > field.
> > 
> > Since both of the actions performed by the dpci timer are not
> > required, remove it altogether.
> > 
> > Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> > ---
> > As with previous patches, I'm having a hard time figuring out why this
> > was required in the first place. I see no reason for Xen to be
> > deasserting the guest virtual line. There's a comment:
> > 
> > /*
> >  * Set a timer to see if the guest can finish the interrupt or not. For
> >  * example, the guest OS may unmask the PIC during boot, before the
> >  * guest driver is loaded. hvm_pci_intx_assert() may succeed, but the
> >  * guest will never deal with the irq, then the physical interrupt line
> >  * will never be deasserted.
> >  */
> > 
> > Did this happen because the device was passed through in a bogus state
> > where it would generate interrupts without the guest requesting
> 
> It could be a case where two devices share the same interrupt line and
> are assigned to different domains. In this case, the interrupt activity of 
> two devices interfere with each other.

This would also seem to be problematic if the device decides to use
MSI instead of INTx, but due to the shared nature of the INTx line we
would continue to inject INTx (generated from another device not
passed through to the guest) to the guest even if the device has
switched to MSI.

> > 
> > Won't the guest face the same issues when booted on bare metal, and
> > thus would already have the means to deal with such issues?
> 
> The original commit was added by me in ~13yrs ago (0f843ba00c95)
> when enabling Xen in a client virtualization environment where interrupt
> sharing is popular.

Thanks, the reference to the above commit is helpful, I wasn't able to
find it and it contains a comment that I think has been lost, which
provides the background on why this was added.

> I believe above comment was recorded for a real 
> problem at the moment (deassert resets the intx line to unblock further
> interrupts). But I'm not sure whether it is still the case after both Xen and 
> guest OS have changed a lot. At least some test from people who
> still use Xen in shared interrupt scenario would be helpful. Or, if such
> usage is already niche, maybe we can consider disallow passing through
> devices which share the same interrupt line to different domains and
> then safely remove this dpci EOI trick.

So the deassert done by timeout only deasserts the virtual line, but
doesn't for example clear the IRR bit from the vIO-APIC pin, which
will cause further interrupts to not be delivered anyway until a
proper EOI (or a switch to trigger mode) is done to the pin.

I think it's going to be complicated for me to find a system that has
two devices I can passthrough sharing the same GSI.

It also makes me wonder why do we need to keep all this internal state
about virtual lines and assert counts. Such virtual lines will get
de-asserted when the guest perform an EOI of the interrupt, which also
clear the PIC pending bits and allows further interrupts to be
injected. Wouldn't it be enough to simply try to assert the guest
irq/gsi, and let the interrupt controller decide whether it needs to
inject another interrupt, or there's one already pending?

vIO-APIC has the IRR field which I think it's fairly similar to what
Xen achieves with all the line logic: prevent another interrupt
injection until the current one has been EOI'ed. The i8259 doesn't
have such field, and might indeed end up with an extra interrupt
queued in IRR while there's one still pending in ISR, but I don't
think that would be harmful to the guest.

Thanks, Roger.



 


Rackspace

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