[SeaBIOS] [PATCH 2/2] malloc: Fallback to low-zone when alloc from high-zone fails

Kevin O'Connor kevin at koconnor.net
Tue Nov 13 19:16:07 CET 2018


On Tue, Nov 13, 2018 at 05:53:41PM +0200, Liran Alon wrote:
> When 32-bit code needs to allocate memory which remains permanent
> after completion of the initialization phase, it doesn't care if
> it is allocated from high-zone or low-zone.
> 
> Currently all these cases just attempt to allocate from high-zone
> as low-zone memory is scarce.
> 
> However, in cases we don't have enough space left in high-zone,
> it makes sense to use low-zone as a fallback.

Thanks, but I fear this change would have poor secondary effects.
There is only a tiny amount of ram available in the permanent "low"
area of ram (typically less that 64K).  If the code has exhausted the
permanent "high" ram (typically 256K) then it is likely to rapidly
exhaust the low ram and cause a worse failure when code that requires
a tiny amount of "low" space fails.

Typical work arounds are to extend the amount of high ram available
(see BUILD_MAX_HIGHTABLE) or to use malloc_tmphigh() and manually
reserve the space in the e820 map.

-Kevin



More information about the SeaBIOS mailing list