All of lore.kernel.org
 help / color / mirror / Atom feed
From: Manish Jaggi <mjaggi@caviumnetworks.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	Andre Przywara <andre.przywara@arm.com>,
	Julien Grall <julien.grall@arm.com>,
	"Kumar, Vijaya" <Vijaya.Kumar@cavium.com>
Subject: [RFC] [PATCH] arm64-its: Add ITS support for ACPI dom0
Date: Tue, 30 May 2017 11:37:26 +0530	[thread overview]
Message-ID: <6283fc94-f05e-85ec-f389-ab6ca0cc5ccc@caviumnetworks.com> (raw)

This patch is an RFC on top of Andre's v10 series.
https://www.mail-archive.com/xen-devel@lists.xen.org/msg109093.html

This patch deny's access to ITS region for the guest and also updates
the acpi tables for dom0.

Signed-off-by: Manish Jaggi <mjaggi@cavium.com>
---
  xen/arch/arm/gic-v3.c            | 49 ++++++++++++++++++++++++++++++++++++++++
  xen/include/asm-arm/gic_v3_its.h |  1 +
  2 files changed, 50 insertions(+)

diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
index c927306..f496fc1 100644
--- a/xen/arch/arm/gic-v3.c
+++ b/xen/arch/arm/gic-v3.c
@@ -1301,6 +1301,7 @@ static int gicv3_iomem_deny_access(const struct domain *d)
  {
      int rc, i;
      unsigned long mfn, nr;
+    const struct host_its *its_data;
  
      mfn = dbase >> PAGE_SHIFT;
      nr = DIV_ROUND_UP(SZ_64K, PAGE_SIZE);
@@ -1333,6 +1334,16 @@ static int gicv3_iomem_deny_access(const struct domain *d)
          return iomem_deny_access(d, mfn, mfn + nr);
      }
  
+    /* deny for ITS as well */
+    list_for_each_entry(its_data, &host_its_list, entry)
+    {
+        mfn = its_data->addr >> PAGE_SHIFT;
+        nr = DIV_ROUND_UP(SZ_128K, PAGE_SIZE);
+        rc = iomem_deny_access(d, mfn, mfn + nr);
+        if ( rc )
+            return rc;
+    }
+
      return 0;
  }
  
@@ -1357,8 +1368,10 @@ static int gicv3_make_hwdom_madt(const struct domain *d, u32 offset)
      struct acpi_subtable_header *header;
      struct acpi_madt_generic_interrupt *host_gicc, *gicc;
      struct acpi_madt_generic_redistributor *gicr;
+    struct acpi_madt_generic_translator *gic_its;
      u8 *base_ptr = d->arch.efi_acpi_table + offset;
      u32 i, table_len = 0, size;
+    const struct host_its *its_data;
  
      /* Add Generic Interrupt */
      header = acpi_table_get_entry_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT, 0);
@@ -1374,6 +1387,7 @@ static int gicv3_make_hwdom_madt(const struct domain *d, u32 offset)
      for ( i = 0; i < d->max_vcpus; i++ )
      {
          gicc = (struct acpi_madt_generic_interrupt *)(base_ptr + table_len);
+
          ACPI_MEMCPY(gicc, host_gicc, size);
          gicc->cpu_interface_number = i;
          gicc->uid = i;
@@ -1399,6 +1413,18 @@ static int gicv3_make_hwdom_madt(const struct domain *d, u32 offset)
          gicr->length = d->arch.vgic.rdist_regions[i].size;
          table_len += size;
      }
+
+    /* Update GIC ITS information in dom0 madt */
+    list_for_each_entry(its_data, &host_its_list, entry)
+    {
+        size = sizeof(struct acpi_madt_generic_translator);
+        gic_its = (struct acpi_madt_generic_translator *)(base_ptr + table_len);
+        gic_its->header.type = ACPI_MADT_TYPE_GENERIC_TRANSLATOR;
+        gic_its->header.length = size;
+        gic_its->base_address = its_data->addr;
+        gic_its->translation_id = its_data->translation_id;
+        table_len +=  size;
+    }
  
      return table_len;
  }
@@ -1511,6 +1537,25 @@ gic_acpi_get_madt_redistributor_num(struct acpi_subtable_header *header,
       */
      return 0;
  }
+#define ACPI_GICV3_ITS_MEM_SIZE (SZ_128K)
+
+int  gicv3_its_acpi_init(struct acpi_subtable_header *header, const unsigned long end)
+{
+    struct acpi_madt_generic_translator *its_entry;
+    struct host_its *its_data;
+
+    its_data = xzalloc(struct host_its);
+    its_entry = (struct acpi_madt_generic_translator *)header;
+    its_data->addr  = its_entry->base_address;
+    its_data->size = ACPI_GICV3_ITS_MEM_SIZE;
+
+    spin_lock_init(&its_data->cmd_lock);
+
+    printk("GICv3: Found ITS @0x%lx\n", its_data->addr);
+
+    list_add_tail(&its_data->entry, &host_its_list);
+    return 0;
+}
  
  static void __init gicv3_acpi_init(void)
  {
@@ -1567,6 +1612,9 @@ static void __init gicv3_acpi_init(void)
  
      gicv3.rdist_stride = 0;
  
+    acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_TRANSLATOR,
+                          gicv3_its_acpi_init, 0);
+
      /*
       * In ACPI, 0 is considered as the invalid address. However the rest
       * of the initialization rely on the invalid address to be
@@ -1585,6 +1633,7 @@ static void __init gicv3_acpi_init(void)
      else
          vsize = GUEST_GICC_SIZE;
  
+
  }
  #else
  static void __init gicv3_acpi_init(void) { }
diff --git a/xen/include/asm-arm/gic_v3_its.h b/xen/include/asm-arm/gic_v3_its.h
index d2a3e53..c92cdb9 100644
--- a/xen/include/asm-arm/gic_v3_its.h
+++ b/xen/include/asm-arm/gic_v3_its.h
@@ -125,6 +125,7 @@ struct host_its {
      spinlock_t cmd_lock;
      void *cmd_buf;
      unsigned int flags;
+    u32 translation_id;
  };
  
  
-- 
2.7.4



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

             reply	other threads:[~2017-05-30  6:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-30  6:07 Manish Jaggi [this message]
2017-05-30 10:37 ` [RFC] [PATCH] arm64-its: Add ITS support for ACPI dom0 Julien Grall
2017-06-08 12:11   ` Manish Jaggi
2017-06-08 12:38     ` Julien Grall

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=6283fc94-f05e-85ec-f389-ab6ca0cc5ccc@caviumnetworks.com \
    --to=mjaggi@caviumnetworks.com \
    --cc=Vijaya.Kumar@cavium.com \
    --cc=andre.przywara@arm.com \
    --cc=julien.grall@arm.com \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.