All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hengqi Chen <hengqi.chen@gmail.com>
To: loongarch@lists.linux.dev, bpf@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
	chenhuacai@kernel.org, kernel@xen0n.name, yangtiezhu@loongson.cn,
	hengqi.chen@gmail.com
Subject: [PATCH bpf-next 5/8] LoongArch: BPF: Support 32-bit offset jmp instructions
Date: Thu, 26 Oct 2023 18:43:34 +0000	[thread overview]
Message-ID: <20231026184337.563801-6-hengqi.chen@gmail.com> (raw)
In-Reply-To: <20231026184337.563801-1-hengqi.chen@gmail.com>

Add support for 32-bit offset jmp instruction. Currently,
we use b instruction which supports range within ±128MB
for such jumps. This should be large enough for BPF progs.

Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
---
 arch/loongarch/net/bpf_jit.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/loongarch/net/bpf_jit.c b/arch/loongarch/net/bpf_jit.c
index a8be6d4b058c..050fcf233a34 100644
--- a/arch/loongarch/net/bpf_jit.c
+++ b/arch/loongarch/net/bpf_jit.c
@@ -848,7 +848,11 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext
 
 	/* PC += off */
 	case BPF_JMP | BPF_JA:
-		jmp_offset = bpf2la_offset(i, off, ctx);
+	case BPF_JMP32 | BPF_JA:
+		if (BPF_CLASS(code) == BPF_JMP)
+			jmp_offset = bpf2la_offset(i, off, ctx);
+		else
+			jmp_offset = bpf2la_offset(i, imm, ctx);
 		if (emit_uncond_jmp(ctx, jmp_offset) < 0)
 			goto toofar;
 		break;
-- 
2.34.1


  parent reply	other threads:[~2023-10-27  6:01 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-26 18:43 [PATCH bpf-next 0/8] bpf: Support cpu v4 instructions for LoongArch Hengqi Chen
2023-10-26 18:43 ` [PATCH bpf-next 1/8] LoongArch: Add more instruction opcodes and emit_* helpers Hengqi Chen
2023-10-26 18:43 ` [PATCH bpf-next 2/8] LoongArch: BPF: Support sign-extension load instructions Hengqi Chen
2023-10-26 18:43 ` [PATCH bpf-next 3/8] LoongArch: BPF: Support sign-extension mov instructions Hengqi Chen
2023-10-26 18:43 ` [PATCH bpf-next 4/8] LoongArch: BPF: Support unconditional bswap instructions Hengqi Chen
2023-10-26 18:43 ` Hengqi Chen [this message]
2023-10-26 18:43 ` [PATCH bpf-next 6/8] LoongArch: BPF: Support signed div instructions Hengqi Chen
2023-10-26 18:43 ` [PATCH bpf-next 7/8] LoongArch: BPF: Support signed mod instructions Hengqi Chen
2023-10-26 18:43 ` [PATCH bpf-next 8/8] selftests/bpf: Enable cpu v4 tests for LoongArch Hengqi Chen
2023-10-27  7:05   ` Huacai Chen
2023-10-27  8:39     ` Hengqi Chen
2023-10-27  8:42       ` Huacai Chen
2023-10-27  9:41         ` Hengqi Chen
2023-10-27  9:46           ` Huacai Chen
2023-11-09 15:25   ` Huacai Chen
2023-11-11 14:50     ` Hengqi Chen
2023-11-11 16:19       ` Huacai Chen
2023-11-12  2:49         ` Huacai Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231026184337.563801-6-hengqi.chen@gmail.com \
    --to=hengqi.chen@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=chenhuacai@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel@xen0n.name \
    --cc=loongarch@lists.linux.dev \
    --cc=yangtiezhu@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.