diff options
author | Arthur Heymans <arthur@aheymans.xyz> | 2022-10-25 21:09:58 +0200 |
---|---|---|
committer | ron minnich <rminnich@gmail.com> | 2024-03-04 22:15:53 +0000 |
commit | 2fa8caba507aca56af1b1d225043ecae1011fd3c (patch) | |
tree | 5f0fbcfaf33306242701da1a3c4cd32bff8b9339 | |
parent | b6efe17137bf458a511ba5110667cad4bae7dc87 (diff) |
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>
-rw-r--r-- | src/lib/ramdetect.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/lib/ramdetect.c b/src/lib/ramdetect.c index cfec0296e7..9a29d0fe94 100644 --- a/src/lib/ramdetect.c +++ b/src/lib/ramdetect.c @@ -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); |