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 A90C6C3DA66 for ; Thu, 24 Aug 2023 01:17:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239007AbjHXBR2 (ORCPT ); Wed, 23 Aug 2023 21:17:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239003AbjHXBRZ (ORCPT ); Wed, 23 Aug 2023 21:17:25 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6411510E4; Wed, 23 Aug 2023 18:17:23 -0700 (PDT) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RWQ8B1qzzzNn3Y; Thu, 24 Aug 2023 09:13:46 +0800 (CST) Received: from [10.67.109.184] (10.67.109.184) by kwepemi500020.china.huawei.com (7.221.188.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 24 Aug 2023 09:17:20 +0800 Message-ID: <490126e3-b5da-4523-11af-62a2a3c33514@huawei.com> Date: Thu, 24 Aug 2023 09:17:19 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: [PATCH bpf-next 3/7] riscv, bpf: Support sign-extension mov insns Content-Language: en-US To: =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Pu Lehui , , , , 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 References: <20230823231059.3363698-1-pulehui@huaweicloud.com> <20230823231059.3363698-4-pulehui@huaweicloud.com> <87pm3dlj80.fsf@all.your.base.are.belong.to.us> From: Pu Lehui In-Reply-To: <87pm3dlj80.fsf@all.your.base.are.belong.to.us> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.109.184] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemi500020.china.huawei.com (7.221.188.8) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/8/24 2:14, Björn Töpel wrote: > 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_comp64.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. alright, will fix it > > (Side note: Maybe it's time to add Zbb support to the JIT soon! ;-)) > > > Björn