Title: [kvm-devel] [PATCH 2/3] virtio ring implementation
Rusty Russell wrote:
These helper routines supply most of the
virtqueue_ops for hypervisors
which want to use a ring for virtio. Unlike the previous lguest
implementation:
1) The rings are variable sized (2^n-1 elements).
2) They have an unfortunate limit of 65535 bytes per sg element.
3) The page numbers are always 64 bit (PAE anyone?)
4) They no longer place used[] on a separate page, just a separate
cacheline.
5) We do a modulo on a variable. We could be tricky if we cared.
6) Interrupts and notifies are suppressed using flags within the rings.
Users need only implement the new_vq and free_vq hooks (KVM wants the
guest to allocate the rings, lguest does it sanely).
Signed-off-by: Rusty Russell <rusty@xxxxxxxxxxxxxxx>
[snip]
+irqreturn_t vring_interrupt(int irq, void *_vq)
+{
+ struct vring_virtqueue *vq = to_vvq(_vq);
+
+ pr_debug("virtqueue interrupt for %p\n", vq);
+
+ if (unlikely(vq->broken))
+ return IRQ_HANDLED;
+
+ if (more_used(vq)) {
+ pr_debug("virtqueue callback for %p (%p)\n",
+ vq, vq->vq.callback);
+ if (!vq->vq.callback)
+ return IRQ_NONE;
+ if (!vq->vq.callback(&vq->vq))
+ vq->vring.avail->flags |=
VRING_AVAIL_F_NO_INTERRUPT;
+ } else
+ pr_debug("virtqueue %p no more used\n", vq);
+
+ return IRQ_HANDLED;
+}
+
Seems like there is a problem with shared irq line, the
interrupt handler always returns IRQ_HANDLED (except for the trivial
case
were the callback is null).
It can be solved by having a host irq counter (in the shared ring) and
a guest irq counter and return
mb(); return (host_counter!=guest_counter)? IRQ_HANDLED:IRQ_NONE;
Dor.
|
_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linux-foundation.org/mailman/listinfo/virtualization