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>
This commit is contained in:
Arthur Heymans
2022-10-25 21:09:58 +02:00
committed by ron minnich
parent b6efe17137
commit 2fa8caba50

View File

@@ -57,9 +57,12 @@ size_t probe_ramsize(const uintptr_t dram_start, const size_t probe_size)
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);