Nico Huber has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/41958 )
Change subject: device: Introduce RESOURCE_ALLOCATION_COMPAT ......................................................................
device: Introduce RESOURCE_ALLOCATION_COMPAT
Add a v3-compatibility mode to the v4.5 allocator. We avoid all space above 4G and then disable all remaining memranges but the biggest. It also forces top-down allocation.
Change-Id: I1c8512e4b6264f1967cf7018debdf9cabf11d84f Signed-off-by: Nico Huber nico.h@gmx.de --- M src/device/Kconfig M src/device/resource_allocator_v4.5.c 2 files changed, 27 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/58/41958/1
diff --git a/src/device/Kconfig b/src/device/Kconfig index 35433b0..50e3857 100644 --- a/src/device/Kconfig +++ b/src/device/Kconfig @@ -825,4 +825,9 @@ bool "Allocate resources from top down" depends on RESOURCE_ALLOCATOR_V4 || RESOURCE_ALLOCATOR_V4_5
+config RESOURCE_ALLOCATION_COMPAT + bool "Resource allocator v3 compatibility mode" + depends on RESOURCE_ALLOCATOR_V4_5 + select RESOURCE_ALLOCATION_TOP_DOWN + endmenu diff --git a/src/device/resource_allocator_v4.5.c b/src/device/resource_allocator_v4.5.c index 4a03a23..34e9fdd 100644 --- a/src/device/resource_allocator_v4.5.c +++ b/src/device/resource_allocator_v4.5.c @@ -350,6 +350,28 @@
avoid_fixed_resources(ranges, domain, mask_match);
+ if (CONFIG(RESOURCE_ALLOCATION_COMPAT)) { + struct range_entry *r, *biggest = NULL; + + /* Don't allow allocations above 4G. */ + memranges_create_hole(ranges, POWER_OF_2(32), UINT64_MAX - POWER_OF_2(32) + 1); + + /* Set all but the biggest range's tag to 0. */ + memranges_each_entry(r, ranges) { + if (!biggest) { + biggest = r; + continue; + } + + if (range_entry_size(r) > range_entry_size(biggest)) { + range_entry_update_tag(biggest, 0); + biggest = r; + } else { + range_entry_update_tag(r, 0); + } + } + } + print_resource_ranges(domain, ranges); }