From nobody Fri May  9 09:34:30 2025
Delivered-To: importer@patchew.org
Authentication-Results: mx.zohomail.com;
	dkim=fail  header.i=@wdc.com;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=fail(p=none dis=none)  header.from=wdc.com
ARC-Seal: i=1; a=rsa-sha256; t=1620728846; cv=none;
	d=zohomail.com; s=zohoarc;
	b=dyuQtyQSRPOa18R9AnBis0ZvmvNjo5EN4sxokhHr7F9+D04063VAriUmF6EECuZCThBdX3T34PDDuDThsIj0nksuNmrK3tiwTChKLhGFEQnyLeB+dGY6/iNQJwbDd4sPqC34NOrOcVT/T7B7jyFkBLHK+q3Reun/0HxbQ6cV+n8=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;
 s=zohoarc;
	t=1620728846;
 h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To;
	bh=77jST2TftMFGeVkAF6nfLL/mjHLx0rItvrssyGcqgB0=;
	b=L1v9FWMPtaSOX8n6CVr45kBvgd921RA/CKkBh05dvxQhcl4Aoka6w6dM/qhNcYMr1o3AcHQa07l/E+MMkkJphBoWlWAsfTNJAqbJLXvqbFRYQI89XxetO7Ls+TfEqdX/YLuXLZ9s28kwETJO7ve4f7F7+edwPsGhKqDjlNATuGo=
ARC-Authentication-Results: i=1; mx.zohomail.com;
	dkim=fail  header.i=@wdc.com;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=fail header.from=<alistair.francis@wdc.com> (p=none dis=none)
 header.from=<alistair.francis@wdc.com>
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 1620728846373523.221679356266;
 Tue, 11 May 2021 03:27:26 -0700 (PDT)
Received: from localhost ([::1]:48882 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1lgPbp-0004b8-6D
	for importer@patchew.org; Tue, 11 May 2021 06:27:25 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:37602)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1)
 (envelope-from <prvs=7584e029c=alistair.francis@wdc.com>)
 id 1lgPUu-0008Jp-LR
 for qemu-devel@nongnu.org; Tue, 11 May 2021 06:20:21 -0400
Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41098)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1)
 (envelope-from <prvs=7584e029c=alistair.francis@wdc.com>)
 id 1lgPUn-0006V6-8z
 for qemu-devel@nongnu.org; Tue, 11 May 2021 06:20:15 -0400
Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com)
 ([199.255.45.14])
 by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:20:05 +0800
Received: from uls-op-cesaip01.wdc.com ([10.248.3.36])
 by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 11 May 2021 03:00:04 -0700
Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48])
 by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:20:03 -0700
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
 d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com;
 t=1620728407; x=1652264407;
 h=from:to:cc:subject:date:message-id:in-reply-to:
 references:mime-version:content-transfer-encoding;
 bh=BdYYVeUYgq1mi3A8UHIIcrCtropB7TiiKZWRQSAagxg=;
 b=KmfMBAq/+/gYJvq9BKqOUL4ycGEtqwEZY2rQ3TZ496fz3mjw1ICPU7l9
 SLis5aWnNUwQEG99RjFBz41Rd4aU61BlnxctpGs1BJKYaapTnY8LQc0tJ
 9yDX9Hje6wgm5TZeUN9ubnoLzELZR7eN3BdcPtNgjX3sa0yGM6XA3pJfB
 Ho9KMG6v/zAkPcGhOxmhP+MuzO7s9bB7m/8HMc+hNXQza6beEDNhcW48Z
 nFe+kLGzWFKbVHDnfQPPMpw0XLnk4UJmHz4aUxpQ4aXU7Rjc8hubB8f+j
 bG8/U8n1mnt30k5DOco4C2oLKC/U0IaWtf3tWXnyTG0HWp/KmnWx2iERE w==;
IronPort-SDR: 
 DRurbCGvTwk5yELL0a8Jg2aqfCWdSgKRgVJl8MlPEV3P7eFdAmKAl1FBUfSgS7o4G9YXxE2kKm
 LPZLrJnDdSSYKfasGcS2U9pWrEYDFWXiUVjAZfzqOakHM9+PPggvJvAO9kbwccLjbeyvRNaOOT
 xAXG4ceBw0u3s9FC+dBPm+386PCc/u9l3cQrcl41/AOIsQJNM7QQbM82OoKr/3B3AMm77oGIbb
 +tPoGjCLx6QIr0pA4z9OGbhZ+7ldN+4Qff8QUohsP09+4XCsGPgX6a8B1D55XF/4wLFap7osIW
 GcM=
X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735325"
IronPort-SDR: 
 f14K/L3Qh8hlUHQL0rf9qTZM0jP8Fz+g4vAzcStNy8ifCYSkvKCwsafmZalmHwP242uKSInPvG
 /yvrqPF/ZTZl55URwFS3Bct9LmR6QNpGodfwhj/JZXKZUpAhooGS2y+dYc+vJiyJgoNlqU0oyx
 8eonMrGCsHxHo8NgNFJ2Tp3BiPSq3XiBNybuSf25bX1IMFtcqU/VD4HMTFpdztfFT8oeRQS1SY
 pDovQiCnVGGMhLaJ0b6GjCinrEwCNttxZVQXCmebMdqknwcS1QYOAXM1980dFtECHwLzHmnqtV
 +bXLUpAV4Yp/t44YB1r5rHo9
IronPort-SDR: 
 vTjTenOGJk2HKyjCn5yko6iy+rqdjCmUXV4TlsKSyLtDHnoqPP84yOfj416t5RtpE7O3fvwgQ9
 3amaSOvbR6qpEvJrdhOkrwJDHy4hWA7xar2XxRCOPrvQ6RKlGpykeR5gQo6lLYKJP7z1LdZTRK
 rnUgp8478TeOwrUIW6CsFPGrV2W0TJb2MLXpjOnf+5m6+H0JCU5r5ekknr9/SjhZvxheqCYhwZ
 QSoU65pjUotUhJk1BIoqVc+GKRIswoWEUZu0EYqvh+b3i2zXi6pTn3k5GEe9lJVJiWYdwjryB7
 9rU=
WDCIronportException: Internal
From: Alistair Francis <alistair.francis@wdc.com>
To: peter.maydell@linaro.org
Subject: [PULL v3 01/42] target/riscv: Remove privilege v1.9 specific CSR
 related code
Date: Tue, 11 May 2021 20:19:10 +1000
Message-Id: <20210511101951.165287-2-alistair.francis@wdc.com>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com>
References: <20210511101951.165287-1-alistair.francis@wdc.com>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17
 as permitted sender) client-ip=209.51.188.17;
 envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org;
 helo=lists.gnu.org;
Received-SPF: pass client-ip=216.71.153.144;
 envelope-from=prvs=7584e029c=alistair.francis@wdc.com;
 helo=esa5.hgst.iphmx.com
X-Spam_score_int: -27
X-Spam_score: -2.8
X-Spam_bar: --
X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.23
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: alistair23@gmail.com, Alistair Francis <alistair.francis@wdc.com>,
 qemu-devel@nongnu.org, Atish Patra <atish.patra@wdc.com>
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
X-ZohoMail-DKIM: fail (Header signature does not verify)
Content-Type: text/plain; charset="utf-8"

From: Atish Patra <atish.patra@wdc.com>

Qemu doesn't support RISC-V privilege specification v1.9. Remove the
remaining v1.9 specific references from the implementation.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-Id: <20210319194534.2082397-2-atish.patra@wdc.com>
[Changes by AF:
 - Rebase on latest patches
 - Bump the vmstate_riscv_cpu version_id and minimum_version_id
 ]
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 target/riscv/cpu.h        |  4 +---
 target/riscv/cpu_bits.h   | 23 ---------------------
 target/riscv/cpu.c        |  2 +-
 target/riscv/cpu_helper.c | 12 +++++------
 target/riscv/csr.c        | 42 ++++++++++-----------------------------
 target/riscv/machine.c    |  8 +++-----
 target/riscv/translate.c  |  4 ++--
 7 files changed, 23 insertions(+), 72 deletions(-)

diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
index 0a33d387ba..311b1db875 100644
--- a/target/riscv/cpu.h
+++ b/target/riscv/cpu.h
@@ -163,10 +163,8 @@ struct CPURISCVState {
     target_ulong mie;
     target_ulong mideleg;
=20
-    target_ulong sptbr;  /* until: priv-1.9.1 */
     target_ulong satp;   /* since: priv-1.10.0 */
-    target_ulong sbadaddr;
-    target_ulong mbadaddr;
+    target_ulong stval;
     target_ulong medeleg;
=20
     target_ulong stvec;
diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h
index caf4599207..b42dd4f8d8 100644
--- a/target/riscv/cpu_bits.h
+++ b/target/riscv/cpu_bits.h
@@ -153,12 +153,6 @@
 /* 32-bit only */
 #define CSR_MSTATUSH        0x310
=20
-/* Legacy Counter Setup (priv v1.9.1) */
-/* Update to #define CSR_MCOUNTINHIBIT 0x320 for 1.11.0 */
-#define CSR_MUCOUNTEREN     0x320
-#define CSR_MSCOUNTEREN     0x321
-#define CSR_MHCOUNTEREN     0x322
-
 /* Machine Trap Handling */
 #define CSR_MSCRATCH        0x340
 #define CSR_MEPC            0x341
@@ -166,9 +160,6 @@
 #define CSR_MTVAL           0x343
 #define CSR_MIP             0x344
=20
-/* Legacy Machine Trap Handling (priv v1.9.1) */
-#define CSR_MBADADDR        0x343
-
 /* Supervisor Trap Setup */
 #define CSR_SSTATUS         0x100
 #define CSR_SEDELEG         0x102
@@ -184,9 +175,6 @@
 #define CSR_STVAL           0x143
 #define CSR_SIP             0x144
=20
-/* Legacy Supervisor Trap Handling (priv v1.9.1) */
-#define CSR_SBADADDR        0x143
-
 /* Supervisor Protection and Translation */
 #define CSR_SPTBR           0x180
 #define CSR_SATP            0x180
@@ -354,14 +342,6 @@
 #define CSR_MHPMCOUNTER30H  0xb9e
 #define CSR_MHPMCOUNTER31H  0xb9f
=20
-/* Legacy Machine Protection and Translation (priv v1.9.1) */
-#define CSR_MBASE           0x380
-#define CSR_MBOUND          0x381
-#define CSR_MIBASE          0x382
-#define CSR_MIBOUND         0x383
-#define CSR_MDBASE          0x384
-#define CSR_MDBOUND         0x385
-
 /* mstatus CSR bits */
 #define MSTATUS_UIE         0x00000001
 #define MSTATUS_SIE         0x00000002
@@ -375,10 +355,8 @@
 #define MSTATUS_FS          0x00006000
 #define MSTATUS_XS          0x00018000
 #define MSTATUS_MPRV        0x00020000
-#define MSTATUS_PUM         0x00040000 /* until: priv-1.9.1 */
 #define MSTATUS_SUM         0x00040000 /* since: priv-1.10 */
 #define MSTATUS_MXR         0x00080000
-#define MSTATUS_VM          0x1F000000 /* until: priv-1.9.1 */
 #define MSTATUS_TVM         0x00100000 /* since: priv-1.10 */
 #define MSTATUS_TW          0x00200000 /* since: priv-1.10 */
 #define MSTATUS_TSR         0x00400000 /* since: priv-1.10 */
@@ -416,7 +394,6 @@
 #define SSTATUS_SPP         0x00000100
 #define SSTATUS_FS          0x00006000
 #define SSTATUS_XS          0x00018000
-#define SSTATUS_PUM         0x00040000 /* until: priv-1.9.1 */
 #define SSTATUS_SUM         0x00040000 /* since: priv-1.10 */
 #define SSTATUS_MXR         0x00080000
=20
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index 7d6ed80f6b..86e7dbeb20 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -282,7 +282,7 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f,=
 int flags)
         qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "vscause ", env->vscaus=
e);
     }
     qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtval ", env->mtval);
-    qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "stval ", env->sbadaddr);
+    qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "stval ", env->stval);
     if (riscv_has_ext(env, RVH)) {
         qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "htval ", env->htval);
         qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtval2 ", env->mtval2);
diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
index 21c54ef561..503c2559f8 100644
--- a/target/riscv/cpu_helper.c
+++ b/target/riscv/cpu_helper.c
@@ -136,8 +136,8 @@ void riscv_cpu_swap_hypervisor_regs(CPURISCVState *env)
         env->vscause =3D env->scause;
         env->scause =3D env->scause_hs;
=20
-        env->vstval =3D env->sbadaddr;
-        env->sbadaddr =3D env->stval_hs;
+        env->vstval =3D env->stval;
+        env->stval =3D env->stval_hs;
=20
         env->vsatp =3D env->satp;
         env->satp =3D env->satp_hs;
@@ -159,8 +159,8 @@ void riscv_cpu_swap_hypervisor_regs(CPURISCVState *env)
         env->scause_hs =3D env->scause;
         env->scause =3D env->vscause;
=20
-        env->stval_hs =3D env->sbadaddr;
-        env->sbadaddr =3D env->vstval;
+        env->stval_hs =3D env->stval;
+        env->stval =3D env->vstval;
=20
         env->satp_hs =3D env->satp;
         env->satp =3D env->vsatp;
@@ -1023,7 +1023,7 @@ void riscv_cpu_do_interrupt(CPUState *cs)
         env->mstatus =3D s;
         env->scause =3D cause | ((target_ulong)async << (TARGET_LONG_BITS =
- 1));
         env->sepc =3D env->pc;
-        env->sbadaddr =3D tval;
+        env->stval =3D tval;
         env->htval =3D htval;
         env->pc =3D (env->stvec >> 2 << 2) +
             ((async && (env->stvec & 3) =3D=3D 1) ? cause * 4 : 0);
@@ -1054,7 +1054,7 @@ void riscv_cpu_do_interrupt(CPUState *cs)
         env->mstatus =3D s;
         env->mcause =3D cause | ~(((target_ulong)-1) >> async);
         env->mepc =3D env->pc;
-        env->mbadaddr =3D tval;
+        env->mtval =3D tval;
         env->mtval2 =3D mtval2;
         env->pc =3D (env->mtvec >> 2 << 2) +
             ((async && (env->mtvec & 3) =3D=3D 1) ? cause * 4 : 0);
diff --git a/target/riscv/csr.c b/target/riscv/csr.c
index d2585395bf..de7427d8f8 100644
--- a/target/riscv/csr.c
+++ b/target/riscv/csr.c
@@ -644,26 +644,6 @@ static int write_mcounteren(CPURISCVState *env, int cs=
rno, target_ulong val)
     return 0;
 }
=20
-/* This regiser is replaced with CSR_MCOUNTINHIBIT in 1.11.0 */
-static int read_mscounteren(CPURISCVState *env, int csrno, target_ulong *v=
al)
-{
-    if (env->priv_ver < PRIV_VERSION_1_11_0) {
-        return -RISCV_EXCP_ILLEGAL_INST;
-    }
-    *val =3D env->mcounteren;
-    return 0;
-}
-
-/* This regiser is replaced with CSR_MCOUNTINHIBIT in 1.11.0 */
-static int write_mscounteren(CPURISCVState *env, int csrno, target_ulong v=
al)
-{
-    if (env->priv_ver < PRIV_VERSION_1_11_0) {
-        return -RISCV_EXCP_ILLEGAL_INST;
-    }
-    env->mcounteren =3D val;
-    return 0;
-}
-
 /* Machine Trap Handling */
 static int read_mscratch(CPURISCVState *env, int csrno, target_ulong *val)
 {
@@ -701,15 +681,15 @@ static int write_mcause(CPURISCVState *env, int csrno=
, target_ulong val)
     return 0;
 }
=20
-static int read_mbadaddr(CPURISCVState *env, int csrno, target_ulong *val)
+static int read_mtval(CPURISCVState *env, int csrno, target_ulong *val)
 {
-    *val =3D env->mbadaddr;
+    *val =3D env->mtval;
     return 0;
 }
=20
-static int write_mbadaddr(CPURISCVState *env, int csrno, target_ulong val)
+static int write_mtval(CPURISCVState *env, int csrno, target_ulong val)
 {
-    env->mbadaddr =3D val;
+    env->mtval =3D val;
     return 0;
 }
=20
@@ -853,15 +833,15 @@ static int write_scause(CPURISCVState *env, int csrno=
, target_ulong val)
     return 0;
 }
=20
-static int read_sbadaddr(CPURISCVState *env, int csrno, target_ulong *val)
+static int read_stval(CPURISCVState *env, int csrno, target_ulong *val)
 {
-    *val =3D env->sbadaddr;
+    *val =3D env->stval;
     return 0;
 }
=20
-static int write_sbadaddr(CPURISCVState *env, int csrno, target_ulong val)
+static int write_stval(CPURISCVState *env, int csrno, target_ulong val)
 {
-    env->sbadaddr =3D val;
+    env->stval =3D val;
     return 0;
 }
=20
@@ -1419,13 +1399,11 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] =3D {
=20
     [CSR_MSTATUSH]    =3D { "mstatush",   any32, read_mstatush,    write_m=
statush    },
=20
-    [CSR_MSCOUNTEREN] =3D { "msounteren", any,   read_mscounteren, write_m=
scounteren },
-
     /* Machine Trap Handling */
     [CSR_MSCRATCH] =3D { "mscratch", any,  read_mscratch, write_mscratch },
     [CSR_MEPC]     =3D { "mepc",     any,  read_mepc,     write_mepc     },
     [CSR_MCAUSE]   =3D { "mcause",   any,  read_mcause,   write_mcause   },
-    [CSR_MBADADDR] =3D { "mbadaddr", any,  read_mbadaddr, write_mbadaddr },
+    [CSR_MTVAL]    =3D { "mtval",    any,  read_mtval,    write_mtval    },
     [CSR_MIP]      =3D { "mip",      any,  NULL,    NULL, rmw_mip        },
=20
     /* Supervisor Trap Setup */
@@ -1438,7 +1416,7 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] =3D {
     [CSR_SSCRATCH] =3D { "sscratch", smode, read_sscratch, write_sscratch =
},
     [CSR_SEPC]     =3D { "sepc",     smode, read_sepc,     write_sepc     =
},
     [CSR_SCAUSE]   =3D { "scause",   smode, read_scause,   write_scause   =
},
-    [CSR_SBADADDR] =3D { "sbadaddr", smode, read_sbadaddr, write_sbadaddr =
},
+    [CSR_STVAL]    =3D { "stval",    smode, read_stval,   write_stval   },
     [CSR_SIP]      =3D { "sip",      smode, NULL,    NULL, rmw_sip        =
},
=20
     /* Supervisor Protection and Translation */
diff --git a/target/riscv/machine.c b/target/riscv/machine.c
index 44d4015bd6..16a08302da 100644
--- a/target/riscv/machine.c
+++ b/target/riscv/machine.c
@@ -140,8 +140,8 @@ static const VMStateDescription vmstate_hyper =3D {
=20
 const VMStateDescription vmstate_riscv_cpu =3D {
     .name =3D "cpu",
-    .version_id =3D 1,
-    .minimum_version_id =3D 1,
+    .version_id =3D 2,
+    .minimum_version_id =3D 2,
     .fields =3D (VMStateField[]) {
         VMSTATE_UINTTL_ARRAY(env.gpr, RISCVCPU, 32),
         VMSTATE_UINT64_ARRAY(env.fpr, RISCVCPU, 32),
@@ -165,10 +165,8 @@ const VMStateDescription vmstate_riscv_cpu =3D {
         VMSTATE_UINT32(env.miclaim, RISCVCPU),
         VMSTATE_UINTTL(env.mie, RISCVCPU),
         VMSTATE_UINTTL(env.mideleg, RISCVCPU),
-        VMSTATE_UINTTL(env.sptbr, RISCVCPU),
         VMSTATE_UINTTL(env.satp, RISCVCPU),
-        VMSTATE_UINTTL(env.sbadaddr, RISCVCPU),
-        VMSTATE_UINTTL(env.mbadaddr, RISCVCPU),
+        VMSTATE_UINTTL(env.stval, RISCVCPU),
         VMSTATE_UINTTL(env.medeleg, RISCVCPU),
         VMSTATE_UINTTL(env.stvec, RISCVCPU),
         VMSTATE_UINTTL(env.sepc, RISCVCPU),
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
index 2f9f5ccc62..26eccc5eb1 100644
--- a/target/riscv/translate.c
+++ b/target/riscv/translate.c
@@ -116,7 +116,7 @@ static void generate_exception(DisasContext *ctx, int e=
xcp)
     ctx->base.is_jmp =3D DISAS_NORETURN;
 }
=20
-static void generate_exception_mbadaddr(DisasContext *ctx, int excp)
+static void generate_exception_mtval(DisasContext *ctx, int excp)
 {
     tcg_gen_movi_tl(cpu_pc, ctx->base.pc_next);
     tcg_gen_st_tl(cpu_pc, cpu_env, offsetof(CPURISCVState, badaddr));
@@ -160,7 +160,7 @@ static void gen_exception_illegal(DisasContext *ctx)
=20
 static void gen_exception_inst_addr_mis(DisasContext *ctx)
 {
-    generate_exception_mbadaddr(ctx, RISCV_EXCP_INST_ADDR_MIS);
+    generate_exception_mtval(ctx, RISCV_EXCP_INST_ADDR_MIS);
 }
=20
 static inline bool use_goto_tb(DisasContext *ctx, target_ulong dest)
--=20
2.31.1