From nobody Mon Feb 9 17:36:06 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527035468526779.1918504333414; Tue, 22 May 2018 17:31:08 -0700 (PDT) Received: from localhost ([::1]:58565 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fLHgF-0001x9-SK for importer@patchew.org; Tue, 22 May 2018 20:31:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42627) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fLHTj-0000Gt-NP for qemu-devel@nongnu.org; Tue, 22 May 2018 20:18:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fLHTh-0001Dn-Iw for qemu-devel@nongnu.org; Tue, 22 May 2018 20:18:07 -0400 Received: from mail-pf0-x22b.google.com ([2607:f8b0:400e:c00::22b]:44824) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fLHTh-0001DH-Af for qemu-devel@nongnu.org; Tue, 22 May 2018 20:18:05 -0400 Received: by mail-pf0-x22b.google.com with SMTP id q22-v6so9549866pff.11 for ; Tue, 22 May 2018 17:18:05 -0700 (PDT) Received: from localhost.localdomain (122-58-167-22-fibre.bb.spark.co.nz. [122.58.167.22]) by smtp.gmail.com with ESMTPSA id j1-v6sm28935626pfh.95.2018.05.22.17.18.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 May 2018 17:18:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=C7JMG8B4zh2TBmMsAU0bXZLxykm3GnekkcnhB6cR2wE=; b=JqsHYiJAFbQO77zyhtm+P8nts/H5o+C3S/gUd21DrWrHnenl7A8YeOivWKMTcOhmo5 i1d/sfne3r/L2irlu0An92OADBHrGpuAVyh0Pzj9z9YfEvc1PrloGphuaXf3d1EUUdE6 Qbt72Njc6je+crbFZzwp+cFjdHZ1ZHO1cFSF51gPO+uLJRhKpyxd+Cnmyq/Et7/90Lgj 17CwdGgde4t0L7RE2yWEui9vFW47csIpy2Nuisv6g8RczSK2gEPpCjqGCbSStikffqkx XgUXh7SKCQ+ADLltEmskC/ZCnaQDTb1uzw/uHPUDEJTe2qYlnudhvt2TWHJzql9TCPbt FpUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=C7JMG8B4zh2TBmMsAU0bXZLxykm3GnekkcnhB6cR2wE=; b=pd4WbAFfPVS94DJH+XpPQ+4Tt9tXFqXDu2sYHF7EsawPQ2CTtQPJwwIIPG2tkb3kK4 7Ahg+uf8s9ib7DN8rA7DaT+m1p/zmgLpg65wrMWiZnB7CC+UtCqZoLRllR2Kdx26MJbR SZzAQYEplv4DCBxImMZjUvAMqLzVOvHJTUX/uBMkeFFiWgnUA7pdG0PpQ4Yb3kPK3ZgB wI2CfzZk5GXl1x3fcg58KQt4qdoYw+P/jc0wq0BoQqLSbSXUcI/J5O+GuKY+1TmGZBpV OC2A6Yx7CmrCUo3qMplaoPdEGqazdbEjFMU/+BttLxo+4kbAq/qKW62YFbD6CQ42gf5x nyLQ== X-Gm-Message-State: ALKqPwdXqq8EzmpiM7HYQ0BxZyWjr2lsdouVxEaIKekeDOx++fsGPkfO vDUyu4T/Sy2XBz2R3NP9iheZeO2U1mM= X-Google-Smtp-Source: AB8JxZrUOMx+PstS+R8Il1QfazG/1hDHSUQxTaqGi63Oqpd4V9OdKapVP7+z26SXGBDLjvQ9RVLx9A== X-Received: by 2002:a62:4fd8:: with SMTP id f85-v6mr581005pfj.77.1527034684335; Tue, 22 May 2018 17:18:04 -0700 (PDT) From: Michael Clark To: qemu-devel@nongnu.org Date: Wed, 23 May 2018 12:15:08 +1200 Message-Id: <1527034517-7851-22-git-send-email-mjc@sifive.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1527034517-7851-1-git-send-email-mjc@sifive.com> References: <1527034517-7851-1-git-send-email-mjc@sifive.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22b Subject: [Qemu-devel] [PATCH v1 21/30] RISC-V: Add misa.MAFD checks to translate X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sagar Karandikar , Bastian Koppelmann , Palmer Dabbelt , "Emilio G . Cota" , Michael Clark , Alistair Francis , patches@groups.riscv.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add misa checks for M, A, F and D extensions and if they are not present generate illegal instructions. This improves emulation accurary for harts with a limited set of extensions. Cc: Palmer Dabbelt Cc: Sagar Karandikar Cc: Bastian Koppelmann Cc: Alistair Francis Cc: Emilio G. Cota Signed-off-by: Michael Clark --- target/riscv/translate.c | 158 +++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 158 insertions(+) diff --git a/target/riscv/translate.c b/target/riscv/translate.c index fd21b133a5a4..e488101ff56d 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -290,24 +290,42 @@ static void gen_arith(DisasContext *ctx, uint32_t opc= , int rd, int rs1, tcg_gen_and_tl(source1, source1, source2); break; CASE_OP_32_64(OPC_RISC_MUL): + if (!has_ext(ctx, RVM)) { + goto do_illegal; + } tcg_gen_mul_tl(source1, source1, source2); break; case OPC_RISC_MULH: + if (!has_ext(ctx, RVM)) { + goto do_illegal; + } tcg_gen_muls2_tl(source2, source1, source1, source2); break; case OPC_RISC_MULHSU: + if (!has_ext(ctx, RVM)) { + goto do_illegal; + } gen_mulhsu(source1, source1, source2); break; case OPC_RISC_MULHU: + if (!has_ext(ctx, RVM)) { + goto do_illegal; + } tcg_gen_mulu2_tl(source2, source1, source1, source2); break; #if defined(TARGET_RISCV64) case OPC_RISC_DIVW: + if (!has_ext(ctx, RVM)) { + goto do_illegal; + } tcg_gen_ext32s_tl(source1, source1); tcg_gen_ext32s_tl(source2, source2); /* fall through to DIV */ #endif case OPC_RISC_DIV: + if (!has_ext(ctx, RVM)) { + goto do_illegal; + } /* Handle by altering args to tcg_gen_div to produce req'd results: * For overflow: want source1 in source1 and 1 in source2 * For div by zero: want -1 in source1 and 1 in source2 -> -1 resu= lt */ @@ -339,11 +357,17 @@ static void gen_arith(DisasContext *ctx, uint32_t opc= , int rd, int rs1, break; #if defined(TARGET_RISCV64) case OPC_RISC_DIVUW: + if (!has_ext(ctx, RVM)) { + goto do_illegal; + } tcg_gen_ext32u_tl(source1, source1); tcg_gen_ext32u_tl(source2, source2); /* fall through to DIVU */ #endif case OPC_RISC_DIVU: + if (!has_ext(ctx, RVM)) { + goto do_illegal; + } cond1 =3D tcg_temp_new(); zeroreg =3D tcg_const_tl(0); resultopt1 =3D tcg_temp_new(); @@ -363,11 +387,17 @@ static void gen_arith(DisasContext *ctx, uint32_t opc= , int rd, int rs1, break; #if defined(TARGET_RISCV64) case OPC_RISC_REMW: + if (!has_ext(ctx, RVM)) { + goto do_illegal; + } tcg_gen_ext32s_tl(source1, source1); tcg_gen_ext32s_tl(source2, source2); /* fall through to REM */ #endif case OPC_RISC_REM: + if (!has_ext(ctx, RVM)) { + goto do_illegal; + } cond1 =3D tcg_temp_new(); cond2 =3D tcg_temp_new(); zeroreg =3D tcg_const_tl(0); @@ -395,11 +425,17 @@ static void gen_arith(DisasContext *ctx, uint32_t opc= , int rd, int rs1, break; #if defined(TARGET_RISCV64) case OPC_RISC_REMUW: + if (!has_ext(ctx, RVM)) { + goto do_illegal; + } tcg_gen_ext32u_tl(source1, source1); tcg_gen_ext32u_tl(source2, source2); /* fall through to REMU */ #endif case OPC_RISC_REMU: + if (!has_ext(ctx, RVM)) { + goto do_illegal; + } cond1 =3D tcg_temp_new(); zeroreg =3D tcg_const_tl(0); resultopt1 =3D tcg_temp_new(); @@ -417,6 +453,7 @@ static void gen_arith(DisasContext *ctx, uint32_t opc, = int rd, int rs1, tcg_temp_free(zeroreg); tcg_temp_free(resultopt1); break; + do_illegal: default: gen_exception_illegal(ctx); return; @@ -697,13 +734,20 @@ static void gen_fp_load(DisasContext *ctx, uint32_t o= pc, int rd, =20 switch (opc) { case OPC_RISC_FLW: + if (!has_ext(ctx, RVF)) { + goto do_illegal; + } tcg_gen_qemu_ld_i64(cpu_fpr[rd], t0, ctx->mem_idx, MO_TEUL); /* RISC-V requires NaN-boxing of narrower width floating point val= ues */ tcg_gen_ori_i64(cpu_fpr[rd], cpu_fpr[rd], 0xffffffff00000000ULL); break; case OPC_RISC_FLD: + if (!has_ext(ctx, RVD)) { + goto do_illegal; + } tcg_gen_qemu_ld_i64(cpu_fpr[rd], t0, ctx->mem_idx, MO_TEQ); break; + do_illegal: default: gen_exception_illegal(ctx); break; @@ -729,11 +773,18 @@ static void gen_fp_store(DisasContext *ctx, uint32_t = opc, int rs1, =20 switch (opc) { case OPC_RISC_FSW: + if (!has_ext(ctx, RVF)) { + goto do_illegal; + } tcg_gen_qemu_st_i64(cpu_fpr[rs2], t0, ctx->mem_idx, MO_TEUL); break; case OPC_RISC_FSD: + if (!has_ext(ctx, RVD)) { + goto do_illegal; + } tcg_gen_qemu_st_i64(cpu_fpr[rs2], t0, ctx->mem_idx, MO_TEQ); break; + do_illegal: default: gen_exception_illegal(ctx); break; @@ -897,15 +948,22 @@ static void gen_fp_fmadd(DisasContext *ctx, uint32_t = opc, int rd, { switch (opc) { case OPC_RISC_FMADD_S: + if (!has_ext(ctx, RVF)) { + goto do_illegal; + } gen_set_rm(ctx, rm); gen_helper_fmadd_s(cpu_fpr[rd], cpu_env, cpu_fpr[rs1], cpu_fpr[rs2], cpu_fpr[rs3]); break; case OPC_RISC_FMADD_D: + if (!has_ext(ctx, RVD)) { + goto do_illegal; + } gen_set_rm(ctx, rm); gen_helper_fmadd_d(cpu_fpr[rd], cpu_env, cpu_fpr[rs1], cpu_fpr[rs2], cpu_fpr[rs3]); break; + do_illegal: default: gen_exception_illegal(ctx); break; @@ -917,15 +975,22 @@ static void gen_fp_fmsub(DisasContext *ctx, uint32_t = opc, int rd, { switch (opc) { case OPC_RISC_FMSUB_S: + if (!has_ext(ctx, RVF)) { + goto do_illegal; + } gen_set_rm(ctx, rm); gen_helper_fmsub_s(cpu_fpr[rd], cpu_env, cpu_fpr[rs1], cpu_fpr[rs2], cpu_fpr[rs3]); break; case OPC_RISC_FMSUB_D: + if (!has_ext(ctx, RVD)) { + goto do_illegal; + } gen_set_rm(ctx, rm); gen_helper_fmsub_d(cpu_fpr[rd], cpu_env, cpu_fpr[rs1], cpu_fpr[rs2], cpu_fpr[rs3]); break; + do_illegal: default: gen_exception_illegal(ctx); break; @@ -937,15 +1002,22 @@ static void gen_fp_fnmsub(DisasContext *ctx, uint32_= t opc, int rd, { switch (opc) { case OPC_RISC_FNMSUB_S: + if (!has_ext(ctx, RVF)) { + goto do_illegal; + } gen_set_rm(ctx, rm); gen_helper_fnmsub_s(cpu_fpr[rd], cpu_env, cpu_fpr[rs1], cpu_fpr[rs2], cpu_fpr[rs3]); break; case OPC_RISC_FNMSUB_D: + if (!has_ext(ctx, RVD)) { + goto do_illegal; + } gen_set_rm(ctx, rm); gen_helper_fnmsub_d(cpu_fpr[rd], cpu_env, cpu_fpr[rs1], cpu_fpr[rs2], cpu_fpr[rs3]); break; + do_illegal: default: gen_exception_illegal(ctx); break; @@ -957,15 +1029,22 @@ static void gen_fp_fnmadd(DisasContext *ctx, uint32_= t opc, int rd, { switch (opc) { case OPC_RISC_FNMADD_S: + if (!has_ext(ctx, RVF)) { + goto do_illegal; + } gen_set_rm(ctx, rm); gen_helper_fnmadd_s(cpu_fpr[rd], cpu_env, cpu_fpr[rs1], cpu_fpr[rs2], cpu_fpr[rs3]); break; case OPC_RISC_FNMADD_D: + if (!has_ext(ctx, RVD)) { + goto do_illegal; + } gen_set_rm(ctx, rm); gen_helper_fnmadd_d(cpu_fpr[rd], cpu_env, cpu_fpr[rs1], cpu_fpr[rs2], cpu_fpr[rs3]); break; + do_illegal: default: gen_exception_illegal(ctx); break; @@ -984,30 +1063,51 @@ static void gen_fp_arith(DisasContext *ctx, uint32_t= opc, int rd, =20 switch (opc) { case OPC_RISC_FADD_S: + if (!has_ext(ctx, RVF)) { + goto do_illegal; + } gen_set_rm(ctx, rm); gen_helper_fadd_s(cpu_fpr[rd], cpu_env, cpu_fpr[rs1], cpu_fpr[rs2]= ); break; case OPC_RISC_FSUB_S: + if (!has_ext(ctx, RVF)) { + goto do_illegal; + } gen_set_rm(ctx, rm); gen_helper_fsub_s(cpu_fpr[rd], cpu_env, cpu_fpr[rs1], cpu_fpr[rs2]= ); break; case OPC_RISC_FMUL_S: + if (!has_ext(ctx, RVF)) { + goto do_illegal; + } gen_set_rm(ctx, rm); gen_helper_fmul_s(cpu_fpr[rd], cpu_env, cpu_fpr[rs1], cpu_fpr[rs2]= ); break; case OPC_RISC_FDIV_S: + if (!has_ext(ctx, RVF)) { + goto do_illegal; + } gen_set_rm(ctx, rm); gen_helper_fdiv_s(cpu_fpr[rd], cpu_env, cpu_fpr[rs1], cpu_fpr[rs2]= ); break; case OPC_RISC_FSQRT_S: + if (!has_ext(ctx, RVF)) { + goto do_illegal; + } gen_set_rm(ctx, rm); gen_helper_fsqrt_s(cpu_fpr[rd], cpu_env, cpu_fpr[rs1]); break; case OPC_RISC_FSGNJ_S: + if (!has_ext(ctx, RVF)) { + goto do_illegal; + } gen_fsgnj(ctx, rd, rs1, rs2, rm, INT32_MIN); break; =20 case OPC_RISC_FMIN_S: + if (!has_ext(ctx, RVF)) { + goto do_illegal; + } /* also handles: OPC_RISC_FMAX_S */ switch (rm) { case 0x0: @@ -1023,6 +1123,9 @@ static void gen_fp_arith(DisasContext *ctx, uint32_t = opc, int rd, =20 case OPC_RISC_FEQ_S: /* also handles: OPC_RISC_FLT_S, OPC_RISC_FLE_S */ + if (!has_ext(ctx, RVF)) { + goto do_illegal; + } t0 =3D tcg_temp_new(); switch (rm) { case 0x0: @@ -1044,6 +1147,9 @@ static void gen_fp_arith(DisasContext *ctx, uint32_t = opc, int rd, =20 case OPC_RISC_FCVT_W_S: /* also OPC_RISC_FCVT_WU_S, OPC_RISC_FCVT_L_S, OPC_RISC_FCVT_LU_S = */ + if (!has_ext(ctx, RVF)) { + goto do_illegal; + } t0 =3D tcg_temp_new(); switch (rs2) { case 0: /* FCVT_W_S */ @@ -1074,6 +1180,9 @@ static void gen_fp_arith(DisasContext *ctx, uint32_t = opc, int rd, =20 case OPC_RISC_FCVT_S_W: /* also OPC_RISC_FCVT_S_WU, OPC_RISC_FCVT_S_L, OPC_RISC_FCVT_S_LU = */ + if (!has_ext(ctx, RVF)) { + goto do_illegal; + } t0 =3D tcg_temp_new(); gen_get_gpr(t0, rs1); switch (rs2) { @@ -1103,6 +1212,9 @@ static void gen_fp_arith(DisasContext *ctx, uint32_t = opc, int rd, =20 case OPC_RISC_FMV_X_S: /* also OPC_RISC_FCLASS_S */ + if (!has_ext(ctx, RVF)) { + goto do_illegal; + } t0 =3D tcg_temp_new(); switch (rm) { case 0: /* FMV */ @@ -1124,6 +1236,9 @@ static void gen_fp_arith(DisasContext *ctx, uint32_t = opc, int rd, break; =20 case OPC_RISC_FMV_S_X: + if (!has_ext(ctx, RVF)) { + goto do_illegal; + } t0 =3D tcg_temp_new(); gen_get_gpr(t0, rs1); #if defined(TARGET_RISCV64) @@ -1136,22 +1251,37 @@ static void gen_fp_arith(DisasContext *ctx, uint32_= t opc, int rd, =20 /* double */ case OPC_RISC_FADD_D: + if (!has_ext(ctx, RVD)) { + goto do_illegal; + } gen_set_rm(ctx, rm); gen_helper_fadd_d(cpu_fpr[rd], cpu_env, cpu_fpr[rs1], cpu_fpr[rs2]= ); break; case OPC_RISC_FSUB_D: + if (!has_ext(ctx, RVD)) { + goto do_illegal; + } gen_set_rm(ctx, rm); gen_helper_fsub_d(cpu_fpr[rd], cpu_env, cpu_fpr[rs1], cpu_fpr[rs2]= ); break; case OPC_RISC_FMUL_D: + if (!has_ext(ctx, RVD)) { + goto do_illegal; + } gen_set_rm(ctx, rm); gen_helper_fmul_d(cpu_fpr[rd], cpu_env, cpu_fpr[rs1], cpu_fpr[rs2]= ); break; case OPC_RISC_FDIV_D: + if (!has_ext(ctx, RVD)) { + goto do_illegal; + } gen_set_rm(ctx, rm); gen_helper_fdiv_d(cpu_fpr[rd], cpu_env, cpu_fpr[rs1], cpu_fpr[rs2]= ); break; case OPC_RISC_FSQRT_D: + if (!has_ext(ctx, RVD)) { + goto do_illegal; + } gen_set_rm(ctx, rm); gen_helper_fsqrt_d(cpu_fpr[rd], cpu_env, cpu_fpr[rs1]); break; @@ -1161,6 +1291,9 @@ static void gen_fp_arith(DisasContext *ctx, uint32_t = opc, int rd, =20 case OPC_RISC_FMIN_D: /* also OPC_RISC_FMAX_D */ + if (!has_ext(ctx, RVD)) { + goto do_illegal; + } switch (rm) { case 0: gen_helper_fmin_d(cpu_fpr[rd], cpu_env, cpu_fpr[rs1], cpu_fpr[= rs2]); @@ -1174,6 +1307,9 @@ static void gen_fp_arith(DisasContext *ctx, uint32_t = opc, int rd, break; =20 case OPC_RISC_FCVT_S_D: + if (!has_ext(ctx, RVD)) { + goto do_illegal; + } switch (rs2) { case 1: gen_set_rm(ctx, rm); @@ -1185,6 +1321,9 @@ static void gen_fp_arith(DisasContext *ctx, uint32_t = opc, int rd, break; =20 case OPC_RISC_FCVT_D_S: + if (!has_ext(ctx, RVD)) { + goto do_illegal; + } switch (rs2) { case 0: gen_set_rm(ctx, rm); @@ -1197,6 +1336,9 @@ static void gen_fp_arith(DisasContext *ctx, uint32_t = opc, int rd, =20 case OPC_RISC_FEQ_D: /* also OPC_RISC_FLT_D, OPC_RISC_FLE_D */ + if (!has_ext(ctx, RVD)) { + goto do_illegal; + } t0 =3D tcg_temp_new(); switch (rm) { case 0: @@ -1218,6 +1360,9 @@ static void gen_fp_arith(DisasContext *ctx, uint32_t = opc, int rd, =20 case OPC_RISC_FCVT_W_D: /* also OPC_RISC_FCVT_WU_D, OPC_RISC_FCVT_L_D, OPC_RISC_FCVT_LU_D = */ + if (!has_ext(ctx, RVD)) { + goto do_illegal; + } t0 =3D tcg_temp_new(); switch (rs2) { case 0: @@ -1248,6 +1393,9 @@ static void gen_fp_arith(DisasContext *ctx, uint32_t = opc, int rd, =20 case OPC_RISC_FCVT_D_W: /* also OPC_RISC_FCVT_D_WU, OPC_RISC_FCVT_D_L, OPC_RISC_FCVT_D_LU = */ + if (!has_ext(ctx, RVD)) { + goto do_illegal; + } t0 =3D tcg_temp_new(); gen_get_gpr(t0, rs1); switch (rs2) { @@ -1278,6 +1426,9 @@ static void gen_fp_arith(DisasContext *ctx, uint32_t = opc, int rd, #if defined(TARGET_RISCV64) case OPC_RISC_FMV_X_D: /* also OPC_RISC_FCLASS_D */ + if (!has_ext(ctx, RVD)) { + goto do_illegal; + } switch (rm) { case 0: /* FMV */ gen_set_gpr(rd, cpu_fpr[rs1]); @@ -1295,6 +1446,9 @@ static void gen_fp_arith(DisasContext *ctx, uint32_t = opc, int rd, break; =20 case OPC_RISC_FMV_D_X: + if (!has_ext(ctx, RVD)) { + goto do_illegal; + } t0 =3D tcg_temp_new(); gen_get_gpr(t0, rs1); tcg_gen_mov_tl(cpu_fpr[rd], t0); @@ -1786,6 +1940,9 @@ static void decode_RV32_64G(DisasContext *ctx) GET_STORE_IMM(ctx->opcode)); break; case OPC_RISC_ATOMIC: + if (!has_ext(ctx, RVA)) { + goto do_illegal; + } gen_atomic(ctx, MASK_OP_ATOMIC(ctx->opcode), rd, rs1, rs2); break; case OPC_RISC_FMADD: @@ -1826,6 +1983,7 @@ static void decode_RV32_64G(DisasContext *ctx) gen_system(ctx, MASK_OP_SYSTEM(ctx->opcode), rd, rs1, (ctx->opcode & 0xFFF00000) >> 20); break; + do_illegal: default: gen_exception_illegal(ctx); break; --=20 2.7.0