You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
seabios/SOURCES/seabios-malloc-use-variable...

80 lines
2.6 KiB

From dd4841701064e7649c0fe70db1d7f322a08215d2 Mon Sep 17 00:00:00 2001
From: Jon Maloy <jmaloy@redhat.com>
Date: Thu, 3 Aug 2023 20:07:38 -0400
Subject: [PATCH 1/2] malloc: use variable for ZoneHigh size
RH-Author: Jon Maloy <jmaloy@redhat.com>
RH-MergeRequest: 10: malloc: use variable for ZoneHigh size
RH-Bugzilla: 2228485
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
RH-Commit: [1/2] 7508668d9288ac3a2ed73802fc100c969c2e3784 (jmaloy/jmaloy-src-seabios)
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2228485
Upstream: Merged
commit 3b91e8e9fe93d5ff7edf17f984c401f9e6ba55fe
Author: Gerd Hoffmann <kraxel@redhat.com>
Date: Mon Apr 25 09:20:02 2022 +0200
malloc: use variable for ZoneHigh size
Use the variable highram_size instead of the BUILD_MAX_HIGHTABLE #define
for the ZoneHigh size. Initialize the new variable with the old #define,
so behavior does not change.
This allows to easily adjust the ZoneHigh size at runtime in a followup
patch.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
---
src/malloc.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/malloc.c b/src/malloc.c
index 3733855c..ecd8c9ac 100644
--- a/src/malloc.c
+++ b/src/malloc.c
@@ -422,7 +422,8 @@ malloc_preinit(void)
e820_add(BUILD_BIOS_ADDR, BUILD_BIOS_SIZE, E820_RESERVED);
// Populate temp high ram
- u32 highram = 0;
+ u32 highram_start = 0;
+ u32 highram_size = BUILD_MAX_HIGHTABLE;
int i;
for (i=e820_count-1; i>=0; i--) {
struct e820entry *en = &e820_list[i];
@@ -432,10 +433,10 @@ malloc_preinit(void)
if (en->type != E820_RAM || end > 0xffffffff)
continue;
u32 s = en->start, e = end;
- if (!highram) {
- u32 newe = ALIGN_DOWN(e - BUILD_MAX_HIGHTABLE, MALLOC_MIN_ALIGN);
+ if (!highram_start) {
+ u32 newe = ALIGN_DOWN(e - highram_size, MALLOC_MIN_ALIGN);
if (newe <= e && newe >= s) {
- highram = newe;
+ highram_start = newe;
e = newe;
}
}
@@ -444,9 +445,9 @@ malloc_preinit(void)
// Populate regions
alloc_add(&ZoneTmpLow, BUILD_STACK_ADDR, BUILD_EBDA_MINIMUM);
- if (highram) {
- alloc_add(&ZoneHigh, highram, highram + BUILD_MAX_HIGHTABLE);
- e820_add(highram, BUILD_MAX_HIGHTABLE, E820_RESERVED);
+ if (highram_start) {
+ alloc_add(&ZoneHigh, highram_start, highram_start + highram_size);
+ e820_add(highram_start, highram_size, E820_RESERVED);
}
}
--
2.37.3