From 27435d3bcdd4c7bccb326f77ca64a54d3fb1170a Mon Sep 17 00:00:00 2001 From: Aaron Durbin Date: Mon, 3 Jun 2013 09:46:56 -0500 Subject: [PATCH] haswell: fix overflow handling TOUUD It's possible that the TOUUD can be set to less than 4GiB. When that is the case the size_k variable is an extremely large value. Instead ensure TOUUD is greater than 4GiB before adding said resources. Change-Id: I456633d6210824e60665281538300fd15656b86d Signed-off-by: Aaron Durbin Reviewed-on: http://review.coreboot.org/3352 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich --- src/northbridge/intel/haswell/northbridge.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/northbridge/intel/haswell/northbridge.c b/src/northbridge/intel/haswell/northbridge.c index 5c1ab3e1ff..45d967e788 100644 --- a/src/northbridge/intel/haswell/northbridge.c +++ b/src/northbridge/intel/haswell/northbridge.c @@ -312,6 +312,7 @@ static void mc_report_map_entries(device_t dev, uint64_t *values) static void mc_add_dram_resources(device_t dev) { unsigned long base_k, size_k; + unsigned long touud_k; unsigned long index; struct resource *resource; uint64_t mc_values[NUM_MAP_ENTRIES]; @@ -396,8 +397,9 @@ static void mc_add_dram_resources(device_t dev) /* 4GiB -> TOUUD */ base_k = 4096 * 1024; /* 4GiB */ - size_k = (unsigned long)(mc_values[TOUUD_REG] >> 10) - base_k; - if (size_k > 0) + touud_k = mc_values[TOUUD_REG] >> 10; + size_k = touud_k - base_k; + if (touud_k > base_k) ram_resource(dev, index++, base_k, size_k); /* Reserve everything between A segment and 1MB: