* [Qemu-devel] [PATCH] KVM_CAP_IRQFD and KVM_CAP_IRQFD_RESAMPLE checks
@ 2014-08-29 17:38 Eric Auger
2014-09-01 10:49 ` Paolo Bonzini
0 siblings, 1 reply; 3+ messages in thread
From: Eric Auger @ 2014-08-29 17:38 UTC (permalink / raw)
To: eric.auger, christoffer.dall, qemu-devel, a.rigo, agraf,
peter.maydell, pbonzini, mtosatti, borntraeger, cornelia.huck,
rth, thuth, afaerber, qemu-ppc, marc.zyngier
Cc: eric.auger, patches, will.deacon, stuart.yoder, Bharat.Bhushan,
alex.williamson, a.motakis, kvmarm
Compute kvm_irqfds_allowed by checking the KVM_CAP_IRQFD extension.
Remove direct settings in architecture specific files.
Add a new kvm_resamplefds_allowed variable, initialized by
checking the KVM_CAP_IRQFD_RESAMPLE extension. Add a corresponding
kvm_resamplefds_enabled() function.
Signed-off-by: Eric Auger <eric.auger@linaro.org>
---
in practice KVM_CAP_IRQFD_RESAMPLE seems to be always enabled
as soon as kernel has HAVE_KVM_IRQFD so the resamplefd check
may be unnecessary.
---
hw/intc/openpic_kvm.c | 1 -
hw/intc/xics_kvm.c | 1 -
include/sysemu/kvm.h | 10 ++++++++++
kvm-all.c | 7 +++++++
target-i386/kvm.c | 1 -
target-s390x/kvm.c | 1 -
6 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/hw/intc/openpic_kvm.c b/hw/intc/openpic_kvm.c
index e3bce04..6cef3b1 100644
--- a/hw/intc/openpic_kvm.c
+++ b/hw/intc/openpic_kvm.c
@@ -229,7 +229,6 @@ static void kvm_openpic_realize(DeviceState *dev, Error **errp)
kvm_irqchip_add_irq_route(kvm_state, i, 0, i);
}
- kvm_irqfds_allowed = true;
kvm_msi_via_irqfd_allowed = true;
kvm_gsi_routing_allowed = true;
diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
index 20b19e9..c15453f 100644
--- a/hw/intc/xics_kvm.c
+++ b/hw/intc/xics_kvm.c
@@ -448,7 +448,6 @@ static void xics_kvm_realize(DeviceState *dev, Error **errp)
}
kvm_kernel_irqchip = true;
- kvm_irqfds_allowed = true;
kvm_msi_via_irqfd_allowed = true;
kvm_gsi_direct_mapping = true;
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 174ea36..69c4d0f 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -45,6 +45,7 @@ extern bool kvm_async_interrupts_allowed;
extern bool kvm_halt_in_kernel_allowed;
extern bool kvm_eventfds_allowed;
extern bool kvm_irqfds_allowed;
+extern bool kvm_resamplefds_allowed;
extern bool kvm_msi_via_irqfd_allowed;
extern bool kvm_gsi_routing_allowed;
extern bool kvm_gsi_direct_mapping;
@@ -102,6 +103,15 @@ extern bool kvm_readonly_mem_allowed;
#define kvm_irqfds_enabled() (kvm_irqfds_allowed)
/**
+ * kvm_resamplefds_enabled:
+ *
+ * Returns: true if we can use resamplefds to inject interrupts into
+ * a KVM CPU (ie the kernel supports resamplefds and we are running
+ * with a configuration where it is meaningful to use them).
+ */
+#define kvm_resamplefds_enabled() (kvm_resamplefds_allowed)
+
+/**
* kvm_msi_via_irqfd_enabled:
*
* Returns: true if we can route a PCI MSI (Message Signaled Interrupt)
diff --git a/kvm-all.c b/kvm-all.c
index 1402f4f..fdc97d6 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -116,6 +116,7 @@ bool kvm_async_interrupts_allowed;
bool kvm_halt_in_kernel_allowed;
bool kvm_eventfds_allowed;
bool kvm_irqfds_allowed;
+bool kvm_resamplefds_allowed;
bool kvm_msi_via_irqfd_allowed;
bool kvm_gsi_routing_allowed;
bool kvm_gsi_direct_mapping;
@@ -1548,6 +1549,12 @@ int kvm_init(MachineClass *mc)
kvm_eventfds_allowed =
(kvm_check_extension(s, KVM_CAP_IOEVENTFD) > 0);
+ kvm_irqfds_allowed =
+ (kvm_check_extension(s, KVM_CAP_IRQFD) > 0);
+
+ kvm_resamplefds_allowed =
+ (kvm_check_extension(s, KVM_CAP_IRQFD_RESAMPLE) > 0);
+
ret = kvm_arch_init(s);
if (ret < 0) {
goto err;
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 097fe11..4bc2d80 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -2447,7 +2447,6 @@ void kvm_arch_init_irq_routing(KVMState *s)
* irqchip, so we can use irqfds, and on x86 we know
* we can use msi via irqfd and GSI routing.
*/
- kvm_irqfds_allowed = true;
kvm_msi_via_irqfd_allowed = true;
kvm_gsi_routing_allowed = true;
}
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index a32d91a..4d2bca6 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -1281,7 +1281,6 @@ void kvm_arch_init_irq_routing(KVMState *s)
* have to override the common code kvm_halt_in_kernel_allowed setting.
*/
if (kvm_check_extension(s, KVM_CAP_IRQ_ROUTING)) {
- kvm_irqfds_allowed = true;
kvm_gsi_routing_allowed = true;
kvm_halt_in_kernel_allowed = false;
}
--
1.8.3.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] KVM_CAP_IRQFD and KVM_CAP_IRQFD_RESAMPLE checks
2014-08-29 17:38 [Qemu-devel] [PATCH] KVM_CAP_IRQFD and KVM_CAP_IRQFD_RESAMPLE checks Eric Auger
@ 2014-09-01 10:49 ` Paolo Bonzini
2014-09-01 11:49 ` Eric Auger
0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2014-09-01 10:49 UTC (permalink / raw)
To: Eric Auger, eric.auger, christoffer.dall, qemu-devel, a.rigo,
agraf, peter.maydell, mtosatti, borntraeger, cornelia.huck, rth,
thuth, afaerber, qemu-ppc, marc.zyngier
Cc: patches, will.deacon, stuart.yoder, Bharat.Bhushan,
alex.williamson, a.motakis, kvmarm
Il 29/08/2014 19:38, Eric Auger ha scritto:
> Compute kvm_irqfds_allowed by checking the KVM_CAP_IRQFD extension.
> Remove direct settings in architecture specific files.
>
> Add a new kvm_resamplefds_allowed variable, initialized by
> checking the KVM_CAP_IRQFD_RESAMPLE extension. Add a corresponding
> kvm_resamplefds_enabled() function.
Please add a user too (in hw/misc/vfio.c).
Otherwise looks good, thanks!
Paolo
> Signed-off-by: Eric Auger <eric.auger@linaro.org>
>
> ---
>
> in practice KVM_CAP_IRQFD_RESAMPLE seems to be always enabled
> as soon as kernel has HAVE_KVM_IRQFD so the resamplefd check
> may be unnecessary.
> ---
> hw/intc/openpic_kvm.c | 1 -
> hw/intc/xics_kvm.c | 1 -
> include/sysemu/kvm.h | 10 ++++++++++
> kvm-all.c | 7 +++++++
> target-i386/kvm.c | 1 -
> target-s390x/kvm.c | 1 -
> 6 files changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/hw/intc/openpic_kvm.c b/hw/intc/openpic_kvm.c
> index e3bce04..6cef3b1 100644
> --- a/hw/intc/openpic_kvm.c
> +++ b/hw/intc/openpic_kvm.c
> @@ -229,7 +229,6 @@ static void kvm_openpic_realize(DeviceState *dev, Error **errp)
> kvm_irqchip_add_irq_route(kvm_state, i, 0, i);
> }
>
> - kvm_irqfds_allowed = true;
> kvm_msi_via_irqfd_allowed = true;
> kvm_gsi_routing_allowed = true;
>
> diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
> index 20b19e9..c15453f 100644
> --- a/hw/intc/xics_kvm.c
> +++ b/hw/intc/xics_kvm.c
> @@ -448,7 +448,6 @@ static void xics_kvm_realize(DeviceState *dev, Error **errp)
> }
>
> kvm_kernel_irqchip = true;
> - kvm_irqfds_allowed = true;
> kvm_msi_via_irqfd_allowed = true;
> kvm_gsi_direct_mapping = true;
>
> diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
> index 174ea36..69c4d0f 100644
> --- a/include/sysemu/kvm.h
> +++ b/include/sysemu/kvm.h
> @@ -45,6 +45,7 @@ extern bool kvm_async_interrupts_allowed;
> extern bool kvm_halt_in_kernel_allowed;
> extern bool kvm_eventfds_allowed;
> extern bool kvm_irqfds_allowed;
> +extern bool kvm_resamplefds_allowed;
> extern bool kvm_msi_via_irqfd_allowed;
> extern bool kvm_gsi_routing_allowed;
> extern bool kvm_gsi_direct_mapping;
> @@ -102,6 +103,15 @@ extern bool kvm_readonly_mem_allowed;
> #define kvm_irqfds_enabled() (kvm_irqfds_allowed)
>
> /**
> + * kvm_resamplefds_enabled:
> + *
> + * Returns: true if we can use resamplefds to inject interrupts into
> + * a KVM CPU (ie the kernel supports resamplefds and we are running
> + * with a configuration where it is meaningful to use them).
> + */
> +#define kvm_resamplefds_enabled() (kvm_resamplefds_allowed)
> +
> +/**
> * kvm_msi_via_irqfd_enabled:
> *
> * Returns: true if we can route a PCI MSI (Message Signaled Interrupt)
> diff --git a/kvm-all.c b/kvm-all.c
> index 1402f4f..fdc97d6 100644
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -116,6 +116,7 @@ bool kvm_async_interrupts_allowed;
> bool kvm_halt_in_kernel_allowed;
> bool kvm_eventfds_allowed;
> bool kvm_irqfds_allowed;
> +bool kvm_resamplefds_allowed;
> bool kvm_msi_via_irqfd_allowed;
> bool kvm_gsi_routing_allowed;
> bool kvm_gsi_direct_mapping;
> @@ -1548,6 +1549,12 @@ int kvm_init(MachineClass *mc)
> kvm_eventfds_allowed =
> (kvm_check_extension(s, KVM_CAP_IOEVENTFD) > 0);
>
> + kvm_irqfds_allowed =
> + (kvm_check_extension(s, KVM_CAP_IRQFD) > 0);
> +
> + kvm_resamplefds_allowed =
> + (kvm_check_extension(s, KVM_CAP_IRQFD_RESAMPLE) > 0);
> +
> ret = kvm_arch_init(s);
> if (ret < 0) {
> goto err;
> diff --git a/target-i386/kvm.c b/target-i386/kvm.c
> index 097fe11..4bc2d80 100644
> --- a/target-i386/kvm.c
> +++ b/target-i386/kvm.c
> @@ -2447,7 +2447,6 @@ void kvm_arch_init_irq_routing(KVMState *s)
> * irqchip, so we can use irqfds, and on x86 we know
> * we can use msi via irqfd and GSI routing.
> */
> - kvm_irqfds_allowed = true;
> kvm_msi_via_irqfd_allowed = true;
> kvm_gsi_routing_allowed = true;
> }
> diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
> index a32d91a..4d2bca6 100644
> --- a/target-s390x/kvm.c
> +++ b/target-s390x/kvm.c
> @@ -1281,7 +1281,6 @@ void kvm_arch_init_irq_routing(KVMState *s)
> * have to override the common code kvm_halt_in_kernel_allowed setting.
> */
> if (kvm_check_extension(s, KVM_CAP_IRQ_ROUTING)) {
> - kvm_irqfds_allowed = true;
> kvm_gsi_routing_allowed = true;
> kvm_halt_in_kernel_allowed = false;
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] KVM_CAP_IRQFD and KVM_CAP_IRQFD_RESAMPLE checks
2014-09-01 10:49 ` Paolo Bonzini
@ 2014-09-01 11:49 ` Eric Auger
0 siblings, 0 replies; 3+ messages in thread
From: Eric Auger @ 2014-09-01 11:49 UTC (permalink / raw)
To: Paolo Bonzini, eric.auger, christoffer.dall, qemu-devel, a.rigo,
agraf, peter.maydell, mtosatti, borntraeger, cornelia.huck, rth,
thuth, afaerber, qemu-ppc, marc.zyngier
Cc: patches, will.deacon, stuart.yoder, Bharat.Bhushan,
alex.williamson, a.motakis, kvmarm
On 09/01/2014 12:49 PM, Paolo Bonzini wrote:
> Il 29/08/2014 19:38, Eric Auger ha scritto:
>> Compute kvm_irqfds_allowed by checking the KVM_CAP_IRQFD extension.
>> Remove direct settings in architecture specific files.
>>
>> Add a new kvm_resamplefds_allowed variable, initialized by
>> checking the KVM_CAP_IRQFD_RESAMPLE extension. Add a corresponding
>> kvm_resamplefds_enabled() function.
>
> Please add a user too (in hw/misc/vfio.c).
Hi Paolo,
OK sure. Thanks
Best Regards
Eric
>
> Otherwise looks good, thanks!
>
> Paolo
>
>> Signed-off-by: Eric Auger <eric.auger@linaro.org>
>>
>> ---
>>
>> in practice KVM_CAP_IRQFD_RESAMPLE seems to be always enabled
>> as soon as kernel has HAVE_KVM_IRQFD so the resamplefd check
>> may be unnecessary.
>> ---
>> hw/intc/openpic_kvm.c | 1 -
>> hw/intc/xics_kvm.c | 1 -
>> include/sysemu/kvm.h | 10 ++++++++++
>> kvm-all.c | 7 +++++++
>> target-i386/kvm.c | 1 -
>> target-s390x/kvm.c | 1 -
>> 6 files changed, 17 insertions(+), 4 deletions(-)
>>
>> diff --git a/hw/intc/openpic_kvm.c b/hw/intc/openpic_kvm.c
>> index e3bce04..6cef3b1 100644
>> --- a/hw/intc/openpic_kvm.c
>> +++ b/hw/intc/openpic_kvm.c
>> @@ -229,7 +229,6 @@ static void kvm_openpic_realize(DeviceState *dev, Error **errp)
>> kvm_irqchip_add_irq_route(kvm_state, i, 0, i);
>> }
>>
>> - kvm_irqfds_allowed = true;
>> kvm_msi_via_irqfd_allowed = true;
>> kvm_gsi_routing_allowed = true;
>>
>> diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
>> index 20b19e9..c15453f 100644
>> --- a/hw/intc/xics_kvm.c
>> +++ b/hw/intc/xics_kvm.c
>> @@ -448,7 +448,6 @@ static void xics_kvm_realize(DeviceState *dev, Error **errp)
>> }
>>
>> kvm_kernel_irqchip = true;
>> - kvm_irqfds_allowed = true;
>> kvm_msi_via_irqfd_allowed = true;
>> kvm_gsi_direct_mapping = true;
>>
>> diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
>> index 174ea36..69c4d0f 100644
>> --- a/include/sysemu/kvm.h
>> +++ b/include/sysemu/kvm.h
>> @@ -45,6 +45,7 @@ extern bool kvm_async_interrupts_allowed;
>> extern bool kvm_halt_in_kernel_allowed;
>> extern bool kvm_eventfds_allowed;
>> extern bool kvm_irqfds_allowed;
>> +extern bool kvm_resamplefds_allowed;
>> extern bool kvm_msi_via_irqfd_allowed;
>> extern bool kvm_gsi_routing_allowed;
>> extern bool kvm_gsi_direct_mapping;
>> @@ -102,6 +103,15 @@ extern bool kvm_readonly_mem_allowed;
>> #define kvm_irqfds_enabled() (kvm_irqfds_allowed)
>>
>> /**
>> + * kvm_resamplefds_enabled:
>> + *
>> + * Returns: true if we can use resamplefds to inject interrupts into
>> + * a KVM CPU (ie the kernel supports resamplefds and we are running
>> + * with a configuration where it is meaningful to use them).
>> + */
>> +#define kvm_resamplefds_enabled() (kvm_resamplefds_allowed)
>> +
>> +/**
>> * kvm_msi_via_irqfd_enabled:
>> *
>> * Returns: true if we can route a PCI MSI (Message Signaled Interrupt)
>> diff --git a/kvm-all.c b/kvm-all.c
>> index 1402f4f..fdc97d6 100644
>> --- a/kvm-all.c
>> +++ b/kvm-all.c
>> @@ -116,6 +116,7 @@ bool kvm_async_interrupts_allowed;
>> bool kvm_halt_in_kernel_allowed;
>> bool kvm_eventfds_allowed;
>> bool kvm_irqfds_allowed;
>> +bool kvm_resamplefds_allowed;
>> bool kvm_msi_via_irqfd_allowed;
>> bool kvm_gsi_routing_allowed;
>> bool kvm_gsi_direct_mapping;
>> @@ -1548,6 +1549,12 @@ int kvm_init(MachineClass *mc)
>> kvm_eventfds_allowed =
>> (kvm_check_extension(s, KVM_CAP_IOEVENTFD) > 0);
>>
>> + kvm_irqfds_allowed =
>> + (kvm_check_extension(s, KVM_CAP_IRQFD) > 0);
>> +
>> + kvm_resamplefds_allowed =
>> + (kvm_check_extension(s, KVM_CAP_IRQFD_RESAMPLE) > 0);
>> +
>> ret = kvm_arch_init(s);
>> if (ret < 0) {
>> goto err;
>> diff --git a/target-i386/kvm.c b/target-i386/kvm.c
>> index 097fe11..4bc2d80 100644
>> --- a/target-i386/kvm.c
>> +++ b/target-i386/kvm.c
>> @@ -2447,7 +2447,6 @@ void kvm_arch_init_irq_routing(KVMState *s)
>> * irqchip, so we can use irqfds, and on x86 we know
>> * we can use msi via irqfd and GSI routing.
>> */
>> - kvm_irqfds_allowed = true;
>> kvm_msi_via_irqfd_allowed = true;
>> kvm_gsi_routing_allowed = true;
>> }
>> diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
>> index a32d91a..4d2bca6 100644
>> --- a/target-s390x/kvm.c
>> +++ b/target-s390x/kvm.c
>> @@ -1281,7 +1281,6 @@ void kvm_arch_init_irq_routing(KVMState *s)
>> * have to override the common code kvm_halt_in_kernel_allowed setting.
>> */
>> if (kvm_check_extension(s, KVM_CAP_IRQ_ROUTING)) {
>> - kvm_irqfds_allowed = true;
>> kvm_gsi_routing_allowed = true;
>> kvm_halt_in_kernel_allowed = false;
>> }
>>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-09-01 11:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-29 17:38 [Qemu-devel] [PATCH] KVM_CAP_IRQFD and KVM_CAP_IRQFD_RESAMPLE checks Eric Auger
2014-09-01 10:49 ` Paolo Bonzini
2014-09-01 11:49 ` Eric Auger
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.