From: Jiaxun Yang <jiaxun.yang@flygoat.com>
To: linux-mips@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, tsbogend@alpha.franken.de,
johan.almbladh@anyfinetworks.com, paulburton@kernel.org,
bpf@vger.kernel.org, Jiaxun Yang <jiaxun.yang@flygoat.com>
Subject: [PATCH v2 1/2] MIPS: ebpf jit: Implement DADDI workarounds
Date: Tue, 28 Feb 2023 11:33:04 +0000 [thread overview]
Message-ID: <20230228113305.83751-2-jiaxun.yang@flygoat.com> (raw)
In-Reply-To: <20230228113305.83751-1-jiaxun.yang@flygoat.com>
For DADDI errata we just workaround by disable immediate operation
for BPF_ADD / BPF_SUB to avoid generation of DADDIU.
All other use cases in JIT won't cause overflow thus they are all safe.
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
v2: Drop 64BIT ifdef
---
arch/mips/Kconfig | 1 -
arch/mips/net/bpf_jit_comp.c | 4 ++++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 37072e15b263..df0910e3895c 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -64,7 +64,6 @@ config MIPS
select HAVE_DMA_CONTIGUOUS
select HAVE_DYNAMIC_FTRACE
select HAVE_EBPF_JIT if !CPU_MICROMIPS && \
- !CPU_DADDI_WORKAROUNDS && \
!CPU_R4000_WORKAROUNDS && \
!CPU_R4400_WORKAROUNDS
select HAVE_EXIT_THREAD
diff --git a/arch/mips/net/bpf_jit_comp.c b/arch/mips/net/bpf_jit_comp.c
index b17130d510d4..a40d926b6513 100644
--- a/arch/mips/net/bpf_jit_comp.c
+++ b/arch/mips/net/bpf_jit_comp.c
@@ -218,9 +218,13 @@ bool valid_alu_i(u8 op, s32 imm)
/* All legal eBPF values are valid */
return true;
case BPF_ADD:
+ if (IS_ENABLED(CONFIG_CPU_DADDI_WORKAROUNDS))
+ return false;
/* imm must be 16 bits */
return imm >= -0x8000 && imm <= 0x7fff;
case BPF_SUB:
+ if (IS_ENABLED(CONFIG_CPU_DADDI_WORKAROUNDS))
+ return false;
/* -imm must be 16 bits */
return imm >= -0x7fff && imm <= 0x8000;
case BPF_AND:
--
2.37.1 (Apple Git-137.1)
next prev parent reply other threads:[~2023-02-28 11:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-28 11:33 [PATCH v2 0/2] MIPS: Implement two workarounds for BPF JIT Jiaxun Yang
2023-02-28 11:33 ` Jiaxun Yang [this message]
2023-02-28 12:02 ` [PATCH v2 1/2] MIPS: ebpf jit: Implement DADDI workarounds Philippe Mathieu-Daudé
2023-02-28 12:35 ` Johan Almbladh
2023-02-28 11:33 ` [PATCH v2 2/2] MIPS: ebpf jit: Implement R4000 workarounds Jiaxun Yang
2023-02-28 14:00 ` [PATCH v2 0/2] MIPS: Implement two workarounds for BPF JIT patchwork-bot+netdevbpf
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=20230228113305.83751-2-jiaxun.yang@flygoat.com \
--to=jiaxun.yang@flygoat.com \
--cc=bpf@vger.kernel.org \
--cc=johan.almbladh@anyfinetworks.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=paulburton@kernel.org \
--cc=tsbogend@alpha.franken.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®