From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54310C3DA6F for ; Wed, 23 Aug 2023 18:14:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238064AbjHWSO1 (ORCPT ); Wed, 23 Aug 2023 14:14:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237624AbjHWSOO (ORCPT ); Wed, 23 Aug 2023 14:14:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8025DCC7 for ; Wed, 23 Aug 2023 11:14:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0E2C162D6C for ; Wed, 23 Aug 2023 18:14:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A293FC433C8; Wed, 23 Aug 2023 18:14:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692814451; bh=6WYbdQvbaUTU7jAYsOoRLczdc6WiEmOJqx1owqQdczY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=jnp9OnkqCFGBj/h9OTMFiamfq/+P0dMbhMG2wym3WRwS3We453QbP6a6Naa6WA/55 d4lxewnPO9sJ/eOFdW8Id7q+oLH+qu5WfYDQfCvEZsEqA4fHS1ZXjl/MCVrHUqcm2V rQnTACprz2PN91Wy6YquXbrmyxgR7JTtwCnIMQ5ArUm5o9SmwEW1AslQAiAZraDgQF h2tDxxbMKoaqy+zaiPzYbMLAi/oaijp+DPUTHk158fgQD2Ywb/PZFPbzgyDYkg8qH9 1W3Xw4IOX9qUdj1RLfiTo/cEPzNfdE8Ln2S04DCPkN4s+5vlwAgONpQFbmC2McakrT EjkJ7PP63sJqw== From: =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= To: Pu Lehui , linux-riscv@lists.infradead.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Yonghong Song , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Palmer Dabbelt , Xu Kuohai , Puranjay Mohan , Pu Lehui , Pu Lehui Subject: Re: [PATCH bpf-next 3/7] riscv, bpf: Support sign-extension mov insns In-Reply-To: <20230823231059.3363698-4-pulehui@huaweicloud.com> References: <20230823231059.3363698-1-pulehui@huaweicloud.com> <20230823231059.3363698-4-pulehui@huaweicloud.com> Date: Wed, 23 Aug 2023 20:14:07 +0200 Message-ID: <87pm3dlj80.fsf@all.your.base.are.belong.to.us> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Pu Lehui writes: > From: Pu Lehui > > Add support sign-extension mov instructions for RV64. > > Signed-off-by: Pu Lehui > --- > arch/riscv/net/bpf_jit_comp64.c | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > > diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_com= p64.c > index fd36cb17101a..d1497182cacf 100644 > --- a/arch/riscv/net/bpf_jit_comp64.c > +++ b/arch/riscv/net/bpf_jit_comp64.c > @@ -1047,7 +1047,19 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn,= struct rv_jit_context *ctx, > emit_zext_32(rd, ctx); > break; > } > - emit_mv(rd, rs, ctx); > + switch (insn->off) { > + case 0: > + emit_mv(rd, rs, ctx); > + break; > + case 8: > + case 16: > + emit_slli(rs, rs, 64 - insn->off, ctx); > + emit_srai(rd, rs, 64 - insn->off, ctx); You're clobbering the source register (rs) here, which is correct. (Side note: Maybe it's time to add Zbb support to the JIT soon! ;-)) Bj=C3=B6rn