KVM: x86: Add lowest-priority support for vt-d posted-interrupts
Use vector-hashing to deliver lowest-priority interrupts for VT-d posted-interrupts. This patch extends kvm_intr_is_single_vcpu() to support lowest-priority handling. Signed-off-by: Feng Wu <feng.wu@intel.com> Reviewed-by: Radim Krčmář <rkrcmar@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
520040146a
commit
6228a0da80
@ -798,6 +798,20 @@ out:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This routine tries to handler interrupts in posted mode, here is how
|
||||||
|
* it deals with different cases:
|
||||||
|
* - For single-destination interrupts, handle it in posted mode
|
||||||
|
* - Else if vector hashing is enabled and it is a lowest-priority
|
||||||
|
* interrupt, handle it in posted mode and use the following mechanism
|
||||||
|
* to find the destinaiton vCPU.
|
||||||
|
* 1. For lowest-priority interrupts, store all the possible
|
||||||
|
* destination vCPUs in an array.
|
||||||
|
* 2. Use "guest vector % max number of destination vCPUs" to find
|
||||||
|
* the right destination vCPU in the array for the lowest-priority
|
||||||
|
* interrupt.
|
||||||
|
* - Otherwise, use remapped mode to inject the interrupt.
|
||||||
|
*/
|
||||||
bool kvm_intr_is_single_vcpu_fast(struct kvm *kvm, struct kvm_lapic_irq *irq,
|
bool kvm_intr_is_single_vcpu_fast(struct kvm *kvm, struct kvm_lapic_irq *irq,
|
||||||
struct kvm_vcpu **dest_vcpu)
|
struct kvm_vcpu **dest_vcpu)
|
||||||
{
|
{
|
||||||
@ -839,16 +853,44 @@ bool kvm_intr_is_single_vcpu_fast(struct kvm *kvm, struct kvm_lapic_irq *irq,
|
|||||||
if (cid >= ARRAY_SIZE(map->logical_map))
|
if (cid >= ARRAY_SIZE(map->logical_map))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
for_each_set_bit(i, &bitmap, 16) {
|
if (kvm_vector_hashing_enabled() &&
|
||||||
dst = map->logical_map[cid][i];
|
kvm_lowest_prio_delivery(irq)) {
|
||||||
if (++r == 2)
|
int idx;
|
||||||
|
unsigned int dest_vcpus;
|
||||||
|
|
||||||
|
dest_vcpus = hweight16(bitmap);
|
||||||
|
if (dest_vcpus == 0)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
idx = kvm_vector_to_index(irq->vector, dest_vcpus,
|
||||||
|
&bitmap, 16);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We may find a hardware disabled LAPIC here, if that
|
||||||
|
* is the case, print out a error message once for each
|
||||||
|
* guest and return
|
||||||
|
*/
|
||||||
|
dst = map->logical_map[cid][idx];
|
||||||
|
if (!dst && !kvm->arch.disabled_lapic_found) {
|
||||||
|
kvm->arch.disabled_lapic_found = true;
|
||||||
|
printk(KERN_INFO
|
||||||
|
"Disabled LAPIC found during irq injection\n");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
*dest_vcpu = dst->vcpu;
|
||||||
|
} else {
|
||||||
|
for_each_set_bit(i, &bitmap, 16) {
|
||||||
|
dst = map->logical_map[cid][i];
|
||||||
|
if (++r == 2)
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dst && kvm_apic_present(dst->vcpu))
|
||||||
|
*dest_vcpu = dst->vcpu;
|
||||||
|
else
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dst && kvm_apic_present(dst->vcpu))
|
|
||||||
*dest_vcpu = dst->vcpu;
|
|
||||||
else
|
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = true;
|
ret = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user