mirror of https://github.com/xqemu/xqemu.git
kvm: Add support for direct MSI injections
If the kernel supports KVM_SIGNAL_MSI, we can avoid the route-based MSI injection mechanism. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
This commit is contained in:
parent
80a3eb10fe
commit
4a3adebb18
22
kvm-all.c
22
kvm-all.c
|
@ -96,6 +96,7 @@ struct KVMState
|
||||||
uint32_t *used_gsi_bitmap;
|
uint32_t *used_gsi_bitmap;
|
||||||
unsigned int gsi_count;
|
unsigned int gsi_count;
|
||||||
QTAILQ_HEAD(msi_hashtab, KVMMSIRoute) msi_hashtab[KVM_MSI_HASHTAB_SIZE];
|
QTAILQ_HEAD(msi_hashtab, KVMMSIRoute) msi_hashtab[KVM_MSI_HASHTAB_SIZE];
|
||||||
|
bool direct_msi;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -898,8 +899,10 @@ static void kvm_init_irq_routing(KVMState *s)
|
||||||
s->irq_routes = g_malloc0(sizeof(*s->irq_routes));
|
s->irq_routes = g_malloc0(sizeof(*s->irq_routes));
|
||||||
s->nr_allocated_irq_routes = 0;
|
s->nr_allocated_irq_routes = 0;
|
||||||
|
|
||||||
for (i = 0; i < KVM_MSI_HASHTAB_SIZE; i++) {
|
if (!s->direct_msi) {
|
||||||
QTAILQ_INIT(&s->msi_hashtab[i]);
|
for (i = 0; i < KVM_MSI_HASHTAB_SIZE; i++) {
|
||||||
|
QTAILQ_INIT(&s->msi_hashtab[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
kvm_arch_init_irq_routing(s);
|
kvm_arch_init_irq_routing(s);
|
||||||
|
@ -1005,7 +1008,7 @@ again:
|
||||||
|
|
||||||
return bit - 1 + i * 32;
|
return bit - 1 + i * 32;
|
||||||
}
|
}
|
||||||
if (retry) {
|
if (!s->direct_msi && retry) {
|
||||||
retry = false;
|
retry = false;
|
||||||
kvm_flush_dynamic_msi_routes(s);
|
kvm_flush_dynamic_msi_routes(s);
|
||||||
goto again;
|
goto again;
|
||||||
|
@ -1031,8 +1034,19 @@ static KVMMSIRoute *kvm_lookup_msi_route(KVMState *s, MSIMessage msg)
|
||||||
|
|
||||||
int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg)
|
int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg)
|
||||||
{
|
{
|
||||||
|
struct kvm_msi msi;
|
||||||
KVMMSIRoute *route;
|
KVMMSIRoute *route;
|
||||||
|
|
||||||
|
if (s->direct_msi) {
|
||||||
|
msi.address_lo = (uint32_t)msg.address;
|
||||||
|
msi.address_hi = msg.address >> 32;
|
||||||
|
msi.data = msg.data;
|
||||||
|
msi.flags = 0;
|
||||||
|
memset(msi.pad, 0, sizeof(msi.pad));
|
||||||
|
|
||||||
|
return kvm_vm_ioctl(s, KVM_SIGNAL_MSI, &msi);
|
||||||
|
}
|
||||||
|
|
||||||
route = kvm_lookup_msi_route(s, msg);
|
route = kvm_lookup_msi_route(s, msg);
|
||||||
if (!route) {
|
if (!route) {
|
||||||
int virq, ret;
|
int virq, ret;
|
||||||
|
@ -1209,6 +1223,8 @@ int kvm_init(void)
|
||||||
s->pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2);
|
s->pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
s->direct_msi = (kvm_check_extension(s, KVM_CAP_SIGNAL_MSI) > 0);
|
||||||
|
|
||||||
ret = kvm_arch_init(s);
|
ret = kvm_arch_init(s);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto err;
|
goto err;
|
||||||
|
|
Loading…
Reference in New Issue