On 08/13/2012 12:16 PM, Gleb Natapov wrote:
> Signed-off-by: Gleb Natapov <[email protected]>
>
> -int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src,
> +int kvm_irq_delivery_to_apic(struct kvm_kernel_irq_routing_entry *e,
> + struct kvm *kvm, struct kvm_lapic *src,
> struct kvm_lapic_irq *irq)
Would be nicer to put e at the end, and explain that it is optional.
> {
> - int i, r = -1;
> - struct kvm_vcpu *vcpu, *lowest = NULL;
> + int i, r = -1, c = 0;
> + struct kvm_vcpu *vcpu, *cache = NULL, *lowest = NULL;
>
> if (irq->dest_mode == 0 && irq->dest_id == 0xff &&
> kvm_is_dm_lowest_prio(irq))
> @@ -82,6 +83,8 @@ int kvm_irq_delivery_to_apic(struct kvm *kvm, struct
> kvm_lapic *src,
> if (!kvm_is_dm_lowest_prio(irq)) {
> if (r < 0)
> r = 0;
> + c++;
> + cache = vcpu;
> r += kvm_apic_set_irq(vcpu, irq);
> } else if (kvm_lapic_enabled(vcpu)) {
> if (!lowest)
> @@ -93,6 +96,8 @@ int kvm_irq_delivery_to_apic(struct kvm *kvm, struct
> kvm_lapic *src,
>
> if (lowest)
> r = kvm_apic_set_irq(lowest, irq);
> + else if (e && c == 1)
> + e->vcpu = cache; /* cache it */
>
> return r;
> }
> @@ -118,7 +123,9 @@ int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e,
> irq.shorthand = 0;
>
> /* TODO Deal with RH bit of MSI message address */
> - return kvm_irq_delivery_to_apic(kvm, NULL, &irq);
> + if (e->vcpu)
> + return kvm_apic_set_irq(e->vcpu, &irq);
> + return kvm_irq_delivery_to_apic(e, kvm, NULL, &irq);
> }
>
> int kvm_send_userspace_msi(struct kvm *kvm, struct kvm_msi *msi)
> @@ -131,6 +138,7 @@ int kvm_send_userspace_msi(struct kvm *kvm, struct
> kvm_msi *msi)
> route.msi.address_lo = msi->address_lo;
> route.msi.address_hi = msi->address_hi;
> route.msi.data = msi->data;
> + route.vcpu = NULL;
>
> return kvm_set_msi(&route, kvm, KVM_USERSPACE_IRQ_SOURCE_ID, 1);
> }
>
Missing cache invalidate on apicid write?
Otherwise nice and simple.
--
error compiling committee.c: too many arguments to function
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html