From: vijay.kilari@gmail.com
To: Ian.Campbell@citrix.com, julien.grall@citrix.com,
stefano.stabellini@eu.citrix.com, stefano.stabellini@citrix.com,
tim@xen.org, xen-devel@lists.xen.org
Cc: Prasun.Kapoor@caviumnetworks.com,
Vijaya Kumar K <Vijaya.Kumar@caviumnetworks.com>,
manish.jaggi@caviumnetworks.com, vijay.kilari@gmail.com
Subject: [PATCH v4 06/17] xen/arm: ITS: Add virtual ITS driver
Date: Fri, 10 Jul 2015 13:12:41 +0530 [thread overview]
Message-ID: <1436514172-3263-7-git-send-email-vijay.kilari@gmail.com> (raw)
In-Reply-To: <1436514172-3263-1-git-send-email-vijay.kilari@gmail.com>
From: Vijaya Kumar K <Vijaya.Kumar@caviumnetworks.com>
This patch introduces virtual ITS driver with following
functionality
- Introduces helper functions to manage device table and
ITT table in guest memory
- Helper function to handle virtual ITS devices assigned
to domain
Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@caviumnetworks.com>
---
v4: - Rename functions {find,remove,insert}_vits_* to
vits_{find,remove,insert}.
- Add common helper function to map and read/write dt
or vitt table entry.
- Removed unused code
---
xen/arch/arm/vgic-v3-its.c | 212 +++++++++++++++++++++++++++++++++++++++++
xen/include/asm-arm/domain.h | 4 +
xen/include/asm-arm/gic-its.h | 45 ++++++++-
3 files changed, 260 insertions(+), 1 deletion(-)
diff --git a/xen/arch/arm/vgic-v3-its.c b/xen/arch/arm/vgic-v3-its.c
new file mode 100644
index 0000000..c63f478
--- /dev/null
+++ b/xen/arch/arm/vgic-v3-its.c
@@ -0,0 +1,212 @@
+/*
+ * Copyright (C) 2015 Cavium Inc.
+ * Vijaya Kumar K <Vijaya.Kumar@caviumnetworks.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <xen/bitops.h>
+#include <xen/config.h>
+#include <xen/init.h>
+#include <xen/irq.h>
+#include <xen/list.h>
+#include <xen/sched.h>
+#include <xen/sizes.h>
+#include <asm/device.h>
+#include <asm/mmio.h>
+#include <asm/io.h>
+#include <asm/gic_v3_defs.h>
+#include <asm/gic.h>
+#include <asm/vgic.h>
+#include <asm/gic-its.h>
+#include <xen/log2.h>
+
+static int vits_entry(struct domain *d, paddr_t entry, void *addr,
+ uint32_t size, bool_t set)
+{
+ struct page_info *page;
+ uint64_t offset;
+ p2m_type_t p2mt;
+ void *p;
+
+ page = get_page_from_gfn(d, paddr_to_pfn(entry), &p2mt, P2M_ALLOC);
+ if ( !page )
+ {
+ dprintk(XENLOG_G_ERR, "%pv: vITS: Failed to get table entry\n",
+ current);
+ return -EINVAL;
+ }
+
+ if ( !p2m_is_ram(p2mt) )
+ {
+ put_page(page);
+ dprintk(XENLOG_G_ERR, "%pv: vITS: with wrong attributes\n", current);
+ return -EINVAL;
+ }
+
+ p = __map_domain_page(page);
+ /* Offset within the mapped page */
+ offset = entry & ~PAGE_MASK;
+
+ if ( set )
+ memcpy(p + offset, addr, size);
+ else
+ memcpy(addr, p + offset, size);
+
+ unmap_domain_page(p);
+ put_page(page);
+
+ return 0;
+}
+
+/* ITS device table helper functions */
+static int vits_vdevice_entry(struct domain *d, uint32_t dev_id,
+ struct vdevice_table *entry, bool_t set)
+{
+ uint64_t offset;
+ paddr_t dt_entry;
+
+ BUILD_BUG_ON(sizeof(struct vdevice_table) != 16);
+
+ offset = dev_id * sizeof(struct vdevice_table);
+ if ( offset > d->arch.vits->dt_size )
+ {
+ dprintk(XENLOG_G_ERR,
+ "%pv: vITS: Out of range offset %ld id 0x%x size %ld\n",
+ current, offset, dev_id, d->arch.vits->dt_size);
+ return -EINVAL;
+ }
+
+ dt_entry = d->arch.vits->dt_ipa + offset;
+
+ return vits_entry(d, dt_entry, (void *)entry,
+ sizeof(struct vdevice_table), set);
+}
+
+int vits_set_vdevice_entry(struct domain *d, uint32_t devid,
+ struct vdevice_table *entry)
+{
+ return vits_vdevice_entry(d, devid, entry, 1);
+}
+
+int vits_get_vdevice_entry(struct domain *d, uint32_t devid,
+ struct vdevice_table *entry)
+{
+ return vits_vdevice_entry(d, devid, entry, 0);
+}
+
+static int vits_vitt_entry(struct domain *d, uint32_t devid,
+ uint32_t event, struct vitt *entry, bool_t set)
+{
+ struct vdevice_table dt_entry;
+ paddr_t vitt_entry;
+ uint64_t offset;
+
+ BUILD_BUG_ON(sizeof(struct vitt) != 8);
+
+ if ( vits_get_vdevice_entry(d, devid, &dt_entry) )
+ {
+ dprintk(XENLOG_G_ERR, "%pv: vITS: Fail to get vdevice for dev 0x%x\n",
+ current, devid);
+ return -EINVAL;
+ }
+
+ /* dt_entry is validated when read */
+ offset = event * sizeof(struct vitt);
+ if ( offset > dt_entry.vitt_size )
+ {
+ dprintk(XENLOG_G_ERR, "%pv: vITS: ITT out of range\n", current);
+ return -EINVAL;
+ }
+
+ vitt_entry = dt_entry.vitt_ipa + offset;
+
+ return vits_entry(d, vitt_entry, (void *)entry,
+ sizeof(struct vitt), set);
+}
+
+int vits_set_vitt_entry(struct domain *d, uint32_t devid,
+ uint32_t event, struct vitt *entry)
+{
+ return vits_vitt_entry(d, devid, event, entry, 1);
+}
+
+int vits_get_vitt_entry(struct domain *d, uint32_t devid,
+ uint32_t event, struct vitt *entry)
+{
+ return vits_vitt_entry(d, devid, event, entry, 0);
+}
+
+/* RB-tree helpers for vits_device attached to a domain */
+struct vits_device *vits_find_device(struct rb_root *root, uint32_t devid)
+{
+ struct rb_node *node = root->rb_node;
+
+ while ( node )
+ {
+ struct vits_device *dev;
+
+ dev = container_of(node, struct vits_device, node);
+
+ if ( devid < dev->vdevid )
+ node = node->rb_left;
+ else if ( devid > dev->vdevid )
+ node = node->rb_right;
+ else
+ return dev;
+ }
+
+ return NULL;
+}
+
+int vits_insert_device(struct rb_root *root, struct vits_device *dev)
+{
+ struct rb_node **new, *parent;
+
+ new = &root->rb_node;
+ parent = NULL;
+ while ( *new )
+ {
+ struct vits_device *this;
+
+ this = container_of(*new, struct vits_device, node);
+
+ parent = *new;
+ if ( dev->vdevid < this->vdevid )
+ new = &((*new)->rb_left);
+ else if ( dev->vdevid > this->vdevid )
+ new = &((*new)->rb_right);
+ else
+ return -EEXIST;
+ }
+
+ rb_link_node(&dev->node, parent, new);
+ rb_insert_color(&dev->node, root);
+
+ return 0;
+}
+
+void vits_remove_device(struct rb_root *root, struct vits_device *dev)
+{
+ if ( dev )
+ rb_erase(&dev->node, root);
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h
index f1a087e..67e4695 100644
--- a/xen/include/asm-arm/domain.h
+++ b/xen/include/asm-arm/domain.h
@@ -115,6 +115,10 @@ struct arch_domain
#endif
} vgic;
+#ifdef CONFIG_ARM_64
+ struct vgic_its *vits;
+#endif
+
struct vuart {
#define VUART_BUF_SIZE 128
char *buf;
diff --git a/xen/include/asm-arm/gic-its.h b/xen/include/asm-arm/gic-its.h
index e8d244f..d21aefe 100644
--- a/xen/include/asm-arm/gic-its.h
+++ b/xen/include/asm-arm/gic-its.h
@@ -31,7 +31,20 @@ struct its_collection {
u16 col_id;
};
-/* ITS command structure */
+/*
+ * Per domain virtual ITS structure.
+ */
+struct vgic_its
+{
+ /* vITT device table ipa */
+ paddr_t dt_ipa;
+ /* vITT device table size */
+ uint64_t dt_size;
+ /* Radix-tree root of devices attached to this domain */
+ struct rb_root dev_root;
+};
+
+/* ITS command structures */
typedef union {
u64 bits[4];
struct __packed {
@@ -171,11 +184,41 @@ struct its_device {
struct rb_node node;
};
+struct vits_device {
+ uint32_t vdevid;
+ struct its_device *its_dev;
+ struct rb_node node;
+};
+
+struct vdevice_table {
+ uint64_t vitt_ipa;
+ uint32_t vitt_size;
+ uint32_t padding;
+};
+
+struct vitt {
+ uint16_t valid:1;
+ uint16_t pad:15;
+ uint16_t vcollection;
+ uint32_t vlpi;
+};
+
int its_lpi_init(u32 id_bits);
int its_init(struct rdist_prop *rdists);
int its_cpu_init(void);
struct its_device *its_find_device(u32 devid);
int its_insert_device(struct its_device *dev);
+int vits_set_vitt_entry(struct domain *d, uint32_t devid,
+ uint32_t event, struct vitt *entry);
+int vits_get_vitt_entry(struct domain *d, uint32_t devid,
+ uint32_t event, struct vitt *entry);
+int vits_set_vdevice_entry(struct domain *d, uint32_t devid,
+ struct vdevice_table *entry);
+int vits_get_vdevice_entry(struct domain *d, uint32_t devid,
+ struct vdevice_table *entry);
+struct vits_device *vits_find_device(struct rb_root *root, uint32_t devid);
+int vits_insert_device(struct rb_root *root, struct vits_device *dev);
+void vits_remove_device(struct rb_root *root, struct vits_device *dev);
#endif /* __ASM_ARM_GIC_ITS_H__ */
/*
--
1.7.9.5
next prev parent reply other threads:[~2015-07-10 7:42 UTC|newest]
Thread overview: 113+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-10 7:42 [PATCH v4 00/17] Add ITS support vijay.kilari
2015-07-10 7:42 ` [PATCH v4 01/17] xen/arm: Add bitmap_find_next_zero_area helper function vijay.kilari
2015-07-10 9:01 ` Jan Beulich
2015-07-10 9:28 ` Vijay Kilari
2015-07-10 9:30 ` Vijay Kilari
2015-07-10 9:45 ` Vijay Kilari
2015-07-10 10:07 ` Jan Beulich
2015-07-10 7:42 ` [PATCH v4 02/17] xen: Add log2 functionality vijay.kilari
2015-07-10 7:42 ` [PATCH v4 03/17] xen/arm: ITS: Port ITS driver to Xen vijay.kilari
2015-07-10 13:01 ` Ian Campbell
2015-07-15 10:23 ` Julien Grall
2015-07-10 7:42 ` [PATCH v4 04/17] xen/arm: ITS: Add helper functions to manage its_devices vijay.kilari
2015-07-10 13:05 ` Ian Campbell
2015-07-15 10:37 ` Julien Grall
2015-07-15 14:21 ` Vijay Kilari
2015-07-15 14:28 ` Julien Grall
2015-07-10 7:42 ` [PATCH v4 05/17] xen/arm: ITS: implement hw_irq_controller for LPIs vijay.kilari
2015-07-10 13:46 ` Ian Campbell
2015-07-11 14:40 ` Vijay Kilari
2015-07-11 18:08 ` Julien Grall
2015-07-13 9:17 ` Ian Campbell
2015-07-13 21:18 ` Julien Grall
2015-07-15 7:16 ` Vijay Kilari
2015-07-15 8:26 ` Julien Grall
2015-07-15 9:32 ` Ian Campbell
2015-07-15 9:49 ` Julien Grall
2015-07-15 10:01 ` Ian Campbell
2015-07-15 14:15 ` Vijay Kilari
2015-07-15 14:22 ` Julien Grall
2015-07-15 14:28 ` Ian Campbell
2015-07-15 17:01 ` Vijay Kilari
2015-07-16 14:49 ` Ian Campbell
2015-07-16 15:21 ` Marc Zyngier
2015-07-16 16:18 ` Ian Campbell
2015-07-16 16:27 ` Marc Zyngier
2015-07-16 16:37 ` Ian Campbell
2015-07-18 10:13 ` Julien Grall
2015-07-20 11:52 ` Ian Campbell
2015-07-20 12:22 ` Ian Campbell
2015-07-15 18:19 ` Julien Grall
2015-07-10 7:42 ` vijay.kilari [this message]
2015-07-10 13:54 ` [PATCH v4 06/17] xen/arm: ITS: Add virtual ITS driver Ian Campbell
2015-07-11 14:48 ` Vijay Kilari
2015-07-13 9:27 ` Ian Campbell
2015-07-10 14:15 ` Ian Campbell
2015-07-11 14:48 ` Vijay Kilari
2015-07-13 9:25 ` Ian Campbell
2015-07-15 12:17 ` Julien Grall
2015-07-10 7:42 ` [PATCH v4 07/17] xen/arm: ITS: Add virtual ITS commands support vijay.kilari
2015-07-10 14:35 ` Ian Campbell
2015-07-11 14:49 ` Vijay Kilari
2015-07-13 9:22 ` Ian Campbell
2015-07-13 11:15 ` Vijay Kilari
2015-07-13 11:37 ` Ian Campbell
2015-07-17 15:01 ` Vijay Kilari
2015-07-15 13:02 ` Julien Grall
2015-07-15 13:56 ` Ian Campbell
2015-07-15 12:57 ` Julien Grall
2015-07-17 14:12 ` Vijay Kilari
2015-07-17 15:15 ` Julien Grall
2015-07-17 15:34 ` Ian Campbell
2015-07-17 15:44 ` Julien Grall
2015-07-10 7:42 ` [PATCH v4 08/17] xen/arm: ITS: Add APIs to add and assign device vijay.kilari
2015-07-10 14:52 ` Ian Campbell
2015-07-15 13:14 ` Julien Grall
2015-07-16 13:40 ` Vijay Kilari
2015-07-16 14:38 ` Julien Grall
2015-07-15 14:15 ` Julien Grall
2015-07-18 9:44 ` Vijay Kilari
2015-07-18 10:06 ` Julien Grall
2015-07-10 7:42 ` [PATCH v4 09/17] xen/arm: ITS: Add GITS registers emulation vijay.kilari
2015-07-10 14:56 ` Ian Campbell
2015-07-15 16:13 ` Julien Grall
2015-07-10 7:42 ` [PATCH v4 10/17] xen/arm: ITS: Enable physical and virtual ITS driver compilation vijay.kilari
2015-07-15 16:16 ` Julien Grall
2015-07-10 7:42 ` [PATCH v4 11/17] xen/arm: ITS: Add GICR register emulation vijay.kilari
2015-07-10 15:10 ` Ian Campbell
2015-07-11 18:25 ` Julien Grall
2015-07-13 9:28 ` Ian Campbell
2015-07-13 9:53 ` Ian Campbell
2015-07-13 16:53 ` Stefano Stabellini
2015-07-15 17:32 ` Julien Grall
2015-07-16 14:15 ` Vijay Kilari
2015-07-16 14:41 ` Julien Grall
2015-07-16 14:46 ` Vijay Kilari
2015-07-16 14:58 ` Julien Grall
2015-07-10 7:42 ` [PATCH v4 12/17] xen/arm: ITS: Initialize LPI irq descriptors and route vijay.kilari
2015-07-10 15:30 ` Ian Campbell
2015-07-20 13:07 ` Vijay Kilari
2015-07-20 13:25 ` Julien Grall
2015-07-22 13:31 ` Vijay Kilari
2015-07-22 13:39 ` Julien Grall
2015-07-22 14:17 ` Julien Grall
2015-07-13 17:03 ` Stefano Stabellini
2015-07-13 17:13 ` Stefano Stabellini
2015-07-13 17:36 ` Julien Grall
2015-07-15 18:13 ` Julien Grall
2015-07-16 8:06 ` Julien Grall
2015-07-16 8:37 ` Julien Grall
2015-07-10 7:42 ` [PATCH v4 13/17] xen/arm: ITS: Initialize physical ITS vijay.kilari
2015-07-13 17:06 ` Stefano Stabellini
2015-07-10 7:42 ` [PATCH v4 14/17] xen/arm: ITS: Add domain specific ITS initialization vijay.kilari
2015-07-10 15:41 ` Ian Campbell
2015-07-15 17:41 ` Julien Grall
2015-07-10 7:42 ` [PATCH v4 15/17] xen/arm: ITS: Map ITS translation space vijay.kilari
2015-07-10 15:43 ` Ian Campbell
2015-07-15 9:01 ` Julien Grall
2015-07-10 7:42 ` [PATCH v4 16/17] xen/arm: ITS: Generate ITS node for Dom0 vijay.kilari
2015-07-13 16:32 ` Stefano Stabellini
2015-07-13 17:31 ` Julien Grall
2015-07-13 17:36 ` Stefano Stabellini
2015-07-10 7:42 ` [PATCH v4 17/17] xen/arm: ITS: Add pci devices in ThunderX vijay.kilari
2015-07-10 15:45 ` Ian Campbell
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=1436514172-3263-7-git-send-email-vijay.kilari@gmail.com \
--to=vijay.kilari@gmail.com \
--cc=Ian.Campbell@citrix.com \
--cc=Prasun.Kapoor@caviumnetworks.com \
--cc=Vijaya.Kumar@caviumnetworks.com \
--cc=julien.grall@citrix.com \
--cc=manish.jaggi@caviumnetworks.com \
--cc=stefano.stabellini@citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xen.org \
/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;
as well as URLs for NNTP newsgroup(s).