From: Christoffer Dall <christoffer.dall@linaro.org>
To: Pavel Fedin <p.fedin@samsung.com>
Cc: 'Marc Zyngier' <marc.zyngier@arm.com>,
kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org
Subject: Re: [PATCH] KVM: arm/arm64: BUG FIX: Do not inject spurious interrupts
Date: Mon, 14 Sep 2015 13:29:32 +0200 [thread overview]
Message-ID: <20150914112932.GH15712@cbox> (raw)
In-Reply-To: <00ca01d0e171$7ff1c710$7fd55530$@samsung.com>
On Fri, Aug 28, 2015 at 12:11:17PM +0300, Pavel Fedin wrote:
> Hello!
>
> > It's a bit weird to just sned this as a new patch without replying to my
> > mail from yesterday with feedback
>
> Sorry. But changes are actually minimal, and i remember that i replied to you with the promise of
> testing your suggestion. So, done, works fine. :)
>
> > I think you're missing a potential change to the irq_pending_on_cpu
> > field here, which you have to compute by calling vgic_update_state()
> > like we do elsewhere when we change status bits
>
> I have just checked this. vgic_update_state() never resets this bit. This bit is reset only in
> __kvm_vgic_flush_hwstate() and only if we have consumed completely everything. I have followed
> through the code and looks like it's perfectly safe to have this bit set while nothing is actually
> pendng. Following __kvm_vgic_flush_hwstate(), having this bit cleared is actually a shorthand for
> "no interrupt is pending at all". If it is set without any interrupt actually being pending (this
> ends up in pa_percpu and pa_shared being all zeroes), all three for_each_set_bit() loops will just
> not do anything, and we still get to "epilog:" label, just after a bit longer check. And, since we
> are here, the guest has already been disturbed.
ok, looks like it is functionally correct, but I'm not thrilled about us
setting the state in the VGIC to something is pending on the CPU, when
really there is not. In that case, we should explicitly mark the bit as
a hint and not rely on its correctness and your patch should explain
this in vgic_update_irq_pending().
The alternative is to just call compute_pending which does nothing more
than a few bitwise and/or operations plus a couple of handfuls of
load/stores on this IRQ injection path, so I don't see the problem doing
this.
Does the code look awful? If so, why?
>
> > different from the incorrect approach I suggested yesterday where we
> > always just clear the bit for that vcpu).
>
> Yes, it is extremely bad idea to clear it because this bit summarizes all interrupts for this vcpu,
> and clearing it means that we are going to lose everything.
yes, I see this.
> An alternate would be: clear the bit, THEN call vgic_update_state() which would set it back if
> necessary. But does this extra bit of complexity worth anything, given one paragraph above?
>
I'm not sure your suggested approach works, because you could still
loose state for other IRQs I think.
-Christoffer
next prev parent reply other threads:[~2015-09-14 11:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-27 11:51 [PATCH] KVM: arm/arm64: BUG FIX: Do not inject spurious interrupts Pavel Fedin
2015-08-27 12:44 ` Christoffer Dall
2015-08-28 9:11 ` Pavel Fedin
2015-09-14 11:29 ` Christoffer Dall [this message]
2015-09-25 14:01 ` Pavel Fedin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150914112932.GH15712@cbox \
--to=christoffer.dall@linaro.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=marc.zyngier@arm.com \
--cc=p.fedin@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.