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.

Merge branch 'bpf-live-registers-computation-with-gotox'

Anton Protopopov says:

====================
bpf: Live registers computation with gotox

While adding a selftest for live registers computation with gotox,
I've noticed that the code is actually incomplete. Namely, the
destination register rX in `gotox rX` wasn't actually considered
as used. Fix this and add a selftest.

v1 -> v2:
* only enable the new selftest on x86 and arm64

v1: https://lore.kernel.org/bpf/20260114113314.32649-1-a.s.protopopov@gmail.com/T/#t
====================

Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://patch.msgid.link/20260114162544.83253-1-a.s.protopopov@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

+47
+6
kernel/bpf/verifier.c
··· 24848 24848 case BPF_JMP32: 24849 24849 switch (code) { 24850 24850 case BPF_JA: 24851 + def = 0; 24852 + if (BPF_SRC(insn->code) == BPF_X) 24853 + use = dst; 24854 + else 24855 + use = 0; 24856 + break; 24851 24857 case BPF_JCOND: 24852 24858 def = 0; 24853 24859 use = 0;
+41
tools/testing/selftests/bpf/progs/compute_live_registers.c
··· 431 431 ::: __clobber_all); 432 432 } 433 433 434 + #if defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64) 435 + 436 + SEC("socket") 437 + __log_level(2) 438 + __msg("2: .1........ (07) r1 += 8") 439 + __msg("3: .1........ (79) r2 = *(u64 *)(r1 +0)") 440 + __msg("4: ..2....... (b7) r3 = 1") 441 + __msg("5: ..23...... (b7) r4 = 2") 442 + __msg("6: ..234..... (0d) gotox r2") 443 + __msg("7: ...3...... (bf) r0 = r3") 444 + __msg("8: 0......... (95) exit") 445 + __msg("9: ....4..... (bf) r0 = r4") 446 + __msg("10: 0......... (95) exit") 447 + __naked 448 + void gotox(void) 449 + { 450 + asm volatile ( 451 + ".pushsection .jumptables,\"\",@progbits;" 452 + "jt0_%=: .quad l0_%= - socket;" 453 + ".quad l1_%= - socket;" 454 + ".size jt0_%=, 16;" 455 + ".global jt0_%=;" 456 + ".popsection;" 457 + 458 + "r1 = jt0_%= ll;" 459 + "r1 += 8;" 460 + "r2 = *(u64 *)(r1 + 0);" 461 + "r3 = 1;" 462 + "r4 = 2;" 463 + ".8byte %[gotox_r2];" 464 + "l0_%=: r0 = r3;" 465 + "exit;" 466 + "l1_%=: r0 = r4;" 467 + "exit;" 468 + : 469 + : __imm_insn(gotox_r2, BPF_RAW_INSN(BPF_JMP | BPF_JA | BPF_X, BPF_REG_2, BPF_REG_0, 0, 0)) 470 + : __clobber_all); 471 + } 472 + 473 + #endif /* __TARGET_ARCH_x86 || __TARGET_ARCH_arm64 */ 474 + 434 475 /* to retain debug info for BTF generation */ 435 476 void kfunc_root(void) 436 477 {