Zephyr TF-M IPC example triggers failed assertion !arm_feature(env, ARM_FEATURE_M) on recent Qemu
Host environment
- Operating system: Debian Sid (bookworm)
- OS/kernel version: Linux 6.1.0-7-amd64 SMP PREEMPT_DYNAMIC Debian 6.1.20-1 (2023-03-19) x86_64 GNU/Linux
- Architecture: x86_64
- QEMU flavor: qemu-system-arm
- QEMU version: v8.0.0-918-g6972ef14
- QEMU command line: qemu-system-arm -M mps2-an521 -device loader,file=tfm_merged.hex -serial stdio
Emulated/Virtualized environment
- Operating system: TF-M / Zephyr
- OS/kernel version: Zephyr 7ba5ecf451 https://github.com/zephyrproject-rtos/zephyr/commit/7ba5ecf451ef29f96b30dbe5f0e54c1865839093
- Architecture: ARM Cortex-M33, Armv8-M with TrustZone
Description of problem
I can't run the TrustedFirmware-M IPC example in the Zephyr repo with recent Qemu (in particular v8.0.0).
By bisecting, I got the last commit OK : v7.2.0-351-gfaa1451e
$ qemu-system-arm -M mps2-an521 -device loader,file=tfm_merged.hex -serial stdio
[INF] Beginning TF-M provisioning
[WRN] TFM_DUMMY_PROVISIONING is not suitable for production! This device is NOT SECURE
[Sec Thread] Secure image initializing!
Booting TF-M 8209cb2ed
Creating an empty ITS flash layout.
Creating an empty PS flash layout.
[INF][Crypto] Provisioning entropy seed... complete.
*** Booting Zephyr OS build zephyr-v3.3.0-4041-g7ba5ecf451ef ***
TF-M IPC on mps2_an521_ns
The version of the PSA Framework API is 257.
The PSA Crypto service minor version is 1.
Generating 256 bytes of random data:
71 03 DD 50 8E E5 00 C7 E0 61 7B EB 77 15 E9 38
E9 A8 7D 0C 51 23 76 9F C3 61 E9 8B 8A 67 BD 14
73 A3 2C 6E E5 8C E3 19 53 6B 50 55 A8 A7 F4 7B
56 03 60 AA 48 B6 DF 04 33 56 BE 84 43 FA 4E AC
D7 6E 2E 2E 1D 7E 46 69 D5 9B B0 42 5C 54 E4 09
73 9E 4F 55 F8 3E 05 9E A3 DE 46 D3 E4 02 B0 9C
F3 21 9F 20 85 74 34 07 19 79 07 B8 02 B5 0E 90
74 21 BE B5 09 4C D7 20 D8 43 F7 72 23 1C F0 3E
77 7B D3 70 29 72 69 D3 7F 1F 61 16 12 73 D5 89
C5 8B D1 A3 7B 4B FD F5 11 C2 B1 9A C0 A5 F9 7B
16 3D 98 17 66 FE E9 F4 FE 37 76 62 E0 E6 83 99
69 26 41 CD FF 0C 44 AC F9 F4 91 B8 CA 63 5E 1D
B9 C4 38 D6 0C 11 19 1B 94 BE C9 4F EC 2E 5A 05
3F 72 5F 41 44 3C 91 39 AC 2D 50 75 DF FD D3 11
39 F2 43 18 D7 69 B0 A3 99 0C C0 6E 83 84 1A A8
B0 37 6C 8E 32 B2 8E 4F AA 12 97 09 09 87 D3 FD
qemu-system-arm: terminating on signal 2
But after 452c67a4, for example v8.0.0-918-g6972ef14, I get :
$ qemu-system-arm -M mps2-an521 -device loader,file=tfm_merged.hex -serial stdio
[INF] Beginning TF-M provisioning
[WRN] TFM_DUMMY_PROVISIONING is not suitable for production! This device is NOT SECURE
[Sec Thread] Secure image initializing!
Booting TF-M 8209cb2ed
Creating an empty ITS flash layout.
Creating an empty PS flash layout.
[INF][Crypto] Provisioning entropy seed... complete.
*** Booting Zephyr OS build zephyr-v3.3.0-4041-g7ba5ecf451ef ***
TF-M IPC on mps2_an521_ns
qemu-system-arm: ../target/arm/cpu.h:2396: arm_is_secure_below_el3: Assertion `!arm_feature(env, ARM_FEATURE_M)' failed.
Aborted
Steps to reproduce
- Build the Zephyr tfm_merged.hex file from Zephyr 7ba5ecf451 https://github.com/zephyrproject-rtos/zephyr/commit/7ba5ecf451ef29f96b30dbe5f0e54c1865839093 :
west -v build -p -b mps2_an521_ns ./samples/tfm_integration/tfm_ipc
- Build qemu-system-arm and run :
qemu-system-arm -M mps2-an521 -device loader,file=tfm_merged.hex -serial stdio
Additional information
More info to build Zephyr TF-M IPC example on the official repo https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/tfm_integration/tfm_ipc
Edited by Rehan MALAK