]> xenbits.xensource.com Git - osstest/seabios.git/commitdiff
check for e820 conflict
authorGerd Hoffmann <kraxel@redhat.com>
Fri, 21 Apr 2023 10:42:51 +0000 (12:42 +0200)
committerGerd Hoffmann <kraxel@redhat.com>
Thu, 24 Aug 2023 08:56:21 +0000 (10:56 +0200)
Add support to check for overlaps with e820 entries.
In case the 64bit pci io window has conflicts move it down.

The only known case where this happens is AMD processors
with 1TB address space which has some space just below
1TB reserved for HT.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
src/e820map.c
src/e820map.h
src/fw/pciinit.c

index 39445cf6399dfe1e86230cb093c13ccb1e3ae1cc..c761e5e98a751bd6e301f33fe779a9e20a93e6f5 100644 (file)
@@ -150,3 +150,18 @@ e820_prepboot(void)
 {
     dump_map();
 }
+
+int
+e820_is_used(u64 start, u64 size)
+{
+    int i;
+    for (i=0; i<e820_count; i++) {
+        struct e820entry *e = &e820_list[i];
+        if (start + size <= e->start)
+            continue;
+        if (start >= e->start + e->size)
+            continue;
+        return 1;
+    }
+    return 0;
+}
index de8b523003c5716f5fe2688992c6d99b6e35d1a0..07ce16ec213f453246c300c168fa3d649652048e 100644 (file)
@@ -18,6 +18,7 @@ struct e820entry {
 void e820_add(u64 start, u64 size, u32 type);
 void e820_remove(u64 start, u64 size);
 void e820_prepboot(void);
+int e820_is_used(u64 start, u64 size);
 
 // e820 map storage
 extern struct e820entry e820_list[];
index b52bd1d5054b13ebe42e176a936fee62b18f9578..c7084f5e397e08d385a9d439ba5141453ce0c6f9 100644 (file)
@@ -1140,6 +1140,8 @@ static void pci_bios_map_devices(struct pci_bus *busses)
             if (r64_mem.base < top - size) {
                 r64_mem.base = top - size;
             }
+            if (e820_is_used(r64_mem.base, size))
+                r64_mem.base -= size;
         }
         r64_mem.base = ALIGN(r64_mem.base, align_mem);
         r64_mem.base = ALIGN(r64_mem.base, (1LL<<30));    // 1G hugepage