diff mbox

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

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

Commit Message

Shannon Zhao March 17, 2016, 9:41 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(+)

Comments

Julien Grall March 22, 2016, 6:18 p.m. UTC | #1
Hi Shannon,

On 17/03/16 09:41, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
>
> Permit access all Xen unused SPIs for Dom0 except the interrupts that
> Xen uses.

You say exactly the same things with all "Xen unused SPIs for Dom0" and 
"except the interrupts that Xen uses".

I would instead say:

"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>
> ---
>   xen/arch/arm/domain_build.c | 31 +++++++++++++++++++++++++++++++
>   1 file changed, 31 insertions(+)
>
> 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

Coding style:

/*
  * FOo
  * Bar
  */

> +     * 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)

Well some of the SPIs used by Xen may not be registered yet. For 
instance the SMMU driver doesn't register any SPIs until it's necessary 
(i.e a device is assigned to a domain).

> +            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
>
Shannon Zhao March 24, 2016, 3:01 p.m. UTC | #2
On 2016年03月23日 02:18, Julien Grall wrote:
> 
>> +     * 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)
> 
> Well some of the SPIs used by Xen may not be registered yet. For
> instance the SMMU driver doesn't register any SPIs until it's necessary
> (i.e a device is assigned to a domain).
But when SMMU requests some SPI, it will delete the route and
reconfigure the SPI, right?

Thanks,
Julien Grall March 24, 2016, 3:37 p.m. UTC | #3
Hi Shannon,

On 24/03/16 15:01, Shannon Zhao wrote:
> On 2016年03月23日 02:18, Julien Grall wrote:
>>
>>> +     * 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)
>>
>> Well some of the SPIs used by Xen may not be registered yet. For
>> instance the SMMU driver doesn't register any SPIs until it's necessary
>> (i.e a device is assigned to a domain).
> But when SMMU requests some SPI, it will delete the route and
> reconfigure the SPI, right?

No, the SMMU driver will fail to request the interrupt if it's already 
in use.

Regards,
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