summaryrefslogtreecommitdiff
path: root/common/system.c
diff options
context:
space:
mode:
authorFabio Baltieri <fabiobaltieri@google.com>2021-06-09 16:22:34 +0000
committerCommit Bot <commit-bot@chromium.org>2021-06-14 21:37:50 +0000
commit9efe07cf273a1bbe9bde1854a2884809d3c11be7 (patch)
tree35a536d87f4e6a26fd75b00536e970a3fe3b965e /common/system.c
parent592ef1dafdd59629df85b9852fbb629c0323acd6 (diff)
downloadchrome-ec-9efe07cf273a1bbe9bde1854a2884809d3c11be7.tar.gz
zephyr: shim: add mpu enable and disable support
Add support for allowing the EC code to control the MPU setup. ECOS code used to handle configuration as well as MPU enable/disable. Zephyr has its own way of handling MPU configuration, so that part of the EC code is compiled out, instead make sure that the fixed MPU regions (that cover code & data) are disabled before the EC code starts, and then enable them when mpu_enable() is called Zephyr APIs do not expose any memory protection funciontality outside of the arch specific code, so this sets the MPU regiers directly. That's not very elegant, but it's done in a sample application as well [1], so it should be an acceptable approach. Disabling the MPU unit entirely could also be an option, but only doing the fixed regions has the advantage of leaving the stack protection and null pointer detection regions enabled. [1] https://github.com/zephyrproject-rtos/zephyr/blob/main/samples/application_development/code_relocation/src/main.c BRANCH=none BUG=b:180039888 TEST=actually tried to write in the static region, verified it fauls after sysjump disable Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I020c347e5f1b929500d4cf1c4c400dcd67e78dfa Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2950168 Reviewed-by: Yuval Peress <peress@chromium.org>
Diffstat (limited to 'common/system.c')
-rw-r--r--common/system.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/common/system.c b/common/system.c
index eaaa9c664b..6da5b538c7 100644
--- a/common/system.c
+++ b/common/system.c
@@ -388,6 +388,7 @@ void system_disable_jump(void)
#ifdef CONFIG_MPU
if (system_is_locked()) {
+#ifndef CONFIG_ZEPHYR
int ret;
enum ec_image __attribute__((unused)) copy;
@@ -443,6 +444,7 @@ void system_disable_jump(void)
return;
}
#endif /* !CONFIG_EXTERNAL_STORAGE */
+#endif /* !CONFIG_ZEPHYR */
/* All regions were configured successfully, enable MPU */
mpu_enable();