[SeaBIOS] [PATCH] ata: Many CPUs cause seabios not to find boot disk

Kevin O'Connor kevin at koconnor.net
Mon Aug 3 16:32:46 CEST 2015


On Mon, Aug 03, 2015 at 01:59:25PM +0800, Huaitong Han wrote:
> When CPUs are 76, mptable_setup will alloc much
> fseg memory,and init_atadrive allocation fails.
> when CPUs are 86, mptable_setup allocation is too
> much to be met, and init_atadrive allocs success.
> So when CPUs are 76~85, seabios cannot find boot
> disk because init_atadrive allocation fails.
> 
> Set a reserved area from fsegzone for atadrive
> allocation, and the fsegzone space also increases
> by the reserved area space.

If I understand your patch, it seems to be trying to force large
mptable allocations to fail while still allowing other f-seg
allocations.  I think a simpler approach would be to just limit the
mptable allocation and leave the malloc implementation unchanged.  See
patch below.

-Kevin


From: Kevin O'Connor <kevin at koconnor.net>
Date: Mon, 3 Aug 2015 10:16:39 -0400
Subject: [PATCH] mptable: Don't create mptable if it is very large

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 at intel.com>
Signed-off-by: Kevin O'Connor <kevin at koconnor.net>
---
 src/config.h        | 2 ++
 src/fw/biostables.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/src/config.h b/src/config.h
index 4bfebe8..6c47f16 100644
--- a/src/config.h
+++ b/src/config.h
@@ -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
diff --git a/src/fw/biostables.c b/src/fw/biostables.c
index 450aca2..cf714e8 100644
--- a/src/fw/biostables.c
+++ b/src/fw/biostables.c
@@ -54,6 +54,8 @@ 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)
+        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.)



More information about the SeaBIOS mailing list