Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1np6Qh-0001Jc-BM for mharc-qemu-riscv@gnu.org; Thu, 12 May 2022 06:52:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58722) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1np6QM-0001Fu-VN; Thu, 12 May 2022 06:52:05 -0400 Received: from gloria.sntech.de ([185.11.138.130]:60354) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1np6QJ-0004bS-O5; Thu, 12 May 2022 06:52:02 -0400 Received: from ip5b412258.dynamic.kabel-deutschland.de ([91.65.34.88] helo=diego.localnet) by gloria.sntech.de with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1np6Q9-0001XS-MS; Thu, 12 May 2022 12:51:49 +0200 From: Heiko =?ISO-8859-1?Q?St=FCbner?= To: qemu-devel@nongnu.org Cc: Dao Lu , Palmer Dabbelt , Alistair Francis , Bin Meng , "open list:RISC-V TCG CPUs" , Dao Lu Subject: Re: [PATCH 1/1] Add Zihintpause support Date: Thu, 12 May 2022 12:51:48 +0200 Message-ID: <2369175.jE0xQCEvom@diego> In-Reply-To: <20220510064231.1384670-2-daolu@rivosinc.com> References: <20220510064231.1384670-1-daolu@rivosinc.com> <20220510064231.1384670-2-daolu@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Received-SPF: none client-ip=185.11.138.130; envelope-from=heiko@sntech.de; helo=gloria.sntech.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-riscv@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 May 2022 10:52:09 -0000 Am Dienstag, 10. Mai 2022, 08:42:31 CEST schrieb Dao Lu: > Added support for RISC-V PAUSE instruction from Zihintpause extension, enabeld > by default. > > Signed-off-by: Dao Lu This patch with your fixup applied to it and of course a matching kernel: Tested-by: Heiko Stuebner > --- > target/riscv/cpu.c | 2 ++ > target/riscv/cpu.h | 1 + > target/riscv/insn32.decode | 7 ++++++- > target/riscv/insn_trans/trans_rvi.c.inc | 18 ++++++++++++++++++ > 4 files changed, 27 insertions(+), 1 deletion(-) > > diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c > index ccacdee215..183fb37fdf 100644 > --- a/target/riscv/cpu.c > +++ b/target/riscv/cpu.c > @@ -825,6 +825,7 @@ static Property riscv_cpu_properties[] = { > DEFINE_PROP_BOOL("Counters", RISCVCPU, cfg.ext_counters, true), > DEFINE_PROP_BOOL("Zifencei", RISCVCPU, cfg.ext_ifencei, true), > DEFINE_PROP_BOOL("Zicsr", RISCVCPU, cfg.ext_icsr, true), > + DEFINE_PROP_BOOL("Zihintpause", RISCVCPU, cfg.ext_zihintpause, true), > DEFINE_PROP_BOOL("Zfh", RISCVCPU, cfg.ext_zfh, false), > DEFINE_PROP_BOOL("Zfhmin", RISCVCPU, cfg.ext_zfhmin, false), > DEFINE_PROP_BOOL("Zve32f", RISCVCPU, cfg.ext_zve32f, false), > @@ -996,6 +997,7 @@ static void riscv_isa_string_ext(RISCVCPU *cpu, char **isa_str, int max_str_len) > * extensions by an underscore. > */ > struct isa_ext_data isa_edata_arr[] = { > + ISA_EDATA_ENTRY(zihintpause, ext_zihintpause), > ISA_EDATA_ENTRY(zfh, ext_zfh), > ISA_EDATA_ENTRY(zfhmin, ext_zfhmin), > ISA_EDATA_ENTRY(zfinx, ext_zfinx), > diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h > index fe6c9a2c92..e466a04a59 100644 > --- a/target/riscv/cpu.h > +++ b/target/riscv/cpu.h > @@ -394,6 +394,7 @@ struct RISCVCPUConfig { > bool ext_counters; > bool ext_ifencei; > bool ext_icsr; > + bool ext_zihintpause; > bool ext_svinval; > bool ext_svnapot; > bool ext_svpbmt; > diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode > index 4033565393..595fdcdad8 100644 > --- a/target/riscv/insn32.decode > +++ b/target/riscv/insn32.decode > @@ -149,7 +149,12 @@ srl 0000000 ..... ..... 101 ..... 0110011 @r > sra 0100000 ..... ..... 101 ..... 0110011 @r > or 0000000 ..... ..... 110 ..... 0110011 @r > and 0000000 ..... ..... 111 ..... 0110011 @r > -fence ---- pred:4 succ:4 ----- 000 ----- 0001111 > + > +{ > + pause 0000 0001 0000 00000 000 00000 0001111 > + fence ---- pred:4 succ:4 ----- 000 ----- 0001111 > +} > + > fence_i ---- ---- ---- ----- 001 ----- 0001111 > csrrw ............ ..... 001 ..... 1110011 @csr > csrrs ............ ..... 010 ..... 1110011 @csr > diff --git a/target/riscv/insn_trans/trans_rvi.c.inc b/target/riscv/insn_trans/trans_rvi.c.inc > index f1342f30f8..528c30c9a2 100644 > --- a/target/riscv/insn_trans/trans_rvi.c.inc > +++ b/target/riscv/insn_trans/trans_rvi.c.inc > @@ -18,6 +18,12 @@ > * this program. If not, see . > */ > > +#define REQUIRE_ZIHINTPAUSE(ctx) do { \ > + if (!ctx->cfg_ptr->ext_zihintpause) { \ > + return false; \ > + } \ > +} while (0) > + > static bool trans_illegal(DisasContext *ctx, arg_empty *a) > { > gen_exception_illegal(ctx); > @@ -796,6 +802,18 @@ static bool trans_srad(DisasContext *ctx, arg_srad *a) > return gen_shift(ctx, a, EXT_SIGN, tcg_gen_sar_tl, NULL); > } > > +static bool trans_pause(DisasContext *ctx, arg_pause *a) > +{ > + REQUIRE_ZIHINTPAUSE(ctx); > + > + /* > + * PAUSE is a no-op in QEMU, > + * however we need to clear the reservation > + */ > + tcg_gen_movi_tl(load_res, -1); > + > + return true; > +} > > static bool trans_fence(DisasContext *ctx, arg_fence *a) > { >