|
160 | 160 | ... |
161 | 161 | } |
162 | 162 |
|
163 | | -2.2.6 __prog Annotation |
| 163 | +2.2.6 __prog Annotation (deprecated, use KF_IMPLICIT_PROG_AUX_ARG instead) |
164 | 164 | --------------------------- |
165 | 165 | This annotation is used to indicate that the argument needs to be fixed up to |
166 | 166 | the bpf_prog_aux of the caller BPF program. Any value passed into this argument |
@@ -374,6 +374,43 @@ encouraged to make their use-cases known as early as possible, and participate |
374 | 374 | in upstream discussions regarding whether to keep, change, deprecate, or remove |
375 | 375 | those kfuncs if and when such discussions occur. |
376 | 376 |
|
| 377 | +2.4.10 KF_IMPLICIT_PROG_AUX_ARG flag |
| 378 | +------------------------------------ |
| 379 | + |
| 380 | +The KF_IMPLICIT_PROG_AUX_ARG flag is used to indicate that the last |
| 381 | +argument of a BPF kfunc is a pointer to struct bpf_prog_aux of the |
| 382 | +caller BPF program, implicitly set by the verifier. |
| 383 | + |
| 384 | +If a kfunc is marked with this flag, the function declaration in the |
| 385 | +kernel must have ``struct bpf_prog_aux *`` as the last argument. |
| 386 | +However in the kernel BTF (produced by pahole) this argument will be |
| 387 | +omitted, making it invisible to BPF programs calling the kfunc. |
| 388 | + |
| 389 | +Note that the implicit argument is an actual BPF argument passed |
| 390 | +through a register, reducing the number of the available function |
| 391 | +arguments. |
| 392 | + |
| 393 | +Example declaration: |
| 394 | + |
| 395 | +.. code-block:: c |
| 396 | +
|
| 397 | + __bpf_kfunc int bpf_task_work_schedule_resume(struct task_struct *task, struct bpf_task_work *tw, |
| 398 | + void *map__map, bpf_task_work_callback_t callback, |
| 399 | + struct bpf_prog_aux *aux) |
| 400 | + { |
| 401 | + return bpf_task_work_schedule(task, tw, map__map, callback, aux, TWA_RESUME); |
| 402 | + } |
| 403 | +
|
| 404 | + BTF_ID_FLAGS(func, bpf_task_work_schedule_resume, KF_TRUSTED_ARGS | KF_IMPLICIT_PROG_AUX_ARG) |
| 405 | +
|
| 406 | +Example usage: |
| 407 | + |
| 408 | +.. code-block:: c |
| 409 | +
|
| 410 | + /* note the last argument is ommitted */ |
| 411 | + bpf_task_work_schedule_resume(task, &tw, &hmap, process_work); |
| 412 | +
|
| 413 | +
|
377 | 414 | 2.5 Registering the kfuncs |
378 | 415 | -------------------------- |
379 | 416 |
|
|
0 commit comments