arm-trusted-firmware/include/lib
Sandrine Bailleux 7b6d330c92 Ensure addresses in is_mem_free() don't overflow
This patch adds some runtime checks to prevent some potential
pointer overflow issues in the is_mem_free() function. The overflow
could happen in the case where the end addresses, computed as the
sum of a base address and a size, results in a value large enough
to wrap around. This, in turn, could lead to unpredictable behaviour.

If such an overflow is detected, the is_mem_free() function will now
declare the memory region as not free. The overflow is detected using
a new macro, called check_uptr_overflow().

This patch also modifies all other places in the 'bl_common.c' file
where an end address was computed as the sum of a base address and a
size and instead keeps the two values separate. This avoids the need
to handle pointer overflows everywhere. The code doesn't actually need
to compute any end address before the is_mem_free() function is called
other than to print information message to the serial output.

This patch also introduces 2 slight changes to the reserve_mem()
function:

 - It fixes the end addresses passed to choose_mem_pos(). It was
   incorrectly passing (base + size) instead of (base + size - 1).

 - When the requested allocation size is 0, the function now exits
   straight away and says so using a warning message.
   Previously, it used to actually reserve some memory. A zero-byte
   allocation was not considered as a special case so the function
   was using the same top/bottom allocation mechanism as for any
   other allocation. As a result, the smallest area of memory starting
   from the requested base address within the free region was
   reserved.

Change-Id: I0e695f961e24e56ffe000718014e0496dc6e1ec6
2016-07-25 12:57:42 +01:00
..
aarch64 Introduce PSCI Library Interface 2016-07-19 10:19:01 +01:00
cpus/aarch64 bl31: Add error reporting registers 2016-07-12 08:05:10 -07:00
el3_runtime Introduce `el3_runtime` and `PSCI` libraries 2016-07-18 17:52:15 +01:00
libfdt Minor libfdt changes to enable TF integration 2016-06-03 14:21:03 +01:00
psci Introduce PSCI Library Interface 2016-07-19 10:19:01 +01:00
stdlib Rework type usage in Trusted Firmware 2016-07-18 17:52:15 +01:00
bakery_lock.h Fix build error with optimizations disabled (-O0) 2016-04-14 16:24:03 +01:00
cassert.h Remove direct usage of __attribute__((foo)) 2016-01-14 10:55:17 -08:00
mmio.h Add mmio utility functions 2015-08-05 19:55:06 +08:00
pmf.h Add Performance Measurement Framework(PMF) 2016-06-16 08:31:42 +01:00
pmf_helpers.h Add Performance Measurement Framework(PMF) 2016-06-16 08:31:42 +01:00
semihosting.h Remove variables from .data section 2014-05-06 17:55:38 +01:00
smcc.h Introduce PSCI Library Interface 2016-07-19 10:19:01 +01:00
spinlock.h Always use named structs in header files 2014-05-06 13:57:48 +01:00
utils.h Ensure addresses in is_mem_free() don't overflow 2016-07-25 12:57:42 +01:00
xlat_tables.h xlat lib: Introduce MT_EXECUTE/MT_EXECUTE_NEVER attributes 2016-07-08 14:37:11 +01:00