LoadVM assert on ARM_FEATURE_M for Cortex M3
Host environment
- Operating system: Ubuntu 20.04
- OS/kernel version: Linux 5.15.0-86-lowlatency
- Architecture: x86_64
- QEMU flavor: qemu-system-arm
- QEMU version: v8.0.0 through v8.2.0
- QEMU command line:
./qemu-system-arm -cpu cortex-m3 -M mps2-an385 -nographic -drive if=none,format=qcow2,file=test.qcow2 -monitor unix:/tmp/qemu-mon.sock,server,no-wait -serial mon:stdio
Emulated/Virtualized environment
- Operating system: -
- OS/kernel version: -
- Architecture: ARM Cortex M3
Description of problem
This appears to be a similar issue to #1775 (closed) and #1658 (closed)
When running loadvm
qemu aborts with this error:
"qemu/target/arm/helper.c:12383: arm_security_space_below_el3: Assertion `!arm_feature(env, ARM_FEATURE_M)' failed."
I've traced the error to pmu_counter_enabled
in qemu\target\arm\helper.c:1172
uint64_t mdcr_el2 = arm_mdcr_el2_eff(env) (link is to 8.2.0 release tag)
The issue is caused by attempting to get the MDCR_EL2 register prior to checking if the CPU has ARM_FEATURE_PMU support.
A simple fix seems to be to check for ARM_PMU_ENABLED
and returning early if it is not enabled.
Steps to reproduce
- Start emulation and connect monitor
- savevm
- Loadvm
Additional information
See screenshot for stack trace
Edited by Abigail Bonnice