linux/arch/mips
Paul Burton bdc18902ea
MIPS: eBPF: Always return sign extended 32b values
The function prototype used to call JITed eBPF code (ie. the type of the
struct bpf_prog bpf_func field) returns an unsigned int. The MIPS n64
ABI that MIPS64 kernels target defines that 32 bit integers should
always be sign extended when passed in registers as either arguments or
return values.

This means that when returning any value which may not already be sign
extended (ie. of type REG_64BIT or REG_32BIT_ZERO_EX) we need to perform
that sign extension in order to comply with the n64 ABI. Without this we
see strange looking test failures from test_bpf.ko, such as:

  test_bpf: #65 ALU64_MOV_X:
    dst = 4294967295 jited:1 ret -1 != -1 FAIL (1 times)

Although the return value printed matches the expected value, this is
only because printf is only examining the least significant 32 bits of
the 64 bit register value we returned. The register holding the expected
value is sign extended whilst the v0 register was set to a zero extended
value by our JITed code, so when compared by a conditional branch
instruction the values are not equal.

We already handle this when the return value register is of type
REG_32BIT_ZERO_EX, so simply extend this to also cover REG_64BIT.

Signed-off-by: Paul Burton <paul.burton@mips.com>
Fixes: b6bd53f9c4 ("MIPS: Add missing file for eBPF JIT.")
Cc: stable@vger.kernel.org # v4.13+
Cc: linux-mips@vger.kernel.org
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: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: Jiong Wang <jiong.wang@netronome.com>
2019-02-19 12:17:28 -08:00
..
alchemy A few early MIPS fixes for 4.21: 2019-01-05 12:48:25 -08:00
ar7 mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
ath25 PCI: consolidate PCI config entry in drivers/pci 2018-11-23 11:45:34 +09:00
ath79 MIPS: ath79: drop !OF clock code 2019-01-22 11:17:22 -08:00
bcm47xx MIPS: BCM47XX: Fix/improve Buffalo WHR-G54S support 2019-02-11 13:29:33 -08:00
bcm63xx A few early MIPS fixes for 4.21: 2019-01-05 12:48:25 -08:00
bmips mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
boot MIPS: OCTEON: program rx/tx-delay always from DT 2019-02-07 15:22:38 -08:00
cavium-octeon MIPS: OCTEON: program rx/tx-delay always from DT 2019-02-07 15:22:38 -08:00
cobalt
configs Here's the main MIPS pull for Linux 4.21. Core architecture changes 2018-12-26 10:45:33 -08:00
crypto MIPS: crypto: Add crc32 and crc32c hw accelerated module 2018-02-19 20:50:36 +00:00
dec mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
emma mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
fw mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
generic MIPS: mscc: add PCB120 to the ocelot fitImage 2018-10-09 10:38:29 -07:00
include MIPS: OCTEON: program rx/tx-delay always from DT 2019-02-07 15:22:38 -08:00
jazz mips/jazz: remove the mapping_error dma_map_ops method 2018-12-06 06:56:38 -08:00
jz4740 mmc: jz4740: Use GPIO descriptor for power 2018-12-17 08:26:24 +01:00
kernel MIPS: CM: Fix indentation 2019-02-15 14:22:44 -08:00
kvm MIPS: MemoryMapID (MMID) Support 2019-02-04 10:56:41 -08:00
lantiq cross-tree: phase out dma_zalloc_coherent() 2019-01-08 07:58:37 -05:00
lasat mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
lib MIPS: MemoryMapID (MMID) Support 2019-02-04 10:56:41 -08:00
loongson32 MIPS: Loongson32: Remove DMA & NAND devices from ls1b/board.c 2019-02-04 14:44:33 -08:00
loongson64 Kconfig file consolidation for v4.21 2018-12-29 13:40:29 -08:00
math-emu mips: math-emu: no need to check return value of debugfs_create functions 2019-01-22 11:17:20 -08:00
mm MIPS: Delete unused flush_cache_sigtramp() 2019-02-07 12:59:45 -08:00
mti-malta MIPS: malta: Use img-ascii-lcd driver for LCD display 2018-11-20 21:05:39 -08:00
net MIPS: eBPF: Always return sign extended 32b values 2019-02-19 12:17:28 -08:00
netlogic mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
oprofile Remove 'type' argument from access_ok() function 2019-01-03 18:57:57 -08:00
paravirt mips: unify prom_putchar() declarations 2018-07-17 09:40:17 -07:00
pci MIPS: ath79: drop legacy pci code 2019-01-22 11:17:22 -08:00
pic32 mips: unify prom_putchar() declarations 2018-07-17 09:40:17 -07:00
pistachio License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pmcs-msp71xx PCI: consolidate PCI config entry in drivers/pci 2018-11-23 11:45:34 +09:00
pnx833x mtd: rawnand: Move platform_nand_xxx definitions out of rawnand.h 2018-10-03 11:12:25 +02:00
power License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ralink mips: ralink: no need to check return value of debugfs_create functions 2019-01-22 11:17:20 -08:00
rb532 ata: rb532_cf: Convert to use GPIO descriptors 2018-12-04 17:15:25 -07:00
sgi-ip22 MIPS: Remove no-op/identity casts 2018-08-31 11:49:20 -07:00
sgi-ip27 MIPS: Loongson3,SGI-IP27: Simplify max_low_pfn calculation 2018-11-15 15:42:15 -08:00
sgi-ip32 MIPS: IP32: use generic dma noncoherent ops 2018-06-24 09:27:27 -07:00
sibyte Remove 'type' argument from access_ok() function 2019-01-03 18:57:57 -08:00
sni MIPS: sni: Remove the read_persistent_clock() 2018-05-14 23:58:25 +01:00
tools MIPS: Use a custom elf-entry program to find kernel entry point 2018-08-30 09:39:22 -07:00
txx9 PCI: consolidate PCI config entry in drivers/pci 2018-11-23 11:45:34 +09:00
vdso MIPS: Enable Undefined Behavior Sanitizer UBSAN 2018-11-20 12:23:06 -08:00
vr41xx PCI: consolidate PCI config entry in drivers/pci 2018-11-23 11:45:34 +09:00
Kbuild MIPS: Disable Werror when W= is set 2017-04-10 11:56:07 +02:00
Kbuild.platforms MIPS: Xilfpga: Switch to using generic defconfigs 2017-11-08 22:54:14 +00:00
Kconfig MIPS: Loongson32: Fix config brokenness; select SYS_SUPPORTS_32BIT_KERNEL 2019-02-04 14:44:06 -08:00
Kconfig.debug Kconfig: consolidate the "Kernel hacking" menu 2018-08-02 08:06:48 +09:00
Makefile MIPS: Add GINVT instruction helpers 2019-02-04 10:56:35 -08:00
Makefile.postlink License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00