diff mbox

[Xen-devel,RFC,28/35] arm: acpi map acpi tables in dom0

Message ID 1423058539-26403-29-git-send-email-parth.dixit@linaro.org
State New
Headers show

Commit Message

Parth Dixit Feb. 4, 2015, 2:02 p.m. UTC
From: Parth Dixit <parth.dixit@linaro.org>

map acpi tables described in uefi table to dom0 address space

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
---
 xen/arch/arm/arm64/acpi/arm-core.c | 43 ++++++++++++++++++++++++++++++++++++++
 xen/arch/arm/domain_build.c        |  4 ++++
 xen/include/asm-arm/acpi.h         |  1 +
 3 files changed, 48 insertions(+)

Comments

Julien Grall Feb. 5, 2015, 4:29 a.m. UTC | #1
Hi Parth,

On 04/02/2015 14:02, parth.dixit@linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
>
> map acpi tables described in uefi table to dom0 address space
>
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> ---
>   xen/arch/arm/arm64/acpi/arm-core.c | 43 ++++++++++++++++++++++++++++++++++++++
>   xen/arch/arm/domain_build.c        |  4 ++++
>   xen/include/asm-arm/acpi.h         |  1 +
>   3 files changed, 48 insertions(+)
>
> diff --git a/xen/arch/arm/arm64/acpi/arm-core.c b/xen/arch/arm/arm64/acpi/arm-core.c
> index cc11fce..6707e4c 100644
> --- a/xen/arch/arm/arm64/acpi/arm-core.c
> +++ b/xen/arch/arm/arm64/acpi/arm-core.c
> @@ -31,6 +31,7 @@
>
>   #include <asm/cputype.h>
>   #include <asm/acpi.h>
> +#include <asm/p2m.h>
>
>   /*
>    * We never plan to use RSDT on arm/arm64 as its deprecated in spec but this
> @@ -241,6 +242,48 @@ static int __init acpi_parse_fadt(struct acpi_table_header *table)
>          return 0;
>   }
>
> +int acpi_map_tables(struct domain *d)

This should be __init

> +{
> +    int i,res;
> +    u64 addr, size;
> +
> +    /* map rsdp table */
> +    addr = acpi_os_get_root_pointer();
> +    size = sizeof(struct acpi_table_rsdp);
> +
> +    res = map_ram_regions(d,
> +                            paddr_to_pfn(addr & PAGE_MASK),
> +                            DIV_ROUND_UP(size, PAGE_SIZE),
> +                            paddr_to_pfn(addr & PAGE_MASK));

It's not related to this patch. As ACPI may reside in RAM, this mean 
that the ACPI region should be marked as reserved to avoid Xen 
allocating the memory for a guest.

Did you take care of it?

> +    if ( res )
> +    {
> +         printk(XENLOG_ERR "Unable to map 0x%"PRIx64
> +                " - 0x%"PRIx64" in domain \n",
> +                addr & PAGE_MASK, PAGE_ALIGN(addr + size) - 1);
> +         return res;
> +    }
> +
> +    for( i = 0; i < acpi_gbl_root_table_list.count; i++ )
> +    {
> +        addr = acpi_gbl_root_table_list.tables[i].address;
> +        size = acpi_gbl_root_table_list.tables[i].length;
> +
> +        res = map_ram_regions(d,
> +                            paddr_to_pfn(addr & PAGE_MASK),
> +                            DIV_ROUND_UP(size, PAGE_SIZE),
> +                            paddr_to_pfn(addr & PAGE_MASK));
> +        if ( res )
> +        {
> +             printk(XENLOG_ERR "Unable to map 0x%"PRIx64
> +                    " - 0x%"PRIx64" in domain \n",
> +                    addr & PAGE_MASK, PAGE_ALIGN(addr + size) - 1);
> +             return res;
> +        }
> +    }
> +
> +    return 0;
> +}
> +
>   /*
>    * acpi_boot_table_init() called from setup_arch(), always.
>    *      1. find RSDP and get its address, and then find XSDT
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 49eb52a..a504064 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1278,6 +1278,10 @@ static int map_acpi_regions(struct domain *d)
>   {
>       int res;
>
> +    res = acpi_map_tables(d);
> +    if ( res )
> +        return res;
> +
>       res = acpi_map_mmio(d);
>       if ( res )
>           return res;
> diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
> index 01ce28d..4f52cd6 100644
> --- a/xen/include/asm-arm/acpi.h
> +++ b/xen/include/asm-arm/acpi.h
> @@ -108,5 +108,6 @@ static inline void acpi_disable_pci(void)
>   #define MAX_GIC_CPU_INTERFACE 65535
>   #define MAX_GIC_DISTRIBUTOR   1                /* should be the same as MAX_GIC_NR */
>   extern int __init acpi_gic_init(void);
> +int acpi_map_tables(struct domain *d);
>
>   #endif /*_ASM_ARM_ACPI_H*/
>

Regards,
Parth Dixit Feb. 5, 2015, 7:38 p.m. UTC | #2
On 5 February 2015 at 22:25, Stefano Stabellini
<stefano.stabellini@eu.citrix.com> wrote:
> On Wed, 4 Feb 2015, parth.dixit@linaro.org wrote:
>> From: Parth Dixit <parth.dixit@linaro.org>
>>
>> map acpi tables described in uefi table to dom0 address space
>>
>> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>> ---
>>  xen/arch/arm/arm64/acpi/arm-core.c | 43 ++++++++++++++++++++++++++++++++++++++
>>  xen/arch/arm/domain_build.c        |  4 ++++
>>  xen/include/asm-arm/acpi.h         |  1 +
>>  3 files changed, 48 insertions(+)
>>
>> diff --git a/xen/arch/arm/arm64/acpi/arm-core.c b/xen/arch/arm/arm64/acpi/arm-core.c
>> index cc11fce..6707e4c 100644
>> --- a/xen/arch/arm/arm64/acpi/arm-core.c
>> +++ b/xen/arch/arm/arm64/acpi/arm-core.c
>> @@ -31,6 +31,7 @@
>>
>>  #include <asm/cputype.h>
>>  #include <asm/acpi.h>
>> +#include <asm/p2m.h>
>>
>>  /*
>>   * We never plan to use RSDT on arm/arm64 as its deprecated in spec but this
>> @@ -241,6 +242,48 @@ static int __init acpi_parse_fadt(struct acpi_table_header *table)
>>         return 0;
>>  }
>>
>> +int acpi_map_tables(struct domain *d)
>> +{
>> +    int i,res;
>> +    u64 addr, size;
>> +
>> +    /* map rsdp table */
>> +    addr = acpi_os_get_root_pointer();
>
> I cannot seem to find the patch that actually adds the rsdp to the mini
> dtb. It would make sense to have that change in this patch.
it is added earlier in patch 22, "create chosen node"
should i merge it with this patch?
>
>> +    size = sizeof(struct acpi_table_rsdp);
>> +
>> +    res = map_ram_regions(d,
>> +                            paddr_to_pfn(addr & PAGE_MASK),
>> +                            DIV_ROUND_UP(size, PAGE_SIZE),
>> +                            paddr_to_pfn(addr & PAGE_MASK));
>> +    if ( res )
>> +    {
>> +         printk(XENLOG_ERR "Unable to map 0x%"PRIx64
>> +                " - 0x%"PRIx64" in domain \n",
>> +                addr & PAGE_MASK, PAGE_ALIGN(addr + size) - 1);
>> +         return res;
>> +    }
>> +
>> +    for( i = 0; i < acpi_gbl_root_table_list.count; i++ )
>> +    {
>> +        addr = acpi_gbl_root_table_list.tables[i].address;
>> +        size = acpi_gbl_root_table_list.tables[i].length;
>> +
>> +        res = map_ram_regions(d,
>> +                            paddr_to_pfn(addr & PAGE_MASK),
>> +                            DIV_ROUND_UP(size, PAGE_SIZE),
>> +                            paddr_to_pfn(addr & PAGE_MASK));
>> +        if ( res )
>> +        {
>> +             printk(XENLOG_ERR "Unable to map 0x%"PRIx64
>> +                    " - 0x%"PRIx64" in domain \n",
>> +                    addr & PAGE_MASK, PAGE_ALIGN(addr + size) - 1);
>> +             return res;
>> +        }
>> +    }
>> +
>> +    return 0;
>> +}
>> +
>>  /*
>>   * acpi_boot_table_init() called from setup_arch(), always.
>>   *      1. find RSDP and get its address, and then find XSDT
>> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
>> index 49eb52a..a504064 100644
>> --- a/xen/arch/arm/domain_build.c
>> +++ b/xen/arch/arm/domain_build.c
>> @@ -1278,6 +1278,10 @@ static int map_acpi_regions(struct domain *d)
>>  {
>>      int res;
>>
>> +    res = acpi_map_tables(d);
>> +    if ( res )
>> +        return res;
>> +
>>      res = acpi_map_mmio(d);
>>      if ( res )
>>          return res;
>> diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
>> index 01ce28d..4f52cd6 100644
>> --- a/xen/include/asm-arm/acpi.h
>> +++ b/xen/include/asm-arm/acpi.h
>> @@ -108,5 +108,6 @@ static inline void acpi_disable_pci(void)
>>  #define MAX_GIC_CPU_INTERFACE 65535
>>  #define MAX_GIC_DISTRIBUTOR   1                /* should be the same as MAX_GIC_NR */
>>  extern int __init acpi_gic_init(void);
>> +int acpi_map_tables(struct domain *d);
>>
>>  #endif /*_ASM_ARM_ACPI_H*/
>> --
>> 1.9.1
>>
>>
>> _______________________________________________
>> Xen-devel mailing list
>> Xen-devel@lists.xen.org
>> http://lists.xen.org/xen-devel
>>
diff mbox

Patch

diff --git a/xen/arch/arm/arm64/acpi/arm-core.c b/xen/arch/arm/arm64/acpi/arm-core.c
index cc11fce..6707e4c 100644
--- a/xen/arch/arm/arm64/acpi/arm-core.c
+++ b/xen/arch/arm/arm64/acpi/arm-core.c
@@ -31,6 +31,7 @@ 
 
 #include <asm/cputype.h>
 #include <asm/acpi.h>
+#include <asm/p2m.h>
 
 /*
  * We never plan to use RSDT on arm/arm64 as its deprecated in spec but this
@@ -241,6 +242,48 @@  static int __init acpi_parse_fadt(struct acpi_table_header *table)
        return 0;
 }
 
+int acpi_map_tables(struct domain *d)
+{
+    int i,res;
+    u64 addr, size;
+
+    /* map rsdp table */
+    addr = acpi_os_get_root_pointer();
+    size = sizeof(struct acpi_table_rsdp);
+
+    res = map_ram_regions(d,
+                            paddr_to_pfn(addr & PAGE_MASK),
+                            DIV_ROUND_UP(size, PAGE_SIZE),
+                            paddr_to_pfn(addr & PAGE_MASK));
+    if ( res )
+    {
+         printk(XENLOG_ERR "Unable to map 0x%"PRIx64
+                " - 0x%"PRIx64" in domain \n",
+                addr & PAGE_MASK, PAGE_ALIGN(addr + size) - 1);
+         return res;
+    }
+
+    for( i = 0; i < acpi_gbl_root_table_list.count; i++ )
+    {
+        addr = acpi_gbl_root_table_list.tables[i].address;
+        size = acpi_gbl_root_table_list.tables[i].length;
+
+        res = map_ram_regions(d,
+                            paddr_to_pfn(addr & PAGE_MASK),
+                            DIV_ROUND_UP(size, PAGE_SIZE),
+                            paddr_to_pfn(addr & PAGE_MASK));
+        if ( res )
+        {
+             printk(XENLOG_ERR "Unable to map 0x%"PRIx64
+                    " - 0x%"PRIx64" in domain \n",
+                    addr & PAGE_MASK, PAGE_ALIGN(addr + size) - 1);
+             return res;
+        }
+    }
+
+    return 0;
+}
+
 /*
  * acpi_boot_table_init() called from setup_arch(), always.
  *      1. find RSDP and get its address, and then find XSDT
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 49eb52a..a504064 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1278,6 +1278,10 @@  static int map_acpi_regions(struct domain *d)
 {
     int res;
 
+    res = acpi_map_tables(d);
+    if ( res )
+        return res;
+
     res = acpi_map_mmio(d);
     if ( res )
         return res;
diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
index 01ce28d..4f52cd6 100644
--- a/xen/include/asm-arm/acpi.h
+++ b/xen/include/asm-arm/acpi.h
@@ -108,5 +108,6 @@  static inline void acpi_disable_pci(void)
 #define MAX_GIC_CPU_INTERFACE 65535
 #define MAX_GIC_DISTRIBUTOR   1                /* should be the same as MAX_GIC_NR */
 extern int __init acpi_gic_init(void);
+int acpi_map_tables(struct domain *d);
 
 #endif /*_ASM_ARM_ACPI_H*/