From nobody Fri May 3 15:17:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.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=quarantine dis=none) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631077132328309.7071403500447; Tue, 7 Sep 2021 21:58:52 -0700 (PDT) Received: from localhost ([::1]:53502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNpfe-0007C0-Ms for importer@patchew.org; Wed, 08 Sep 2021 00:58:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38160) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNpbh-0007R2-LX for qemu-devel@nongnu.org; Wed, 08 Sep 2021 00:54:45 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:16643) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNpbf-0003tb-VC for qemu-devel@nongnu.org; Wed, 08 Sep 2021 00:54:45 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 08 Sep 2021 12:54:41 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2021 21:29:40 -0700 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2021 21:54:43 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4H48v60PnSz1RvlY for ; Tue, 7 Sep 2021 21:54:42 -0700 (PDT) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id IR752sZKVPib for ; Tue, 7 Sep 2021 21:54:41 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.165.20]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4H48v06kkYz1RvlR; Tue, 7 Sep 2021 21:54:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1631076883; x=1662612883; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JnuooeBmOvrNM6LgCIWux/Znpi60xXVkixxcdpQC3rA=; b=KPlwOQdiFskG1us3BtP4YN6pYAavHp1g1N2mR9afhllAgPiiLt1cNgpc MzWJ5rmvh12FRBoeDQ6LZX7HkCx3pIVA3x9cUuMvYmaiqb8+Oo/tpxuTN pXxKD06BJ8BdzsuujEHa6KnIE74xoXmhpPcE6YEyW+yLHCrqJ+/YdNyeX 09ZHR6gJekGxmM2RSRPHlfkYP4XkVNUkXzVsodrM7YOVnddU+CrnQfI2j exBIGZN+uHbx/VUkdnDVtHioIO6Zs9Na8pDrJrNfcmrAlD3OuaMq0tzie zBFv4/khOmfEjvfHce7q4BfeZZZ8bWP5l6PIR1j9m4TYgF4/7Ca+iOJNo g==; X-IronPort-AV: E=Sophos;i="5.85,276,1624291200"; d="scan'208";a="179443435" IronPort-SDR: 7uCrYXnZpzXg7bK9mTf9fK/1Z8pwMsytvluMTVKHQ0riZ4QOZCF/QRZY0czxEl4ELv+9dG83wU wAo/cl7bXeG/D31FN7/uBOxjFMfaRCoMyr3t8qpP/KyLk6pUhAD0nDnHlA4k3PbqyOykKilZQm tgmxyw13oEGtpnCz9LmZl9wkFfKV1hjKZIArhJOfM+SGEVVNwmR2SbSjQo3mrIpwG+5iAWHPWT Ae5u8dG68NWwJZN3X/I8ZMhtLwXAUF6yh7hsMCPJ/lwxHIerMrBKs/JWXT3ZdbyjXHOO3mZyA5 OwrIM8t1jjgIp/AtBAK7TO69 IronPort-SDR: QYTHQ2dNRFs+O3MoWHelXpdEiF9q0vkgXY0/br6av/C0MItoS1JDM/crHBygIVRgNjdg5HTEWz hZ5fzuzCyOCP4zyaLQ7O96nMYoDkooJF04TMuk9YcCaOO4rGwlOtDmEp2EPFN+WUf0FsDkPorZ Rn2YMwCkasOeOkXPA2mPagbXn5Ed2mEhCFRWdqcvgSRbHyLlr3RGqDf12idh5KR89TinuU68sF q2MKmRHEUF5P8romyV9i+MAYFbwv72pJqRqMtCRofTMiF7S9s1IoQCZ5nmYHGJXLHtrn+9SB50 bBk= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1631076881; x=1633668882; bh=JnuooeBmOvrNM6LgCI Wux/Znpi60xXVkixxcdpQC3rA=; b=KQugqwMO/ulvTIyNkzDA4OUdMZehJxcZ/P EdiSk1ERUmcByoPjzemkVkaJGi9o+nSvcO2oCMWPASreG7Zi5ulGjVTqyfm1GVkD 3jPPVSL1ciktiyRUIbt0IkhAuQ8jLRiMUWXp6BzFl4VWsNF4+jHahNzUZpXGvuP4 Hvb5mDbTcOYxSD600yKEO+0BOnfQIBx5i0bEd+JTmFFIdeqj5DE4i3N22f7XDsbb /vYWwPn3zf9eGMRt73H3cQ2Pns4D3L+rOyB/E2r4IrptUgaxRZtbcIrxH7nroyqT tuvT6Noaa5kW0l2EW+MIrJPCRb/fT6rLVNd27Bx1Nq+xUOo3E93A== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: bmeng.cn@gmail.com, palmer@dabbelt.com, alistair.francis@wdc.com, alistair23@gmail.com Subject: [PATCH v2 1/3] target/riscv: Set the opcode in DisasContext Date: Wed, 8 Sep 2021 14:54:28 +1000 Message-Id: <2540484d3fb928600d403182529bf345b2b1f915.1631076834.git.alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: 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=87817de26=alistair.francis@opensource.wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1631077133233100001 Content-Type: text/plain; charset="utf-8" From: Alistair Francis Signed-off-by: Alistair Francis Reviewed-by: Bin Meng --- target/riscv/translate.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/target/riscv/translate.c b/target/riscv/translate.c index e356fc6c46..25670be435 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -485,20 +485,20 @@ static uint32_t opcode_at(DisasContextBase *dcbase, t= arget_ulong pc) /* Include the auto-generated decoder for 16 bit insn */ #include "decode-insn16.c.inc" =20 -static void decode_opc(CPURISCVState *env, DisasContext *ctx, uint16_t opc= ode) +static void decode_opc(CPURISCVState *env, DisasContext *ctx) { /* check for compressed insn */ - if (extract16(opcode, 0, 2) !=3D 3) { + if (extract16(ctx->opcode, 0, 2) !=3D 3) { if (!has_ext(ctx, RVC)) { gen_exception_illegal(ctx); } else { ctx->pc_succ_insn =3D ctx->base.pc_next + 2; - if (!decode_insn16(ctx, opcode)) { + if (!decode_insn16(ctx, ctx->opcode)) { gen_exception_illegal(ctx); } } } else { - uint32_t opcode32 =3D opcode; + uint32_t opcode32 =3D ctx->opcode; opcode32 =3D deposit32(opcode32, 16, 16, translator_lduw(env, ctx->base.pc_next + 2)); ctx->pc_succ_insn =3D ctx->base.pc_next + 4; @@ -561,9 +561,9 @@ static void riscv_tr_translate_insn(DisasContextBase *d= cbase, CPUState *cpu) { DisasContext *ctx =3D container_of(dcbase, DisasContext, base); CPURISCVState *env =3D cpu->env_ptr; - uint16_t opcode16 =3D translator_lduw(env, ctx->base.pc_next); + ctx->opcode =3D translator_lduw(env, ctx->base.pc_next); =20 - decode_opc(env, ctx, opcode16); + decode_opc(env, ctx); ctx->base.pc_next =3D ctx->pc_succ_insn; ctx->w =3D false; =20 --=20 2.31.1 From nobody Fri May 3 15:17:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.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=quarantine dis=none) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631077374648593.2015931248034; Tue, 7 Sep 2021 22:02:54 -0700 (PDT) Received: from localhost ([::1]:34468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNpjZ-0004yP-Ft for importer@patchew.org; Wed, 08 Sep 2021 01:02:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNpbx-0008Nu-AQ for qemu-devel@nongnu.org; Wed, 08 Sep 2021 00:55:01 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:14755) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNpbv-000481-FH for qemu-devel@nongnu.org; Wed, 08 Sep 2021 00:55:01 -0400 Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 08 Sep 2021 12:54:56 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2021 21:29:53 -0700 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2021 21:54:56 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4H48vM3Sgzz1Rvlx for ; Tue, 7 Sep 2021 21:54:55 -0700 (PDT) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id F0xYFrpCmxl0 for ; Tue, 7 Sep 2021 21:54:54 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.165.20]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4H48vG74cfz1RvlR; Tue, 7 Sep 2021 21:54:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1631076899; x=1662612899; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HEO1kCxZJwHAqSHtUt8zjoYuh/MLhfznEY4xo9ze6iY=; b=FQb/JO8MqBkOtR4Ug/MvFfxuWSA+2y3IT93huNpDla9yImjFTkn3Aytg ZMBPcYBIpP0/Ya/SHGkll6sIex3jypC+wcIgVJes0yHiFFj6tn03aTGOW WH3fwIFUji0SM5G5C+qaIsOPvpWtVHBrBpC+1vxQGRP6XQ+KmdBU2GcFz 1gtaFqzFqDkDu7SJEVw3oAOGUrHFjv662jIVhHHGE4GbLw8K3kl0WmbUr 3lUqysMHfzSWqkAESaUl98U+YIDuk4dXgyjjDzdvJDvoLYOa8EZpQvR/q XaWLTjuOZmxsvPyuW+XIL7bJOii879GfCDIYeZpm18cLzDFBhfSm1Ewtq Q==; X-IronPort-AV: E=Sophos;i="5.85,276,1624291200"; d="scan'208";a="179971603" IronPort-SDR: dIbQBUl/kzr6A7bHEQRHEjz56UhT2ws/RiYdr5e6jVaZQSszbmUpisSXnpxqopOUNo77wI6z2Q 06sK0lCr1KkREN/tdr994l5u9RRPv0cztbXfiryYDl1l1cSK1+4aTs1dxIGx4VmKFp7l+wRGo+ oET8a74EfKxDKFUOMqz3ryYfbfYKWUSUozp5gla6w+zDG+bJIvVOWYX9fWmMvTbIH+Rrro+ac+ bmhMdGD6/A5U44A7zn7iLmQS++2PmS/pXHWdIOOUmSBaeRKzM25BZjdApxpsE30fuXYss+WfPm Iy75Vr7Pt63t92xUi2LvBdur IronPort-SDR: pFyq1cl5Q8Qc4cdcnCW7PnZDwldqLhcLB7q+iY/Pbx8rNEiD+IcDIgAX/2G383EDgZ7Jjj++c5 xdZyBDSnrm4+g1snvgwBMfZYVidG1o8BOMwVTv9uYAjTFEZx7pf61a35nGVAk8sr+/pKBHgb5V hJuvmgfdl6wnNH6WnN3DblrdaWWCY+SH6o4wSyBLctC5qV1vPpZYc+ddGxY4hl0U+9X9/QH6v6 cqjuzOXd1Rjg8mguq/5cx/a+O2QBtsMBaf+LdyHywq0FoHFotn40rSSeWkttbFQGnRTAFORt5H hdI= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1631076894; x=1633668895; bh=HEO1kCxZJwHAqSHtUt 8zjoYuh/MLhfznEY4xo9ze6iY=; b=Sc3mhlnc/bsWEkmhhg59v7rb6ZSHcWjqJp /N8l2l/WoC3rMC6E2VoLWOMq4CCDs0Dc2yBlRCLcKUGLR46+ZHtDt6k/MW/IhoYB GQA+QJwdQkehhSAq6ztcJJNwL7fjhFakrKtSf7m5FQflPj5OXrYdLZ1lpQaApxaP 5IwCZCaF7sWVz7ptUVn0cVpndBuZEKrSnRSb6dP4R/20q2MrogbWWcO+X4JL3xRd ZfGu/w5wwiS47+q5c5IsGotljgXN0tDZYiSPen2kyjgz+Zb3JnM9FHD78lURsXBI rl1qFCpKpQCLGiBdDUdhTUQ6noSawKeVZdhOZX5tp5QKVRXHKw+A== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: bmeng.cn@gmail.com, palmer@dabbelt.com, alistair.francis@wdc.com, alistair23@gmail.com Subject: [PATCH v2 2/3] target/riscv: Implement the stval/mtval illegal instruction Date: Wed, 8 Sep 2021 14:54:44 +1000 Message-Id: <6809670a315a07e7e6b435cf7942f82bdd8b99d6.1631076834.git.alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: 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.154.45; envelope-from=prvs=87817de26=alistair.francis@opensource.wdc.com; helo=esa6.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1631077376307100001 Content-Type: text/plain; charset="utf-8" From: Alistair Francis The stval and mtval registers can optionally contain the faulting instruction on an illegal instruction exception. This patch adds support for setting the stval and mtval registers based on the CPU feature. Signed-off-by: Alistair Francis Reviewed-by: Bin Meng --- target/riscv/cpu.h | 5 ++++- target/riscv/cpu_helper.c | 10 ++++++++++ target/riscv/translate.c | 31 +++++++++++++++++-------------- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index bf1c899c00..d11db1f031 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -77,7 +77,8 @@ enum { RISCV_FEATURE_MMU, RISCV_FEATURE_PMP, RISCV_FEATURE_EPMP, - RISCV_FEATURE_MISA + RISCV_FEATURE_MISA, + RISCV_FEATURE_MTVAL_INST, }; =20 #define PRIV_VERSION_1_10_0 0x00011000 @@ -130,6 +131,8 @@ struct CPURISCVState { target_ulong frm; =20 target_ulong badaddr; + uint32_t bins; + target_ulong guest_phys_fault_addr; =20 target_ulong priv_ver; diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 968cb8046f..65832967e1 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -967,6 +967,16 @@ void riscv_cpu_do_interrupt(CPUState *cs) write_tval =3D true; tval =3D env->badaddr; break; + case RISCV_EXCP_ILLEGAL_INST: + if (riscv_feature(env, RISCV_FEATURE_MTVAL_INST)) { + /* + * The stval/mtval register can optionally also be used to + * return the faulting instruction bits on an illegal + * instruction exception. + */ + tval =3D env->bins; + } + break; default: break; } diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 25670be435..99810db57d 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -173,8 +173,25 @@ static void lookup_and_goto_ptr(DisasContext *ctx) } } =20 +/* + * Wrappers for getting reg values. + * + * The $zero register does not have cpu_gpr[0] allocated -- we supply the + * constant zero as a source, and an uninitialized sink as destination. + * + * Further, we may provide an extension for word operations. + */ +static TCGv temp_new(DisasContext *ctx) +{ + assert(ctx->ntemp < ARRAY_SIZE(ctx->temp)); + return ctx->temp[ctx->ntemp++] =3D tcg_temp_new(); +} + static void gen_exception_illegal(DisasContext *ctx) { + tcg_gen_st_i32(tcg_constant_i32(ctx->opcode), cpu_env, + offsetof(CPURISCVState, bins)); + generate_exception(ctx, RISCV_EXCP_ILLEGAL_INST); } =20 @@ -195,20 +212,6 @@ static void gen_goto_tb(DisasContext *ctx, int n, targ= et_ulong dest) } } =20 -/* - * Wrappers for getting reg values. - * - * The $zero register does not have cpu_gpr[0] allocated -- we supply the - * constant zero as a source, and an uninitialized sink as destination. - * - * Further, we may provide an extension for word operations. - */ -static TCGv temp_new(DisasContext *ctx) -{ - assert(ctx->ntemp < ARRAY_SIZE(ctx->temp)); - return ctx->temp[ctx->ntemp++] =3D tcg_temp_new(); -} - static TCGv get_gpr(DisasContext *ctx, int reg_num, DisasExtend ext) { TCGv t; --=20 2.31.1 From nobody Fri May 3 15:17:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.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=quarantine dis=none) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631077222216145.7442921450762; Tue, 7 Sep 2021 22:00:22 -0700 (PDT) Received: from localhost ([::1]:59124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNph7-0002Uj-2L for importer@patchew.org; Wed, 08 Sep 2021 01:00:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNpc9-0000X5-Gg for qemu-devel@nongnu.org; Wed, 08 Sep 2021 00:55:13 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:17723) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNpc7-0004Jv-T4 for qemu-devel@nongnu.org; Wed, 08 Sep 2021 00:55:13 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 08 Sep 2021 12:55:09 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2021 21:30:07 -0700 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2021 21:55:10 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4H48vd0Dzsz1RvlV for ; Tue, 7 Sep 2021 21:55:09 -0700 (PDT) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id E9Rl0_KyFoD4 for ; Tue, 7 Sep 2021 21:55:08 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.165.20]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4H48vX0p9qz1RvlR; Tue, 7 Sep 2021 21:55:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1631076911; x=1662612911; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LpOad2nvuMiQqd52ek+2sI6Tr0RTCGKCgSGSgHgcKLs=; b=E3VpI65jQAG1pK6fKNgudCmzTjfH4tziqmD8uR5K6yZ7f9iisGE5s5hk J0EdL+8wCsue5R25MbGjVNcUDIX1YDSlfmkzxWZ5Bz7GxrY0+6k+q7TA5 bLjSCnAgo2O7mwMu0fl0dGtJppgp47YFdww9aVuQ3UtXLGpJKSdgpGlD9 uO02tYWnOWM0QIxytI0K2nKcKtLvP8i+muYVXozD2HQKik4ZgxJdMLA0M Ad9yE4w9ciJgiCT0bbbSSS7yquvxXNOhqrub7zNeZstTN+74f8s/baVQt gUd1bsYUm4hDAkTU4XjYnDbC1entIwuMo6bcEzSLIA1Ic1yhuKrCpm2uO A==; X-IronPort-AV: E=Sophos;i="5.85,276,1624291200"; d="scan'208";a="283234111" IronPort-SDR: c+MHBOQsO8w5XFEc/vkLiuZXhQX1CGO45PHXNMp6F6fUrUht3qI5SDyKKpOY1Q5K8RwALo7twp liXUztV7cbeo6TGLyY1NF/FCGYep541wL+oWbPT+h1K59TTuIqDwGHgkKglhuGoz5v2pf0GOpL pQ9HOeL8vDbYCdrVq4WjXdOvv4nJeCIMv0wHEReflfHgiwaFtYbd77dGYlns8n9QhW3fA8BFkO N0IFQJgYZxASQMfDr4LHpU2VhYxQZP7IPMSYSq8Lk23iKKNh6jYV12MPglfuvBIhdntnGQ7KZz e097NhdMBi5sHpedNU0R/Ry7 IronPort-SDR: 5fF/UEtySpMO+pgLQ31+amB/y/x0yPAPhbadbbrWr1xBUJFEyP28tmfhUi7pqTAi7/ncpk827+ 9vqfBsoa8ISSOgpN8YScKy3HqMRdYZ5AastaUIPi0FbMdPj1GNK7JAsqiLX3FA/kb8MZUUh46W q+UEYOi30vvFJOZgn1Drw+xj3vXcp7x7Y2dYl3DA9Xz4ovY+31059uFr4QJRixQ3FD1dEZDf4h 2JuTO6hBAhu6hdv4wvm0ckiG3r4jEyjOB33j86N+SKORv+OTcTT55PQkpDHLt5xktC834uqw0r +wM= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1631076908; x=1633668909; bh=LpOad2nvuMiQqd52ek +2sI6Tr0RTCGKCgSGSgHgcKLs=; b=oo4zmYH38Z8SJahEc0R2N4K8fuaSdXk1/+ mLXadFSU2IENfQVOTcru0ZUtTWUxpw/wnDq4JBKEZbaRNEaHjxtwY6zCsnXFcYyp 3GuZQcydGIjaeLzVW3E2ZFFnOYmbxHawcdk89WC88BfXswy4IruUNbt5B7GbEMXH s4rS/69E0xA1j9BGZMMqEQ3a5Vx/XLXZ12E1OITSqB2Wf3WyO793ACmZ556YyaYz bquzSWaXASTWCJdjBesBxgYVjjLQKbVYbUJX42i2WwOW+rBkFu1BaUquHHMGdYWs N5UKeZrR7lnTisVb7OkdmzKmYUDnl8bBhy2U2K6UwCTiFtegpw0g== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: bmeng.cn@gmail.com, palmer@dabbelt.com, alistair.francis@wdc.com, alistair23@gmail.com Subject: [PATCH v2 3/3] target/riscv: Set mtval and stval support Date: Wed, 8 Sep 2021 14:54:57 +1000 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: 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=68.232.143.124; envelope-from=prvs=87817de26=alistair.francis@opensource.wdc.com; helo=esa2.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1631077222785100003 Content-Type: text/plain; charset="utf-8" From: Alistair Francis Signed-off-by: Alistair Francis --- target/riscv/cpu.h | 1 + target/riscv/cpu.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index d11db1f031..5b0bbf2fca 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -309,6 +309,7 @@ struct RISCVCPU { bool mmu; bool pmp; bool epmp; + bool mtval_inst; uint64_t resetvec; } cfg; }; diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 1a2b03d579..537f2af341 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -437,6 +437,10 @@ static void riscv_cpu_realize(DeviceState *dev, Error = **errp) } } =20 + if (cpu->cfg.mtval_inst) { + set_feature(env, RISCV_FEATURE_MTVAL_INST); + } + set_resetvec(env, cpu->cfg.resetvec); =20 /* If only XLEN is set for misa, then set misa from properties */ @@ -600,7 +604,7 @@ static Property riscv_cpu_properties[] =3D { DEFINE_PROP_BOOL("mmu", RISCVCPU, cfg.mmu, true), DEFINE_PROP_BOOL("pmp", RISCVCPU, cfg.pmp, true), DEFINE_PROP_BOOL("x-epmp", RISCVCPU, cfg.epmp, false), - + DEFINE_PROP_BOOL("tval-inst", RISCVCPU, cfg.mtval_inst, true), DEFINE_PROP_UINT64("resetvec", RISCVCPU, cfg.resetvec, DEFAULT_RSTVEC), DEFINE_PROP_END_OF_LIST(), }; --=20 2.31.1