* [PATCH v9 1/5] KVM: arm/arm64: unset CONFIG_HAVE_KVM_IRQCHIP
2015-03-04 10:14 [PATCH v9 0/5] irqfd support for arm/arm64 Eric Auger
@ 2015-03-04 10:14 ` Eric Auger
2015-03-04 10:14 ` [PATCH v9 2/5] KVM: introduce kvm_arch_intc_initialized and use it in irqfd Eric Auger
` (3 subsequent siblings)
4 siblings, 0 replies; 15+ messages in thread
From: Eric Auger @ 2015-03-04 10:14 UTC (permalink / raw)
To: eric.auger, eric.auger, christoffer.dall, marc.zyngier,
linux-arm-kernel, kvmarm, kvm
Cc: andre.przywara, linux-kernel, patches, gleb, pbonzini
CONFIG_HAVE_KVM_IRQCHIP is needed to support IRQ routing (along
with irq_comm.c and irqchip.c usage). This is not the case for
arm/arm64 currently.
This patch unsets the flag for both arm and arm64.
Signed-off-by: Eric Auger <eric.auger@linaro.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Acked-by: Christoffer Dall <christoffer.dall@linaro.org>
Acked-by: Will Deacon <will.deacon@arm.com>
---
arch/arm/kvm/Kconfig | 2 --
arch/arm64/kvm/Kconfig | 1 -
2 files changed, 3 deletions(-)
diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig
index 338ace7..aae5242 100644
--- a/arch/arm/kvm/Kconfig
+++ b/arch/arm/kvm/Kconfig
@@ -58,7 +58,6 @@ config KVM_ARM_MAX_VCPUS
config KVM_ARM_VGIC
bool "KVM support for Virtual GIC"
depends on KVM_ARM_HOST && OF
- select HAVE_KVM_IRQCHIP
default y
---help---
Adds support for a hardware assisted, in-kernel GIC emulation.
@@ -66,7 +65,6 @@ config KVM_ARM_VGIC
config KVM_ARM_TIMER
bool "KVM support for Architected Timers"
depends on KVM_ARM_VGIC && ARM_ARCH_TIMER
- select HAVE_KVM_IRQCHIP
default y
---help---
Adds support for the Architected Timers in virtual machines
diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig
index f5590c8..039d8cf 100644
--- a/arch/arm64/kvm/Kconfig
+++ b/arch/arm64/kvm/Kconfig
@@ -53,7 +53,6 @@ config KVM_ARM_MAX_VCPUS
config KVM_ARM_VGIC
bool
depends on KVM_ARM_HOST && OF
- select HAVE_KVM_IRQCHIP
---help---
Adds support for a hardware assisted, in-kernel GIC emulation.
--
1.9.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v9 2/5] KVM: introduce kvm_arch_intc_initialized and use it in irqfd
2015-03-04 10:14 [PATCH v9 0/5] irqfd support for arm/arm64 Eric Auger
2015-03-04 10:14 ` [PATCH v9 1/5] KVM: arm/arm64: unset CONFIG_HAVE_KVM_IRQCHIP Eric Auger
@ 2015-03-04 10:14 ` Eric Auger
2015-03-04 10:14 ` [PATCH v9 3/5] KVM: arm/arm64: implement kvm_arch_intc_initialized Eric Auger
` (2 subsequent siblings)
4 siblings, 0 replies; 15+ messages in thread
From: Eric Auger @ 2015-03-04 10:14 UTC (permalink / raw)
To: eric.auger, eric.auger, christoffer.dall, marc.zyngier,
linux-arm-kernel, kvmarm, kvm
Cc: andre.przywara, linux-kernel, patches, gleb, pbonzini
Introduce __KVM_HAVE_ARCH_INTC_INITIALIZED define and
associated kvm_arch_intc_initialized function. This latter
allows to test whether the virtual interrupt controller is initialized
and ready to accept virtual IRQ injection. On some architectures,
the virtual interrupt controller is dynamically instantiated, justifying
that kind of check.
The new function can now be used by irqfd to check whether the
virtual interrupt controller is ready on KVM_IRQFD request. If not,
KVM_IRQFD returns -EAGAIN.
Signed-off-by: Eric Auger <eric.auger@linaro.org>
Acked-by: Christoffer Dall <christoffer.dall@linaro.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
---
v7 -> v8:
- correct typo in comment
- add Andre's Reviewed-by
v6 -> v7:
- From now on, kvm_irqfd_assign calls kvm_arch_intc_initialized
(previously introduced in subsequent patch file).
- add Christoffer's ack
v5 -> v6:
- rename function name and macro
- add kvm_arch_intc_initialized declaration in case the archi defines
the macro
---
include/linux/kvm_host.h | 14 ++++++++++++++
virt/kvm/eventfd.c | 3 +++
2 files changed, 17 insertions(+)
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index d12b210..ae9c720 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -700,6 +700,20 @@ static inline wait_queue_head_t *kvm_arch_vcpu_wq(struct kvm_vcpu *vcpu)
#endif
}
+#ifdef __KVM_HAVE_ARCH_INTC_INITIALIZED
+/*
+ * returns true if the virtual interrupt controller is initialized and
+ * ready to accept virtual IRQ. On some architectures the virtual interrupt
+ * controller is dynamically instantiated and this is not always true.
+ */
+bool kvm_arch_intc_initialized(struct kvm *kvm);
+#else
+static inline bool kvm_arch_intc_initialized(struct kvm *kvm)
+{
+ return true;
+}
+#endif
+
int kvm_arch_init_vm(struct kvm *kvm, unsigned long type);
void kvm_arch_destroy_vm(struct kvm *kvm);
void kvm_arch_sync_events(struct kvm *kvm);
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 148b239..fc5f43e 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -311,6 +311,9 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
unsigned int events;
int idx;
+ if (!kvm_arch_intc_initialized(kvm))
+ return -EAGAIN;
+
irqfd = kzalloc(sizeof(*irqfd), GFP_KERNEL);
if (!irqfd)
return -ENOMEM;
--
1.9.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v9 3/5] KVM: arm/arm64: implement kvm_arch_intc_initialized
2015-03-04 10:14 [PATCH v9 0/5] irqfd support for arm/arm64 Eric Auger
2015-03-04 10:14 ` [PATCH v9 1/5] KVM: arm/arm64: unset CONFIG_HAVE_KVM_IRQCHIP Eric Auger
2015-03-04 10:14 ` [PATCH v9 2/5] KVM: introduce kvm_arch_intc_initialized and use it in irqfd Eric Auger
@ 2015-03-04 10:14 ` Eric Auger
2015-03-04 10:14 ` [PATCH v9 4/5] KVM: arm/arm64: remove coarse grain dist locking at kvm_vgic_sync_hwstate Eric Auger
2015-03-04 10:14 ` [PATCH v9 5/5] KVM: arm/arm64: add irqfd support Eric Auger
4 siblings, 0 replies; 15+ messages in thread
From: Eric Auger @ 2015-03-04 10:14 UTC (permalink / raw)
To: eric.auger, eric.auger, christoffer.dall, marc.zyngier,
linux-arm-kernel, kvmarm, kvm
Cc: andre.przywara, linux-kernel, patches, gleb, pbonzini
On arm/arm64 the VGIC is dynamically instantiated and it is useful
to expose its state, especially for irqfd setup.
This patch defines __KVM_HAVE_ARCH_INTC_INITIALIZED and
implements kvm_arch_intc_initialized.
Signed-off-by: Eric Auger <eric.auger@linaro.org>
Acked-by: Christoffer Dall <christoffer.dall@linaro.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
---
v7 -> v8:
- add Andre's Reviewed-by
v6 -> v7:
- usage of the new function in irqfd is introduced in previous patch
file.
- Changed the title and the commit message accordingly
v5 -> v6:
- remove kvm_arch_intc_initialized declaration from
architecture specific kvm_host.h since it is now in
generic kvm_host.h
- squash v5 patch files 3 & 4
---
arch/arm/include/asm/kvm_host.h | 2 ++
arch/arm/kvm/arm.c | 5 +++++
arch/arm64/include/asm/kvm_host.h | 2 ++
3 files changed, 9 insertions(+)
diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h
index 41008cd..902a7d1 100644
--- a/arch/arm/include/asm/kvm_host.h
+++ b/arch/arm/include/asm/kvm_host.h
@@ -27,6 +27,8 @@
#include <asm/fpstate.h>
#include <kvm/arm_arch_timer.h>
+#define __KVM_HAVE_ARCH_INTC_INITIALIZED
+
#if defined(CONFIG_KVM_ARM_MAX_VCPUS)
#define KVM_MAX_VCPUS CONFIG_KVM_ARM_MAX_VCPUS
#else
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index 07e7eb1..5300d5a 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -452,6 +452,11 @@ static int kvm_vcpu_first_run_init(struct kvm_vcpu *vcpu)
return 0;
}
+bool kvm_arch_intc_initialized(struct kvm *kvm)
+{
+ return vgic_initialized(kvm);
+}
+
static void vcpu_pause(struct kvm_vcpu *vcpu)
{
wait_queue_head_t *wq = kvm_arch_vcpu_wq(vcpu);
diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index 8ac3c70..967fb1c 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -28,6 +28,8 @@
#include <asm/kvm_asm.h>
#include <asm/kvm_mmio.h>
+#define __KVM_HAVE_ARCH_INTC_INITIALIZED
+
#if defined(CONFIG_KVM_ARM_MAX_VCPUS)
#define KVM_MAX_VCPUS CONFIG_KVM_ARM_MAX_VCPUS
#else
--
1.9.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v9 4/5] KVM: arm/arm64: remove coarse grain dist locking at kvm_vgic_sync_hwstate
2015-03-04 10:14 [PATCH v9 0/5] irqfd support for arm/arm64 Eric Auger
` (2 preceding siblings ...)
2015-03-04 10:14 ` [PATCH v9 3/5] KVM: arm/arm64: implement kvm_arch_intc_initialized Eric Auger
@ 2015-03-04 10:14 ` Eric Auger
2015-03-04 10:14 ` [PATCH v9 5/5] KVM: arm/arm64: add irqfd support Eric Auger
4 siblings, 0 replies; 15+ messages in thread
From: Eric Auger @ 2015-03-04 10:14 UTC (permalink / raw)
To: eric.auger, eric.auger, christoffer.dall, marc.zyngier,
linux-arm-kernel, kvmarm, kvm
Cc: andre.przywara, linux-kernel, patches, gleb, pbonzini
To prepare for irqfd addition, coarse grain locking is removed at
kvm_vgic_sync_hwstate level and finer grain locking is introduced in
vgic_process_maintenance only.
Signed-off-by: Eric Auger <eric.auger@linaro.org>
Acked-by: Christoffer Dall <christoffer.dall@linaro.org>
---
virt/kvm/arm/vgic.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index 0cc6ab6..4e9b6d3 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -1081,6 +1081,7 @@ epilog:
static bool vgic_process_maintenance(struct kvm_vcpu *vcpu)
{
u32 status = vgic_get_interrupt_status(vcpu);
+ struct vgic_dist *dist = &vcpu->kvm->arch.vgic;
bool level_pending = false;
kvm_debug("STATUS = %08x\n", status);
@@ -1098,6 +1099,7 @@ static bool vgic_process_maintenance(struct kvm_vcpu *vcpu)
struct vgic_lr vlr = vgic_get_lr(vcpu, lr);
WARN_ON(vgic_irq_is_edge(vcpu, vlr.irq));
+ spin_lock(&dist->lock);
vgic_irq_clear_queued(vcpu, vlr.irq);
WARN_ON(vlr.state & LR_STATE_MASK);
vlr.state = 0;
@@ -1125,6 +1127,8 @@ static bool vgic_process_maintenance(struct kvm_vcpu *vcpu)
vgic_cpu_irq_clear(vcpu, vlr.irq);
}
+ spin_unlock(&dist->lock);
+
/*
* Despite being EOIed, the LR may not have
* been marked as empty.
@@ -1139,10 +1143,7 @@ static bool vgic_process_maintenance(struct kvm_vcpu *vcpu)
return level_pending;
}
-/*
- * Sync back the VGIC state after a guest run. The distributor lock is
- * needed so we don't get preempted in the middle of the state processing.
- */
+/* Sync back the VGIC state after a guest run */
static void __kvm_vgic_sync_hwstate(struct kvm_vcpu *vcpu)
{
struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu;
@@ -1189,14 +1190,10 @@ void kvm_vgic_flush_hwstate(struct kvm_vcpu *vcpu)
void kvm_vgic_sync_hwstate(struct kvm_vcpu *vcpu)
{
- struct vgic_dist *dist = &vcpu->kvm->arch.vgic;
-
if (!irqchip_in_kernel(vcpu->kvm))
return;
- spin_lock(&dist->lock);
__kvm_vgic_sync_hwstate(vcpu);
- spin_unlock(&dist->lock);
}
int kvm_vgic_vcpu_pending_irq(struct kvm_vcpu *vcpu)
--
1.9.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v9 5/5] KVM: arm/arm64: add irqfd support
2015-03-04 10:14 [PATCH v9 0/5] irqfd support for arm/arm64 Eric Auger
` (3 preceding siblings ...)
2015-03-04 10:14 ` [PATCH v9 4/5] KVM: arm/arm64: remove coarse grain dist locking at kvm_vgic_sync_hwstate Eric Auger
@ 2015-03-04 10:14 ` Eric Auger
2015-03-05 10:53 ` Marc Zyngier
4 siblings, 1 reply; 15+ messages in thread
From: Eric Auger @ 2015-03-04 10:14 UTC (permalink / raw)
To: eric.auger, eric.auger, christoffer.dall, marc.zyngier,
linux-arm-kernel, kvmarm, kvm
Cc: andre.przywara, linux-kernel, patches, gleb, pbonzini
This patch enables irqfd on arm/arm64.
Both irqfd and resamplefd are supported. Injection is implemented
in vgic.c without routing.
This patch enables CONFIG_HAVE_KVM_EVENTFD and CONFIG_HAVE_KVM_IRQFD.
KVM_CAP_IRQFD is now advertised. KVM_CAP_IRQFD_RESAMPLE capability
automatically is advertised as soon as CONFIG_HAVE_KVM_IRQFD is set.
Irqfd injection is restricted to SPI. The rationale behind not
supporting PPI irqfd injection is that any device using a PPI would
be a private-to-the-CPU device (timer for instance), so its state
would have to be context-switched along with the VCPU and would
require in-kernel wiring anyhow. It is not a relevant use case for
irqfds.
Signed-off-by: Eric Auger <eric.auger@linaro.org>
Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
---
v8 -> v9:
- replace kvm_debug by trace_kvm_set_irq and add
BUG_ON(!vgic_initialized(kvm));
v7 -> v8:
- remove kvm_irq_has_notifier call
- part of dist locking changes now are part of previous patch file
- remove gic_initialized() check in kvm_set_irq
- remove Christoffer's Reviewed-by after this change
v5 -> v6:
- KVM_CAP_IRQFD support depends on vgic_present
- add Christoffer's Reviewed-by
v4 -> v5:
- squash [PATCH v4 3/3] KVM: arm64: add irqfd support into this patch
- some rewording in Documentation/virtual/kvm/api.txt and in vgic
vgic_process_maintenance unlock comment.
- move explanation of why not supporting PPI into commit message
- in case of injection before gic readiness, -ENODEV is returned. It is
up to the user space to avoid this situation.
v3 -> v4:
- reword commit message
- explain why we unlock the distributor before calling kvm_notify_acked_irq
- rename is_assigned_irq into has_notifier
- change EOI and injection kvm_debug format string
- remove error local variable in kvm_set_irq
- Move HAVE_KVM_IRQCHIP unset in a separate patch
- handle case were the irqfd injection is attempted before the vgic is ready.
in such a case the notifier, if any, is called immediatly
- use nr_irqs to test spi is within correct range
v2 -> v3:
- removal of irq.h from eventfd.c put in a separate patch to increase
visibility
- properly expose KVM_CAP_IRQFD capability in arm.c
- remove CONFIG_HAVE_KVM_IRQCHIP meaningfull only if irq_comm.c is used
v1 -> v2:
- rebase on 3.17rc1
- move of the dist unlock in process_maintenance
- remove of dist lock in __kvm_vgic_sync_hwstate
- rewording of the commit message (add resamplefd reference)
- remove irq.h
Conflicts:
arch/arm64/kvm/Kconfig
---
Documentation/virtual/kvm/api.txt | 6 ++++-
arch/arm/include/uapi/asm/kvm.h | 3 +++
arch/arm/kvm/Kconfig | 2 ++
arch/arm/kvm/Makefile | 2 +-
arch/arm/kvm/arm.c | 5 ++++
arch/arm64/include/uapi/asm/kvm.h | 3 +++
arch/arm64/kvm/Kconfig | 2 ++
arch/arm64/kvm/Makefile | 2 +-
virt/kvm/arm/vgic.c | 48 +++++++++++++++++++++++++++++++++++++++
9 files changed, 70 insertions(+), 3 deletions(-)
diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
index b112efc..b265d8e 100644
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -2234,7 +2234,7 @@ into the hash PTE second double word).
4.75 KVM_IRQFD
Capability: KVM_CAP_IRQFD
-Architectures: x86 s390
+Architectures: x86 s390 arm arm64
Type: vm ioctl
Parameters: struct kvm_irqfd (in)
Returns: 0 on success, -1 on error
@@ -2260,6 +2260,10 @@ Note that closing the resamplefd is not sufficient to disable the
irqfd. The KVM_IRQFD_FLAG_RESAMPLE is only necessary on assignment
and need not be specified with KVM_IRQFD_FLAG_DEASSIGN.
+On ARM/ARM64, the gsi field in the kvm_irqfd struct specifies the Shared
+Peripheral Interrupt (SPI) index, such that the GIC interrupt ID is
+given by gsi + 32.
+
4.76 KVM_PPC_ALLOCATE_HTAB
Capability: KVM_CAP_PPC_ALLOC_HTAB
diff --git a/arch/arm/include/uapi/asm/kvm.h b/arch/arm/include/uapi/asm/kvm.h
index 0db25bc..2499867 100644
--- a/arch/arm/include/uapi/asm/kvm.h
+++ b/arch/arm/include/uapi/asm/kvm.h
@@ -198,6 +198,9 @@ struct kvm_arch_memory_slot {
/* Highest supported SPI, from VGIC_NR_IRQS */
#define KVM_ARM_IRQ_GIC_MAX 127
+/* One single KVM irqchip, ie. the VGIC */
+#define KVM_NR_IRQCHIPS 1
+
/* PSCI interface */
#define KVM_PSCI_FN_BASE 0x95c1ba5e
#define KVM_PSCI_FN(n) (KVM_PSCI_FN_BASE + (n))
diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig
index aae5242..d735a3e 100644
--- a/arch/arm/kvm/Kconfig
+++ b/arch/arm/kvm/Kconfig
@@ -27,6 +27,7 @@ config KVM
select KVM_GENERIC_DIRTYLOG_READ_PROTECT
select SRCU
depends on ARM_VIRT_EXT && ARM_LPAE
+ select HAVE_KVM_EVENTFD
---help---
Support hosting virtualized guest machines. You will also
need to select one or more of the processor modules below.
@@ -58,6 +59,7 @@ config KVM_ARM_MAX_VCPUS
config KVM_ARM_VGIC
bool "KVM support for Virtual GIC"
depends on KVM_ARM_HOST && OF
+ select HAVE_KVM_IRQFD
default y
---help---
Adds support for a hardware assisted, in-kernel GIC emulation.
diff --git a/arch/arm/kvm/Makefile b/arch/arm/kvm/Makefile
index 443b8be..539c1a5 100644
--- a/arch/arm/kvm/Makefile
+++ b/arch/arm/kvm/Makefile
@@ -15,7 +15,7 @@ AFLAGS_init.o := -Wa,-march=armv7-a$(plus_virt)
AFLAGS_interrupts.o := -Wa,-march=armv7-a$(plus_virt)
KVM := ../../../virt/kvm
-kvm-arm-y = $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o
+kvm-arm-y = $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o $(KVM)/eventfd.o
obj-y += kvm-arm.o init.o interrupts.o
obj-y += arm.o handle_exit.o guest.o mmu.o emulate.o reset.o
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index 5300d5a..4313776 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -175,6 +175,11 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
case KVM_CAP_IRQCHIP:
r = vgic_present;
break;
+#ifdef CONFIG_HAVE_KVM_IRQFD
+ case KVM_CAP_IRQFD:
+ r = vgic_present;
+ break;
+#endif
case KVM_CAP_DEVICE_CTRL:
case KVM_CAP_USER_MEMORY:
case KVM_CAP_SYNC_MMU:
diff --git a/arch/arm64/include/uapi/asm/kvm.h b/arch/arm64/include/uapi/asm/kvm.h
index 3ef77a4..c154c0b 100644
--- a/arch/arm64/include/uapi/asm/kvm.h
+++ b/arch/arm64/include/uapi/asm/kvm.h
@@ -191,6 +191,9 @@ struct kvm_arch_memory_slot {
/* Highest supported SPI, from VGIC_NR_IRQS */
#define KVM_ARM_IRQ_GIC_MAX 127
+/* One single KVM irqchip, ie. the VGIC */
+#define KVM_NR_IRQCHIPS 1
+
/* PSCI interface */
#define KVM_PSCI_FN_BASE 0x95c1ba5e
#define KVM_PSCI_FN(n) (KVM_PSCI_FN_BASE + (n))
diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig
index 039d8cf..143c9fd 100644
--- a/arch/arm64/kvm/Kconfig
+++ b/arch/arm64/kvm/Kconfig
@@ -29,6 +29,7 @@ config KVM
select KVM_ARM_TIMER
select KVM_GENERIC_DIRTYLOG_READ_PROTECT
select SRCU
+ select HAVE_KVM_EVENTFD
---help---
Support hosting virtualized guest machines.
@@ -53,6 +54,7 @@ config KVM_ARM_MAX_VCPUS
config KVM_ARM_VGIC
bool
depends on KVM_ARM_HOST && OF
+ select HAVE_KVM_IRQFD
---help---
Adds support for a hardware assisted, in-kernel GIC emulation.
diff --git a/arch/arm64/kvm/Makefile b/arch/arm64/kvm/Makefile
index 4e6e09e..0dffb5f 100644
--- a/arch/arm64/kvm/Makefile
+++ b/arch/arm64/kvm/Makefile
@@ -11,7 +11,7 @@ ARM=../../../arch/arm/kvm
obj-$(CONFIG_KVM_ARM_HOST) += kvm.o
-kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o
+kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o $(KVM)/eventfd.o
kvm-$(CONFIG_KVM_ARM_HOST) += $(ARM)/arm.o $(ARM)/mmu.o $(ARM)/mmio.o
kvm-$(CONFIG_KVM_ARM_HOST) += $(ARM)/psci.o $(ARM)/perf.o
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index 4e9b6d3..2dfb299 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -31,6 +31,7 @@
#include <asm/kvm_emulate.h>
#include <asm/kvm_arm.h>
#include <asm/kvm_mmu.h>
+#include <trace/events/kvm.h>
/*
* How the whole thing works (courtesy of Christoffer Dall):
@@ -1083,6 +1084,7 @@ static bool vgic_process_maintenance(struct kvm_vcpu *vcpu)
u32 status = vgic_get_interrupt_status(vcpu);
struct vgic_dist *dist = &vcpu->kvm->arch.vgic;
bool level_pending = false;
+ struct kvm *kvm = vcpu->kvm;
kvm_debug("STATUS = %08x\n", status);
@@ -1118,6 +1120,17 @@ static bool vgic_process_maintenance(struct kvm_vcpu *vcpu)
*/
vgic_dist_irq_clear_soft_pend(vcpu, vlr.irq);
+ /*
+ * kvm_notify_acked_irq calls kvm_set_irq()
+ * to reset the IRQ level. Need to release the
+ * lock for kvm_set_irq to grab it.
+ */
+ spin_unlock(&dist->lock);
+
+ kvm_notify_acked_irq(kvm, 0,
+ vlr.irq - VGIC_NR_PRIVATE_IRQS);
+ spin_lock(&dist->lock);
+
/* Any additional pending interrupt? */
if (vgic_dist_irq_get_level(vcpu, vlr.irq)) {
vgic_cpu_irq_set(vcpu, vlr.irq);
@@ -1911,3 +1924,38 @@ out_free_irq:
free_percpu_irq(vgic->maint_irq, kvm_get_running_vcpus());
return ret;
}
+
+int kvm_irq_map_gsi(struct kvm *kvm,
+ struct kvm_kernel_irq_routing_entry *entries,
+ int gsi)
+{
+ return gsi;
+}
+
+int kvm_irq_map_chip_pin(struct kvm *kvm, unsigned irqchip, unsigned pin)
+{
+ return pin;
+}
+
+int kvm_set_irq(struct kvm *kvm, int irq_source_id,
+ u32 irq, int level, bool line_status)
+{
+ unsigned int spi = irq + VGIC_NR_PRIVATE_IRQS;
+
+ trace_kvm_set_irq(irq, level, irq_source_id);
+
+ BUG_ON(!vgic_initialized(kvm));
+
+ if (spi > kvm->arch.vgic.nr_irqs)
+ return -EINVAL;
+ return kvm_vgic_inject_irq(kvm, 0, spi, level);
+
+}
+
+/* MSI not implemented yet */
+int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e,
+ struct kvm *kvm, int irq_source_id,
+ int level, bool line_status)
+{
+ return 0;
+}
--
1.9.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v9 5/5] KVM: arm/arm64: add irqfd support
2015-03-04 10:14 ` [PATCH v9 5/5] KVM: arm/arm64: add irqfd support Eric Auger
@ 2015-03-05 10:53 ` Marc Zyngier
2015-03-05 11:27 ` Paolo Bonzini
2015-03-05 14:04 ` Eric Auger
0 siblings, 2 replies; 15+ messages in thread
From: Marc Zyngier @ 2015-03-05 10:53 UTC (permalink / raw)
To: Eric Auger, eric.auger, christoffer.dall, linux-arm-kernel, kvmarm, kvm
Cc: Andre Przywara, linux-kernel, patches, gleb, pbonzini
On 04/03/15 10:14, Eric Auger wrote:
> This patch enables irqfd on arm/arm64.
>
> Both irqfd and resamplefd are supported. Injection is implemented
> in vgic.c without routing.
>
> This patch enables CONFIG_HAVE_KVM_EVENTFD and CONFIG_HAVE_KVM_IRQFD.
>
> KVM_CAP_IRQFD is now advertised. KVM_CAP_IRQFD_RESAMPLE capability
> automatically is advertised as soon as CONFIG_HAVE_KVM_IRQFD is set.
>
> Irqfd injection is restricted to SPI. The rationale behind not
> supporting PPI irqfd injection is that any device using a PPI would
> be a private-to-the-CPU device (timer for instance), so its state
> would have to be context-switched along with the VCPU and would
> require in-kernel wiring anyhow. It is not a relevant use case for
> irqfds.
>
> Signed-off-by: Eric Auger <eric.auger@linaro.org>
> Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
>
> ---
> v8 -> v9:
> - replace kvm_debug by trace_kvm_set_irq and add
> BUG_ON(!vgic_initialized(kvm));
>
> v7 -> v8:
> - remove kvm_irq_has_notifier call
> - part of dist locking changes now are part of previous patch file
> - remove gic_initialized() check in kvm_set_irq
> - remove Christoffer's Reviewed-by after this change
>
> v5 -> v6:
> - KVM_CAP_IRQFD support depends on vgic_present
> - add Christoffer's Reviewed-by
>
> v4 -> v5:
> - squash [PATCH v4 3/3] KVM: arm64: add irqfd support into this patch
> - some rewording in Documentation/virtual/kvm/api.txt and in vgic
> vgic_process_maintenance unlock comment.
> - move explanation of why not supporting PPI into commit message
> - in case of injection before gic readiness, -ENODEV is returned. It is
> up to the user space to avoid this situation.
>
> v3 -> v4:
> - reword commit message
> - explain why we unlock the distributor before calling kvm_notify_acked_irq
> - rename is_assigned_irq into has_notifier
> - change EOI and injection kvm_debug format string
> - remove error local variable in kvm_set_irq
> - Move HAVE_KVM_IRQCHIP unset in a separate patch
> - handle case were the irqfd injection is attempted before the vgic is ready.
> in such a case the notifier, if any, is called immediatly
> - use nr_irqs to test spi is within correct range
>
> v2 -> v3:
> - removal of irq.h from eventfd.c put in a separate patch to increase
> visibility
> - properly expose KVM_CAP_IRQFD capability in arm.c
> - remove CONFIG_HAVE_KVM_IRQCHIP meaningfull only if irq_comm.c is used
>
> v1 -> v2:
> - rebase on 3.17rc1
> - move of the dist unlock in process_maintenance
> - remove of dist lock in __kvm_vgic_sync_hwstate
> - rewording of the commit message (add resamplefd reference)
> - remove irq.h
>
> Conflicts:
> arch/arm64/kvm/Kconfig
> ---
> Documentation/virtual/kvm/api.txt | 6 ++++-
> arch/arm/include/uapi/asm/kvm.h | 3 +++
> arch/arm/kvm/Kconfig | 2 ++
> arch/arm/kvm/Makefile | 2 +-
> arch/arm/kvm/arm.c | 5 ++++
> arch/arm64/include/uapi/asm/kvm.h | 3 +++
> arch/arm64/kvm/Kconfig | 2 ++
> arch/arm64/kvm/Makefile | 2 +-
> virt/kvm/arm/vgic.c | 48 +++++++++++++++++++++++++++++++++++++++
> 9 files changed, 70 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
> index b112efc..b265d8e 100644
> --- a/Documentation/virtual/kvm/api.txt
> +++ b/Documentation/virtual/kvm/api.txt
> @@ -2234,7 +2234,7 @@ into the hash PTE second double word).
> 4.75 KVM_IRQFD
>
> Capability: KVM_CAP_IRQFD
> -Architectures: x86 s390
> +Architectures: x86 s390 arm arm64
> Type: vm ioctl
> Parameters: struct kvm_irqfd (in)
> Returns: 0 on success, -1 on error
> @@ -2260,6 +2260,10 @@ Note that closing the resamplefd is not sufficient to disable the
> irqfd. The KVM_IRQFD_FLAG_RESAMPLE is only necessary on assignment
> and need not be specified with KVM_IRQFD_FLAG_DEASSIGN.
>
> +On ARM/ARM64, the gsi field in the kvm_irqfd struct specifies the Shared
> +Peripheral Interrupt (SPI) index, such that the GIC interrupt ID is
> +given by gsi + 32.
> +
> 4.76 KVM_PPC_ALLOCATE_HTAB
>
> Capability: KVM_CAP_PPC_ALLOC_HTAB
> diff --git a/arch/arm/include/uapi/asm/kvm.h b/arch/arm/include/uapi/asm/kvm.h
> index 0db25bc..2499867 100644
> --- a/arch/arm/include/uapi/asm/kvm.h
> +++ b/arch/arm/include/uapi/asm/kvm.h
> @@ -198,6 +198,9 @@ struct kvm_arch_memory_slot {
> /* Highest supported SPI, from VGIC_NR_IRQS */
> #define KVM_ARM_IRQ_GIC_MAX 127
>
> +/* One single KVM irqchip, ie. the VGIC */
> +#define KVM_NR_IRQCHIPS 1
> +
> /* PSCI interface */
> #define KVM_PSCI_FN_BASE 0x95c1ba5e
> #define KVM_PSCI_FN(n) (KVM_PSCI_FN_BASE + (n))
> diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig
> index aae5242..d735a3e 100644
> --- a/arch/arm/kvm/Kconfig
> +++ b/arch/arm/kvm/Kconfig
> @@ -27,6 +27,7 @@ config KVM
> select KVM_GENERIC_DIRTYLOG_READ_PROTECT
> select SRCU
> depends on ARM_VIRT_EXT && ARM_LPAE
> + select HAVE_KVM_EVENTFD
> ---help---
> Support hosting virtualized guest machines. You will also
> need to select one or more of the processor modules below.
> @@ -58,6 +59,7 @@ config KVM_ARM_MAX_VCPUS
> config KVM_ARM_VGIC
> bool "KVM support for Virtual GIC"
> depends on KVM_ARM_HOST && OF
> + select HAVE_KVM_IRQFD
> default y
> ---help---
> Adds support for a hardware assisted, in-kernel GIC emulation.
> diff --git a/arch/arm/kvm/Makefile b/arch/arm/kvm/Makefile
> index 443b8be..539c1a5 100644
> --- a/arch/arm/kvm/Makefile
> +++ b/arch/arm/kvm/Makefile
> @@ -15,7 +15,7 @@ AFLAGS_init.o := -Wa,-march=armv7-a$(plus_virt)
> AFLAGS_interrupts.o := -Wa,-march=armv7-a$(plus_virt)
>
> KVM := ../../../virt/kvm
> -kvm-arm-y = $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o
> +kvm-arm-y = $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o $(KVM)/eventfd.o
>
> obj-y += kvm-arm.o init.o interrupts.o
> obj-y += arm.o handle_exit.o guest.o mmu.o emulate.o reset.o
> diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
> index 5300d5a..4313776 100644
> --- a/arch/arm/kvm/arm.c
> +++ b/arch/arm/kvm/arm.c
> @@ -175,6 +175,11 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
> case KVM_CAP_IRQCHIP:
> r = vgic_present;
> break;
> +#ifdef CONFIG_HAVE_KVM_IRQFD
> + case KVM_CAP_IRQFD:
> + r = vgic_present;
> + break;
> +#endif
Nitpick: we have "select HAVE_KVM_IRQFD", so we can lose the #ifdef-ery.
> case KVM_CAP_DEVICE_CTRL:
> case KVM_CAP_USER_MEMORY:
> case KVM_CAP_SYNC_MMU:
> diff --git a/arch/arm64/include/uapi/asm/kvm.h b/arch/arm64/include/uapi/asm/kvm.h
> index 3ef77a4..c154c0b 100644
> --- a/arch/arm64/include/uapi/asm/kvm.h
> +++ b/arch/arm64/include/uapi/asm/kvm.h
> @@ -191,6 +191,9 @@ struct kvm_arch_memory_slot {
> /* Highest supported SPI, from VGIC_NR_IRQS */
> #define KVM_ARM_IRQ_GIC_MAX 127
>
> +/* One single KVM irqchip, ie. the VGIC */
> +#define KVM_NR_IRQCHIPS 1
> +
> /* PSCI interface */
> #define KVM_PSCI_FN_BASE 0x95c1ba5e
> #define KVM_PSCI_FN(n) (KVM_PSCI_FN_BASE + (n))
> diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig
> index 039d8cf..143c9fd 100644
> --- a/arch/arm64/kvm/Kconfig
> +++ b/arch/arm64/kvm/Kconfig
> @@ -29,6 +29,7 @@ config KVM
> select KVM_ARM_TIMER
> select KVM_GENERIC_DIRTYLOG_READ_PROTECT
> select SRCU
> + select HAVE_KVM_EVENTFD
> ---help---
> Support hosting virtualized guest machines.
>
> @@ -53,6 +54,7 @@ config KVM_ARM_MAX_VCPUS
> config KVM_ARM_VGIC
> bool
> depends on KVM_ARM_HOST && OF
> + select HAVE_KVM_IRQFD
Hmmm. There is way too many selects here. Can't we just select it with
CONFIG_KVM_ARM_VGIC, and be done with it?
> ---help---
> Adds support for a hardware assisted, in-kernel GIC emulation.
>
> diff --git a/arch/arm64/kvm/Makefile b/arch/arm64/kvm/Makefile
> index 4e6e09e..0dffb5f 100644
> --- a/arch/arm64/kvm/Makefile
> +++ b/arch/arm64/kvm/Makefile
> @@ -11,7 +11,7 @@ ARM=../../../arch/arm/kvm
>
> obj-$(CONFIG_KVM_ARM_HOST) += kvm.o
>
> -kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o
> +kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o $(KVM)/eventfd.o
> kvm-$(CONFIG_KVM_ARM_HOST) += $(ARM)/arm.o $(ARM)/mmu.o $(ARM)/mmio.o
> kvm-$(CONFIG_KVM_ARM_HOST) += $(ARM)/psci.o $(ARM)/perf.o
>
> diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
> index 4e9b6d3..2dfb299 100644
> --- a/virt/kvm/arm/vgic.c
> +++ b/virt/kvm/arm/vgic.c
> @@ -31,6 +31,7 @@
> #include <asm/kvm_emulate.h>
> #include <asm/kvm_arm.h>
> #include <asm/kvm_mmu.h>
> +#include <trace/events/kvm.h>
>
> /*
> * How the whole thing works (courtesy of Christoffer Dall):
> @@ -1083,6 +1084,7 @@ static bool vgic_process_maintenance(struct kvm_vcpu *vcpu)
> u32 status = vgic_get_interrupt_status(vcpu);
> struct vgic_dist *dist = &vcpu->kvm->arch.vgic;
> bool level_pending = false;
> + struct kvm *kvm = vcpu->kvm;
>
> kvm_debug("STATUS = %08x\n", status);
>
> @@ -1118,6 +1120,17 @@ static bool vgic_process_maintenance(struct kvm_vcpu *vcpu)
> */
> vgic_dist_irq_clear_soft_pend(vcpu, vlr.irq);
>
> + /*
> + * kvm_notify_acked_irq calls kvm_set_irq()
> + * to reset the IRQ level. Need to release the
> + * lock for kvm_set_irq to grab it.
> + */
> + spin_unlock(&dist->lock);
> +
> + kvm_notify_acked_irq(kvm, 0,
> + vlr.irq - VGIC_NR_PRIVATE_IRQS);
> + spin_lock(&dist->lock);
> +
I tried hard to break that one, and failed. It must be correct! ;-)
> /* Any additional pending interrupt? */
> if (vgic_dist_irq_get_level(vcpu, vlr.irq)) {
> vgic_cpu_irq_set(vcpu, vlr.irq);
> @@ -1911,3 +1924,38 @@ out_free_irq:
> free_percpu_irq(vgic->maint_irq, kvm_get_running_vcpus());
> return ret;
> }
> +
> +int kvm_irq_map_gsi(struct kvm *kvm,
> + struct kvm_kernel_irq_routing_entry *entries,
> + int gsi)
> +{
> + return gsi;
> +}
> +
> +int kvm_irq_map_chip_pin(struct kvm *kvm, unsigned irqchip, unsigned pin)
> +{
> + return pin;
> +}
> +
> +int kvm_set_irq(struct kvm *kvm, int irq_source_id,
> + u32 irq, int level, bool line_status)
> +{
> + unsigned int spi = irq + VGIC_NR_PRIVATE_IRQS;
> +
> + trace_kvm_set_irq(irq, level, irq_source_id);
> +
> + BUG_ON(!vgic_initialized(kvm));
> +
> + if (spi > kvm->arch.vgic.nr_irqs)
> + return -EINVAL;
> + return kvm_vgic_inject_irq(kvm, 0, spi, level);
> +
> +}
> +
> +/* MSI not implemented yet */
> +int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e,
> + struct kvm *kvm, int irq_source_id,
> + int level, bool line_status)
> +{
> + return 0;
> +}
>
Despite from the nits mentionned before, this looks good, and I think we
should merge it in 4.1 (or whatever this is called).
So for the whole series:
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
M.
--
Jazz is not dead. It just smells funny...
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v9 5/5] KVM: arm/arm64: add irqfd support
2015-03-05 10:53 ` Marc Zyngier
@ 2015-03-05 11:27 ` Paolo Bonzini
2015-03-05 11:33 ` Marc Zyngier
2015-03-11 14:24 ` Christoffer Dall
2015-03-05 14:04 ` Eric Auger
1 sibling, 2 replies; 15+ messages in thread
From: Paolo Bonzini @ 2015-03-05 11:27 UTC (permalink / raw)
To: Marc Zyngier, Eric Auger, eric.auger, christoffer.dall,
linux-arm-kernel, kvmarm, kvm
Cc: Andre Przywara, linux-kernel, patches, gleb
On 05/03/2015 11:53, Marc Zyngier wrote:
> > +#ifdef CONFIG_HAVE_KVM_IRQFD
> > + case KVM_CAP_IRQFD:
> > + r = vgic_present;
> > + break;
> > +#endif
>
> Nitpick: we have "select HAVE_KVM_IRQFD", so we can lose the #ifdef-ery.
Alternatively, I've just posted a patch to move the KVM_CAP_IRQFD case
to common code.
vgic_present probably should be replaced by
IS_ENABLED(CONFIG_KVM_ARM_VGIC). I've sent a patch for this.
Paolo
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v9 5/5] KVM: arm/arm64: add irqfd support
2015-03-05 11:27 ` Paolo Bonzini
@ 2015-03-05 11:33 ` Marc Zyngier
2015-03-11 14:24 ` Christoffer Dall
1 sibling, 0 replies; 15+ messages in thread
From: Marc Zyngier @ 2015-03-05 11:33 UTC (permalink / raw)
To: Paolo Bonzini, Eric Auger, eric.auger, christoffer.dall,
linux-arm-kernel, kvmarm, kvm
Cc: Andre Przywara, linux-kernel, patches, gleb
On 05/03/15 11:27, Paolo Bonzini wrote:
>
>
> On 05/03/2015 11:53, Marc Zyngier wrote:
>>> +#ifdef CONFIG_HAVE_KVM_IRQFD
>>> + case KVM_CAP_IRQFD:
>>> + r = vgic_present;
>>> + break;
>>> +#endif
>>
>> Nitpick: we have "select HAVE_KVM_IRQFD", so we can lose the #ifdef-ery.
>
> Alternatively, I've just posted a patch to move the KVM_CAP_IRQFD case
> to common code.
>
> vgic_present probably should be replaced by
> IS_ENABLED(CONFIG_KVM_ARM_VGIC). I've sent a patch for this.
Right. We can probably take this at the same time as Eric's series.
Thanks,
M.
--
Jazz is not dead. It just smells funny...
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v9 5/5] KVM: arm/arm64: add irqfd support
2015-03-05 11:27 ` Paolo Bonzini
2015-03-05 11:33 ` Marc Zyngier
@ 2015-03-11 14:24 ` Christoffer Dall
2015-03-11 16:54 ` Eric Auger
1 sibling, 1 reply; 15+ messages in thread
From: Christoffer Dall @ 2015-03-11 14:24 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Marc Zyngier, Eric Auger, eric.auger, linux-arm-kernel, kvmarm,
kvm, Andre Przywara, linux-kernel, patches, gleb
On Thu, Mar 05, 2015 at 12:27:42PM +0100, Paolo Bonzini wrote:
>
>
> On 05/03/2015 11:53, Marc Zyngier wrote:
> > > +#ifdef CONFIG_HAVE_KVM_IRQFD
> > > + case KVM_CAP_IRQFD:
> > > + r = vgic_present;
> > > + break;
> > > +#endif
> >
> > Nitpick: we have "select HAVE_KVM_IRQFD", so we can lose the #ifdef-ery.
>
> Alternatively, I've just posted a patch to move the KVM_CAP_IRQFD case
> to common code.
>
> vgic_present probably should be replaced by
> IS_ENABLED(CONFIG_KVM_ARM_VGIC). I've sent a patch for this.
>
I have applied all of this together with my kill-the-vgic-config-option
patch here:
git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git queue
Take a look please.
Thanks,
-Christoffer
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v9 5/5] KVM: arm/arm64: add irqfd support
2015-03-11 14:24 ` Christoffer Dall
@ 2015-03-11 16:54 ` Eric Auger
0 siblings, 0 replies; 15+ messages in thread
From: Eric Auger @ 2015-03-11 16:54 UTC (permalink / raw)
To: Christoffer Dall, Paolo Bonzini
Cc: Marc Zyngier, eric.auger, linux-arm-kernel, kvmarm, kvm,
Andre Przywara, linux-kernel, patches, gleb
On 03/11/2015 03:24 PM, Christoffer Dall wrote:
> On Thu, Mar 05, 2015 at 12:27:42PM +0100, Paolo Bonzini wrote:
>>
>>
>> On 05/03/2015 11:53, Marc Zyngier wrote:
>>>> +#ifdef CONFIG_HAVE_KVM_IRQFD
>>>> + case KVM_CAP_IRQFD:
>>>> + r = vgic_present;
>>>> + break;
>>>> +#endif
>>>
>>> Nitpick: we have "select HAVE_KVM_IRQFD", so we can lose the #ifdef-ery.
>>
>> Alternatively, I've just posted a patch to move the KVM_CAP_IRQFD case
>> to common code.
>>
>> vgic_present probably should be replaced by
>> IS_ENABLED(CONFIG_KVM_ARM_VGIC). I've sent a patch for this.
>>
> I have applied all of this together with my kill-the-vgic-config-option
> patch here:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git queue
>
> Take a look please.
Hi Christoffer,
This looks good to me. Thanks for the integration.
- Eric
>
> Thanks,
> -Christoffer
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v9 5/5] KVM: arm/arm64: add irqfd support
2015-03-05 10:53 ` Marc Zyngier
2015-03-05 11:27 ` Paolo Bonzini
@ 2015-03-05 14:04 ` Eric Auger
2015-03-05 14:20 ` Marc Zyngier
1 sibling, 1 reply; 15+ messages in thread
From: Eric Auger @ 2015-03-05 14:04 UTC (permalink / raw)
To: Marc Zyngier, eric.auger, christoffer.dall, linux-arm-kernel,
kvmarm, kvm
Cc: Andre Przywara, linux-kernel, patches, gleb, pbonzini
Hi Marc,
On 03/05/2015 11:53 AM, Marc Zyngier wrote:
> On 04/03/15 10:14, Eric Auger wrote:
>> This patch enables irqfd on arm/arm64.
>>
>> Both irqfd and resamplefd are supported. Injection is implemented
>> in vgic.c without routing.
>>
>> This patch enables CONFIG_HAVE_KVM_EVENTFD and CONFIG_HAVE_KVM_IRQFD.
>>
>> KVM_CAP_IRQFD is now advertised. KVM_CAP_IRQFD_RESAMPLE capability
>> automatically is advertised as soon as CONFIG_HAVE_KVM_IRQFD is set.
>>
>> Irqfd injection is restricted to SPI. The rationale behind not
>> supporting PPI irqfd injection is that any device using a PPI would
>> be a private-to-the-CPU device (timer for instance), so its state
>> would have to be context-switched along with the VCPU and would
>> require in-kernel wiring anyhow. It is not a relevant use case for
>> irqfds.
>>
>> Signed-off-by: Eric Auger <eric.auger@linaro.org>
>> Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
>>
>> ---
>> v8 -> v9:
>> - replace kvm_debug by trace_kvm_set_irq and add
>> BUG_ON(!vgic_initialized(kvm));
>>
>> v7 -> v8:
>> - remove kvm_irq_has_notifier call
>> - part of dist locking changes now are part of previous patch file
>> - remove gic_initialized() check in kvm_set_irq
>> - remove Christoffer's Reviewed-by after this change
>>
>> v5 -> v6:
>> - KVM_CAP_IRQFD support depends on vgic_present
>> - add Christoffer's Reviewed-by
>>
>> v4 -> v5:
>> - squash [PATCH v4 3/3] KVM: arm64: add irqfd support into this patch
>> - some rewording in Documentation/virtual/kvm/api.txt and in vgic
>> vgic_process_maintenance unlock comment.
>> - move explanation of why not supporting PPI into commit message
>> - in case of injection before gic readiness, -ENODEV is returned. It is
>> up to the user space to avoid this situation.
>>
>> v3 -> v4:
>> - reword commit message
>> - explain why we unlock the distributor before calling kvm_notify_acked_irq
>> - rename is_assigned_irq into has_notifier
>> - change EOI and injection kvm_debug format string
>> - remove error local variable in kvm_set_irq
>> - Move HAVE_KVM_IRQCHIP unset in a separate patch
>> - handle case were the irqfd injection is attempted before the vgic is ready.
>> in such a case the notifier, if any, is called immediatly
>> - use nr_irqs to test spi is within correct range
>>
>> v2 -> v3:
>> - removal of irq.h from eventfd.c put in a separate patch to increase
>> visibility
>> - properly expose KVM_CAP_IRQFD capability in arm.c
>> - remove CONFIG_HAVE_KVM_IRQCHIP meaningfull only if irq_comm.c is used
>>
>> v1 -> v2:
>> - rebase on 3.17rc1
>> - move of the dist unlock in process_maintenance
>> - remove of dist lock in __kvm_vgic_sync_hwstate
>> - rewording of the commit message (add resamplefd reference)
>> - remove irq.h
>>
>> Conflicts:
>> arch/arm64/kvm/Kconfig
>> ---
>> Documentation/virtual/kvm/api.txt | 6 ++++-
>> arch/arm/include/uapi/asm/kvm.h | 3 +++
>> arch/arm/kvm/Kconfig | 2 ++
>> arch/arm/kvm/Makefile | 2 +-
>> arch/arm/kvm/arm.c | 5 ++++
>> arch/arm64/include/uapi/asm/kvm.h | 3 +++
>> arch/arm64/kvm/Kconfig | 2 ++
>> arch/arm64/kvm/Makefile | 2 +-
>> virt/kvm/arm/vgic.c | 48 +++++++++++++++++++++++++++++++++++++++
>> 9 files changed, 70 insertions(+), 3 deletions(-)
>>
>> diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
>> index b112efc..b265d8e 100644
>> --- a/Documentation/virtual/kvm/api.txt
>> +++ b/Documentation/virtual/kvm/api.txt
>> @@ -2234,7 +2234,7 @@ into the hash PTE second double word).
>> 4.75 KVM_IRQFD
>>
>> Capability: KVM_CAP_IRQFD
>> -Architectures: x86 s390
>> +Architectures: x86 s390 arm arm64
>> Type: vm ioctl
>> Parameters: struct kvm_irqfd (in)
>> Returns: 0 on success, -1 on error
>> @@ -2260,6 +2260,10 @@ Note that closing the resamplefd is not sufficient to disable the
>> irqfd. The KVM_IRQFD_FLAG_RESAMPLE is only necessary on assignment
>> and need not be specified with KVM_IRQFD_FLAG_DEASSIGN.
>>
>> +On ARM/ARM64, the gsi field in the kvm_irqfd struct specifies the Shared
>> +Peripheral Interrupt (SPI) index, such that the GIC interrupt ID is
>> +given by gsi + 32.
>> +
>> 4.76 KVM_PPC_ALLOCATE_HTAB
>>
>> Capability: KVM_CAP_PPC_ALLOC_HTAB
>> diff --git a/arch/arm/include/uapi/asm/kvm.h b/arch/arm/include/uapi/asm/kvm.h
>> index 0db25bc..2499867 100644
>> --- a/arch/arm/include/uapi/asm/kvm.h
>> +++ b/arch/arm/include/uapi/asm/kvm.h
>> @@ -198,6 +198,9 @@ struct kvm_arch_memory_slot {
>> /* Highest supported SPI, from VGIC_NR_IRQS */
>> #define KVM_ARM_IRQ_GIC_MAX 127
>>
>> +/* One single KVM irqchip, ie. the VGIC */
>> +#define KVM_NR_IRQCHIPS 1
>> +
>> /* PSCI interface */
>> #define KVM_PSCI_FN_BASE 0x95c1ba5e
>> #define KVM_PSCI_FN(n) (KVM_PSCI_FN_BASE + (n))
>> diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig
>> index aae5242..d735a3e 100644
>> --- a/arch/arm/kvm/Kconfig
>> +++ b/arch/arm/kvm/Kconfig
>> @@ -27,6 +27,7 @@ config KVM
>> select KVM_GENERIC_DIRTYLOG_READ_PROTECT
>> select SRCU
>> depends on ARM_VIRT_EXT && ARM_LPAE
>> + select HAVE_KVM_EVENTFD
>> ---help---
>> Support hosting virtualized guest machines. You will also
>> need to select one or more of the processor modules below.
>> @@ -58,6 +59,7 @@ config KVM_ARM_MAX_VCPUS
>> config KVM_ARM_VGIC
>> bool "KVM support for Virtual GIC"
>> depends on KVM_ARM_HOST && OF
>> + select HAVE_KVM_IRQFD
>> default y
>> ---help---
>> Adds support for a hardware assisted, in-kernel GIC emulation.
>> diff --git a/arch/arm/kvm/Makefile b/arch/arm/kvm/Makefile
>> index 443b8be..539c1a5 100644
>> --- a/arch/arm/kvm/Makefile
>> +++ b/arch/arm/kvm/Makefile
>> @@ -15,7 +15,7 @@ AFLAGS_init.o := -Wa,-march=armv7-a$(plus_virt)
>> AFLAGS_interrupts.o := -Wa,-march=armv7-a$(plus_virt)
>>
>> KVM := ../../../virt/kvm
>> -kvm-arm-y = $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o
>> +kvm-arm-y = $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o $(KVM)/eventfd.o
>>
>> obj-y += kvm-arm.o init.o interrupts.o
>> obj-y += arm.o handle_exit.o guest.o mmu.o emulate.o reset.o
>> diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
>> index 5300d5a..4313776 100644
>> --- a/arch/arm/kvm/arm.c
>> +++ b/arch/arm/kvm/arm.c
>> @@ -175,6 +175,11 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
>> case KVM_CAP_IRQCHIP:
>> r = vgic_present;
>> break;
>> +#ifdef CONFIG_HAVE_KVM_IRQFD
>> + case KVM_CAP_IRQFD:
>> + r = vgic_present;
>> + break;
>> +#endif
>
> Nitpick: we have "select HAVE_KVM_IRQFD", so we can lose the #ifdef-ery.
right. Also I think the vgic_present can be removed since
CONFIG_HAVE_KVM_IRQFD always is set when CONFIG_KVM_ARM_VGIC is set.
So overall this indeed can simply be replaced by Paolo's patch.
>
>> case KVM_CAP_DEVICE_CTRL:
>> case KVM_CAP_USER_MEMORY:
>> case KVM_CAP_SYNC_MMU:
>> diff --git a/arch/arm64/include/uapi/asm/kvm.h b/arch/arm64/include/uapi/asm/kvm.h
>> index 3ef77a4..c154c0b 100644
>> --- a/arch/arm64/include/uapi/asm/kvm.h
>> +++ b/arch/arm64/include/uapi/asm/kvm.h
>> @@ -191,6 +191,9 @@ struct kvm_arch_memory_slot {
>> /* Highest supported SPI, from VGIC_NR_IRQS */
>> #define KVM_ARM_IRQ_GIC_MAX 127
>>
>> +/* One single KVM irqchip, ie. the VGIC */
>> +#define KVM_NR_IRQCHIPS 1
>> +
>> /* PSCI interface */
>> #define KVM_PSCI_FN_BASE 0x95c1ba5e
>> #define KVM_PSCI_FN(n) (KVM_PSCI_FN_BASE + (n))
>> diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig
>> index 039d8cf..143c9fd 100644
>> --- a/arch/arm64/kvm/Kconfig
>> +++ b/arch/arm64/kvm/Kconfig
>> @@ -29,6 +29,7 @@ config KVM
>> select KVM_ARM_TIMER
>> select KVM_GENERIC_DIRTYLOG_READ_PROTECT
>> select SRCU
>> + select HAVE_KVM_EVENTFD
>> ---help---
>> Support hosting virtualized guest machines.
>>
>> @@ -53,6 +54,7 @@ config KVM_ARM_MAX_VCPUS
>> config KVM_ARM_VGIC
>> bool
>> depends on KVM_ARM_HOST && OF
>> + select HAVE_KVM_IRQFD
>
> Hmmm. There is way too many selects here. Can't we just select it with
> CONFIG_KVM_ARM_VGIC, and be done with it?
I did that way since CONFIG_KVM_ARM_VGIC is not selected in the config
KVM section on 32b. Currently the IRQFD select location is same for arm
and arm64.
do you prefer I select HAVE_KVM_IRQFD in the config KVM section, ie. at
the same place we select CONFIG_KVM_ARM_VGIC?
>
>> ---help---
>> Adds support for a hardware assisted, in-kernel GIC emulation.
>>
>> diff --git a/arch/arm64/kvm/Makefile b/arch/arm64/kvm/Makefile
>> index 4e6e09e..0dffb5f 100644
>> --- a/arch/arm64/kvm/Makefile
>> +++ b/arch/arm64/kvm/Makefile
>> @@ -11,7 +11,7 @@ ARM=../../../arch/arm/kvm
>>
>> obj-$(CONFIG_KVM_ARM_HOST) += kvm.o
>>
>> -kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o
>> +kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o $(KVM)/eventfd.o
>> kvm-$(CONFIG_KVM_ARM_HOST) += $(ARM)/arm.o $(ARM)/mmu.o $(ARM)/mmio.o
>> kvm-$(CONFIG_KVM_ARM_HOST) += $(ARM)/psci.o $(ARM)/perf.o
>>
>> diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
>> index 4e9b6d3..2dfb299 100644
>> --- a/virt/kvm/arm/vgic.c
>> +++ b/virt/kvm/arm/vgic.c
>> @@ -31,6 +31,7 @@
>> #include <asm/kvm_emulate.h>
>> #include <asm/kvm_arm.h>
>> #include <asm/kvm_mmu.h>
>> +#include <trace/events/kvm.h>
>>
>> /*
>> * How the whole thing works (courtesy of Christoffer Dall):
>> @@ -1083,6 +1084,7 @@ static bool vgic_process_maintenance(struct kvm_vcpu *vcpu)
>> u32 status = vgic_get_interrupt_status(vcpu);
>> struct vgic_dist *dist = &vcpu->kvm->arch.vgic;
>> bool level_pending = false;
>> + struct kvm *kvm = vcpu->kvm;
>>
>> kvm_debug("STATUS = %08x\n", status);
>>
>> @@ -1118,6 +1120,17 @@ static bool vgic_process_maintenance(struct kvm_vcpu *vcpu)
>> */
>> vgic_dist_irq_clear_soft_pend(vcpu, vlr.irq);
>>
>> + /*
>> + * kvm_notify_acked_irq calls kvm_set_irq()
>> + * to reset the IRQ level. Need to release the
>> + * lock for kvm_set_irq to grab it.
>> + */
>> + spin_unlock(&dist->lock);
>> +
>> + kvm_notify_acked_irq(kvm, 0,
>> + vlr.irq - VGIC_NR_PRIVATE_IRQS);
>> + spin_lock(&dist->lock);
>> +
>
> I tried hard to break that one, and failed. It must be correct! ;-)
Knock on wood!
Do I need to post a v10 based on Paolo's patch?
Thanks
Eric
>
>> /* Any additional pending interrupt? */
>> if (vgic_dist_irq_get_level(vcpu, vlr.irq)) {
>> vgic_cpu_irq_set(vcpu, vlr.irq);
>> @@ -1911,3 +1924,38 @@ out_free_irq:
>> free_percpu_irq(vgic->maint_irq, kvm_get_running_vcpus());
>> return ret;
>> }
>> +
>> +int kvm_irq_map_gsi(struct kvm *kvm,
>> + struct kvm_kernel_irq_routing_entry *entries,
>> + int gsi)
>> +{
>> + return gsi;
>> +}
>> +
>> +int kvm_irq_map_chip_pin(struct kvm *kvm, unsigned irqchip, unsigned pin)
>> +{
>> + return pin;
>> +}
>> +
>> +int kvm_set_irq(struct kvm *kvm, int irq_source_id,
>> + u32 irq, int level, bool line_status)
>> +{
>> + unsigned int spi = irq + VGIC_NR_PRIVATE_IRQS;
>> +
>> + trace_kvm_set_irq(irq, level, irq_source_id);
>> +
>> + BUG_ON(!vgic_initialized(kvm));
>> +
>> + if (spi > kvm->arch.vgic.nr_irqs)
>> + return -EINVAL;
>> + return kvm_vgic_inject_irq(kvm, 0, spi, level);
>> +
>> +}
>> +
>> +/* MSI not implemented yet */
>> +int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e,
>> + struct kvm *kvm, int irq_source_id,
>> + int level, bool line_status)
>> +{
>> + return 0;
>> +}
>>
>
> Despite from the nits mentionned before, this looks good, and I think we
> should merge it in 4.1 (or whatever this is called).
>
> So for the whole series:
>
> Acked-by: Marc Zyngier <marc.zyngier@arm.com>
>
> M.
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v9 5/5] KVM: arm/arm64: add irqfd support
2015-03-05 14:04 ` Eric Auger
@ 2015-03-05 14:20 ` Marc Zyngier
2015-03-05 14:26 ` Eric Auger
0 siblings, 1 reply; 15+ messages in thread
From: Marc Zyngier @ 2015-03-05 14:20 UTC (permalink / raw)
To: Eric Auger, eric.auger, christoffer.dall, linux-arm-kernel, kvmarm, kvm
Cc: Andre Przywara, linux-kernel, patches, gleb, pbonzini
On 05/03/15 14:04, Eric Auger wrote:
> Hi Marc,
> On 03/05/2015 11:53 AM, Marc Zyngier wrote:
>> On 04/03/15 10:14, Eric Auger wrote:
>>> This patch enables irqfd on arm/arm64.
>>>
>>> Both irqfd and resamplefd are supported. Injection is implemented
>>> in vgic.c without routing.
>>>
>>> This patch enables CONFIG_HAVE_KVM_EVENTFD and CONFIG_HAVE_KVM_IRQFD.
>>>
>>> KVM_CAP_IRQFD is now advertised. KVM_CAP_IRQFD_RESAMPLE capability
>>> automatically is advertised as soon as CONFIG_HAVE_KVM_IRQFD is set.
>>>
>>> Irqfd injection is restricted to SPI. The rationale behind not
>>> supporting PPI irqfd injection is that any device using a PPI would
>>> be a private-to-the-CPU device (timer for instance), so its state
>>> would have to be context-switched along with the VCPU and would
>>> require in-kernel wiring anyhow. It is not a relevant use case for
>>> irqfds.
>>>
>>> Signed-off-by: Eric Auger <eric.auger@linaro.org>
>>> Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
>>>
>>> ---
>>> v8 -> v9:
>>> - replace kvm_debug by trace_kvm_set_irq and add
>>> BUG_ON(!vgic_initialized(kvm));
>>>
>>> v7 -> v8:
>>> - remove kvm_irq_has_notifier call
>>> - part of dist locking changes now are part of previous patch file
>>> - remove gic_initialized() check in kvm_set_irq
>>> - remove Christoffer's Reviewed-by after this change
>>>
>>> v5 -> v6:
>>> - KVM_CAP_IRQFD support depends on vgic_present
>>> - add Christoffer's Reviewed-by
>>>
>>> v4 -> v5:
>>> - squash [PATCH v4 3/3] KVM: arm64: add irqfd support into this patch
>>> - some rewording in Documentation/virtual/kvm/api.txt and in vgic
>>> vgic_process_maintenance unlock comment.
>>> - move explanation of why not supporting PPI into commit message
>>> - in case of injection before gic readiness, -ENODEV is returned. It is
>>> up to the user space to avoid this situation.
>>>
>>> v3 -> v4:
>>> - reword commit message
>>> - explain why we unlock the distributor before calling kvm_notify_acked_irq
>>> - rename is_assigned_irq into has_notifier
>>> - change EOI and injection kvm_debug format string
>>> - remove error local variable in kvm_set_irq
>>> - Move HAVE_KVM_IRQCHIP unset in a separate patch
>>> - handle case were the irqfd injection is attempted before the vgic is ready.
>>> in such a case the notifier, if any, is called immediatly
>>> - use nr_irqs to test spi is within correct range
>>>
>>> v2 -> v3:
>>> - removal of irq.h from eventfd.c put in a separate patch to increase
>>> visibility
>>> - properly expose KVM_CAP_IRQFD capability in arm.c
>>> - remove CONFIG_HAVE_KVM_IRQCHIP meaningfull only if irq_comm.c is used
>>>
>>> v1 -> v2:
>>> - rebase on 3.17rc1
>>> - move of the dist unlock in process_maintenance
>>> - remove of dist lock in __kvm_vgic_sync_hwstate
>>> - rewording of the commit message (add resamplefd reference)
>>> - remove irq.h
>>>
>>> Conflicts:
>>> arch/arm64/kvm/Kconfig
>>> ---
>>> Documentation/virtual/kvm/api.txt | 6 ++++-
>>> arch/arm/include/uapi/asm/kvm.h | 3 +++
>>> arch/arm/kvm/Kconfig | 2 ++
>>> arch/arm/kvm/Makefile | 2 +-
>>> arch/arm/kvm/arm.c | 5 ++++
>>> arch/arm64/include/uapi/asm/kvm.h | 3 +++
>>> arch/arm64/kvm/Kconfig | 2 ++
>>> arch/arm64/kvm/Makefile | 2 +-
>>> virt/kvm/arm/vgic.c | 48 +++++++++++++++++++++++++++++++++++++++
>>> 9 files changed, 70 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
>>> index b112efc..b265d8e 100644
>>> --- a/Documentation/virtual/kvm/api.txt
>>> +++ b/Documentation/virtual/kvm/api.txt
>>> @@ -2234,7 +2234,7 @@ into the hash PTE second double word).
>>> 4.75 KVM_IRQFD
>>>
>>> Capability: KVM_CAP_IRQFD
>>> -Architectures: x86 s390
>>> +Architectures: x86 s390 arm arm64
>>> Type: vm ioctl
>>> Parameters: struct kvm_irqfd (in)
>>> Returns: 0 on success, -1 on error
>>> @@ -2260,6 +2260,10 @@ Note that closing the resamplefd is not sufficient to disable the
>>> irqfd. The KVM_IRQFD_FLAG_RESAMPLE is only necessary on assignment
>>> and need not be specified with KVM_IRQFD_FLAG_DEASSIGN.
>>>
>>> +On ARM/ARM64, the gsi field in the kvm_irqfd struct specifies the Shared
>>> +Peripheral Interrupt (SPI) index, such that the GIC interrupt ID is
>>> +given by gsi + 32.
>>> +
>>> 4.76 KVM_PPC_ALLOCATE_HTAB
>>>
>>> Capability: KVM_CAP_PPC_ALLOC_HTAB
>>> diff --git a/arch/arm/include/uapi/asm/kvm.h b/arch/arm/include/uapi/asm/kvm.h
>>> index 0db25bc..2499867 100644
>>> --- a/arch/arm/include/uapi/asm/kvm.h
>>> +++ b/arch/arm/include/uapi/asm/kvm.h
>>> @@ -198,6 +198,9 @@ struct kvm_arch_memory_slot {
>>> /* Highest supported SPI, from VGIC_NR_IRQS */
>>> #define KVM_ARM_IRQ_GIC_MAX 127
>>>
>>> +/* One single KVM irqchip, ie. the VGIC */
>>> +#define KVM_NR_IRQCHIPS 1
>>> +
>>> /* PSCI interface */
>>> #define KVM_PSCI_FN_BASE 0x95c1ba5e
>>> #define KVM_PSCI_FN(n) (KVM_PSCI_FN_BASE + (n))
>>> diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig
>>> index aae5242..d735a3e 100644
>>> --- a/arch/arm/kvm/Kconfig
>>> +++ b/arch/arm/kvm/Kconfig
>>> @@ -27,6 +27,7 @@ config KVM
>>> select KVM_GENERIC_DIRTYLOG_READ_PROTECT
>>> select SRCU
>>> depends on ARM_VIRT_EXT && ARM_LPAE
>>> + select HAVE_KVM_EVENTFD
>>> ---help---
>>> Support hosting virtualized guest machines. You will also
>>> need to select one or more of the processor modules below.
>>> @@ -58,6 +59,7 @@ config KVM_ARM_MAX_VCPUS
>>> config KVM_ARM_VGIC
>>> bool "KVM support for Virtual GIC"
>>> depends on KVM_ARM_HOST && OF
>>> + select HAVE_KVM_IRQFD
>>> default y
>>> ---help---
>>> Adds support for a hardware assisted, in-kernel GIC emulation.
>>> diff --git a/arch/arm/kvm/Makefile b/arch/arm/kvm/Makefile
>>> index 443b8be..539c1a5 100644
>>> --- a/arch/arm/kvm/Makefile
>>> +++ b/arch/arm/kvm/Makefile
>>> @@ -15,7 +15,7 @@ AFLAGS_init.o := -Wa,-march=armv7-a$(plus_virt)
>>> AFLAGS_interrupts.o := -Wa,-march=armv7-a$(plus_virt)
>>>
>>> KVM := ../../../virt/kvm
>>> -kvm-arm-y = $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o
>>> +kvm-arm-y = $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o $(KVM)/eventfd.o
>>>
>>> obj-y += kvm-arm.o init.o interrupts.o
>>> obj-y += arm.o handle_exit.o guest.o mmu.o emulate.o reset.o
>>> diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
>>> index 5300d5a..4313776 100644
>>> --- a/arch/arm/kvm/arm.c
>>> +++ b/arch/arm/kvm/arm.c
>>> @@ -175,6 +175,11 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
>>> case KVM_CAP_IRQCHIP:
>>> r = vgic_present;
>>> break;
>>> +#ifdef CONFIG_HAVE_KVM_IRQFD
>>> + case KVM_CAP_IRQFD:
>>> + r = vgic_present;
>>> + break;
>>> +#endif
>>
>> Nitpick: we have "select HAVE_KVM_IRQFD", so we can lose the #ifdef-ery.
> right. Also I think the vgic_present can be removed since
> CONFIG_HAVE_KVM_IRQFD always is set when CONFIG_KVM_ARM_VGIC is set.
> So overall this indeed can simply be replaced by Paolo's patch.
>>
>>> case KVM_CAP_DEVICE_CTRL:
>>> case KVM_CAP_USER_MEMORY:
>>> case KVM_CAP_SYNC_MMU:
>>> diff --git a/arch/arm64/include/uapi/asm/kvm.h b/arch/arm64/include/uapi/asm/kvm.h
>>> index 3ef77a4..c154c0b 100644
>>> --- a/arch/arm64/include/uapi/asm/kvm.h
>>> +++ b/arch/arm64/include/uapi/asm/kvm.h
>>> @@ -191,6 +191,9 @@ struct kvm_arch_memory_slot {
>>> /* Highest supported SPI, from VGIC_NR_IRQS */
>>> #define KVM_ARM_IRQ_GIC_MAX 127
>>>
>>> +/* One single KVM irqchip, ie. the VGIC */
>>> +#define KVM_NR_IRQCHIPS 1
>>> +
>>> /* PSCI interface */
>>> #define KVM_PSCI_FN_BASE 0x95c1ba5e
>>> #define KVM_PSCI_FN(n) (KVM_PSCI_FN_BASE + (n))
>>> diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig
>>> index 039d8cf..143c9fd 100644
>>> --- a/arch/arm64/kvm/Kconfig
>>> +++ b/arch/arm64/kvm/Kconfig
>>> @@ -29,6 +29,7 @@ config KVM
>>> select KVM_ARM_TIMER
>>> select KVM_GENERIC_DIRTYLOG_READ_PROTECT
>>> select SRCU
>>> + select HAVE_KVM_EVENTFD
>>> ---help---
>>> Support hosting virtualized guest machines.
>>>
>>> @@ -53,6 +54,7 @@ config KVM_ARM_MAX_VCPUS
>>> config KVM_ARM_VGIC
>>> bool
>>> depends on KVM_ARM_HOST && OF
>>> + select HAVE_KVM_IRQFD
>>
>> Hmmm. There is way too many selects here. Can't we just select it with
>> CONFIG_KVM_ARM_VGIC, and be done with it?
>
> I did that way since CONFIG_KVM_ARM_VGIC is not selected in the config
> KVM section on 32b. Currently the IRQFD select location is same for arm
> and arm64.
>
> do you prefer I select HAVE_KVM_IRQFD in the config KVM section, ie. at
> the same place we select CONFIG_KVM_ARM_VGIC?
We cannot have irqfd without vgic, can we? Or am I misunderstanding the
dependency chain entirely?
[...]
> Do I need to post a v10 based on Paolo's patch?
I don't think so, we can probably fixup things when we merge things.
Let's sort the above first, and we should be good.
Thanks,
M.
--
Jazz is not dead. It just smells funny...
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v9 5/5] KVM: arm/arm64: add irqfd support
2015-03-05 14:20 ` Marc Zyngier
@ 2015-03-05 14:26 ` Eric Auger
2015-03-05 14:34 ` Marc Zyngier
0 siblings, 1 reply; 15+ messages in thread
From: Eric Auger @ 2015-03-05 14:26 UTC (permalink / raw)
To: Marc Zyngier, eric.auger, christoffer.dall, linux-arm-kernel,
kvmarm, kvm
Cc: Andre Przywara, linux-kernel, patches, gleb, pbonzini
On 03/05/2015 03:20 PM, Marc Zyngier wrote:
> On 05/03/15 14:04, Eric Auger wrote:
>> Hi Marc,
>> On 03/05/2015 11:53 AM, Marc Zyngier wrote:
>>> On 04/03/15 10:14, Eric Auger wrote:
>>>> This patch enables irqfd on arm/arm64.
>>>>
>>>> Both irqfd and resamplefd are supported. Injection is implemented
>>>> in vgic.c without routing.
>>>>
>>>> This patch enables CONFIG_HAVE_KVM_EVENTFD and CONFIG_HAVE_KVM_IRQFD.
>>>>
>>>> KVM_CAP_IRQFD is now advertised. KVM_CAP_IRQFD_RESAMPLE capability
>>>> automatically is advertised as soon as CONFIG_HAVE_KVM_IRQFD is set.
>>>>
>>>> Irqfd injection is restricted to SPI. The rationale behind not
>>>> supporting PPI irqfd injection is that any device using a PPI would
>>>> be a private-to-the-CPU device (timer for instance), so its state
>>>> would have to be context-switched along with the VCPU and would
>>>> require in-kernel wiring anyhow. It is not a relevant use case for
>>>> irqfds.
>>>>
>>>> Signed-off-by: Eric Auger <eric.auger@linaro.org>
>>>> Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
>>>>
>>>> ---
>>>> v8 -> v9:
>>>> - replace kvm_debug by trace_kvm_set_irq and add
>>>> BUG_ON(!vgic_initialized(kvm));
>>>>
>>>> v7 -> v8:
>>>> - remove kvm_irq_has_notifier call
>>>> - part of dist locking changes now are part of previous patch file
>>>> - remove gic_initialized() check in kvm_set_irq
>>>> - remove Christoffer's Reviewed-by after this change
>>>>
>>>> v5 -> v6:
>>>> - KVM_CAP_IRQFD support depends on vgic_present
>>>> - add Christoffer's Reviewed-by
>>>>
>>>> v4 -> v5:
>>>> - squash [PATCH v4 3/3] KVM: arm64: add irqfd support into this patch
>>>> - some rewording in Documentation/virtual/kvm/api.txt and in vgic
>>>> vgic_process_maintenance unlock comment.
>>>> - move explanation of why not supporting PPI into commit message
>>>> - in case of injection before gic readiness, -ENODEV is returned. It is
>>>> up to the user space to avoid this situation.
>>>>
>>>> v3 -> v4:
>>>> - reword commit message
>>>> - explain why we unlock the distributor before calling kvm_notify_acked_irq
>>>> - rename is_assigned_irq into has_notifier
>>>> - change EOI and injection kvm_debug format string
>>>> - remove error local variable in kvm_set_irq
>>>> - Move HAVE_KVM_IRQCHIP unset in a separate patch
>>>> - handle case were the irqfd injection is attempted before the vgic is ready.
>>>> in such a case the notifier, if any, is called immediatly
>>>> - use nr_irqs to test spi is within correct range
>>>>
>>>> v2 -> v3:
>>>> - removal of irq.h from eventfd.c put in a separate patch to increase
>>>> visibility
>>>> - properly expose KVM_CAP_IRQFD capability in arm.c
>>>> - remove CONFIG_HAVE_KVM_IRQCHIP meaningfull only if irq_comm.c is used
>>>>
>>>> v1 -> v2:
>>>> - rebase on 3.17rc1
>>>> - move of the dist unlock in process_maintenance
>>>> - remove of dist lock in __kvm_vgic_sync_hwstate
>>>> - rewording of the commit message (add resamplefd reference)
>>>> - remove irq.h
>>>>
>>>> Conflicts:
>>>> arch/arm64/kvm/Kconfig
>>>> ---
>>>> Documentation/virtual/kvm/api.txt | 6 ++++-
>>>> arch/arm/include/uapi/asm/kvm.h | 3 +++
>>>> arch/arm/kvm/Kconfig | 2 ++
>>>> arch/arm/kvm/Makefile | 2 +-
>>>> arch/arm/kvm/arm.c | 5 ++++
>>>> arch/arm64/include/uapi/asm/kvm.h | 3 +++
>>>> arch/arm64/kvm/Kconfig | 2 ++
>>>> arch/arm64/kvm/Makefile | 2 +-
>>>> virt/kvm/arm/vgic.c | 48 +++++++++++++++++++++++++++++++++++++++
>>>> 9 files changed, 70 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
>>>> index b112efc..b265d8e 100644
>>>> --- a/Documentation/virtual/kvm/api.txt
>>>> +++ b/Documentation/virtual/kvm/api.txt
>>>> @@ -2234,7 +2234,7 @@ into the hash PTE second double word).
>>>> 4.75 KVM_IRQFD
>>>>
>>>> Capability: KVM_CAP_IRQFD
>>>> -Architectures: x86 s390
>>>> +Architectures: x86 s390 arm arm64
>>>> Type: vm ioctl
>>>> Parameters: struct kvm_irqfd (in)
>>>> Returns: 0 on success, -1 on error
>>>> @@ -2260,6 +2260,10 @@ Note that closing the resamplefd is not sufficient to disable the
>>>> irqfd. The KVM_IRQFD_FLAG_RESAMPLE is only necessary on assignment
>>>> and need not be specified with KVM_IRQFD_FLAG_DEASSIGN.
>>>>
>>>> +On ARM/ARM64, the gsi field in the kvm_irqfd struct specifies the Shared
>>>> +Peripheral Interrupt (SPI) index, such that the GIC interrupt ID is
>>>> +given by gsi + 32.
>>>> +
>>>> 4.76 KVM_PPC_ALLOCATE_HTAB
>>>>
>>>> Capability: KVM_CAP_PPC_ALLOC_HTAB
>>>> diff --git a/arch/arm/include/uapi/asm/kvm.h b/arch/arm/include/uapi/asm/kvm.h
>>>> index 0db25bc..2499867 100644
>>>> --- a/arch/arm/include/uapi/asm/kvm.h
>>>> +++ b/arch/arm/include/uapi/asm/kvm.h
>>>> @@ -198,6 +198,9 @@ struct kvm_arch_memory_slot {
>>>> /* Highest supported SPI, from VGIC_NR_IRQS */
>>>> #define KVM_ARM_IRQ_GIC_MAX 127
>>>>
>>>> +/* One single KVM irqchip, ie. the VGIC */
>>>> +#define KVM_NR_IRQCHIPS 1
>>>> +
>>>> /* PSCI interface */
>>>> #define KVM_PSCI_FN_BASE 0x95c1ba5e
>>>> #define KVM_PSCI_FN(n) (KVM_PSCI_FN_BASE + (n))
>>>> diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig
>>>> index aae5242..d735a3e 100644
>>>> --- a/arch/arm/kvm/Kconfig
>>>> +++ b/arch/arm/kvm/Kconfig
>>>> @@ -27,6 +27,7 @@ config KVM
>>>> select KVM_GENERIC_DIRTYLOG_READ_PROTECT
>>>> select SRCU
>>>> depends on ARM_VIRT_EXT && ARM_LPAE
>>>> + select HAVE_KVM_EVENTFD
>>>> ---help---
>>>> Support hosting virtualized guest machines. You will also
>>>> need to select one or more of the processor modules below.
>>>> @@ -58,6 +59,7 @@ config KVM_ARM_MAX_VCPUS
>>>> config KVM_ARM_VGIC
>>>> bool "KVM support for Virtual GIC"
>>>> depends on KVM_ARM_HOST && OF
>>>> + select HAVE_KVM_IRQFD
>>>> default y
>>>> ---help---
>>>> Adds support for a hardware assisted, in-kernel GIC emulation.
>>>> diff --git a/arch/arm/kvm/Makefile b/arch/arm/kvm/Makefile
>>>> index 443b8be..539c1a5 100644
>>>> --- a/arch/arm/kvm/Makefile
>>>> +++ b/arch/arm/kvm/Makefile
>>>> @@ -15,7 +15,7 @@ AFLAGS_init.o := -Wa,-march=armv7-a$(plus_virt)
>>>> AFLAGS_interrupts.o := -Wa,-march=armv7-a$(plus_virt)
>>>>
>>>> KVM := ../../../virt/kvm
>>>> -kvm-arm-y = $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o
>>>> +kvm-arm-y = $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o $(KVM)/eventfd.o
>>>>
>>>> obj-y += kvm-arm.o init.o interrupts.o
>>>> obj-y += arm.o handle_exit.o guest.o mmu.o emulate.o reset.o
>>>> diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
>>>> index 5300d5a..4313776 100644
>>>> --- a/arch/arm/kvm/arm.c
>>>> +++ b/arch/arm/kvm/arm.c
>>>> @@ -175,6 +175,11 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
>>>> case KVM_CAP_IRQCHIP:
>>>> r = vgic_present;
>>>> break;
>>>> +#ifdef CONFIG_HAVE_KVM_IRQFD
>>>> + case KVM_CAP_IRQFD:
>>>> + r = vgic_present;
>>>> + break;
>>>> +#endif
>>>
>>> Nitpick: we have "select HAVE_KVM_IRQFD", so we can lose the #ifdef-ery.
>> right. Also I think the vgic_present can be removed since
>> CONFIG_HAVE_KVM_IRQFD always is set when CONFIG_KVM_ARM_VGIC is set.
>> So overall this indeed can simply be replaced by Paolo's patch.
>>>
>>>> case KVM_CAP_DEVICE_CTRL:
>>>> case KVM_CAP_USER_MEMORY:
>>>> case KVM_CAP_SYNC_MMU:
>>>> diff --git a/arch/arm64/include/uapi/asm/kvm.h b/arch/arm64/include/uapi/asm/kvm.h
>>>> index 3ef77a4..c154c0b 100644
>>>> --- a/arch/arm64/include/uapi/asm/kvm.h
>>>> +++ b/arch/arm64/include/uapi/asm/kvm.h
>>>> @@ -191,6 +191,9 @@ struct kvm_arch_memory_slot {
>>>> /* Highest supported SPI, from VGIC_NR_IRQS */
>>>> #define KVM_ARM_IRQ_GIC_MAX 127
>>>>
>>>> +/* One single KVM irqchip, ie. the VGIC */
>>>> +#define KVM_NR_IRQCHIPS 1
>>>> +
>>>> /* PSCI interface */
>>>> #define KVM_PSCI_FN_BASE 0x95c1ba5e
>>>> #define KVM_PSCI_FN(n) (KVM_PSCI_FN_BASE + (n))
>>>> diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig
>>>> index 039d8cf..143c9fd 100644
>>>> --- a/arch/arm64/kvm/Kconfig
>>>> +++ b/arch/arm64/kvm/Kconfig
>>>> @@ -29,6 +29,7 @@ config KVM
>>>> select KVM_ARM_TIMER
>>>> select KVM_GENERIC_DIRTYLOG_READ_PROTECT
>>>> select SRCU
>>>> + select HAVE_KVM_EVENTFD
>>>> ---help---
>>>> Support hosting virtualized guest machines.
>>>>
>>>> @@ -53,6 +54,7 @@ config KVM_ARM_MAX_VCPUS
>>>> config KVM_ARM_VGIC
>>>> bool
>>>> depends on KVM_ARM_HOST && OF
>>>> + select HAVE_KVM_IRQFD
>>>
>>> Hmmm. There is way too many selects here. Can't we just select it with
>>> CONFIG_KVM_ARM_VGIC, and be done with it?
>>
>> I did that way since CONFIG_KVM_ARM_VGIC is not selected in the config
>> KVM section on 32b. Currently the IRQFD select location is same for arm
>> and arm64.
>>
>> do you prefer I select HAVE_KVM_IRQFD in the config KVM section, ie. at
>> the same place we select CONFIG_KVM_ARM_VGIC?
>
> We cannot have irqfd without vgic, can we? Or am I misunderstanding the
> dependency chain entirely?
No we can't have irqfd without vgic.
>
> [...]
>
>> Do I need to post a v10 based on Paolo's patch?
>
> I don't think so, we can probably fixup things when we merge things.
> Let's sort the above first, and we should be good.
OK
Thanks
Eric
>
> Thanks,
>
> M.
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v9 5/5] KVM: arm/arm64: add irqfd support
2015-03-05 14:26 ` Eric Auger
@ 2015-03-05 14:34 ` Marc Zyngier
0 siblings, 0 replies; 15+ messages in thread
From: Marc Zyngier @ 2015-03-05 14:34 UTC (permalink / raw)
To: Eric Auger, eric.auger, christoffer.dall, linux-arm-kernel, kvmarm, kvm
Cc: Andre Przywara, linux-kernel, patches, gleb, pbonzini
On 05/03/15 14:26, Eric Auger wrote:
> On 03/05/2015 03:20 PM, Marc Zyngier wrote:
>> On 05/03/15 14:04, Eric Auger wrote:
>>> Hi Marc,
>>> On 03/05/2015 11:53 AM, Marc Zyngier wrote:
>>>> On 04/03/15 10:14, Eric Auger wrote:
>>>>> This patch enables irqfd on arm/arm64.
>>>>>
>>>>> Both irqfd and resamplefd are supported. Injection is implemented
>>>>> in vgic.c without routing.
>>>>>
>>>>> This patch enables CONFIG_HAVE_KVM_EVENTFD and CONFIG_HAVE_KVM_IRQFD.
>>>>>
>>>>> KVM_CAP_IRQFD is now advertised. KVM_CAP_IRQFD_RESAMPLE capability
>>>>> automatically is advertised as soon as CONFIG_HAVE_KVM_IRQFD is set.
>>>>>
>>>>> Irqfd injection is restricted to SPI. The rationale behind not
>>>>> supporting PPI irqfd injection is that any device using a PPI would
>>>>> be a private-to-the-CPU device (timer for instance), so its state
>>>>> would have to be context-switched along with the VCPU and would
>>>>> require in-kernel wiring anyhow. It is not a relevant use case for
>>>>> irqfds.
>>>>>
>>>>> Signed-off-by: Eric Auger <eric.auger@linaro.org>
>>>>> Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
>>>>>
>>>>> ---
>>>>> v8 -> v9:
>>>>> - replace kvm_debug by trace_kvm_set_irq and add
>>>>> BUG_ON(!vgic_initialized(kvm));
>>>>>
>>>>> v7 -> v8:
>>>>> - remove kvm_irq_has_notifier call
>>>>> - part of dist locking changes now are part of previous patch file
>>>>> - remove gic_initialized() check in kvm_set_irq
>>>>> - remove Christoffer's Reviewed-by after this change
>>>>>
>>>>> v5 -> v6:
>>>>> - KVM_CAP_IRQFD support depends on vgic_present
>>>>> - add Christoffer's Reviewed-by
>>>>>
>>>>> v4 -> v5:
>>>>> - squash [PATCH v4 3/3] KVM: arm64: add irqfd support into this patch
>>>>> - some rewording in Documentation/virtual/kvm/api.txt and in vgic
>>>>> vgic_process_maintenance unlock comment.
>>>>> - move explanation of why not supporting PPI into commit message
>>>>> - in case of injection before gic readiness, -ENODEV is returned. It is
>>>>> up to the user space to avoid this situation.
>>>>>
>>>>> v3 -> v4:
>>>>> - reword commit message
>>>>> - explain why we unlock the distributor before calling kvm_notify_acked_irq
>>>>> - rename is_assigned_irq into has_notifier
>>>>> - change EOI and injection kvm_debug format string
>>>>> - remove error local variable in kvm_set_irq
>>>>> - Move HAVE_KVM_IRQCHIP unset in a separate patch
>>>>> - handle case were the irqfd injection is attempted before the vgic is ready.
>>>>> in such a case the notifier, if any, is called immediatly
>>>>> - use nr_irqs to test spi is within correct range
>>>>>
>>>>> v2 -> v3:
>>>>> - removal of irq.h from eventfd.c put in a separate patch to increase
>>>>> visibility
>>>>> - properly expose KVM_CAP_IRQFD capability in arm.c
>>>>> - remove CONFIG_HAVE_KVM_IRQCHIP meaningfull only if irq_comm.c is used
>>>>>
>>>>> v1 -> v2:
>>>>> - rebase on 3.17rc1
>>>>> - move of the dist unlock in process_maintenance
>>>>> - remove of dist lock in __kvm_vgic_sync_hwstate
>>>>> - rewording of the commit message (add resamplefd reference)
>>>>> - remove irq.h
>>>>>
>>>>> Conflicts:
>>>>> arch/arm64/kvm/Kconfig
>>>>> ---
>>>>> Documentation/virtual/kvm/api.txt | 6 ++++-
>>>>> arch/arm/include/uapi/asm/kvm.h | 3 +++
>>>>> arch/arm/kvm/Kconfig | 2 ++
>>>>> arch/arm/kvm/Makefile | 2 +-
>>>>> arch/arm/kvm/arm.c | 5 ++++
>>>>> arch/arm64/include/uapi/asm/kvm.h | 3 +++
>>>>> arch/arm64/kvm/Kconfig | 2 ++
>>>>> arch/arm64/kvm/Makefile | 2 +-
>>>>> virt/kvm/arm/vgic.c | 48 +++++++++++++++++++++++++++++++++++++++
>>>>> 9 files changed, 70 insertions(+), 3 deletions(-)
>>>>>
>>>>> diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
>>>>> index b112efc..b265d8e 100644
>>>>> --- a/Documentation/virtual/kvm/api.txt
>>>>> +++ b/Documentation/virtual/kvm/api.txt
>>>>> @@ -2234,7 +2234,7 @@ into the hash PTE second double word).
>>>>> 4.75 KVM_IRQFD
>>>>>
>>>>> Capability: KVM_CAP_IRQFD
>>>>> -Architectures: x86 s390
>>>>> +Architectures: x86 s390 arm arm64
>>>>> Type: vm ioctl
>>>>> Parameters: struct kvm_irqfd (in)
>>>>> Returns: 0 on success, -1 on error
>>>>> @@ -2260,6 +2260,10 @@ Note that closing the resamplefd is not sufficient to disable the
>>>>> irqfd. The KVM_IRQFD_FLAG_RESAMPLE is only necessary on assignment
>>>>> and need not be specified with KVM_IRQFD_FLAG_DEASSIGN.
>>>>>
>>>>> +On ARM/ARM64, the gsi field in the kvm_irqfd struct specifies the Shared
>>>>> +Peripheral Interrupt (SPI) index, such that the GIC interrupt ID is
>>>>> +given by gsi + 32.
>>>>> +
>>>>> 4.76 KVM_PPC_ALLOCATE_HTAB
>>>>>
>>>>> Capability: KVM_CAP_PPC_ALLOC_HTAB
>>>>> diff --git a/arch/arm/include/uapi/asm/kvm.h b/arch/arm/include/uapi/asm/kvm.h
>>>>> index 0db25bc..2499867 100644
>>>>> --- a/arch/arm/include/uapi/asm/kvm.h
>>>>> +++ b/arch/arm/include/uapi/asm/kvm.h
>>>>> @@ -198,6 +198,9 @@ struct kvm_arch_memory_slot {
>>>>> /* Highest supported SPI, from VGIC_NR_IRQS */
>>>>> #define KVM_ARM_IRQ_GIC_MAX 127
>>>>>
>>>>> +/* One single KVM irqchip, ie. the VGIC */
>>>>> +#define KVM_NR_IRQCHIPS 1
>>>>> +
>>>>> /* PSCI interface */
>>>>> #define KVM_PSCI_FN_BASE 0x95c1ba5e
>>>>> #define KVM_PSCI_FN(n) (KVM_PSCI_FN_BASE + (n))
>>>>> diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig
>>>>> index aae5242..d735a3e 100644
>>>>> --- a/arch/arm/kvm/Kconfig
>>>>> +++ b/arch/arm/kvm/Kconfig
>>>>> @@ -27,6 +27,7 @@ config KVM
>>>>> select KVM_GENERIC_DIRTYLOG_READ_PROTECT
>>>>> select SRCU
>>>>> depends on ARM_VIRT_EXT && ARM_LPAE
>>>>> + select HAVE_KVM_EVENTFD
>>>>> ---help---
>>>>> Support hosting virtualized guest machines. You will also
>>>>> need to select one or more of the processor modules below.
>>>>> @@ -58,6 +59,7 @@ config KVM_ARM_MAX_VCPUS
>>>>> config KVM_ARM_VGIC
>>>>> bool "KVM support for Virtual GIC"
>>>>> depends on KVM_ARM_HOST && OF
>>>>> + select HAVE_KVM_IRQFD
>>>>> default y
>>>>> ---help---
>>>>> Adds support for a hardware assisted, in-kernel GIC emulation.
>>>>> diff --git a/arch/arm/kvm/Makefile b/arch/arm/kvm/Makefile
>>>>> index 443b8be..539c1a5 100644
>>>>> --- a/arch/arm/kvm/Makefile
>>>>> +++ b/arch/arm/kvm/Makefile
>>>>> @@ -15,7 +15,7 @@ AFLAGS_init.o := -Wa,-march=armv7-a$(plus_virt)
>>>>> AFLAGS_interrupts.o := -Wa,-march=armv7-a$(plus_virt)
>>>>>
>>>>> KVM := ../../../virt/kvm
>>>>> -kvm-arm-y = $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o
>>>>> +kvm-arm-y = $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o $(KVM)/eventfd.o
>>>>>
>>>>> obj-y += kvm-arm.o init.o interrupts.o
>>>>> obj-y += arm.o handle_exit.o guest.o mmu.o emulate.o reset.o
>>>>> diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
>>>>> index 5300d5a..4313776 100644
>>>>> --- a/arch/arm/kvm/arm.c
>>>>> +++ b/arch/arm/kvm/arm.c
>>>>> @@ -175,6 +175,11 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
>>>>> case KVM_CAP_IRQCHIP:
>>>>> r = vgic_present;
>>>>> break;
>>>>> +#ifdef CONFIG_HAVE_KVM_IRQFD
>>>>> + case KVM_CAP_IRQFD:
>>>>> + r = vgic_present;
>>>>> + break;
>>>>> +#endif
>>>>
>>>> Nitpick: we have "select HAVE_KVM_IRQFD", so we can lose the #ifdef-ery.
>>> right. Also I think the vgic_present can be removed since
>>> CONFIG_HAVE_KVM_IRQFD always is set when CONFIG_KVM_ARM_VGIC is set.
>>> So overall this indeed can simply be replaced by Paolo's patch.
>>>>
>>>>> case KVM_CAP_DEVICE_CTRL:
>>>>> case KVM_CAP_USER_MEMORY:
>>>>> case KVM_CAP_SYNC_MMU:
>>>>> diff --git a/arch/arm64/include/uapi/asm/kvm.h b/arch/arm64/include/uapi/asm/kvm.h
>>>>> index 3ef77a4..c154c0b 100644
>>>>> --- a/arch/arm64/include/uapi/asm/kvm.h
>>>>> +++ b/arch/arm64/include/uapi/asm/kvm.h
>>>>> @@ -191,6 +191,9 @@ struct kvm_arch_memory_slot {
>>>>> /* Highest supported SPI, from VGIC_NR_IRQS */
>>>>> #define KVM_ARM_IRQ_GIC_MAX 127
>>>>>
>>>>> +/* One single KVM irqchip, ie. the VGIC */
>>>>> +#define KVM_NR_IRQCHIPS 1
>>>>> +
>>>>> /* PSCI interface */
>>>>> #define KVM_PSCI_FN_BASE 0x95c1ba5e
>>>>> #define KVM_PSCI_FN(n) (KVM_PSCI_FN_BASE + (n))
>>>>> diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig
>>>>> index 039d8cf..143c9fd 100644
>>>>> --- a/arch/arm64/kvm/Kconfig
>>>>> +++ b/arch/arm64/kvm/Kconfig
>>>>> @@ -29,6 +29,7 @@ config KVM
>>>>> select KVM_ARM_TIMER
>>>>> select KVM_GENERIC_DIRTYLOG_READ_PROTECT
>>>>> select SRCU
>>>>> + select HAVE_KVM_EVENTFD
>>>>> ---help---
>>>>> Support hosting virtualized guest machines.
>>>>>
>>>>> @@ -53,6 +54,7 @@ config KVM_ARM_MAX_VCPUS
>>>>> config KVM_ARM_VGIC
>>>>> bool
>>>>> depends on KVM_ARM_HOST && OF
>>>>> + select HAVE_KVM_IRQFD
>>>>
>>>> Hmmm. There is way too many selects here. Can't we just select it with
>>>> CONFIG_KVM_ARM_VGIC, and be done with it?
>>>
>>> I did that way since CONFIG_KVM_ARM_VGIC is not selected in the config
>>> KVM section on 32b. Currently the IRQFD select location is same for arm
>>> and arm64.
>>>
>>> do you prefer I select HAVE_KVM_IRQFD in the config KVM section, ie. at
>>> the same place we select CONFIG_KVM_ARM_VGIC?
>>
>> We cannot have irqfd without vgic, can we? Or am I misunderstanding the
>> dependency chain entirely?
>
> No we can't have irqfd without vgic.
Blah. Ignore me. The additional select is for eventfd, not irqfd. Your
patch is just fine...
Sorry about the noise.
M.
--
Jazz is not dead. It just smells funny...
^ permalink raw reply [flat|nested] 15+ messages in thread