target/riscv: AMO to a Zicfiss shadow-stack page with A=0 raises a store/AMO page fault instead of an access fault
What is wrong
With Zicfiss enabled (menvcfg.SSE = 1) and Sv39, an AMO from S-mode to a shadow-stack page (R=0, W=1, X=0) whose PTE has A = 0 and D = 0 raises a store/AMO page fault (scause 15). Ordinary stores (sb/sh/sw/sd) to the same page in the same state correctly raise a store/AMO access fault (scause 7).
In get_physical_address() (target/riscv/tcg/cpu_helper.c), a non-shadow-stack access to an SS page gets rwx = PTE_R unless it is a probe. The AMO appears to reach the A/D check through that read permission, so with menvcfg.ADUE = 0 it fails on A = 0 before anything rejects the write to the SS page.
Correct behavior
The AMO should raise a store/AMO access fault (scause 7), as the stores do. The privileged spec (cfi.adoc, Shadow Stack Memory Protection) says: "Memory mapped as an SS page cannot be written to by instructions other than ssamoswap.w, ssamoswap.d, sspush, and c.sspush. Attempts will raise a store/AMO access-fault exception." Its read exception covers only "instructions that only load from memory", which excludes AMOs.
Reproduce
2026-11-08-qemu-zicfiss-amo-ss-page-ad.tar.gz
qemu-system-riscv64 -nographic -semihosting -icount shift=1 -machine virt,aia=aplic-imsic,aia-guests=7 -cpu max,smpmpmt=false,pmu-mask=0xfffffff8,smdbltrp=true,ssdbltrp=true -bios Zicfiss_S_page_access_ad-00.elfThe test (from riscv-arch-test) maps the SS page with A = D = 0, runs the four stores and then amoswap.w, amoadd.w, amoor.w, amoswap.d and amoadd.d from S-mode, and checks each trap. QEMU 11.1.3 and master (76fdb337) report scause 15, xepc = the amoswap.w at 0x80001410, stval 0x140300000. The README in the tarball lists the files.
Other simulators
Sail and Spike (c20813c) raise scause 7 for every store and AMO in this test.