From nobody Sat Nov 23 21:01:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1730347347; cv=none; d=zohomail.com; s=zohoarc; b=XZLm0H/ktWGN6T37FsEYKoFCBqXICKet8GGiIzpSSaOOjG0B+5cs4E/d8XyiJ2LssV4PC7GxJOwIJWcG2Cv7mKGUnnaPgXKDqDExsS3iAyQbu15ykp/K2ipqzHCWLSHMH33XW6knwpqTo5Lo44d5+lOwZk1NyAHpZ0iJGQCtHMo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730347347; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IpbmVYRsQHTshVOLheV2H2hr8xzumFDJSdvIQ9aBZ9o=; b=dwamIXkkHxN5THgK4WAIq5LcsQ5A52tL5J9iqn41i57B655eEpMKbN9v/KnrQdhUaetaWglfejJX5zxljp1pZMLUOQ0HpAaIW9Yk/+uN3mdqE1rw/djK7nf0i4z4gZSOMKqGXnnbpzmzlZalEbktw69EHqZsel2jskf3dKEfqrU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 173034734755318.65820702663018; Wed, 30 Oct 2024 21:02:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6MHV-0002np-Sy; Wed, 30 Oct 2024 23:55:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t6MHC-00023E-Kq for qemu-devel@nongnu.org; Wed, 30 Oct 2024 23:55:17 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t6MHA-0004DM-Vb for qemu-devel@nongnu.org; Wed, 30 Oct 2024 23:55:14 -0400 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-7db238d07b3so446047a12.2 for ; Wed, 30 Oct 2024 20:55:12 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21105707064sm3022795ad.70.2024.10.30.20.55.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 20:55:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730346911; x=1730951711; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IpbmVYRsQHTshVOLheV2H2hr8xzumFDJSdvIQ9aBZ9o=; b=DkUUxqHNVjv1Zaqfvn7mbKY2XVCPpLVXq6i/IhrYfqA6fckN3SArNYHljwVGo7Kkos ZFKTyNucaQO3c4Yhj+GHNdX8jVtfJkv5KMtVcPwAg+2anNI/5LNh3DnJlrpvCYxGMHSr HgOy8RleM5zYgmxEQW5pPX8kQH7WE5Tsp+k5l+BmYhbCL4XK73rzSXjxXaT7tsGtlZiN 8/icqirLj/jU0aegqRfp4BcHeYetHsajky05MyyfspMEBsGfLtiOecJbSxV8cQpaKQEh p0OOWmZ+qXwe5/8umPqHlZFYNss4ykbgJbaO1zLFyiE8fLofSdjvxksGkJU3A0oPdNXG hWcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730346911; x=1730951711; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IpbmVYRsQHTshVOLheV2H2hr8xzumFDJSdvIQ9aBZ9o=; b=obKdz621Dnwdo4ZGyQrkdmRovKyXpS2GDt3lZjjBx1vJ2dJpj1vqdWlY82g5xWZsSg IXrcaeFHlZGANLiAQEaDRg+wnrWqKViwfR7Vqa58OHBOBWUdb33BYbOaZOuf7XEZj48t Bd0tQgmh3r204nEDLf+5nAcqfucXeRPJ6KdQJmK2sLyzfrOi9GbolH8lgDxCRPK71fCg WKXxjMncplxZJnIY3SL687A5o+0uOgGM+RSmbRI/RMZVkedR5C+SsDgGy2yatxx0gafy 6DsCnAfMCy+WlNRy+FhaoJ6QPHiWJetqja9F5y+q9YZPz1XUFRAF/BV7phrMImA2U5Pi mJQw== X-Gm-Message-State: AOJu0YzmjhBjH2BszsdeIfofSQ1W4lDxSro37Lkrr03DBSVzoVdrVNgX nuFKeK+XvsDtXm9McRAB/QyM/jKhYkLmHWA7oMGXAETxUrjC5ZDl5qUDB13l X-Google-Smtp-Source: AGHT+IHMYDQXTehQaYm+DBMLjuInHndOheuIfOJn+XB370WWchnMLHPCBU5JsoSnO5mcb4nWvkeVGg== X-Received: by 2002:a05:6a21:e90:b0:1d9:de8:f355 with SMTP id adf61e73a8af0-1d9a83cdd71mr21815543637.14.1730346911233; Wed, 30 Oct 2024 20:55:11 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Deepak Gupta , Alistair Francis Subject: [PULL 33/50] disas/riscv: enable disassembly for zicfiss instructions Date: Thu, 31 Oct 2024 13:53:01 +1000 Message-ID: <20241031035319.731906-34-alistair.francis@wdc.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241031035319.731906-1-alistair.francis@wdc.com> References: <20241031035319.731906-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=2607:f8b0:4864:20::533; envelope-from=alistair23@gmail.com; helo=mail-pg1-x533.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1730347348062116600 Content-Type: text/plain; charset="utf-8" From: Deepak Gupta Enable disassembly for sspush, sspopchk, ssrdp & ssamoswap. Disasembly is only enabled if zimop and zicfiss ext is set to true. Signed-off-by: Deepak Gupta Acked-by: Alistair Francis Message-ID: <20241008225010.1861630-19-debug@rivosinc.com> Signed-off-by: Alistair Francis --- disas/riscv.h | 1 + disas/riscv.c | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/disas/riscv.h b/disas/riscv.h index ae78352e38..e197f5d435 100644 --- a/disas/riscv.h +++ b/disas/riscv.h @@ -224,6 +224,7 @@ enum { =20 #define rv_fmt_none "O\t" #define rv_fmt_rs1 "O\t1" +#define rv_fmt_rs2 "O\t2" #define rv_fmt_offset "O\to" #define rv_fmt_pred_succ "O\tp,s" #define rv_fmt_rs1_rs2 "O\t1,2" diff --git a/disas/riscv.c b/disas/riscv.c index 513225129c..1f0eb66d01 100644 --- a/disas/riscv.c +++ b/disas/riscv.c @@ -977,6 +977,11 @@ typedef enum { rv_op_wrs_sto =3D 946, rv_op_wrs_nto =3D 947, rv_op_lpad =3D 948, + rv_op_sspush =3D 949, + rv_op_sspopchk =3D 950, + rv_op_ssrdp =3D 951, + rv_op_ssamoswap_w =3D 952, + rv_op_ssamoswap_d =3D 953, } rv_op; =20 /* register names */ @@ -2238,6 +2243,11 @@ const rv_opcode_data rvi_opcode_data[] =3D { { "wrs.sto", rv_codec_none, rv_fmt_none, NULL, 0, 0, 0 }, { "wrs.nto", rv_codec_none, rv_fmt_none, NULL, 0, 0, 0 }, { "lpad", rv_codec_lp, rv_fmt_imm, NULL, 0, 0, 0 }, + { "sspush", rv_codec_r, rv_fmt_rs2, NULL, 0, 0, 0 }, + { "sspopchk", rv_codec_r, rv_fmt_rs1, NULL, 0, 0, 0 }, + { "ssrdp", rv_codec_r, rv_fmt_rd, NULL, 0, 0, 0 }, + { "ssamoswap.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "ssamoswap.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, }; =20 /* CSR names */ @@ -2255,6 +2265,7 @@ static const char *csr_name(int csrno) case 0x0009: return "vxsat"; case 0x000a: return "vxrm"; case 0x000f: return "vcsr"; + case 0x0011: return "ssp"; case 0x0015: return "seed"; case 0x0017: return "jvt"; case 0x0040: return "uscratch"; @@ -3081,6 +3092,8 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa= isa) case 66: op =3D rv_op_amoor_w; break; case 67: op =3D rv_op_amoor_d; break; case 68: op =3D rv_op_amoor_q; break; + case 74: op =3D rv_op_ssamoswap_w; break; + case 75: op =3D rv_op_ssamoswap_d; break; case 96: op =3D rv_op_amoand_b; break; case 97: op =3D rv_op_amoand_h; break; case 98: op =3D rv_op_amoand_w; break; @@ -4034,7 +4047,7 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa= isa) case 3: op =3D rv_op_csrrc; break; case 4: if (dec->cfg->ext_zimop) { - int imm_mop5, imm_mop3; + int imm_mop5, imm_mop3, reg_num; if ((extract32(inst, 22, 10) & 0b1011001111) =3D=3D 0b1000000111) { imm_mop5 =3D deposit32(deposit32(extract32(inst, 2= 0, 2), @@ -4042,11 +4055,36 @@ static void decode_inst_opcode(rv_decode *dec, rv_i= sa isa) extract32(inst, 26,= 2)), 4, 1, extract32(inst, 30, 1)); op =3D rv_mop_r_0 + imm_mop5; + /* if zicfiss enabled and mop5 is shadow stack */ + if (dec->cfg->ext_zicfiss && + ((imm_mop5 & 0b11100) =3D=3D 0b11100)) { + /* rs1=3D0 means ssrdp */ + if ((inst & (0b011111 << 15)) =3D=3D 0) { + op =3D rv_op_ssrdp; + } + /* rd=3D0 means sspopchk */ + reg_num =3D (inst >> 15) & 0b011111; + if (((inst & (0b011111 << 7)) =3D=3D 0) && + ((reg_num =3D=3D 1) || (reg_num =3D=3D= 5))) { + op =3D rv_op_sspopchk; + } + } } else if ((extract32(inst, 25, 7) & 0b1011001) =3D=3D 0b1000001) { imm_mop3 =3D deposit32(extract32(inst, 26, 2), 2, 1, extract32(inst, 30, 1)); op =3D rv_mop_rr_0 + imm_mop3; + /* if zicfiss enabled and mop3 is shadow stack */ + if (dec->cfg->ext_zicfiss && + ((imm_mop3 & 0b111) =3D=3D 0b111)) { + /* rs1=3D0 and rd=3D0 means sspush */ + reg_num =3D (inst >> 20) & 0b011111; + if (((inst & (0b011111 << 15)) =3D=3D 0) && + ((inst & (0b011111 << 7)) =3D=3D 0) && + ((reg_num =3D=3D 1) || (reg_num =3D=3D= 5))) { + op =3D rv_op_sspush; + } + } } } break; --=20 2.47.0