diff mbox

[Xen-devel,v5,15/22] arm/acpi: Permit access all Xen unused SPIs for Dom0

Message ID 1457072152-16128-16-git-send-email-zhaoshenglong@huawei.com
State Superseded
Headers show

Commit Message

Shannon Zhao March 4, 2016, 6:15 a.m. UTC
From: Shannon Zhao <shannon.zhao@linaro.org>

Permit access all Xen unused SPIs for Dom0 except the interrupts that
Xen uses. Then when Dom0 configures the interrupt, it could set the
interrupt type and route it to Dom0.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 xen/arch/arm/domain_build.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
diff mbox

Patch

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 6726e45..1e5ee0e 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1359,6 +1359,33 @@  static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 #ifdef CONFIG_ACPI
 #define ACPI_DOM0_FDT_MIN_SIZE 4096
 
+static int acpi_permit_spi_access(struct domain *d)
+{
+    int i, res;
+    struct irq_desc *desc;
+
+    /* Here just permit Dom0 to access the SPIs which Xen doesn't use. Then when
+     * Dom0 configures the interrupt, set the interrupt type and route it to
+     * Dom0.
+     */
+    for( i = NR_LOCAL_IRQS; i < vgic_num_irqs(d); i++ )
+    {
+        desc = irq_to_desc(i);
+        if( desc->action != NULL)
+            continue;
+
+        res = irq_permit_access(d, i);
+        if ( res )
+        {
+            printk(XENLOG_ERR "Unable to permit to dom%u access to IRQ %u\n",
+                   d->domain_id, i);
+            return res;
+        }
+    }
+
+    return 0;
+}
+
 static int make_chosen_node(const struct kernel_info *kinfo,
                             struct membank tbl_add[])
 {
@@ -1849,6 +1876,10 @@  static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     if ( rc != 0 )
         return rc;
 
+    rc = acpi_permit_spi_access(d);
+    if ( rc != 0 )
+        return rc;
+
     return 0;
 }
 #else