]> xenbits.xensource.com Git - seabios.git/commitdiff
mptable: Don't create mptable if it is very large
authorKevin O'Connor <kevin@koconnor.net>
Mon, 3 Aug 2015 14:16:39 +0000 (10:16 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Tue, 4 Aug 2015 14:05:27 +0000 (10:05 -0400)
Very large mptable structures can fill up the space in the f-segment
and cause other important f-segment allocations to fail.  Limit the
maximum size of the mptable to prevent this.

On QEMU, with the current maximum size of 600 bytes, the mptable will
not be created in configurations of ~20 cpus or more.  The mptable is
rarely used in modern OSes so this should not be a problem.

Reported-by: Huaitong Han <huaitong.han@intel.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/config.h
src/fw/biostables.c

index 4bfebe83c064152528cdf3faf006899667f0b7c3..6c47f161c965244608404ddb1ba892d301c75bdf 100644 (file)
@@ -22,6 +22,8 @@
 #define BUILD_MAX_EXTDRIVE 16
 // Number of bytes the smbios may be and still live in the f-segment
 #define BUILD_MAX_SMBIOS_FSEG     600
+// Maximum number of bytes the mptable may be and still be copied to f-segment
+#define BUILD_MAX_MPTABLE_FSEG    600
 
 #define BUILD_MODEL_ID      0xFC
 #define BUILD_SUBMODEL_ID   0x00
index 450aca282e4541a79ddf911791de964b40dde610..71a1a0de54f324f660d17ee934f150e3048f700c 100644 (file)
@@ -54,6 +54,11 @@ copy_mptable(void *pos)
         return;
     u32 length = p->length * 16;
     u16 mpclength = ((struct mptable_config_s *)p->physaddr)->length;
+    if (length + mpclength > BUILD_MAX_MPTABLE_FSEG) {
+        dprintf(1, "Skipping MPTABLE copy due to large size (%d bytes)\n"
+                , length + mpclength);
+        return;
+    }
     // Allocate final memory location.  (In theory the config
     // structure can go in high memory, but Linux kernels before
     // v2.6.30 crash with that.)