diff mbox

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

Message ID 1458913735-2678-16-git-send-email-shannon.zhao@linaro.org
State New
Headers show

Commit Message

Shannon Zhao March 25, 2016, 1:48 p.m. UTC
Allow DOM0 to use all SPIs but the ones used by Xen. 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>
---
v7: add a TODO for SMMU used SPIs
---
 xen/arch/arm/domain_build.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

Comments

Julien Grall March 29, 2016, 4:10 p.m. UTC | #1
Hi Shannon,

On 25/03/16 13:48, Shannon Zhao wrote:
> Allow DOM0 to use all SPIs but the ones used by Xen. 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>

Acked-by: Julien Grall <julien.grall@arm.com>

Regards,
diff mbox

Patch

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 58a44ff..28b85e5 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1359,6 +1359,37 @@  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++ )
+    {
+        /*
+	 * TODO: Exclude the SPIs SMMU uses which should not be routed to Dom0.
+	 */
+        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 acpi_make_chosen_node(const struct kernel_info *kinfo)
 {
     int res;
@@ -1884,6 +1915,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