From: tewaro <tewaro@theorem.dev>
To: qemu-devel@nongnu.org
Cc: disclosures@theorem.dev, tewaro <tewaro@tewaro.org>
Subject: [PATCH 0/2] target/riscv: write mstatus.GVA on every trap into M-mode
Date: Mon, 2 Nov 2026 23:42:12 -0800 [thread overview]
Message-ID: <cover.1793677945.git.tewaro@theorem.dev> (raw)
Hi,
Based-on: <cover.1793677944.git.tewaro@theorem.dev>
("target/riscv: fix mtinst/htinst for G-stage faults on VS-stage A/D
updates", whose hyp-guest.h and hyp-guest.S this test reuses)
Patch 1 fixes mstatus.GVA. On every trap into M-mode, GVA should be
set to 1 if mtval holds a guest virtual address and to 0 otherwise [1].
QEMU does not clear gva or set GVA for particular faults.
Both date back to 9034e90ad9. The fix sets mstatus.GVA from write_gva,
the value QEMU already computes for hstatus.GVA.
Patch 2 adds a test, all 4 pass on upstream Spike, all fail on master.
This bug was found while examining <cover.1793677944.git.tewaro@theorem.dev>
and writing a generalized test. Claude was used to diagnose the issue. All
commits were human written.
[1] Privileged ISA v1.12, 8.2.1, the description of GVA and the note
under hstatus.GVA
https://github.com/riscv/riscv-isa-manual/releases/tag/Priv-v1.12
tewaro (2):
target/riscv: write mstatus.GVA on every trap into M-mode
tests/tcg/riscv64: test mstatus.GVA on traps into M-mode
target/riscv/tcg/cpu_helper.c | 4 +-
tests/tcg/riscv64/system/meson.build | 21 ++++++++
tests/tcg/riscv64/test-mstatus-gva.S | 75 ++++++++++++++++++++++++++++
3 files changed, 97 insertions(+), 3 deletions(-)
create mode 100644 tests/tcg/riscv64/test-mstatus-gva.S
--
2.54.0 (Apple Git-157)
next reply other threads:[~2026-11-03 7:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 7:42 tewaro [this message]
2026-11-03 7:42 ` [PATCH 1/2] target/riscv: write mstatus.GVA on every trap into M-mode tewaro
2026-11-03 7:42 ` [PATCH 2/2] tests/tcg/riscv64: test mstatus.GVA on traps " tewaro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1793677945.git.tewaro@theorem.dev \
--to=tewaro@theorem.dev \
--cc=disclosures@theorem.dev \
--cc=qemu-devel@nongnu.org \
--cc=tewaro@tewaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.