@@ -16125,7 +16125,7 @@ static int visit_func_call_insn(int t, struct bpf_insn *insns,
16125
16125
*/
16126
16126
static u32 helper_fastcall_clobber_mask(const struct bpf_func_proto *fn)
16127
16127
{
16128
- u8 mask;
16128
+ u32 mask;
16129
16129
int i;
16130
16130
16131
16131
mask = 0;
@@ -16153,6 +16153,26 @@ static bool verifier_inlines_helper_call(struct bpf_verifier_env *env, s32 imm)
16153
16153
}
16154
16154
}
16155
16155
16156
+ /* Same as helper_fastcall_clobber_mask() but for kfuncs, see comment above */
16157
+ static u32 kfunc_fastcall_clobber_mask(struct bpf_kfunc_call_arg_meta *meta)
16158
+ {
16159
+ u32 vlen, i, mask;
16160
+
16161
+ vlen = btf_type_vlen(meta->func_proto);
16162
+ mask = 0;
16163
+ if (!btf_type_is_void(btf_type_by_id(meta->btf, meta->func_proto->type)))
16164
+ mask |= BIT(BPF_REG_0);
16165
+ for (i = 0; i < vlen; ++i)
16166
+ mask |= BIT(BPF_REG_1 + i);
16167
+ return mask;
16168
+ }
16169
+
16170
+ /* Same as verifier_inlines_helper_call() but for kfuncs, see comment above */
16171
+ static bool is_fastcall_kfunc_call(struct bpf_kfunc_call_arg_meta *meta)
16172
+ {
16173
+ return false;
16174
+ }
16175
+
16156
16176
/* LLVM define a bpf_fastcall function attribute.
16157
16177
* This attribute means that function scratches only some of
16158
16178
* the caller saved registers defined by ABI.
@@ -16250,6 +16270,19 @@ static void mark_fastcall_pattern_for_call(struct bpf_verifier_env *env,
16250
16270
bpf_jit_inlines_helper_call(call->imm));
16251
16271
}
16252
16272
16273
+ if (bpf_pseudo_kfunc_call(call)) {
16274
+ struct bpf_kfunc_call_arg_meta meta;
16275
+ int err;
16276
+
16277
+ err = fetch_kfunc_meta(env, call, &meta, NULL);
16278
+ if (err < 0)
16279
+ /* error would be reported later */
16280
+ return;
16281
+
16282
+ clobbered_regs_mask = kfunc_fastcall_clobber_mask(&meta);
16283
+ can_be_inlined = is_fastcall_kfunc_call(&meta);
16284
+ }
16285
+
16253
16286
if (clobbered_regs_mask == ALL_CALLER_SAVED_REGS)
16254
16287
return;
16255
16288
0 commit comments