QEMU increments instret for ecall

Host environment

  • Operating system:

    AlmaLinux 9.7

  • Architecture:

    x86_64

  • QEMU flavor:

    qemu-system-riscv64

  • QEMU version:

    QEMU 11.0.2

  • QEMU command line:

    qemu-system-riscv32 -d in_asm,int,mmu,unimp,cpu,fpu,vpu,exec,nochain -D ZicntrS-00.trace.log -nographic -semihosting -icount shift=1 -machine virt -cpu max,pmu-mask=0xfffffff8,smdbltrp=true,ssdbltrp=true -bios ZicntrS-00.elf

Description of problem

The spec states that "As ECALL and EBREAK cause synchronous exceptions, they are not considered to retire, and should not increment the minstret CSR." However, QEMU does increment instret on ecall.

Steps to reproduce

  1. Run the attached elf file with the QEMU command line

Additional information

ZicntrS-00.elf.gz

ZicntrS-00.log.gz

The behavior appears when QEMU is run with:

-icount shift=1