[PATCH bpf-next 1/2] bpf, parisc: Add support for BPF_MOVSX in the parisc64 JIT

From: Nicholas Dudar

Date: Fri Nov 13 2026 - 16:24:31 EST


RFC9669 defines BPF_MOV | BPF_X with an offset of 8, 16 or 32 as a
sign-extending move, dst = (s8,s16,s32)src. The parisc64 JIT does not
look at the offset and emits a plain move, so r0 = (s8)r0 with 0x80
gives 128 instead of -128.

Sign-extend the low 8, 16 or 32 bits of the source with extrd,s for
ALU64, and the low 8 or 16 bits with extrw,s for ALU32. Zero-extend the
ALU32 result unless the verifier inserts the zero extension.

Under QEMU on a 64-bit kernel, with test_progs built as a static 32-bit
binary with jit_insns only:

# ./test_progs -t jit_insns -d jit_insns/helper_calls -w 0
[...]
#201/33 jit_insns/movsx:OK
[...]
#202 jit_insns_blinded:OK
Summary: 1/46 PASSED, 0 SKIPPED, 1/5 FAILED

Without this change jit_insns/movsx fails as well. The five failures
left fail without it too. jit_insns/helper_calls is left out because it
does not complete on the 64-bit kernel with or without this change.

Signed-off-by: Nicholas Dudar <main.kalliope@xxxxxxxxx>
---
arch/parisc/net/bpf_jit_comp64.c | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/arch/parisc/net/bpf_jit_comp64.c b/arch/parisc/net/bpf_jit_comp64.c
index c326fa737ec8..315ae2a3ead8 100644
--- a/arch/parisc/net/bpf_jit_comp64.c
+++ b/arch/parisc/net/bpf_jit_comp64.c
@@ -619,6 +619,17 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, struct hppa_jit_context *ctx,
emit_zext_32(rd, ctx);
break;
}
+ if (off == 8 || off == 16 || (is64 && off == 32)) {
+ /* Sign-extending mov: dst = (s8,s16,s32)src */
+ if (is64)
+ emit_hppa64_extrd(rs, 63, off, rd, true, ctx);
+ else
+ emit_hppa64_extrw(rs, 31, off, rd, true, ctx);
+
+ if (!is64 && !aux->verifier_zext)
+ emit_hppa64_zext32(rd, rd, ctx);
+ break;
+ }
if (!is64 && !aux->verifier_zext)
emit_hppa64_zext32(rs, rd, ctx);
else

--
2.53.0