diff options
author | Andrew McRae <amcrae@google.com> | 2022-05-09 12:12:00 +1000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-05-10 16:30:44 +0000 |
commit | 55e00cff9917c94389cd7440e114ac4c0bdb2d83 (patch) | |
tree | 3868396292b3bea99fd5f4ea20f2800f54cda9dd /zephyr/CMakeLists.txt | |
parent | 3ce502272d2af53145b12d5a1f60778a92b30903 (diff) | |
download | chrome-ec-55e00cff9917c94389cd7440e114ac4c0bdb2d83.tar.gz |
zephyr: it81302: Enable divide-by-zero exception check
Enable the divide-by-zero exception check in the the compiler
for RISCV CPUs.
Without this change:
ec:~$ crash divzero
ffffffffCommand returned error: 1
With this change:
ec:~$ crash divzero
E:
E: mcause: 3, Breakpoint
E: mtval: 0
E: a0: 00000001 t0: 8010d988
E: a1: fffffffe t1: 00000020
E: a2: 00000000 t2: 00000000
E: a3: 000000c0 t3: 00000000
E: a4: 00f02700 t4: 00000001
E: a5: 00000008 t5: aaaaaaaa
E: a6: 00000011 t6: aaaaaaaa
E: a7: 00000000
E: tp: aaaaaaaa
E: ra: 80013866
E: mepc: 8001386a
E: mstatus: 00001880
E:
E: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
E: Current thread: 0x801063f0 (shell_uart)
E: Halting system
BUG=b:231844211
TEST=crash divzero
BRANCH=none
Signed-off-by: Andrew McRae <amcrae@google.com>
Cq-Depend: chromium:3637157
Change-Id: I4edf7d5b33d31a39d2172f3b8b1e4becdd94def4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3631725
Reviewed-by: Dino Li <Dino.Li@ite.com.tw>
Reviewed-by: Yuval Peress <peress@google.com>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Diffstat (limited to 'zephyr/CMakeLists.txt')
-rw-r--r-- | zephyr/CMakeLists.txt | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index ae3e8413b7..9173c67253 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -65,6 +65,10 @@ endif() # Set extra compiler flags. zephyr_cc_option(-mno-unaligned-access) +if (DEFINED CONFIG_RISCV) + zephyr_cc_option(-fsanitize=integer-divide-by-zero) + zephyr_cc_option(-fsanitize-undefined-trap-on-error) +endif() # The EC application is split into two libraries: # app: contains all the legacy code |