Let offload JITs know when instructions are replaced and optimized out, so they can update their state appropriately. The optimizations are best effort, if JIT returns an error from any callback verifier will stop notifying it as state may now be out of sync, but the verifier continues making progress.
Showing the changes to include/linux (2 of 4 files). Show all
Unified · Split
| @@ -268,9 +268,15 @@ struct bpf_verifier_ops { · 267 unmodified lines | ||
| 268 | 268 | }; |
| 269 | 269 | |
| 270 | 270 | struct bpf_prog_offload_ops { |
| 271 | + /* verifier basic callbacks */ | |
| 271 | 272 | int (*insn_hook)(struct bpf_verifier_env *env, |
| 272 | 273 | int insn_idx, int prev_insn_idx); |
| 273 | 274 | int (*finalize)(struct bpf_verifier_env *env); |
| 275 | + /* verifier optimization callbacks (called after .finalize) */ | |
| 276 | + int (*replace_insn)(struct bpf_verifier_env *env, u32 off, | |
| 277 | + struct bpf_insn *insn); | |
| 278 | + int (*remove_insns)(struct bpf_verifier_env *env, u32 off, u32 cnt); | |
| 279 | + /* program management callbacks */ | |
| 274 | 280 | int (*prepare)(struct bpf_prog *prog); |
| 275 | 281 | int (*translate)(struct bpf_prog *prog); |
| 276 | 282 | void (*destroy)(struct bpf_prog *prog); |
| @@ -283,6 +289,7 @@ struct bpf_prog_offload { · 6 unmodified lines | ||
| 283 | 289 | void *dev_priv; |
| 284 | 290 | struct list_head offloads; |
| 285 | 291 | bool dev_state; |
| 292 | + bool opt_failed; | |
| 286 | 293 | void *jited_image; |
| 287 | 294 | u32 jited_len; |
| 288 | 295 | }; |
| @@ -266,5 +266,10 @@ int bpf_prog_offload_verifier_prep(struct bpf_prog *prog); · 265 unmodified lines | ||
| 266 | 266 | int bpf_prog_offload_verify_insn(struct bpf_verifier_env *env, |
| 267 | 267 | int insn_idx, int prev_insn_idx); |
| 268 | 268 | int bpf_prog_offload_finalize(struct bpf_verifier_env *env); |
| 269 | +void | |
| 270 | +bpf_prog_offload_replace_insn(struct bpf_verifier_env *env, u32 off, | |
| 271 | + struct bpf_insn *insn); | |
| 272 | +void | |
| 273 | +bpf_prog_offload_remove_insns(struct bpf_verifier_env *env, u32 off, u32 cnt); | |
| 269 | 274 | |
| 270 | 275 | #endif /* _LINUX_BPF_VERIFIER_H */ |