diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2018-06-15 12:07:34 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2018-06-22 07:44:07 +0200 |
commit | a638acfa4cc772b42093c8bfe55669829a641293 (patch) | |
tree | f33df16ed6099c511df370b5acc85fe0944257c4 | |
parent | 7bf9ffff1a6ac6a554ddb508fe468c0a88235c8f (diff) | |
download | seabios-a638acfa4cc772b42093c8bfe55669829a641293.tar.gz |
pmm: use tmp zone on oom
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
-rw-r--r-- | src/pmm.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -8,6 +8,7 @@ #include "config.h" // CONFIG_* #include "malloc.h" // _malloc #include "output.h" // dprintf +#include "e820map.h" // struct e820entry #include "std/pmm.h" // PMM_SIGNATURE #include "string.h" // checksum #include "util.h" // pmm_init @@ -75,6 +76,18 @@ handle_pmm00(u16 *args) break; case 2: data = malloc_palloc(highzone, size, align); + if (!data && (flags & 8)) { + /* + * We are out of meory. So go allocate from the (big) + * ZoneTmpHigh instead and reserve the block in the e820 + * map so the OS will not override it. That way we can + * handle big permanent allocations without needing a big + * ZoneHigh. + */ + data = malloc_palloc(&ZoneTmpHigh, size, align); + if (data) + e820_add(data, size, E820_RESERVED); + } break; case 3: { data = malloc_palloc(lowzone, size, align); |