ron minnich has submitted this change. ( https://review.coreboot.org/c/coreboot/+/68842?usp=email )
Change subject: lib/ramdetect: Limit probe size to function argument ......................................................................
lib/ramdetect: Limit probe size to function argument
This avoids probing above the function argument where other things than DRAM could be mapped.
Change-Id: Ie7f915c6e150629eff235ee94719172467a54db2 Signed-off-by: Arthur Heymans arthur@aheymans.xyz Reviewed-on: https://review.coreboot.org/c/coreboot/+/68842 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: ron minnich rminnich@gmail.com Reviewed-by: Maximilian Brune maximilian.brune@9elements.com --- M src/lib/ramdetect.c 1 file changed, 4 insertions(+), 1 deletion(-)
Approvals: Maximilian Brune: Looks good to me, approved build bot (Jenkins): Verified ron minnich: Looks good to me, approved
diff --git a/src/lib/ramdetect.c b/src/lib/ramdetect.c index cfec029..9a29d0f 100644 --- a/src/lib/ramdetect.c +++ b/src/lib/ramdetect.c @@ -57,9 +57,12 @@ msb = MIN(msb, MAX_ADDRESSABLE_SPACE);
/* Compact binary search. */ - for (i = msb; i >= 0; i--) + for (i = msb; i >= 0; i--) { + if ((discovered | (1ULL << i)) > probe_size) + continue; if (probe_mb(dram_start, (discovered | (1ULL << i)))) discovered |= (1ULL << i); + }
saved_result = discovered; printk(BIOS_DEBUG, "RAMDETECT: Found %zu MiB RAM\n", discovered);