diff mbox

[RFC,9/9,SeaBIOS] enable memory devices if e820 entry is present

Message ID 1334844527-18869-10-git-send-email-vasilis.liaskovitis@profitbricks.com
State New
Headers show

Commit Message

Vasilis Liaskovitis April 19, 2012, 2:08 p.m. UTC
On a reboot, seabios regenerates srat/ssdt objects. If a valid e820 entry is
 found spanning the whole address range of a hotplug memory device, the  device
 will be enabled. This ensures persistency of hotplugged memory slots across VM
 reboots.

 Signed-off-by: Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com>
---
 src/acpi.c   |    6 +++++-
 src/memmap.c |   15 +++++++++++++++
 2 files changed, 20 insertions(+), 1 deletions(-)

Comments

Wen Congyang April 26, 2012, 12:58 a.m. UTC | #1
At 04/19/2012 10:08 PM, Vasilis Liaskovitis Wrote:
>  On a reboot, seabios regenerates srat/ssdt objects. If a valid e820 entry is
>  found spanning the whole address range of a hotplug memory device, the  device
>  will be enabled. This ensures persistency of hotplugged memory slots across VM
>  reboots.
> 
>  Signed-off-by: Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com>
> ---
>  src/acpi.c   |    6 +++++-
>  src/memmap.c |   15 +++++++++++++++
>  2 files changed, 20 insertions(+), 1 deletions(-)
> 
> diff --git a/src/acpi.c b/src/acpi.c
> index 5580099..2ebed2e 100644
> --- a/src/acpi.c
> +++ b/src/acpi.c
> @@ -601,7 +601,11 @@ build_memssdt(void)
>      for (i = 0; i < nb_memdevs; i++) {
>          mem_base = (((u64)(entry->base_addr_high) << 32 )| entry->base_addr_low);
>          mem_len = (((u64)(entry->length_high) << 32 )| entry->length_low);
> -        *(ssdt_ptr++) = 0x00;
> +        if (find_e820(mem_base, mem_len, E820_RAM)) {

This line will break the building:
Compilation complete. 0 Errors, 16 Warnings, 0 Remarks, 259 Optimizations
  Compiling whole program out/ccode32flat.o
src/acpi.c: In function ‘build_memssdt’:
src/acpi.c:604: warning: implicit declaration of function ‘find_e820’
src/memmap.c:137: note: previous definition of ‘find_e820’ was here
src/acpi.c:604: error: ‘E820_RAM’ undeclared (first use in this function)
src/acpi.c:604: error: (Each undeclared identifier is reported only once
src/acpi.c:604: error: for each function it appears in.)
make: *** [out/ccode32flat.o] Error 1

You should declare the function find_e820() in src/memmap.h and include
this header file in src/acpi.c.

Thanks
Wen Congyang

> +            *(ssdt_ptr++) = 0x01;
> +        }
> +        else
> +            *(ssdt_ptr++) = 0x00;
>          entry++;
>      }
>      build_header((void*)ssdt, SSDT_SIGNATURE, ssdt_ptr - ssdt, 1);
> diff --git a/src/memmap.c b/src/memmap.c
> index 56865b4..9790da1 100644
> --- a/src/memmap.c
> +++ b/src/memmap.c
> @@ -131,6 +131,21 @@ add_e820(u64 start, u64 size, u32 type)
>      //dump_map();
>  }
>  
> +// Check if an e820 entry exists that covers the memory range
> +// [start, start+size) with same type as type.
> +int
> +find_e820(u64 start, u64 size, u32 type)
> +{
> +    int i;
> +    for (i=0; i<e820_count; i++) {
> +        struct e820entry *e = &e820_list[i];
> +        if ((e->start <= start) && (e->size >= (size + start - e->start)) &&
> +            (e->type == type))
> +            return 1;
> +    }
> +    return 0;
> +}
> +
>  // Report on final memory locations.
>  void
>  memmap_finalize(void)
diff mbox

Patch

diff --git a/src/acpi.c b/src/acpi.c
index 5580099..2ebed2e 100644
--- a/src/acpi.c
+++ b/src/acpi.c
@@ -601,7 +601,11 @@  build_memssdt(void)
     for (i = 0; i < nb_memdevs; i++) {
         mem_base = (((u64)(entry->base_addr_high) << 32 )| entry->base_addr_low);
         mem_len = (((u64)(entry->length_high) << 32 )| entry->length_low);
-        *(ssdt_ptr++) = 0x00;
+        if (find_e820(mem_base, mem_len, E820_RAM)) {
+            *(ssdt_ptr++) = 0x01;
+        }
+        else
+            *(ssdt_ptr++) = 0x00;
         entry++;
     }
     build_header((void*)ssdt, SSDT_SIGNATURE, ssdt_ptr - ssdt, 1);
diff --git a/src/memmap.c b/src/memmap.c
index 56865b4..9790da1 100644
--- a/src/memmap.c
+++ b/src/memmap.c
@@ -131,6 +131,21 @@  add_e820(u64 start, u64 size, u32 type)
     //dump_map();
 }
 
+// Check if an e820 entry exists that covers the memory range
+// [start, start+size) with same type as type.
+int
+find_e820(u64 start, u64 size, u32 type)
+{
+    int i;
+    for (i=0; i<e820_count; i++) {
+        struct e820entry *e = &e820_list[i];
+        if ((e->start <= start) && (e->size >= (size + start - e->start)) &&
+            (e->type == type))
+            return 1;
+    }
+    return 0;
+}
+
 // Report on final memory locations.
 void
 memmap_finalize(void)