Fix high memory zone initialization in CSM mode

malloc_high() cannot allocate any memory in CSM mode due to an empty
ZoneHigh. SeaBIOS cannot find any disk to boot from because device
initialization fails.

The bug was introduced in 1.16.1 (commit dc88f9b) when the meaning of
BUILD_MAX_HIGHTABLE changed but CSM code was not updated. This patch
reverts to the previous behavior by using BUILD_MIN_HIGHTABLE in CSM
methods.

Signed-off-by: José Martínez <xose@google.com>
This commit is contained in:
José Martínez 2023-06-13 11:01:34 -04:00 committed by Kevin O'Connor
parent be7e899350
commit 4db444b9a7
2 changed files with 5 additions and 5 deletions

View File

@ -150,9 +150,9 @@ handle_csm_0002(struct bregs *regs)
for (i=0; i < csm_compat_table.E820Length / sizeof(struct e820entry); i++)
e820_add(p[i].start, p[i].size, p[i].type);
if (csm_init_table->HiPmmMemorySizeInBytes > BUILD_MAX_HIGHTABLE) {
if (csm_init_table->HiPmmMemorySizeInBytes > BUILD_MIN_HIGHTABLE) {
u32 hi_pmm_end = csm_init_table->HiPmmMemory + csm_init_table->HiPmmMemorySizeInBytes;
e820_add(hi_pmm_end - BUILD_MAX_HIGHTABLE, BUILD_MAX_HIGHTABLE, E820_RESERVED);
e820_add(hi_pmm_end - BUILD_MIN_HIGHTABLE, BUILD_MIN_HIGHTABLE, E820_RESERVED);
}
// For PCIBIOS 1ab10e

View File

@ -460,10 +460,10 @@ malloc_csm_preinit(u32 low_pmm, u32 low_pmm_size, u32 hi_pmm, u32 hi_pmm_size)
{
ASSERT32FLAT();
if (hi_pmm_size > BUILD_MAX_HIGHTABLE) {
if (hi_pmm_size > BUILD_MIN_HIGHTABLE) {
u32 hi_pmm_end = hi_pmm + hi_pmm_size;
alloc_add(&ZoneTmpHigh, hi_pmm, hi_pmm_end - BUILD_MAX_HIGHTABLE);
alloc_add(&ZoneHigh, hi_pmm_end - BUILD_MAX_HIGHTABLE, hi_pmm_end);
alloc_add(&ZoneTmpHigh, hi_pmm, hi_pmm_end - BUILD_MIN_HIGHTABLE);
alloc_add(&ZoneHigh, hi_pmm_end - BUILD_MIN_HIGHTABLE, hi_pmm_end);
} else {
alloc_add(&ZoneTmpHigh, hi_pmm, hi_pmm + hi_pmm_size);
}