* [Qemu-devel] [PATCH v3 1/2] KVM_CAP_IRQFD and KVM_CAP_IRQFD_RESAMPLE checks
2014-10-31 13:38 [Qemu-devel] [PATCH v3 0/2] actual checks of KVM_CAP_IRQFD and KVM_CAP_IRQFD_RESAMPLE Eric Auger
@ 2014-10-31 13:38 ` Eric Auger
2014-10-31 17:15 ` Cornelia Huck
2014-10-31 13:38 ` [Qemu-devel] [PATCH v3 2/2] vfio: use kvm_resamplefds_enabled() Eric Auger
2014-11-03 12:30 ` [Qemu-devel] [PATCH v3 0/2] actual checks of KVM_CAP_IRQFD and KVM_CAP_IRQFD_RESAMPLE Paolo Bonzini
2 siblings, 1 reply; 7+ messages in thread
From: Eric Auger @ 2014-10-31 13:38 UTC (permalink / raw)
To: eric.auger, christoffer.dall, qemu-devel, agraf, pbonzini, aik,
bsd, mtosatti, borntraeger, cornelia.huck, rth, thuth, afaerber,
qemu-ppc
Cc: peter.maydell, alex.williamson, patches, kvmarm, eric.auger
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.
A special notice for s390 where KVM_CAP_IRQFD was not immediatly
advirtised when irqfd capability was introduced in the kernel.
KVM_CAP_IRQ_ROUTING was advertised instead.
This was fixed in "KVM: s390: announce irqfd capability",
ebc3226202d5956a5963185222982d435378b899 whereas irqfd support
was brought in 84223598778ba08041f4297fda485df83414d57e,
"KVM: s390: irq routing for adapter interrupts". Both commits
first appear in 3.15 so there should not be any kernel
version impacted by this QEMU modification.
Signed-off-by: Eric Auger <eric.auger@linaro.org>
---
v2->v3:
- changed the commit message only
---
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 b0cd657..a23ddab 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 44a5e72..0a3139f 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -120,6 +120,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;
@@ -1566,6 +1567,12 @@ static int kvm_init(MachineState *ms)
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 ccf36e8..3a3dfc4 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -2563,7 +2563,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 5b10a25..9ae1958 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -1294,7 +1294,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] 7+ messages in thread
* [Qemu-devel] [PATCH v3 2/2] vfio: use kvm_resamplefds_enabled()
2014-10-31 13:38 [Qemu-devel] [PATCH v3 0/2] actual checks of KVM_CAP_IRQFD and KVM_CAP_IRQFD_RESAMPLE Eric Auger
2014-10-31 13:38 ` [Qemu-devel] [PATCH v3 1/2] KVM_CAP_IRQFD and KVM_CAP_IRQFD_RESAMPLE checks Eric Auger
@ 2014-10-31 13:38 ` Eric Auger
2014-11-04 22:25 ` Alex Williamson
2014-11-03 12:30 ` [Qemu-devel] [PATCH v3 0/2] actual checks of KVM_CAP_IRQFD and KVM_CAP_IRQFD_RESAMPLE Paolo Bonzini
2 siblings, 1 reply; 7+ messages in thread
From: Eric Auger @ 2014-10-31 13:38 UTC (permalink / raw)
To: eric.auger, christoffer.dall, qemu-devel, agraf, pbonzini, aik,
bsd, mtosatti, borntraeger, cornelia.huck, rth, thuth, afaerber,
qemu-ppc
Cc: peter.maydell, alex.williamson, patches, kvmarm, eric.auger
Use the kvm_resamplefds_enabled function
Signed-off-by: Eric Auger <eric.auger@linaro.org>
---
hw/misc/vfio.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
index b5e7981..75bfa1c 100644
--- a/hw/misc/vfio.c
+++ b/hw/misc/vfio.c
@@ -406,7 +406,7 @@ static void vfio_enable_intx_kvm(VFIODevice *vdev)
if (!VFIO_ALLOW_KVM_INTX || !kvm_irqfds_enabled() ||
vdev->intx.route.mode != PCI_INTX_ENABLED ||
- !kvm_check_extension(kvm_state, KVM_CAP_IRQFD_RESAMPLE)) {
+ !kvm_resamplefds_enabled()) {
return;
}
@@ -568,8 +568,7 @@ static int vfio_enable_intx(VFIODevice *vdev)
* Only conditional to avoid generating error messages on platforms
* where we won't actually use the result anyway.
*/
- if (kvm_irqfds_enabled() &&
- kvm_check_extension(kvm_state, KVM_CAP_IRQFD_RESAMPLE)) {
+ if (kvm_irqfds_enabled() && kvm_resamplefds_enabled()) {
vdev->intx.route = pci_device_route_intx_to_irq(&vdev->pdev,
vdev->intx.pin);
}
--
1.8.3.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH v3 0/2] actual checks of KVM_CAP_IRQFD and KVM_CAP_IRQFD_RESAMPLE
2014-10-31 13:38 [Qemu-devel] [PATCH v3 0/2] actual checks of KVM_CAP_IRQFD and KVM_CAP_IRQFD_RESAMPLE Eric Auger
2014-10-31 13:38 ` [Qemu-devel] [PATCH v3 1/2] KVM_CAP_IRQFD and KVM_CAP_IRQFD_RESAMPLE checks Eric Auger
2014-10-31 13:38 ` [Qemu-devel] [PATCH v3 2/2] vfio: use kvm_resamplefds_enabled() Eric Auger
@ 2014-11-03 12:30 ` Paolo Bonzini
2 siblings, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2014-11-03 12:30 UTC (permalink / raw)
To: Eric Auger, eric.auger, christoffer.dall, qemu-devel, agraf, aik,
bsd, mtosatti, borntraeger, cornelia.huck, rth, thuth, afaerber,
qemu-ppc
Cc: peter.maydell, alex.williamson, kvmarm, patches
On 31/10/2014 14:38, Eric Auger wrote:
> This patch series replaces direct settings of kvm_irqfds_allowed
> in architecture specific files by actual check of the KVM_CAP_IRQFD
> extension in kvm-all.c.
>
> Also A new kvm_resamplefds_enabled() enables to check
> KVM_CAP_IRQFD_RESAMPLE. In the second patch file the vfio device
> becomes the first user of kvm_resamplefds_enabled().
>
> Eric Auger (2):
> KVM_CAP_IRQFD and KVM_CAP_IRQFD_RESAMPLE checks
> vfio: use kvm_resamplefds_enabled()
>
> hw/intc/openpic_kvm.c | 1 -
> hw/intc/xics_kvm.c | 1 -
> hw/misc/vfio.c | 5 ++---
> include/sysemu/kvm.h | 10 ++++++++++
> kvm-all.c | 7 +++++++
> target-i386/kvm.c | 1 -
> target-s390x/kvm.c | 1 -
> 7 files changed, 19 insertions(+), 7 deletions(-)
>
Applied for 2.3 to uq/master. Thanks.
Paolo
^ permalink raw reply [flat|nested] 7+ messages in thread