RISCV: Misaligned AMOs raise load-address-misaligned fault instead of store/amo-address-misaligned fault
<!--This is the upstream QEMU issue tracker. If you are able to, it will greatly facilitate bug triage if you attempt to reproduce the problem with the latest qemu.git master built from source. See https://www.qemu.org/download/#source for instructions on how to do this. QEMU generally supports the last two releases advertised on https://www.qemu.org/. Problems with distro-packaged versions of QEMU older than this should be reported to the distribution instead. See https://www.qemu.org/contribute/report-a-bug/ for additional guidance. If this is a security issue, please consult https://www.qemu.org/contribute/security-process/--> ## Host environment - QEMU flavor: ``` qemu-system-riscv64 ``` - QEMU version: ``` v10.2.2 ``` - QEMU command line: ``` qemu-system-riscv64 -d in_asm,int,mmu,unimp,cpu,fpu,vpu,exec,nochain -D amo_misaligned.trace.log -nographic -semihosting -icount shift=1 -machine virt -cpu max,pmu-mask=0xfffffff8,zama16b=off -bios amo_misaligned.elf ``` ## Description of problem I have disabled zama16b. Now, AMOs are correctly raising faults on misaligned accesses. However the fault being raised is load address misaligned fault instead of store/AMO address misaligned fault. Below is the outcome of executing amoadd.w with a misaligned address. `RVCP: Test Info: "Mismatch in mcause value! Trap was being handled in M-Mode."` `RVCP: Instruction: 0x00050413` `RVCP: Approximate address (failure may be slightly after this): 0x000000008000065c` `RVCP: Register: x8` `RVCP: Bad Value: 0x0000000000000004` `RVCP: Expected Value: 0x0000000000000006` `RVCP: Address of instruction that trapped (XEPC): 0x0000000080000084` `RVCP: Instruction that trapped: 0x00c7a6af` ## Additional information [amo_misaligned.elf](/uploads/9951e5bb3137701beefcd0b79db2fecd/amo_misaligned.elf) [amo_misaligned.trace.log](/uploads/80614472a5fbed448f7bdcc1aa69d0ce/amo_misaligned.trace.log)
issue