提交 92b4e489 编写于 作者: J Jan Kiszka 提交者: Avi Kivity

kvm: Introduce kvm_irqchip_add_msi_route

Add a service that establishes a static route from a virtual IRQ line to
an MSI message. Will be used for IRQFD and device assignment. As we will
use this service outside of CONFIG_KVM protected code, stub it properly.
Signed-off-by: NJan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: NAvi Kivity <avi@redhat.com>
上级 1df186df
...@@ -1080,6 +1080,32 @@ int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg) ...@@ -1080,6 +1080,32 @@ int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg)
return kvm_irqchip_set_irq(s, route->kroute.gsi, 1); return kvm_irqchip_set_irq(s, route->kroute.gsi, 1);
} }
int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
{
struct kvm_irq_routing_entry kroute;
int virq;
if (!kvm_irqchip_in_kernel()) {
return -ENOSYS;
}
virq = kvm_irqchip_get_virq(s);
if (virq < 0) {
return virq;
}
kroute.gsi = virq;
kroute.type = KVM_IRQ_ROUTING_MSI;
kroute.flags = 0;
kroute.u.msi.address_lo = (uint32_t)msg.address;
kroute.u.msi.address_hi = msg.address >> 32;
kroute.u.msi.data = msg.data;
kvm_add_routing_entry(s, &kroute);
return virq;
}
#else /* !KVM_CAP_IRQ_ROUTING */ #else /* !KVM_CAP_IRQ_ROUTING */
static void kvm_init_irq_routing(KVMState *s) static void kvm_init_irq_routing(KVMState *s)
...@@ -1090,6 +1116,11 @@ int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg) ...@@ -1090,6 +1116,11 @@ int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg)
{ {
abort(); abort();
} }
int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
{
abort();
}
#endif /* !KVM_CAP_IRQ_ROUTING */ #endif /* !KVM_CAP_IRQ_ROUTING */
static int kvm_irqchip_create(KVMState *s) static int kvm_irqchip_create(KVMState *s)
......
...@@ -12,10 +12,13 @@ ...@@ -12,10 +12,13 @@
#include "qemu-common.h" #include "qemu-common.h"
#include "hw/hw.h" #include "hw/hw.h"
#include "hw/msi.h"
#include "cpu.h" #include "cpu.h"
#include "gdbstub.h" #include "gdbstub.h"
#include "kvm.h" #include "kvm.h"
KVMState *kvm_state;
int kvm_init_vcpu(CPUArchState *env) int kvm_init_vcpu(CPUArchState *env)
{ {
return -ENOSYS; return -ENOSYS;
...@@ -128,3 +131,8 @@ int kvm_on_sigbus(int code, void *addr) ...@@ -128,3 +131,8 @@ int kvm_on_sigbus(int code, void *addr)
{ {
return 1; return 1;
} }
int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
{
return -ENOSYS;
}
...@@ -44,6 +44,10 @@ typedef struct KVMCapabilityInfo { ...@@ -44,6 +44,10 @@ typedef struct KVMCapabilityInfo {
#define KVM_CAP_INFO(CAP) { "KVM_CAP_" stringify(CAP), KVM_CAP_##CAP } #define KVM_CAP_INFO(CAP) { "KVM_CAP_" stringify(CAP), KVM_CAP_##CAP }
#define KVM_CAP_LAST_INFO { NULL, 0 } #define KVM_CAP_LAST_INFO { NULL, 0 }
struct KVMState;
typedef struct KVMState KVMState;
extern KVMState *kvm_state;
/* external API */ /* external API */
int kvm_init(void); int kvm_init(void);
...@@ -88,10 +92,6 @@ int kvm_on_sigbus(int code, void *addr); ...@@ -88,10 +92,6 @@ int kvm_on_sigbus(int code, void *addr);
/* internal API */ /* internal API */
struct KVMState;
typedef struct KVMState KVMState;
extern KVMState *kvm_state;
int kvm_ioctl(KVMState *s, int type, ...); int kvm_ioctl(KVMState *s, int type, ...);
int kvm_vm_ioctl(KVMState *s, int type, ...); int kvm_vm_ioctl(KVMState *s, int type, ...);
...@@ -213,4 +213,6 @@ int kvm_set_ioeventfd_mmio(int fd, uint32_t adr, uint32_t val, bool assign, ...@@ -213,4 +213,6 @@ int kvm_set_ioeventfd_mmio(int fd, uint32_t adr, uint32_t val, bool assign,
uint32_t size); uint32_t size);
int kvm_set_ioeventfd_pio_word(int fd, uint16_t adr, uint16_t val, bool assign); int kvm_set_ioeventfd_pio_word(int fd, uint16_t adr, uint16_t val, bool assign);
int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg);
#endif #endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册