Received: by 2002:a05:7412:1492:b0:e2:908c:2ebd with SMTP id s18csp666555rdh; Wed, 23 Aug 2023 11:04:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFCbIiXJJhjykhq0rTQhP+mTVZGZCc3RXOxx0NN8pKoJnzbhgAAofablD4a1d6bRBWwJmnO X-Received: by 2002:a17:90b:2304:b0:268:3f2d:66e4 with SMTP id mt4-20020a17090b230400b002683f2d66e4mr10188565pjb.37.1692813856074; Wed, 23 Aug 2023 11:04:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692813856; cv=none; d=google.com; s=arc-20160816; b=H3WOhyNhnxZehenI1ZBUMvaB0IXw2RyQhU2m8oHdFNbSOXNY/rEc9L6yzpFokjIEBW 2BLnkenpU0F6UL1HuCh4NmLH9KEvTUvmwgjL33qHwouHOQJMZOwkFA1ISrXDdsQaaamB 3zrG3HQUwKOcSl/u8mod8FOSAbLLPqEowHWuDHVSyZf0O+wY+O8/z+KT0ThvmbwhbJof 77QELem/Vzwu+aiYXLmmUDIlCGzAwnii/XvGM2J2xvzONUrM+GUNytA1Tmy0fhJ5B7im XklzFjm3lWKF3/9iDcu2krT6RMLHC0XkohEZXtBEoolaPMXq0Jw39qg2hJOJJmTOURYG 4JWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=7mBQZgRe7OFIeMD/tHFXAYeG2Qxa7oFvCTjatWhX0HI=; fh=ZPd1YdvfZgS5RR9ovLb4uYtpvo3A60HJjgebF+yx6GQ=; b=vZgdLR4aU4sr8TvHLfg9fBRHQEfxOa640/undJxZOIej28xy1gYqw5Qk1QfSKMs1pk TVv9u5Xr+0HO9OGxDvEgstcebkHTFqV8Jk1QfCkgcP3Tm0bPQhrMtxAwurkUcJf7NBP/ YOcG4Yd3hsut8DLhLOUyl8b4GcyNQTzyHGHdH1qQ73jOJE85rKgADpn5Xoejlo0TrD32 p9qas+VT66BDccBsrnQHjRlUF5/oTmFmQkbw78Jp+Jl0astqer7nbQSHnraIbMK5Id7y Epbb54wkwaGJyyA3AVSyxAuBo2NEtPfJCeaed9e2IHbWjk709u7wMyeeg9C/vmRRofBz eJBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q59-20020a17090a754100b00263d0beafafsi156420pjk.181.2023.08.23.11.04.03; Wed, 23 Aug 2023 11:04:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236809AbjHWPHJ (ORCPT + 99 others); Wed, 23 Aug 2023 11:07:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236774AbjHWPHB (ORCPT ); Wed, 23 Aug 2023 11:07:01 -0400 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9653E79; Wed, 23 Aug 2023 08:06:55 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.169]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4RW8gr1Ndtz4f3pFZ; Wed, 23 Aug 2023 23:06:48 +0800 (CST) Received: from ultra.huawei.com (unknown [10.90.53.71]) by APP4 (Coremail) with SMTP id gCh0CgAn_qCIIOZksUWeBQ--.39856S5; Wed, 23 Aug 2023 23:06:49 +0800 (CST) From: Pu Lehui To: linux-riscv@lists.infradead.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , 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: [PATCH bpf-next 3/7] riscv, bpf: Support sign-extension mov insns Date: Wed, 23 Aug 2023 23:10:55 +0000 Message-Id: <20230823231059.3363698-4-pulehui@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230823231059.3363698-1-pulehui@huaweicloud.com> References: <20230823231059.3363698-1-pulehui@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgAn_qCIIOZksUWeBQ--.39856S5 X-Coremail-Antispam: 1UD129KBjvdXoWrtFW7tF1rtw13uFW8WFW7Jwb_yoWftFg_Cr n7GayxWw45GFs5Aa4DAr4fArykCws5KF1kXFyv9ryq9rs8Wr1rJryktFyxu34xur1FkFZ5 Zr95J3ySyw42qjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbQ8FF20E14v26rWj6s0DM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M28IrcIa0xkI8V A2jI8067AKxVWUWwA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28C jxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI 8IcVCY1x0267AKxVWxJr0_GcWl84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2 jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4 CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jrv_JF1lYx0Ex4A2jsIE14v26r1j6r4UMcvj eVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I 1lFIxGxcIEc7CjxVA2Y2ka0xkIwI1lc7CjxVAaw2AFwI0_Jw0_GFyl42xK82IYc2Ij64vI r41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8Gjc xK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r4a6rW5MIIYrxkI7VAKI48JMIIF0xvE2Ix0 cI8IcVAFwI0_Gr0_Xr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4UJVWxJr1lIxAIcVCF04 k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIEc7Cj xVAFwI0_Gr1j6F4UJbIYCTnIWIevJa73UjIFyTuYvjTRMq2MDUUUU X-CM-SenderInfo: psxovxtxl6x35dzhxuhorxvhhfrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_00,DATE_IN_FUTURE_06_12, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); + break; + case 32: + emit_addiw(rd, rs, 0, ctx); + break; + } if (!is64 && !aux->verifier_zext) emit_zext_32(rd, ctx); break; -- 2.39.2