[PATCH bpf-next 0/3] support nocsr patterns for calls to kfuncs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As an extension of [1], allow nocsr patterns recognition for kfuncs:
- pattern rules are the same as for helpers;
- spill/fill removal is allowed only for kfuncs marked with KF_NOCSR
  flag;

Mark bpf_cast_to_kern_ctx() and bpf_rdonly_cast() kfuncs as KF_NOCSR
in order to conjure selftests for this feature.

After this patch-set verifier would rewrite the program below:

  r2 = 1
  *(u64 *)(r10 - 32) = r2
  call %[bpf_cast_to_kern_ctx]
  r2 = *(u64 *)(r10 - 32)
  r0 = r2;"

As follows:

  r2 = 1   /* spill/fill at r10[-32] is removed */
  r0 = r1  /* replacement for bpf_cast_to_kern_ctx() */
  r0 = r2
  exit

[1] no_caller_saved_registers attribute for helper calls
    https://lore.kernel.org/bpf/20240722233844.1406874-1-eddyz87@xxxxxxxxx/

Eduard Zingerman (3):
  bpf: support nocsr patterns for calls to kfuncs
  bpf: mark bpf_cast_to_kern_ctx and bpf_rdonly_cast as KF_NOCSR
  selftests/bpf: check if nocsr pattern is recognized for kfuncs

 include/linux/btf.h                           |  1 +
 kernel/bpf/helpers.c                          |  4 +-
 kernel/bpf/verifier.c                         | 37 ++++++++++++++
 .../selftests/bpf/progs/verifier_nocsr.c      | 50 +++++++++++++++++++
 4 files changed, 90 insertions(+), 2 deletions(-)

-- 
2.45.2





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux