From: christoffer.dall@linaro.org (Christoffer Dall)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC v2 8/9] KVM: KVM-VFIO: generic KVM_DEV_VFIO_DEVICE command and IRQ forwarding control
Date: Thu, 11 Sep 2014 19:32:01 +0200 [thread overview]
Message-ID: <20140911173201.GG5535@lvm> (raw)
In-Reply-To: <54116CFC.1050807@linaro.org>
On Thu, Sep 11, 2014 at 11:35:56AM +0200, Eric Auger wrote:
> On 09/11/2014 05:10 AM, Christoffer Dall wrote:
> > On Mon, Sep 01, 2014 at 02:52:47PM +0200, Eric Auger wrote:
[...]
> >> + if (!pfwd)
> >> + return -ENOMEM;
> >> + pfwd->index = fwd_irq->index;
> >> + pfwd->gsi = fwd_irq->gsi;
> >> + pfwd->hwirq = hwirq;
> >> + pfwd->vcpu = kvm_get_vcpu(kdev->kvm, 0);
> >> + ret = kvm_arch_set_fwd_state(pfwd, KVM_VFIO_IRQ_SET_FORWARD);
> >> + if (ret < 0) {
> >> + kvm_arch_set_fwd_state(pfwd, KVM_VFIO_IRQ_CLEANUP);
> >
> > this whole thing feels incredibly broken to me. Setting a forward
> > should either work or not work, not something in between that leaves
> > something to be cleaned up. Why this two-stage thingy here?
> I wanted to exploit the return value of vgic_map_phys_irq which is
> likely to fail if the phys/virt mapping exists at VGIC level.
then just have the kvm_arch_set_fwd_state return with -EXIST and it is
the responsibility of that function itself to cleanup from whatever it
was doing, not to rely on its caller to call a cleanup function.
>
> I already validated the injection from a KVM_VFIO_DEVICE point of view
> (the device/irq is not known internally). But what if another external
> component - which does not exist yet - maps the IRQ at VGIC level? Maybe
> I need to replace the existing validation check by querying the VGIC at
> low level instead of checking KVM-VFIO local variables.
No need to over-complicate this, in this case, the
kvm_arch_set_fwd_state() will simply fail (graceously), as I said above,
and you just return to the user, "sorry, couldn't do what you asked me
because of this error code".
[...]
> >> + *
> >> + * When this function is called, the vcpu already are destroyed. No
> > the VPUCs are already destroyed.
> >> + * vgic manipulation can happen hence the KVM_VFIO_IRQ_CLEANUP
> >> + * kvm_arch_set_fwd_state action
> >
> > this last bit didn't make any sense to me. Also, why are we referring
> > to the vgic in generic code?
> doesn't make sense anymore indeed. I wanted to emphasize the fact that
> VGIC KVM device is destroyed before the KVM VFIO device and this
> explains why I need a special CLEANUP cmd (besides the fact I need to
> call chip->irq_eoi(d) for the forwarded IRQs);
>
I don't think it explains why you need a special CLEANUP cmd. When the
vgic is going away it must cleanup its state. When the kvm vfio device
goes away, it must unforward any unforwarded IRQs, and the architecture
specific implementation MUST correctly unforward such IRQs - as a single
operation!
Hope this helps.
-Christoffer
next prev parent reply other threads:[~2014-09-11 17:32 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-01 12:52 [RFC v2 0/9] KVM-VFIO IRQ forward control Eric Auger
2014-09-01 12:52 ` [RFC v2 1/9] KVM: ARM: VGIC: fix multiple injection of level sensitive forwarded IRQ Eric Auger
2014-09-11 3:09 ` Christoffer Dall
2014-09-11 18:17 ` Eric Auger
2014-09-11 22:14 ` Christoffer Dall
2014-09-01 12:52 ` [RFC v2 2/9] KVM: ARM: VGIC: add forwarded irq rbtree lock Eric Auger
2014-09-11 3:09 ` Christoffer Dall
2014-09-11 17:31 ` Eric Auger
2014-09-01 12:52 ` [RFC v2 3/9] ARM: KVM: Enable the KVM-VFIO device Eric Auger
2014-09-01 12:52 ` [RFC v2 4/9] VFIO: platform: handler tests whether the IRQ is forwarded Eric Auger
2014-09-11 3:10 ` Christoffer Dall
2014-09-11 8:44 ` Eric Auger
2014-09-11 17:05 ` Christoffer Dall
2014-09-11 18:07 ` Alex Williamson
2014-09-11 17:08 ` Antonios Motakis
2014-09-01 12:52 ` [RFC v2 5/9] KVM: KVM-VFIO: update user API to program forwarded IRQ Eric Auger
2014-09-11 3:10 ` Christoffer Dall
2014-09-11 8:49 ` Eric Auger
2014-09-11 17:08 ` Christoffer Dall
2014-09-01 12:52 ` [RFC v2 6/9] VFIO: Extend external user API Eric Auger
2014-09-11 3:10 ` Christoffer Dall
2014-09-11 8:50 ` Eric Auger
2014-09-01 12:52 ` [RFC v2 7/9] KVM: KVM-VFIO: add new VFIO external API hooks Eric Auger
2014-09-11 3:10 ` Christoffer Dall
2014-09-11 8:51 ` Eric Auger
2014-09-01 12:52 ` [RFC v2 8/9] KVM: KVM-VFIO: generic KVM_DEV_VFIO_DEVICE command and IRQ forwarding control Eric Auger
2014-09-11 3:10 ` Christoffer Dall
2014-09-11 5:05 ` Alex Williamson
2014-09-11 12:04 ` Eric Auger
2014-09-11 15:59 ` Alex Williamson
2014-09-11 17:24 ` Christoffer Dall
2014-09-11 17:22 ` Christoffer Dall
2014-09-11 17:10 ` Christoffer Dall
2014-09-11 18:14 ` Alex Williamson
2014-09-11 21:59 ` Christoffer Dall
2014-09-11 9:35 ` Eric Auger
2014-09-11 15:47 ` Alex Williamson
2014-09-11 17:32 ` Christoffer Dall [this message]
2014-09-01 12:52 ` [RFC v2 9/9] KVM: KVM-VFIO: ARM " Eric Auger
2014-09-11 3:10 ` Christoffer Dall
2014-09-02 21:05 ` [RFC v2 0/9] KVM-VFIO IRQ forward control Alex Williamson
2014-09-05 12:52 ` Eric Auger
2014-09-11 3:10 ` Christoffer Dall
2014-09-11 5:09 ` Alex Williamson
2014-11-17 11:25 ` Wu, Feng
2014-11-17 13:41 ` Eric Auger
2014-11-17 13:45 ` Wu, Feng
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=20140911173201.GG5535@lvm \
--to=christoffer.dall@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).