kvm: Make KVM_CAP_SIGNAL_MSI globally available
This capability is useful to determine whether we can use KVM ITS emulation on ARM Signed-off-by: Pavel Fedin <p.fedin@samsung.com> Message-Id: <ff4ccb09b837d37defd639b885526949a25276de.1444916432.git.p.fedin@samsung.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
9bda456e41
commit
50bf31b937
|
@ -52,6 +52,7 @@ extern bool kvm_msi_via_irqfd_allowed;
|
||||||
extern bool kvm_gsi_routing_allowed;
|
extern bool kvm_gsi_routing_allowed;
|
||||||
extern bool kvm_gsi_direct_mapping;
|
extern bool kvm_gsi_direct_mapping;
|
||||||
extern bool kvm_readonly_mem_allowed;
|
extern bool kvm_readonly_mem_allowed;
|
||||||
|
extern bool kvm_direct_msi_allowed;
|
||||||
|
|
||||||
#if defined CONFIG_KVM || !defined NEED_CPU_H
|
#if defined CONFIG_KVM || !defined NEED_CPU_H
|
||||||
#define kvm_enabled() (kvm_allowed)
|
#define kvm_enabled() (kvm_allowed)
|
||||||
|
@ -145,6 +146,13 @@ extern bool kvm_readonly_mem_allowed;
|
||||||
*/
|
*/
|
||||||
#define kvm_readonly_mem_enabled() (kvm_readonly_mem_allowed)
|
#define kvm_readonly_mem_enabled() (kvm_readonly_mem_allowed)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* kvm_direct_msi_enabled:
|
||||||
|
*
|
||||||
|
* Returns: true if KVM allows direct MSI injection.
|
||||||
|
*/
|
||||||
|
#define kvm_direct_msi_enabled() (kvm_direct_msi_allowed)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define kvm_enabled() (0)
|
#define kvm_enabled() (0)
|
||||||
#define kvm_irqchip_in_kernel() (false)
|
#define kvm_irqchip_in_kernel() (false)
|
||||||
|
@ -157,6 +165,7 @@ extern bool kvm_readonly_mem_allowed;
|
||||||
#define kvm_gsi_routing_allowed() (false)
|
#define kvm_gsi_routing_allowed() (false)
|
||||||
#define kvm_gsi_direct_mapping() (false)
|
#define kvm_gsi_direct_mapping() (false)
|
||||||
#define kvm_readonly_mem_enabled() (false)
|
#define kvm_readonly_mem_enabled() (false)
|
||||||
|
#define kvm_direct_msi_enabled() (false)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct kvm_run;
|
struct kvm_run;
|
||||||
|
|
10
kvm-all.c
10
kvm-all.c
|
@ -93,7 +93,6 @@ 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
|
||||||
KVMMemoryListener memory_listener;
|
KVMMemoryListener memory_listener;
|
||||||
};
|
};
|
||||||
|
@ -111,6 +110,7 @@ bool kvm_gsi_direct_mapping;
|
||||||
bool kvm_allowed;
|
bool kvm_allowed;
|
||||||
bool kvm_readonly_mem_allowed;
|
bool kvm_readonly_mem_allowed;
|
||||||
bool kvm_vm_attributes_allowed;
|
bool kvm_vm_attributes_allowed;
|
||||||
|
bool kvm_direct_msi_allowed;
|
||||||
|
|
||||||
static const KVMCapabilityInfo kvm_required_capabilites[] = {
|
static const KVMCapabilityInfo kvm_required_capabilites[] = {
|
||||||
KVM_CAP_INFO(USER_MEMORY),
|
KVM_CAP_INFO(USER_MEMORY),
|
||||||
|
@ -979,7 +979,7 @@ 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;
|
||||||
|
|
||||||
if (!s->direct_msi) {
|
if (!kvm_direct_msi_allowed) {
|
||||||
for (i = 0; i < KVM_MSI_HASHTAB_SIZE; i++) {
|
for (i = 0; i < KVM_MSI_HASHTAB_SIZE; i++) {
|
||||||
QTAILQ_INIT(&s->msi_hashtab[i]);
|
QTAILQ_INIT(&s->msi_hashtab[i]);
|
||||||
}
|
}
|
||||||
|
@ -1113,7 +1113,7 @@ static int kvm_irqchip_get_virq(KVMState *s)
|
||||||
* number can succeed even though a new route entry cannot be added.
|
* number can succeed even though a new route entry cannot be added.
|
||||||
* When this happens, flush dynamic MSI entries to free IRQ route entries.
|
* When this happens, flush dynamic MSI entries to free IRQ route entries.
|
||||||
*/
|
*/
|
||||||
if (!s->direct_msi && s->irq_routes->nr == s->gsi_count) {
|
if (!kvm_direct_msi_allowed && s->irq_routes->nr == s->gsi_count) {
|
||||||
kvm_flush_dynamic_msi_routes(s);
|
kvm_flush_dynamic_msi_routes(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1150,7 +1150,7 @@ int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg)
|
||||||
struct kvm_msi msi;
|
struct kvm_msi msi;
|
||||||
KVMMSIRoute *route;
|
KVMMSIRoute *route;
|
||||||
|
|
||||||
if (s->direct_msi) {
|
if (kvm_direct_msi_allowed) {
|
||||||
msi.address_lo = (uint32_t)msg.address;
|
msi.address_lo = (uint32_t)msg.address;
|
||||||
msi.address_hi = msg.address >> 32;
|
msi.address_hi = msg.address >> 32;
|
||||||
msi.data = le32_to_cpu(msg.data);
|
msi.data = le32_to_cpu(msg.data);
|
||||||
|
@ -1598,7 +1598,7 @@ static int kvm_init(MachineState *ms)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef KVM_CAP_IRQ_ROUTING
|
#ifdef KVM_CAP_IRQ_ROUTING
|
||||||
s->direct_msi = (kvm_check_extension(s, KVM_CAP_SIGNAL_MSI) > 0);
|
kvm_direct_msi_allowed = (kvm_check_extension(s, KVM_CAP_SIGNAL_MSI) > 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
s->intx_set_mask = kvm_check_extension(s, KVM_CAP_PCI_2_3);
|
s->intx_set_mask = kvm_check_extension(s, KVM_CAP_PCI_2_3);
|
||||||
|
|
Loading…
Reference in New Issue