From: Andre Przywara <andre.przywara@arm.com>
To: Christoffer Dall <christoffer.dall@linaro.org>,
Marc Zyngier <marc.zyngier@arm.com>,
Eric Auger <eric.auger@linaro.org>
Cc: kvmarm@lists.cs.columbia.edu,
linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org
Subject: [PATCH v4 08/12] KVM: arm64: connect LPIs to the VGIC emulation
Date: Sat, 26 Mar 2016 02:14:06 +0000 [thread overview]
Message-ID: <1458958450-19662-9-git-send-email-andre.przywara@arm.com> (raw)
In-Reply-To: <1458958450-19662-1-git-send-email-andre.przywara@arm.com>
LPIs are dynamically created (mapped) at guest runtime and their
actual numbers can be quite high, but is mostly assigned using a very
sparse allocation scheme. So arrays are not an ideal data structure
to hold the information. We use our equivalent of the "Interrupt
Translation Table Entry" (ITTE) to hold the vgic_irq struct for a
virtual LPI embedded in in the ITTE.
Connect the VGIC core code via an accessor function to help it get the
struct vgic_irq for a certain LPI.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
virt/kvm/arm/vgic/its-emul.c | 29 +++++++++++++++++++++++++++++
virt/kvm/arm/vgic/vgic.h | 8 +++++++-
2 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/virt/kvm/arm/vgic/its-emul.c b/virt/kvm/arm/vgic/its-emul.c
index c0334ff..1188e9a 100644
--- a/virt/kvm/arm/vgic/its-emul.c
+++ b/virt/kvm/arm/vgic/its-emul.c
@@ -55,11 +55,29 @@ struct its_collection {
struct its_itte {
struct list_head itte_list;
+ struct vgic_irq irq;
struct its_collection *collection;
u32 lpi;
u32 event_id;
};
+/* To be used as an iterator this macro misses the enclosing parentheses */
+#define for_each_lpi(dev, itte, kvm) \
+ list_for_each_entry(dev, &(kvm)->arch.vgic.its.device_list, dev_list) \
+ list_for_each_entry(itte, &(dev)->itt, itte_list)
+
+static struct its_itte *find_itte_by_lpi(struct kvm *kvm, int lpi)
+{
+ struct its_device *device;
+ struct its_itte *itte;
+
+ for_each_lpi(device, itte, kvm) {
+ if (itte->lpi == lpi)
+ return itte;
+ }
+ return NULL;
+}
+
#define BASER_BASE_ADDRESS(x) ((x) & 0xfffffffff000ULL)
static int vgic_mmio_read_its_ctlr(struct kvm_vcpu *vcpu,
@@ -166,6 +184,17 @@ static int vgic_mmio_read_its_idregs(struct kvm_vcpu *vcpu,
return 0;
}
+struct vgic_irq *vgic_its_get_lpi(struct kvm *kvm, u32 intid)
+{
+ struct its_itte *itte;
+
+ itte = find_itte_by_lpi(kvm, intid);
+ if (!itte)
+ return NULL;
+
+ return &itte->irq;
+}
+
static void its_free_itte(struct its_itte *itte)
{
list_del(&itte->itte_list);
diff --git a/virt/kvm/arm/vgic/vgic.h b/virt/kvm/arm/vgic/vgic.h
index 08f97d1..160c511 100644
--- a/virt/kvm/arm/vgic/vgic.h
+++ b/virt/kvm/arm/vgic/vgic.h
@@ -63,6 +63,7 @@ int vgic_register_redist_regions(struct kvm *kvm, gpa_t dist_base_address);
int vits_init(struct kvm *kvm);
void vgic_enable_lpis(struct kvm_vcpu *vcpu);
+struct vgic_irq *vgic_its_get_lpi(struct kvm *kvm, u32 intid);
void vits_destroy(struct kvm *kvm);
#else
static inline void vgic_v3_irq_change_affinity(struct kvm *kvm, u32 intid,
@@ -129,7 +130,7 @@ static inline int vgic_register_redist_regions(struct kvm *kvm,
return -ENODEV;
}
-int vits_init(struct kvm *kvm)
+static inline int vits_init(struct kvm *kvm)
{
return 0;
}
@@ -139,6 +140,11 @@ static inline void vgic_enable_lpis(struct kvm_vcpu *vcpu)
return;
}
+static inline struct vgic_irq *vgic_its_get_lpi(struct kvm *kvm, u32 intid)
+{
+ return NULL;
+}
+
static inline void vits_destroy(struct kvm *kvm)
{
return;
--
2.7.3
next prev parent reply other threads:[~2016-03-26 2:13 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-26 2:13 [PATCH v4 00/12] KVM: arm64: GICv3 ITS emulation Andre Przywara
2016-03-26 2:13 ` [PATCH v4 01/12] KVM: extend struct kvm_msi to hold a 32-bit device ID Andre Przywara
2016-04-03 9:15 ` Christoffer Dall
2016-05-25 15:55 ` Andre Przywara
2016-05-25 16:16 ` Marc Zyngier
2016-05-31 13:05 ` Christoffer Dall
2016-05-05 17:55 ` Chalamarla, Tirumalesh
2016-03-26 2:14 ` [PATCH v4 02/12] KVM: arm/arm64: extend arch CAP checks to allow per-VM capabilities Andre Przywara
2016-04-03 10:08 ` Christoffer Dall
2016-04-05 12:48 ` Eric Auger
2016-05-05 18:00 ` Chalamarla, Tirumalesh
2016-03-26 2:14 ` [PATCH v4 03/12] KVM: arm64: Introduce new MMIO region for the ITS base address Andre Przywara
2016-04-03 10:08 ` Christoffer Dall
2016-04-05 12:47 ` Eric Auger
2016-04-07 13:44 ` Marc Zyngier
2016-05-05 18:08 ` Chalamarla, Tirumalesh
2016-05-09 15:47 ` Marc Zyngier
2016-05-09 16:53 ` Chalamarla, Tirumalesh
2016-05-09 17:09 ` Marc Zyngier
2016-03-26 2:14 ` [PATCH v4 04/12] KVM: arm64: handle ITS related GICv3 redistributor registers Andre Przywara
2016-04-03 10:08 ` Christoffer Dall
2016-04-05 12:55 ` Eric Auger
2016-04-05 15:17 ` Eric Auger
2016-04-07 13:54 ` Marc Zyngier
2016-04-07 13:58 ` Marc Zyngier
2016-05-05 18:06 ` Chalamarla, Tirumalesh
2016-03-26 2:14 ` [PATCH v4 05/12] KVM: arm64: introduce ITS emulation file with stub functions Andre Przywara
2016-04-05 16:03 ` Eric Auger
2016-04-07 14:04 ` Marc Zyngier
2016-04-07 14:08 ` Eric Auger
2016-04-07 14:48 ` Marc Zyngier
2016-04-07 15:09 ` Eric Auger
2016-04-07 15:19 ` Marc Zyngier
2016-03-26 2:14 ` [PATCH v4 06/12] KVM: arm64: implement basic ITS register handlers Andre Przywara
2016-04-03 10:08 ` Christoffer Dall
2016-04-06 9:36 ` Eric Auger
2016-05-25 13:49 ` Andre Przywara
2016-04-07 14:35 ` Marc Zyngier
2016-05-25 11:37 ` Andre Przywara
2016-05-26 9:10 ` Marc Zyngier
2016-06-03 15:42 ` Andre Przywara
2016-06-03 16:54 ` Marc Zyngier
2016-05-05 18:51 ` Chalamarla, Tirumalesh
2016-03-26 2:14 ` [PATCH v4 07/12] KVM: arm64: add data structures to model ITS interrupt translation Andre Przywara
2016-04-06 9:53 ` Eric Auger
2016-03-26 2:14 ` Andre Przywara [this message]
2016-04-06 12:00 ` [PATCH v4 08/12] KVM: arm64: connect LPIs to the VGIC emulation Eric Auger
2016-05-05 18:59 ` Chalamarla, Tirumalesh
2016-03-26 2:14 ` [PATCH v4 09/12] KVM: arm64: sync LPI configuration and pending tables Andre Przywara
2016-04-06 13:41 ` Eric Auger
2016-06-03 14:17 ` Andre Przywara
2016-03-26 2:14 ` [PATCH v4 10/12] KVM: arm64: implement ITS command queue command handlers Andre Przywara
2016-05-05 19:12 ` Chalamarla, Tirumalesh
2016-05-25 14:34 ` Andre Przywara
2016-03-26 2:14 ` [PATCH v4 11/12] KVM: arm64: implement MSI injection in ITS emulation Andre Przywara
2016-03-26 2:14 ` [PATCH v4 12/12] KVM: arm64: enable ITS emulation as a virtual MSI controller Andre Przywara
2016-06-03 4:26 ` [PATCH v4 00/12] KVM: arm64: GICv3 ITS emulation Bharat Bhushan
2016-06-03 14:32 ` Andre Przywara
2016-06-06 5:29 ` Bharat Bhushan
2016-06-07 8:02 ` Christoffer Dall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1458958450-19662-9-git-send-email-andre.przywara@arm.com \
--to=andre.przywara@arm.com \
--cc=christoffer.dall@linaro.org \
--cc=eric.auger@linaro.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=marc.zyngier@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox