aboutsummaryrefslogtreecommitdiff
path: root/target/riscv/machine.c
diff options
context:
space:
mode:
authorMayuresh Chitale <mchitale@ventanamicro.com>2022-10-16 18:17:22 +0530
committerAlistair Francis <alistair.francis@wdc.com>2023-01-06 10:42:55 +1000
commit3bee0e40106df7926e38464d0e9f34a57a0a01ad (patch)
tree14569db98c7c1bb0692c6e296522125cde71fd35 /target/riscv/machine.c
parentaefd1108ee8efe4a11fafdaf03c593b8b953aa4e (diff)
downloadqemu-3bee0e40106df7926e38464d0e9f34a57a0a01ad.zip
qemu-3bee0e40106df7926e38464d0e9f34a57a0a01ad.tar.gz
qemu-3bee0e40106df7926e38464d0e9f34a57a0a01ad.tar.bz2
target/riscv: Add smstateen support
Smstateen extension specifies a mechanism to close the potential covert channels that could cause security issues. This patch adds the CSRs defined in the specification and the corresponding predicates and read/write functions. Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com> Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-Id: <20221016124726.102129-2-mchitale@ventanamicro.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Diffstat (limited to 'target/riscv/machine.c')
-rw-r--r--target/riscv/machine.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/target/riscv/machine.c b/target/riscv/machine.c
index c2a94a8..e687f9f 100644
--- a/target/riscv/machine.c
+++ b/target/riscv/machine.c
@@ -253,6 +253,26 @@ static int riscv_cpu_post_load(void *opaque, int version_id)
return 0;
}
+static bool smstateen_needed(void *opaque)
+{
+ RISCVCPU *cpu = opaque;
+
+ return cpu->cfg.ext_smstateen;
+}
+
+static const VMStateDescription vmstate_smstateen = {
+ .name = "cpu/smtateen",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .needed = smstateen_needed,
+ .fields = (VMStateField[]) {
+ VMSTATE_UINT64_ARRAY(env.mstateen, RISCVCPU, 4),
+ VMSTATE_UINT64_ARRAY(env.hstateen, RISCVCPU, 4),
+ VMSTATE_UINT64_ARRAY(env.sstateen, RISCVCPU, 4),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
static bool envcfg_needed(void *opaque)
{
RISCVCPU *cpu = opaque;
@@ -364,6 +384,7 @@ const VMStateDescription vmstate_riscv_cpu = {
&vmstate_kvmtimer,
&vmstate_envcfg,
&vmstate_debug,
+ &vmstate_smstateen,
NULL
}
};