diff mbox

[Xen-devel,v2,29/41] arm : acpi read acpi memory info from uefi

Message ID 1431893048-5214-30-git-send-email-parth.dixit@linaro.org
State New
Headers show

Commit Message

Parth Dixit May 17, 2015, 8:03 p.m. UTC
ACPI memory is seperate from conventional memory and should
be marked as reserved while passing to DOM0. Create a new meminfo
structure to store all the acpi tables listed in uefi.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
---
 xen/arch/arm/domain_build.c |  2 ++
 xen/arch/arm/efi/efi-boot.h | 20 +++++++++++++++++---
 xen/include/asm-arm/setup.h |  1 +
 3 files changed, 20 insertions(+), 3 deletions(-)

Comments

Parth Dixit July 5, 2015, 1:28 p.m. UTC | #1
+shannon

On 8 June 2015 at 21:39, Julien Grall <julien.grall@citrix.com> wrote:
> Hi Parth,
>
> On 17/05/2015 21:03, Parth Dixit wrote:
>>
>> ACPI memory is seperate from conventional memory and should
>
>
> s/seperate/separate/
>
>> be marked as reserved while passing to DOM0. Create a new meminfo
>> structure to store all the acpi tables listed in uefi.
>>
>> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>> ---
>>   xen/arch/arm/domain_build.c |  2 ++
>>   xen/arch/arm/efi/efi-boot.h | 20 +++++++++++++++++---
>>   xen/include/asm-arm/setup.h |  1 +
>>   3 files changed, 20 insertions(+), 3 deletions(-)
>>
>> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
>> index 865b81a..9d98f64 100644
>> --- a/xen/arch/arm/domain_build.c
>> +++ b/xen/arch/arm/domain_build.c
>> @@ -42,6 +42,8 @@ static void __init parse_dom0_mem(const char *s)
>>   }
>>   custom_param("dom0_mem", parse_dom0_mem);
>>
>> +struct meminfo __initdata acpi_mem;
>> +
>
>
> Please protect it with an CONFIG_ACPI and please keep all the ACPI variable
> in the same place within this file.
>
>
>>   //#define DEBUG_DT
>>
>>   #ifdef DEBUG_DT
>> diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h
>> index b02cc02..d21cba5 100644
>> --- a/xen/arch/arm/efi/efi-boot.h
>> +++ b/xen/arch/arm/efi/efi-boot.h
>> @@ -127,14 +127,16 @@ static EFI_STATUS __init
>> efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR *
>>   {
>>       int Index;
>>       int i = 0;
>> +    int j = 0;
>>       EFI_MEMORY_DESCRIPTOR *desc_ptr = map;
>>
>>       for ( Index = 0; Index < (mmap_size / desc_size); Index++ )
>>       {
>> -        if ( desc_ptr->Type == EfiConventionalMemory
>> -             || desc_ptr->Type == EfiBootServicesCode
>> -             || desc_ptr->Type == EfiBootServicesData )
>> +        switch( desc_ptr->Type )
>>           {
>> +        case EfiConventionalMemory:
>> +        case EfiBootServicesCode:
>> +        case EfiBootServicesData:
>>               if ( i >= NR_MEM_BANKS )
>>               {
>>                   PrintStr(L"Warning: All " __stringify(NR_MEM_BANKS)
>> @@ -144,11 +146,23 @@ static EFI_STATUS __init
>> efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR *
>>               bootinfo.mem.bank[i].start = desc_ptr->PhysicalStart;
>>               bootinfo.mem.bank[i].size = desc_ptr->NumberOfPages *
>> EFI_PAGE_SIZE;
>>               ++i;
>> +            break;
>
>
> #ifdef CONFIG_ACPI
>
>> +        case EfiACPIReclaimMemory:
>> +            if ( j >= NR_MEM_BANKS )
>> +            {
>> +                PrintStr(L"Warning: All " __stringify(NR_MEM_BANKS)
>> +                          " acpi meminfo mem banks exhausted.\r\n");
>
>
> DOM0 will likely fail to boot if one of the ACPI region is not present
> because there is not enough place in the array.
>
> Either you allocate dynamically the array or you stop booting on the
> platform. But a warning is not enough...
>
>> +                break;
>> +            }
>> +            acpi_mem.bank[j].start = desc_ptr->PhysicalStart;
>> +            acpi_mem.bank[j].size  = desc_ptr->NumberOfPages *
>> EFI_PAGE_SIZE;
>> +            ++j;
>>           }
>>           desc_ptr = NextMemoryDescriptor(desc_ptr, desc_size);
>>       }
>>
>>       bootinfo.mem.nr_banks = i;
>> +    acpi_mem.nr_banks = j;
>>       return EFI_SUCCESS;
>>   }
>>
>> diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h
>> index ba5a67d..1865b72 100644
>> --- a/xen/include/asm-arm/setup.h
>> +++ b/xen/include/asm-arm/setup.h
>> @@ -46,6 +46,7 @@ struct bootinfo {
>>   };
>>
>>   extern struct bootinfo bootinfo;
>> +extern struct meminfo acpi_mem;
>
>
> #ifdef CONFIG_ACPI
> ...
> #endif
>
>>
>>   void arch_init_memory(void);
>>
>>
>
> --
> Julien Grall
diff mbox

Patch

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 865b81a..9d98f64 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -42,6 +42,8 @@  static void __init parse_dom0_mem(const char *s)
 }
 custom_param("dom0_mem", parse_dom0_mem);
 
+struct meminfo __initdata acpi_mem;
+
 //#define DEBUG_DT
 
 #ifdef DEBUG_DT
diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h
index b02cc02..d21cba5 100644
--- a/xen/arch/arm/efi/efi-boot.h
+++ b/xen/arch/arm/efi/efi-boot.h
@@ -127,14 +127,16 @@  static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR *
 {
     int Index;
     int i = 0;
+    int j = 0;
     EFI_MEMORY_DESCRIPTOR *desc_ptr = map;
 
     for ( Index = 0; Index < (mmap_size / desc_size); Index++ )
     {
-        if ( desc_ptr->Type == EfiConventionalMemory
-             || desc_ptr->Type == EfiBootServicesCode
-             || desc_ptr->Type == EfiBootServicesData )
+        switch( desc_ptr->Type )
         {
+        case EfiConventionalMemory:
+        case EfiBootServicesCode:
+        case EfiBootServicesData:
             if ( i >= NR_MEM_BANKS )
             {
                 PrintStr(L"Warning: All " __stringify(NR_MEM_BANKS)
@@ -144,11 +146,23 @@  static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR *
             bootinfo.mem.bank[i].start = desc_ptr->PhysicalStart;
             bootinfo.mem.bank[i].size = desc_ptr->NumberOfPages * EFI_PAGE_SIZE;
             ++i;
+            break;
+        case EfiACPIReclaimMemory:
+            if ( j >= NR_MEM_BANKS )
+            {
+                PrintStr(L"Warning: All " __stringify(NR_MEM_BANKS)
+                          " acpi meminfo mem banks exhausted.\r\n");
+                break;
+            }
+            acpi_mem.bank[j].start = desc_ptr->PhysicalStart;
+            acpi_mem.bank[j].size  = desc_ptr->NumberOfPages * EFI_PAGE_SIZE;
+            ++j;
         }
         desc_ptr = NextMemoryDescriptor(desc_ptr, desc_size);
     }
 
     bootinfo.mem.nr_banks = i;
+    acpi_mem.nr_banks = j;
     return EFI_SUCCESS;
 }
 
diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h
index ba5a67d..1865b72 100644
--- a/xen/include/asm-arm/setup.h
+++ b/xen/include/asm-arm/setup.h
@@ -46,6 +46,7 @@  struct bootinfo {
 };
 
 extern struct bootinfo bootinfo;
+extern struct meminfo acpi_mem;
 
 void arch_init_memory(void);