All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] target/riscv: Add mseccfg to VMStateDescription
@ 2026-05-11 12:48 Zishun Yi
  2026-05-11 12:54 ` Daniel P. Berrangé
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Zishun Yi @ 2026-05-11 12:48 UTC (permalink / raw)
  To: Alistair Francis, Palmer Dabbelt
  Cc: Weiwei Li, Daniel Henrique Barboza, Liu Zhiwei, Chao Liu,
	qemu-riscv, qemu-devel, Zishun Yi

Currently, the Machine Security Configuration Register (mseccfg) was
missing from the live migration state. This omission causes the register
to be reset to zero on the destination host after migration.

Fixed by adding vmstate_mseccfg subsection

This vulnerability was discovered and reported by SpecHunter, an
AI-driven architecture specification analysis tool.

Link: https://github.com/yizishun/rv-isa-sec/blob/a22e4459cd026ae970791dfbd9cfe5d110fbd46b/output/riscv-isa-manual/pr-1879/qemu.txt#L121
Signed-off-by: Zishun Yi <vulab@iscas.ac.cn>
---
 target/riscv/machine.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/target/riscv/machine.c b/target/riscv/machine.c
index 09c032a87914..6776e7bf5a11 100644
--- a/target/riscv/machine.c
+++ b/target/riscv/machine.c
@@ -423,6 +423,25 @@ static const VMStateDescription vmstate_sstc = {
     }
 };
 
+static bool mseccfg_needed(void *opaque)
+{
+    RISCVCPU *cpu = opaque;
+
+    return cpu->cfg.ext_smepmp || cpu->cfg.ext_zkr
+        || cpu->cfg.ext_smmpm || cpu->cfg.ext_zicfilp;
+}
+
+static const VMStateDescription vmstate_mseccfg = {
+    .name = "cpu/mseccfg",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .needed = mseccfg_needed,
+    .fields = (const VMStateField[]) {
+        VMSTATE_UINTTL(env.mseccfg, RISCVCPU),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 const VMStateDescription vmstate_riscv_cpu = {
     .name = "cpu",
     .version_id = 11,
@@ -499,6 +518,7 @@ const VMStateDescription vmstate_riscv_cpu = {
         &vmstate_ssp,
         &vmstate_ctr,
         &vmstate_sstc,
+        &vmstate_mseccfg,
         NULL
     }
 };
-- 
2.51.2



^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-06-01 21:08 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-11 12:48 [PATCH v1] target/riscv: Add mseccfg to VMStateDescription Zishun Yi
2026-05-11 12:54 ` Daniel P. Berrangé
2026-05-18  0:39 ` Alistair Francis
2026-05-18  0:42 ` Alistair Francis
2026-05-26  7:26 ` Michael Tokarev
2026-05-26  7:32   ` Michael Tokarev
2026-05-26 23:57   ` Alistair Francis
2026-05-27  7:03     ` Michael Tokarev
2026-05-27 12:20       ` Fabiano Rosas
2026-05-27 13:18         ` Peter Xu
2026-05-29  7:43         ` Michael Tokarev
2026-06-01 21:07           ` Peter Xu

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.