summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2020-05-14 14:32:32 -0700
committerCommit Bot <commit-bot@chromium.org>2020-05-22 19:22:19 +0000
commit4116f1ae6996ecc87b000f335880f4457780ceb8 (patch)
tree00126544311d0817c534ed753a5ccc550c20e93b /core
parent67665bb55473e64da629df0546245e61e810927b (diff)
downloadchrome-ec-4116f1ae6996ecc87b000f335880f4457780ceb8.tar.gz
test: Add on-device MPU unit test
BRANCH=none BUG=b:151105339, b:155229277 TEST=make BOARD=bloonchipper test-mpu -j && \ ./util/flash_jlink.py --board bloonchipper \ --image ./build/bloonchipper/mpu/mpu.bin => On console: "runtest" => All tests pass, except last which correctly panics: Data access violation, mfar = 20000000 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I1c759f50da5075b1e9027cdba253d8c06843be5a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2202852 Commit-Queue: Yicheng Li <yichengli@chromium.org> Tested-by: Yicheng Li <yichengli@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/cortex-m/mpu.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/core/cortex-m/mpu.c b/core/cortex-m/mpu.c
index 7735c2d823..53fffaaaa5 100644
--- a/core/cortex-m/mpu.c
+++ b/core/cortex-m/mpu.c
@@ -65,6 +65,9 @@ int mpu_update_region(uint8_t region, uint32_t addr, uint8_t size_bit,
if (!is_aligned(addr, BIT(size_bit)))
return -EC_ERROR_INVAL;
+ if (region >= mpu_num_regions())
+ return -EC_ERROR_INVAL;
+
asm volatile("isb; dsb;");
MPU_NUMBER = region;