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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 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@xxxxxxxxxxxxxxxx>
---
 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)) {
+            *(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)
-- 
1.7.9

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux