From 226c13e0eecb66f49ba0146bc5268e7ed6d73465 Mon Sep 17 00:00:00 2001 From: Shannon Zhao Date: Wed, 30 Mar 2016 12:10:00 +0200 Subject: [PATCH] arm/acpi: Permit access all Xen unused SPIs for Dom0 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 Reviewed-by: Stefano Stabellini Acked-by: Julien Grall --- xen/arch/arm/domain_build.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 756dea5c3c..6637752010 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; @@ -1887,6 +1918,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 -- 2.30.2