arch/arc/net/bpf_jit_core.c
Source file repositories/reference/linux-study-clean/arch/arc/net/bpf_jit_core.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arc/net/bpf_jit_core.c- Extension
.c- Size
- 37892 bytes
- Lines
- 1415
- Domain
- Architecture Layer
- Bucket
- arch/arc
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bug.hbpf_jit.h
Detected Declarations
struct jit_bufferstruct arc_jit_datastruct jit_contextfunction dump_bytesfunction vm_dumpfunction jit_dumpfunction jit_ctx_initfunction passfunction maybe_freefunction jit_ctx_cleanupfunction analyze_reg_usagefunction jit_buffer_checkfunction jit_buffer_updatefunction handle_prologuefunction handle_epiloguefunction get_index_for_insnfunction get_offsetfunction get_target_index_for_insnfunction has_immfunction is_last_insnfunction set_need_for_extra_passfunction handle_swapfunction check_insn_idx_validfunction bpf_cond_to_arcfunction check_bpf_jumpfunction indexfunction indexfunction feasible_jit_jumpfunction handle_jumpsfunction handle_jmp_epiloguefunction handle_callfunction handle_ld_imm64function handle_insnfunction handle_bodyfunction fill_ill_insnfunction jit_prepare_early_mem_allocfunction jit_preparefunction jit_preparefunction jit_compilefunction jit_finalizefunction check_jit_contextfunction jit_resume_contextfunction handle_callfunction jit_compilefunction bpf_jit_get_func_addr
Annotated Snippet
struct jit_buffer {
u8 *buf;
u32 len;
u32 index;
};
/*
* This is a subset of "struct jit_context" that its information is deemed
* necessary for the next extra pass to come.
*
* bpf_header: Needed to finally lock the region.
* bpf2insn: Used to find the translation for instructions of interest.
*
* Things like "jit.buf" and "jit.len" can be retrieved respectively from
* "prog->bpf_func" and "prog->jited_len".
*/
struct arc_jit_data {
struct bpf_binary_header *bpf_header;
u32 *bpf2insn;
};
/*
* The JIT pertinent context that is used by different functions.
*
* prog: The current eBPF program being handled.
* jit: The JIT buffer and its length.
* bpf_header: The JITed program header. "jit.buf" points inside it.
* emit: If set, opcodes are written to memory; else, a dry-run.
* do_zext: If true, 32-bit sub-regs must be zero extended.
* bpf2insn: Maps BPF insn indices to their counterparts in jit.buf.
* bpf2insn_valid: Indicates if "bpf2ins" is populated with the mappings.
* jit_data: A piece of memory to transfer data to the next pass.
* arc_regs_clobbered: Each bit status determines if that arc reg is clobbered.
* save_blink: Whether ARC's "blink" register needs to be saved.
* frame_size: Derived from "prog->aux->stack_depth".
* epilogue_offset: Used by early "return"s in the code to jump here.
* need_extra_pass: A forecast if an "extra_pass" will occur.
* is_extra_pass: Indicates if the current pass is an extra pass.
* user_bpf_prog: True, if VM opcodes come from a real program.
* success: Indicates if the whole JIT went OK.
*/
struct jit_context {
struct bpf_prog *prog;
struct jit_buffer jit;
struct bpf_binary_header *bpf_header;
bool emit;
bool do_zext;
u32 *bpf2insn;
bool bpf2insn_valid;
struct arc_jit_data *jit_data;
u32 arc_regs_clobbered;
bool save_blink;
u16 frame_size;
u32 epilogue_offset;
bool need_extra_pass;
bool is_extra_pass;
bool user_bpf_prog;
bool success;
};
/*
* If we're in ARC_BPF_JIT_DEBUG mode and the debug level is right, dump the
* input BPF stream. "bpf_jit_dump()" is not fully suited for this purpose.
*/
static void vm_dump(const struct bpf_prog *prog)
{
#ifdef ARC_BPF_JIT_DEBUG
if (bpf_jit_enable > 1)
dump_bytes((u8 *)prog->insns, 8 * prog->len, " VM ");
#endif
}
/*
* If the right level of debug is set, dump the bytes. There are 2 variants
* of this function:
*
* 1. Use the standard bpf_jit_dump() which is meant only for JITed code.
* 2. Use the dump_bytes() to match its "vm_dump()" instance.
*/
static void jit_dump(const struct jit_context *ctx)
{
#ifdef ARC_BPF_JIT_DEBUG
u8 header[8];
#endif
const int pass = ctx->is_extra_pass ? 2 : 1;
if (bpf_jit_enable <= 1 || !ctx->prog->jited)
return;
#ifdef ARC_BPF_JIT_DEBUG
Annotation
- Immediate include surface: `linux/bug.h`, `bpf_jit.h`.
- Detected declarations: `struct jit_buffer`, `struct arc_jit_data`, `struct jit_context`, `function dump_bytes`, `function vm_dump`, `function jit_dump`, `function jit_ctx_init`, `function pass`, `function maybe_free`, `function jit_ctx_cleanup`.
- Atlas domain: Architecture Layer / arch/arc.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.