Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bpf, mips: Implement R4000 workarounds for JIT

For R4000 erratas around multiplication and division instructions,
as our use of those instructions are always followed by mflo/mfhi
instructions, the only issue we need care is

"MIPS R4000PC/SC Errata, Processor Revision 2.2 and 3.0" Errata 28:
"A double-word or a variable shift may give an incorrect result if
executed while an integer multiplication is in progress."

We just emit a mfhi $0 to ensure the operation is completed after
every multiplication instruction according to workaround suggestion
in the document.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Acked-by: Johan Almbladh <johan.almbladh@anyfinetworks.com>
Link: https://lore.kernel.org/bpf/20230228113305.83751-3-jiaxun.yang@flygoat.com

authored by

Jiaxun Yang and committed by
Daniel Borkmann
7364d60c bbefef2f

+4 -3
+1 -3
arch/mips/Kconfig
··· 63 63 select HAVE_DEBUG_STACKOVERFLOW 64 64 select HAVE_DMA_CONTIGUOUS 65 65 select HAVE_DYNAMIC_FTRACE 66 - select HAVE_EBPF_JIT if !CPU_MICROMIPS && \ 67 - !CPU_R4000_WORKAROUNDS && \ 68 - !CPU_R4400_WORKAROUNDS 66 + select HAVE_EBPF_JIT if !CPU_MICROMIPS 69 67 select HAVE_EXIT_THREAD 70 68 select HAVE_FAST_GUP 71 69 select HAVE_FTRACE_MCOUNT_RECORD
+3
arch/mips/net/bpf_jit_comp64.c
··· 228 228 } else { 229 229 emit(ctx, dmultu, dst, src); 230 230 emit(ctx, mflo, dst); 231 + /* Ensure multiplication is completed */ 232 + if (IS_ENABLED(CONFIG_CPU_R4000_WORKAROUNDS)) 233 + emit(ctx, mfhi, MIPS_R_ZERO); 231 234 } 232 235 break; 233 236 /* dst = dst / src */