summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMary Ruthven <mruthven@chromium.org>2021-11-09 17:33:35 -0600
committerCommit Bot <commit-bot@chromium.org>2021-11-18 04:52:21 +0000
commitb22109815b95736de6815c6f4be01bbdc26a8277 (patch)
treee1570cbf0bf1e14309fbe34315fa6ec6ffbfa79e
parent827137140f557f6704aef54e99d668afb3cc6e20 (diff)
downloadchrome-ec-b22109815b95736de6815c6f4be01bbdc26a8277.tar.gz
Revert "cortex-m: mpu: Support unaligned regions and protect code RAM"
This reverts commit b6991dd96d8bf6cb86a39b3da590ccd8b4e1e036. BUG=b:200823466 TEST=make buildall -j Change-Id: Iad57119388644c5b3f3b667d92dbcb3f33efe7ab Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3273443 Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org>
-rw-r--r--common/system.c34
1 files changed, 11 insertions, 23 deletions
diff --git a/common/system.c b/common/system.c
index 8cf7580dbe..f787f8865c 100644
--- a/common/system.c
+++ b/common/system.c
@@ -324,34 +324,23 @@ void system_disable_jump(void)
#ifdef CONFIG_MPU
if (system_is_locked()) {
int ret;
- enum system_image_copy_t __attribute__((unused)) copy;
+ int enable_mpu = 0;
+ enum system_image_copy_t copy;
CPRINTS("MPU type: %08x", mpu_get_type());
/*
- * Protect data RAM from code execution
+ * Protect RAM from code execution
*/
- ret = mpu_protect_data_ram();
+ ret = mpu_protect_ram();
if (ret == EC_SUCCESS) {
- CPRINTS("data RAM locked. Exclusion %pP-%pP",
+ enable_mpu = 1;
+ CPRINTS("data RAM locked. Exclusion %08lx-%08lx",
&__iram_text_start,
&__iram_text_end);
} else {
- CPRINTS("Failed to lock data RAM (%d)", ret);
- return;
+ CPRINTS("Failed to lock RAM (%d)", ret);
}
-#ifdef CONFIG_EXTERNAL_STORAGE
- /*
- * Protect code RAM from being overwritten
- */
- ret = mpu_protect_code_ram();
- if (ret == EC_SUCCESS) {
- CPRINTS("code RAM locked.");
- } else {
- CPRINTS("Failed to lock code RAM (%d)", ret);
- return;
- }
-#else
/*
* Protect inactive image (ie. RO if running RW, vice versa)
* from code execution.
@@ -370,21 +359,20 @@ void system_disable_jump(void)
ret = !EC_SUCCESS;
}
if (ret == EC_SUCCESS) {
+ enable_mpu = 1;
CPRINTS("%s image locked",
system_image_copy_t_to_string(copy));
} else {
CPRINTS("Failed to lock %s image (%d)",
system_image_copy_t_to_string(copy), ret);
- return;
}
-#endif /* !CONFIG_EXTERNAL_STORAGE */
- /* All regions were configured successfully, enable MPU */
- mpu_enable();
+ if (enable_mpu)
+ mpu_enable();
} else {
CPRINTS("System is unlocked. Skip MPU configuration");
}
-#endif /* CONFIG_MPU */
+#endif
}
test_mockable enum system_image_copy_t system_get_image_copy(void)