diff options
author | Nicolas Boichat <drinkcat@chromium.org> | 2018-04-09 11:18:15 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-05-07 20:45:54 -0700 |
commit | 6e8cbe40eea777aeaeffe0fa0781a0a5d1763a4d (patch) | |
tree | d229d77bb060be8ba34d4bf94d257ac035c89c26 /core | |
parent | c24d480d90699bf6aaf534d66dc48513d867bdd0 (diff) | |
download | chrome-ec-6e8cbe40eea777aeaeffe0fa0781a0a5d1763a4d.tar.gz |
shared_mem: Assert that shared memory size is large enough
We add a configuration option to set the minimum shared memory
size (CONFIG_SHAREDMEM_MINIMUM_SIZE), so that the link will fail
if there is not enough IRAM left.
Also, we add 2 macros around shared_mem_acquire, that check, at
build time, that the shared memory size is sufficient for the
allocation:
- SHARED_MEM_ACQUIRE_CHECK should be used instead of
shared_mem_acquire, when size is known in advance.
- SHARED_MEM_CHECK_SIZE should be used when only a maximum size
is known.
This does not account for "jump tags" that boards often add on
jump from RO to RW. Luckily, RW usually does not do verification,
and does not need as much shared memory.
BRANCH=none
BUG=chromium:739771
TEST=make buildall -j, no error
Change-Id: Ic4c72938affe65fe8f8bc17ee5111c1798fc536f
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1002713
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/cortex-m/ec.lds.S | 4 | ||||
-rw-r--r-- | core/cortex-m0/ec.lds.S | 4 | ||||
-rw-r--r-- | core/nds32/ec.lds.S | 4 |
3 files changed, 12 insertions, 0 deletions
diff --git a/core/cortex-m/ec.lds.S b/core/cortex-m/ec.lds.S index 25ce2ef221..b6882d7214 100644 --- a/core/cortex-m/ec.lds.S +++ b/core/cortex-m/ec.lds.S @@ -348,6 +348,10 @@ SECTIONS /* NOTHING MAY GO AFTER THIS! */ } > IRAM + ASSERT((__shared_mem_buf + CONFIG_SHAREDMEM_MINIMUM_SIZE) <= + (CONFIG_RAM_BASE + CONFIG_RAM_SIZE), + "Not enough space for shared memory.") + /* The linker won't notice if the .data section is too big to fit, * apparently because we're sending it into IRAM, not FLASH. The following * symbol isn't used by the code, but running "objdump -t *.elf | grep hey" diff --git a/core/cortex-m0/ec.lds.S b/core/cortex-m0/ec.lds.S index 86f5494797..26515451d3 100644 --- a/core/cortex-m0/ec.lds.S +++ b/core/cortex-m0/ec.lds.S @@ -222,6 +222,10 @@ SECTIONS /* NOTHING MAY GO AFTER THIS! */ } > IRAM + ASSERT((__shared_mem_buf + CONFIG_SHAREDMEM_MINIMUM_SIZE) <= + (CONFIG_RAM_BASE + CONFIG_RAM_SIZE), + "Not enough space for shared memory.") + /* The linker won't notice if the .data section is too big to fit, * apparently because we're sending it into IRAM, not FLASH. The following * symbol isn't used by the code, but running "objdump -t *.elf | grep hey" diff --git a/core/nds32/ec.lds.S b/core/nds32/ec.lds.S index c2897343e6..807534f512 100644 --- a/core/nds32/ec.lds.S +++ b/core/nds32/ec.lds.S @@ -220,6 +220,10 @@ SECTIONS } > IRAM + ASSERT((__shared_mem_buf + CONFIG_SHAREDMEM_MINIMUM_SIZE) <= + (CONFIG_RAM_BASE + CONFIG_RAM_SIZE), + "Not enough space for shared memory.") + __image_size = LOADADDR(.data) + SIZEOF(.data) - FW_OFF(SECTION); #ifdef CONFIG_LPC |