mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-27 13:30:52 +00:00
kvm: Decouple 'irqfds usable' from 'kernel irqchip'
Instead of assuming that we can use irqfds if and only if kvm_irqchip_in_kernel(), add a bool to the KVMState which indicates this, and is set only on x86 and only if the irqchip is in the kernel. The kernel documentation implies that the only thing you need to use KVM_IRQFD is that KVM_CAP_IRQFD is advertised, but this seems to be untrue. In particular the kernel does not (alas) return a sensible error if you try to set up an irqfd when you haven't created an irqchip. If it did we could remove all this nonsense and let the kernel return the error code. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Acked-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
parent
1d31f66bbc
commit
cc7e0ddf5a
@ -101,6 +101,7 @@ struct KVMState
|
|||||||
KVMState *kvm_state;
|
KVMState *kvm_state;
|
||||||
bool kvm_kernel_irqchip;
|
bool kvm_kernel_irqchip;
|
||||||
bool kvm_async_interrupts_allowed;
|
bool kvm_async_interrupts_allowed;
|
||||||
|
bool kvm_irqfds_allowed;
|
||||||
|
|
||||||
static const KVMCapabilityInfo kvm_required_capabilites[] = {
|
static const KVMCapabilityInfo kvm_required_capabilites[] = {
|
||||||
KVM_CAP_INFO(USER_MEMORY),
|
KVM_CAP_INFO(USER_MEMORY),
|
||||||
@ -1126,7 +1127,7 @@ static int kvm_irqchip_assign_irqfd(KVMState *s, int fd, int virq, bool assign)
|
|||||||
.flags = assign ? 0 : KVM_IRQFD_FLAG_DEASSIGN,
|
.flags = assign ? 0 : KVM_IRQFD_FLAG_DEASSIGN,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!kvm_irqchip_in_kernel()) {
|
if (!kvm_irqfds_enabled()) {
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
KVMState *kvm_state;
|
KVMState *kvm_state;
|
||||||
bool kvm_kernel_irqchip;
|
bool kvm_kernel_irqchip;
|
||||||
bool kvm_async_interrupts_allowed;
|
bool kvm_async_interrupts_allowed;
|
||||||
|
bool kvm_irqfds_allowed;
|
||||||
|
|
||||||
int kvm_init_vcpu(CPUArchState *env)
|
int kvm_init_vcpu(CPUArchState *env)
|
||||||
{
|
{
|
||||||
|
11
kvm.h
11
kvm.h
@ -25,6 +25,7 @@
|
|||||||
extern int kvm_allowed;
|
extern int kvm_allowed;
|
||||||
extern bool kvm_kernel_irqchip;
|
extern bool kvm_kernel_irqchip;
|
||||||
extern bool kvm_async_interrupts_allowed;
|
extern bool kvm_async_interrupts_allowed;
|
||||||
|
extern bool kvm_irqfds_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)
|
||||||
@ -40,10 +41,20 @@ extern bool kvm_async_interrupts_allowed;
|
|||||||
*/
|
*/
|
||||||
#define kvm_async_interrupts_enabled() (kvm_async_interrupts_allowed)
|
#define kvm_async_interrupts_enabled() (kvm_async_interrupts_allowed)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* kvm_irqfds_enabled:
|
||||||
|
*
|
||||||
|
* Returns: true if we can use irqfds to inject interrupts into
|
||||||
|
* a KVM CPU (ie the kernel supports irqfds and we are running
|
||||||
|
* with a configuration where it is meaningful to use them).
|
||||||
|
*/
|
||||||
|
#define kvm_irqfds_enabled() (kvm_irqfds_allowed)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define kvm_enabled() (0)
|
#define kvm_enabled() (0)
|
||||||
#define kvm_irqchip_in_kernel() (false)
|
#define kvm_irqchip_in_kernel() (false)
|
||||||
#define kvm_async_interrupts_enabled() (false)
|
#define kvm_async_interrupts_enabled() (false)
|
||||||
|
#define kvm_irqfds_enabled() (false)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct kvm_run;
|
struct kvm_run;
|
||||||
|
@ -2047,4 +2047,8 @@ void kvm_arch_init_irq_routing(KVMState *s)
|
|||||||
*/
|
*/
|
||||||
no_hpet = 1;
|
no_hpet = 1;
|
||||||
}
|
}
|
||||||
|
/* We know at this point that we're using the in-kernel
|
||||||
|
* irqchip, so we can use irqfds.
|
||||||
|
*/
|
||||||
|
kvm_irqfds_allowed = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user