Re: [PATCH bpf-next 2/3] bpf: mark bpf_cast_to_kern_ctx and bpf_rdonly_cast as KF_NOCSR

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

 



On Mon, Aug 12, 2024 at 4:44 PM Eduard Zingerman <eddyz87@xxxxxxxxx> wrote:
>
> do_misc_fixups() relaces bpf_cast_to_kern_ctx() and bpf_rdonly_cast()
> by a single instruction "r0 = r1". This clearly follows nocsr contract.
> Mark these two functions as KF_NOCSR, in order to use them in
> selftests checking KF_NOCSR behaviour for kfuncs.
>
> Signed-off-by: Eduard Zingerman <eddyz87@xxxxxxxxx>
> ---
>  kernel/bpf/helpers.c  | 4 ++--
>  kernel/bpf/verifier.c | 3 ++-
>  2 files changed, 4 insertions(+), 3 deletions(-)

Isn't it now "bpf fastcall" and not "nocsr"? Shouldn't the flag and
verifier code reflect this updated terminology?

>
> diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
> index d02ae323996b..cda3c326eeb1 100644
> --- a/kernel/bpf/helpers.c
> +++ b/kernel/bpf/helpers.c
> @@ -2987,8 +2987,8 @@ BTF_ID(func, bpf_cgroup_release_dtor)
>  #endif
>
>  BTF_KFUNCS_START(common_btf_ids)
> -BTF_ID_FLAGS(func, bpf_cast_to_kern_ctx)
> -BTF_ID_FLAGS(func, bpf_rdonly_cast)
> +BTF_ID_FLAGS(func, bpf_cast_to_kern_ctx, KF_NOCSR)
> +BTF_ID_FLAGS(func, bpf_rdonly_cast, KF_NOCSR)
>  BTF_ID_FLAGS(func, bpf_rcu_read_lock)
>  BTF_ID_FLAGS(func, bpf_rcu_read_unlock)
>  BTF_ID_FLAGS(func, bpf_dynptr_slice, KF_RET_NULL)
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index c579f74be3f9..88e583a37296 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -16159,7 +16159,8 @@ static u32 kfunc_nocsr_clobber_mask(struct bpf_kfunc_call_arg_meta *meta)
>  /* Same as verifier_inlines_helper_call() but for kfuncs, see comment above */
>  static bool verifier_inlines_kfunc_call(struct bpf_kfunc_call_arg_meta *meta)
>  {
> -       return false;
> +       return meta->func_id == special_kfunc_list[KF_bpf_cast_to_kern_ctx] ||
> +              meta->func_id == special_kfunc_list[KF_bpf_rdonly_cast];
>  }
>
>  /* GCC and LLVM define a no_caller_saved_registers function attribute.
> --
> 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