summaryrefslogtreecommitdiff
path: root/zephyr/linker
diff options
context:
space:
mode:
authorRob Barnes <robbarnes@google.com>2022-09-14 20:47:00 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-11-17 00:47:31 +0000
commitafdd762d014f295e19b71d789890e565d5b9286d (patch)
treedc4986e66945c4d246a056852f039fc2c5dce26f /zephyr/linker
parentec31407993ec9b5ae14fed72d728a4061d656d65 (diff)
downloadchrome-ec-afdd762d014f295e19b71d789890e565d5b9286d.tar.gz
system: Ensure space for panic and jump data
Ensure space is available for end of ram data. End of ram data must be located at the very end of noinit ram. This currently includes panic_data followed by jump_data. This is being enforced with linker asserts and build asserts rather than allocating the space directly so RAM utiliztion reports are still relevant. Introduce PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE config option and default it to 1KB. This can be adjusted on boards that are constrained. BUG=b:246778588,b:246798928 BRANCH=None TEST=./twister -c -s zephyr/test/jump_tags/jump_tags.default && make run-kb_8042 Change-Id: I444bbe3a583396b4f9b104bb6999e78ae3ff6f2f Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3896272 Reviewed-by: Aaron Massey <aaronmassey@google.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Diffstat (limited to 'zephyr/linker')
-rw-r--r--zephyr/linker/CMakeLists.txt4
-rw-r--r--zephyr/linker/end-of-ram.ld29
2 files changed, 33 insertions, 0 deletions
diff --git a/zephyr/linker/CMakeLists.txt b/zephyr/linker/CMakeLists.txt
index 94544d454b..adffc2246f 100644
--- a/zephyr/linker/CMakeLists.txt
+++ b/zephyr/linker/CMakeLists.txt
@@ -21,3 +21,7 @@ zephyr_linker_sources_ifdef(CONFIG_SOC_FAMILY_MEC ROM_START SORT_KEY 1
zephyr_linker_sources(DATA_SECTIONS iterables-ram.ld)
zephyr_linker_sources(SECTIONS iterables-rom.ld)
+
+# Ensure there's space for panic and jump data at the end of ram
+# Must be added to "SECTIONS" because this is applied last
+zephyr_linker_sources(SECTIONS end-of-ram.ld)
diff --git a/zephyr/linker/end-of-ram.ld b/zephyr/linker/end-of-ram.ld
new file mode 100644
index 0000000000..e03de7481d
--- /dev/null
+++ b/zephyr/linker/end-of-ram.ld
@@ -0,0 +1,29 @@
+/* Copyright 2022 The Chromium OS Authors.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* This section simply ensures there's enough unused space at the end of ram to
+ * hold panic and jump data. This space isn't directly allocated because it
+ * would result in the SRAM utilization always being reported as 100%.
+ */
+#if !defined(CONFIG_BOARD_NATIVE_POSIX)
+SECTION_PROLOGUE(.end_of_ram_info, 0, )
+{
+ ASSERT(DEFINED(_image_ram_end) && _image_ram_end > 0, "Error: _image_ram_end is not defined");
+
+#if defined(RAM_ADDR) && defined(RAM_SIZE)
+ PROVIDE(__unused_ram_start = _image_ram_end);
+ PROVIDE(__unused_ram_end = RAM_ADDR + RAM_SIZE);
+ PROVIDE(__unused_ram_size = __unused_ram_end - __unused_ram_start);
+ ASSERT(__unused_ram_size >= CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE,
+ "ERROR: Not enough space for preserved end of ram data (see PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE)");
+#endif
+
+#if defined(CONFIG_SHAREDMEM_MINIMUM_SIZE)
+ ASSERT(CONFIG_SHAREDMEM_MINIMUM_SIZE >= CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE,
+ "ERROR: Sharedmem must be at least large enough for preserved end of ram data");
+#endif
+
+}
+#endif