Re: [Xen-devel] [PATCH v7 15/28] xen/arm: ITS: Add virtual ITS driver

2015-09-21 Thread Julien Grall
Hi Vijay,

On 18/09/15 14:09, vijay.kil...@gmail.com wrote:
> From: Vijaya Kumar K 
> 
> 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 

Reviewed-by: Julien Grall 

Regards,

-- 
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH v7 15/28] xen/arm: ITS: Add virtual ITS driver

2015-09-18 Thread vijay . kilari
From: Vijaya Kumar K 

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 
---
v7: - Moved vits_access_guest_table() from vgic-v3-its.c to vgic.c
  and renamed as vgic_access_guest_memory().
- Renamed entry paramter in vgic_access_guest_memory() to gipa
- Introduced new header file vits.h for vITS and moved vits structures
  from gic-its.h to vits.h
v6: - Exported vits_access_guest_memory() api
v5: - Removed RB tree that manages vitual ITS devices
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   |  123 ++
 xen/arch/arm/vgic.c  |   39 ++
 xen/include/asm-arm/domain.h |2 +
 xen/include/asm-arm/vits.h   |   68 +++
 4 files changed, 232 insertions(+)

diff --git a/xen/arch/arm/vgic-v3-its.c b/xen/arch/arm/vgic-v3-its.c
new file mode 100644
index 000..df54ce5
--- /dev/null
+++ b/xen/arch/arm/vgic-v3-its.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2015 Cavium Inc.
+ * Vijaya Kumar K 
+ *
+ * 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 .
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* 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;
+const struct vgic_its *vits = d->arch.vgic.vits;
+
+BUILD_BUG_ON(sizeof(struct vdevice_table) != 16);
+
+offset = dev_id * sizeof(struct vdevice_table);
+if ( offset > vits->dt_size )
+{
+printk(XENLOG_G_ERR
+   "d%d: vITS: Out of range off 0x%"PRIx64" id 0x%"PRIx32"\n",
+   d->domain_id, offset, dev_id);
+return -EINVAL;
+}
+
+dt_entry = vits->dt_ipa + offset;
+
+return vgic_access_guest_memory(d, dt_entry, entry,
+   sizeof(struct vdevice_table), set);
+}
+
+static 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, _entry) )
+{
+printk(XENLOG_G_ERR
+   "d%d: vITS: Fail to get vdevice for vdevid 0x%"PRIx32"\n",
+   d->domain_id, devid);
+return -EINVAL;
+}
+
+/* dt_entry has been validated in vits_get_vdevice_entry */
+offset = event * sizeof(struct vitt);
+if ( offset > dt_entry.vitt_size )
+{
+printk(XENLOG_G_ERR "d%d: vITS: ITT out of range\n", d->domain_id);
+return -EINVAL;
+}
+
+vitt_entry = dt_entry.vitt_ipa + offset;
+
+return vgic_access_guest_memory(d, vitt_entry, entry,
+   sizeof(struct vitt), set);
+}
+
+static 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);
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
index fb2a205..baa74c7 100644
---