On Mon, Aug 03, 2015 at 03:49:14PM +0000, Han, Huaitong wrote:
On Mon, 2015-08-03 at 10:32 -0400, Kevin O'Connor wrote:
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.
Yes, it's a better way to solve problem.
u16 mpclength = ((struct mptable_config_s *)p->physaddr)->length;
- if (length + mpclength > BUILD_MAX_MPTABLE_FSEG)
it's better that warning dprintf is added before return.
Good point. New patch below.
-Kevin
From 194b750f3735cb8b400ead1cba4ecd2e6e16d5ed Mon Sep 17 00:00:00 2001
From: Kevin O'Connor kevin@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@intel.com Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/config.h | 2 ++ src/fw/biostables.c | 5 +++++ 2 files changed, 7 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..71a1a0d 100644 --- a/src/fw/biostables.c +++ b/src/fw/biostables.c @@ -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.)