Patrick Georgi has submitted this change and it was merged. ( https://review.coreboot.org/c/coreboot/+/32291 )
Change subject: nb/via/vx900: Ensure memory size and base are in range ......................................................................
nb/via/vx900: Ensure memory size and base are in range
We need to ensure uma_memory_size and uma_memory_base stay within a 32-bit address range. Both of these variables are 64 bits wide, so it is simplest to use 64 bit math when doing the bit shifts and then check if they are in range after.
Change-Id: Idd180f31e8cff797a6499b12bc685daa993aae05 Signed-off-by: Jacob Garber jgarber1@ualberta.ca Found-by: Coverity CID 1229665, 1229666 Reviewed-on: https://review.coreboot.org/c/coreboot/+/32291 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Patrick Georgi pgeorgi@google.com --- M src/northbridge/via/vx900/northbridge.c 1 file changed, 9 insertions(+), 2 deletions(-)
Approvals: build bot (Jenkins): Verified Patrick Georgi: Looks good to me, approved
diff --git a/src/northbridge/via/vx900/northbridge.c b/src/northbridge/via/vx900/northbridge.c index d865f38..260bd3d 100644 --- a/src/northbridge/via/vx900/northbridge.c +++ b/src/northbridge/via/vx900/northbridge.c @@ -266,8 +266,15 @@ * to be always mapped to the top of 1M, but this can be overcome with * some smart positive/subtractive resource decoding */ ram_resource(dev, idx++, 768, (tolmk - 768)); - uma_memory_size = fbufk << 10; - uma_memory_base = tolmk << 10; + + uma_memory_size = (uint64_t)fbufk << 10; + uma_memory_base = (uint64_t)tolmk << 10; + + if (uma_memory_size > UINT32_MAX) + die("uma_memory_size %llu exceeds 32-bit address range\n", uma_memory_size); + + if (uma_memory_base > UINT32_MAX) + die("uma_memory_base %llu exceeds 32-bit address range\n", uma_memory_base);
//uma_resource(dev, idx++, uma_memory_base>>10, uma_memory_size>>10);