* [PATCH mips-fixes] MIPS: BPF: eBPF JIT: check for MIPS ISA compliance in Kconfig
@ 2019-12-06 8:07 Alexander Lobakin
2019-12-06 19:18 ` Paul Burton
0 siblings, 1 reply; 2+ messages in thread
From: Alexander Lobakin @ 2019-12-06 8:07 UTC (permalink / raw)
To: Paul Burton
Cc: Ralf Baechle, James Hogan, Hassan Naveed, Alexei Starovoitov,
Daniel Borkmann, Martin KaFai Lau, Song Liu, Yonghong Song,
Andrii Nakryiko, Alexander Lobakin, linux-mips, linux-kernel,
netdev, bpf, stable
It is completely wrong to check for compile-time MIPS ISA revision in
the body of bpf_int_jit_compile() as it may lead to get MIPS JIT fully
omitted by the CC while the rest system will think that the JIT is
actually present and works [1].
We can check if the selected CPU really supports MIPS eBPF JIT at
configure time and avoid such situations when kernel can be built
without both JIT and interpreter, but with CONFIG_BPF_SYSCALL=y.
[1] https://lore.kernel.org/linux-mips/09d713a59665d745e21d021deeaebe0a@dlink.ru/
Fixes: 716850ab104d ("MIPS: eBPF: Initial eBPF support for MIPS32 architecture.")
Cc: <stable@vger.kernel.org> # v5.2+
Signed-off-by: Alexander Lobakin <alobakin@dlink.ru>
---
arch/mips/Kconfig | 2 +-
arch/mips/net/ebpf_jit.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index add388236f4e..407b85ee93e4 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -47,7 +47,7 @@ config MIPS
select HAVE_ARCH_TRACEHOOK
select HAVE_ARCH_TRANSPARENT_HUGEPAGE if CPU_SUPPORTS_HUGEPAGES
select HAVE_ASM_MODVERSIONS
- select HAVE_EBPF_JIT if (!CPU_MICROMIPS)
+ select HAVE_EBPF_JIT if !CPU_MICROMIPS && TARGET_ISA_REV >= 2
select HAVE_CONTEXT_TRACKING
select HAVE_COPY_THREAD_TLS
select HAVE_C_RECORDMCOUNT
diff --git a/arch/mips/net/ebpf_jit.c b/arch/mips/net/ebpf_jit.c
index 46b76751f3a5..a2405d5f7d1e 100644
--- a/arch/mips/net/ebpf_jit.c
+++ b/arch/mips/net/ebpf_jit.c
@@ -1803,7 +1803,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
unsigned int image_size;
u8 *image_ptr;
- if (!prog->jit_requested || MIPS_ISA_REV < 2)
+ if (!prog->jit_requested)
return prog;
tmp = bpf_jit_blind_constants(prog);
--
2.24.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH mips-fixes] MIPS: BPF: eBPF JIT: check for MIPS ISA compliance in Kconfig
2019-12-06 8:07 [PATCH mips-fixes] MIPS: BPF: eBPF JIT: check for MIPS ISA compliance in Kconfig Alexander Lobakin
@ 2019-12-06 19:18 ` Paul Burton
0 siblings, 0 replies; 2+ messages in thread
From: Paul Burton @ 2019-12-06 19:18 UTC (permalink / raw)
To: Alexander Lobakin
Cc: Paul Burton, Ralf Baechle, James Hogan, Hassan Naveed,
Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
Yonghong Song, Andrii Nakryiko, Alexander Lobakin, linux-mips,
linux-kernel, netdev, bpf, stable, linux-mips
Hello,
Alexander Lobakin wrote:
> It is completely wrong to check for compile-time MIPS ISA revision in
> the body of bpf_int_jit_compile() as it may lead to get MIPS JIT fully
> omitted by the CC while the rest system will think that the JIT is
> actually present and works [1].
> We can check if the selected CPU really supports MIPS eBPF JIT at
> configure time and avoid such situations when kernel can be built
> without both JIT and interpreter, but with CONFIG_BPF_SYSCALL=y.
>
> [1] https://lore.kernel.org/linux-mips/09d713a59665d745e21d021deeaebe0a@dlink.ru/
Applied to mips-fixes.
> commit 3721376d7d02
> https://git.kernel.org/mips/c/3721376d7d02
>
> Fixes: 716850ab104d ("MIPS: eBPF: Initial eBPF support for MIPS32 architecture.")
> Signed-off-by: Alexander Lobakin <alobakin@dlink.ru>
> Signed-off-by: Paul Burton <paulburton@kernel.org>
Thanks,
Paul
[ This message was auto-generated; if you believe anything is incorrect
then please email paulburton@kernel.org to report it. ]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-12-06 19:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-06 8:07 [PATCH mips-fixes] MIPS: BPF: eBPF JIT: check for MIPS ISA compliance in Kconfig Alexander Lobakin
2019-12-06 19:18 ` Paul Burton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).