| From 0b86eeb0b821738b4661375ee082a8ab5c24d83c Mon Sep 17 00:00:00 2001 |
| From: Alexander Lobakin <alobakin@dlink.ru> |
| Date: Fri, 6 Dec 2019 11:07:41 +0300 |
| Subject: [PATCH] MIPS: BPF: eBPF JIT: check for MIPS ISA compliance in Kconfig |
| |
| commit f596cf0d8062cb5d0a4513a8b3afca318c13be10 upstream. |
| |
| 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> |
| Signed-off-by: Paul Burton <paulburton@kernel.org> |
| Cc: Ralf Baechle <ralf@linux-mips.org> |
| Cc: James Hogan <jhogan@kernel.org> |
| Cc: Hassan Naveed <hnaveed@wavecomp.com> |
| Cc: Alexei Starovoitov <ast@kernel.org> |
| Cc: Daniel Borkmann <daniel@iogearbox.net> |
| Cc: Martin KaFai Lau <kafai@fb.com> |
| Cc: Song Liu <songliubraving@fb.com> |
| Cc: Yonghong Song <yhs@fb.com> |
| Cc: Andrii Nakryiko <andriin@fb.com> |
| Cc: linux-mips@vger.kernel.org |
| Cc: linux-kernel@vger.kernel.org |
| Cc: netdev@vger.kernel.org |
| Cc: bpf@vger.kernel.org |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig |
| index c2ae77f71a66..53025ec6795f 100644 |
| --- a/arch/mips/Kconfig |
| +++ b/arch/mips/Kconfig |
| @@ -43,7 +43,7 @@ config MIPS |
| select HAVE_ARCH_SECCOMP_FILTER |
| select HAVE_ARCH_TRACEHOOK |
| select HAVE_ARCH_TRANSPARENT_HUGEPAGE if CPU_SUPPORTS_HUGEPAGES && 64BIT |
| - select HAVE_EBPF_JIT if (64BIT && !CPU_MICROMIPS) |
| + select HAVE_EBPF_JIT if 64BIT && !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.7.4 |
| |