arch/sparc/net/bpf_jit_comp_64.c
Source file repositories/reference/linux-study-clean/arch/sparc/net/bpf_jit_comp_64.c
File Facts
- System
- Linux kernel
- Corpus path
arch/sparc/net/bpf_jit_comp_64.c- Extension
.c- Size
- 38759 bytes
- Lines
- 1614
- Domain
- Architecture Layer
- Bucket
- arch/sparc
- 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/moduleloader.hlinux/workqueue.hlinux/netdevice.hlinux/filter.hlinux/bpf.hlinux/cache.hlinux/if_vlan.hasm/cacheflush.hasm/ptrace.hbpf_jit_64.h
Detected Declarations
struct jit_ctxstruct sparc64_jit_datafunction is_simm13function is_simm10function is_simm5function is_sethifunction bpf_flush_icachefunction WDISP10function emitfunction emit_callfunction emit_nopfunction emit_reg_movefunction emit_set_constfunction emit_set_const_sextfunction emit_alufunction emit_alu3function emit_alu_Kfunction emit_alu3_Kfunction emit_loadimm32function emit_loadimmfunction emit_loadimm_sextfunction analyze_64bit_constantfunction create_simple_focus_bitsfunction const64_is_2insnsfunction sparc_emit_set_const64_quick2function emit_loadimm64function emit_branchfunction emit_cbcondfunction emit_cbcondifunction emit_compare_and_branchfunction build_prologuefunction build_epiloguefunction emit_tail_callfunction build_insnfunction build_bodyfunction jit_fill_holefunction bpf_jit_needs_zext
Annotated Snippet
struct jit_ctx {
struct bpf_prog *prog;
unsigned int *offset;
int idx;
int epilogue_offset;
bool tmp_1_used;
bool tmp_2_used;
bool tmp_3_used;
bool saw_frame_pointer;
bool saw_call;
bool saw_tail_call;
u32 *image;
};
#define TMP_REG_1 (MAX_BPF_JIT_REG + 0)
#define TMP_REG_2 (MAX_BPF_JIT_REG + 1)
#define TMP_REG_3 (MAX_BPF_JIT_REG + 2)
/* Map BPF registers to SPARC registers */
static const int bpf2sparc[] = {
/* return value from in-kernel function, and exit value from eBPF */
[BPF_REG_0] = O5,
/* arguments from eBPF program to in-kernel function */
[BPF_REG_1] = O0,
[BPF_REG_2] = O1,
[BPF_REG_3] = O2,
[BPF_REG_4] = O3,
[BPF_REG_5] = O4,
/* callee saved registers that in-kernel function will preserve */
[BPF_REG_6] = L0,
[BPF_REG_7] = L1,
[BPF_REG_8] = L2,
[BPF_REG_9] = L3,
/* read-only frame pointer to access stack */
[BPF_REG_FP] = L6,
[BPF_REG_AX] = G7,
/* temporary register for BPF JIT */
[TMP_REG_1] = G1,
[TMP_REG_2] = G2,
[TMP_REG_3] = G3,
};
static void emit(const u32 insn, struct jit_ctx *ctx)
{
if (ctx->image != NULL)
ctx->image[ctx->idx] = insn;
ctx->idx++;
}
static void emit_call(u32 *func, struct jit_ctx *ctx)
{
if (ctx->image != NULL) {
void *here = &ctx->image[ctx->idx];
unsigned int off;
off = (void *)func - here;
ctx->image[ctx->idx] = CALL | ((off >> 2) & 0x3fffffff);
}
ctx->idx++;
}
static void emit_nop(struct jit_ctx *ctx)
{
emit(SETHI(0, G0), ctx);
}
static void emit_reg_move(u32 from, u32 to, struct jit_ctx *ctx)
{
emit(OR | RS1(G0) | RS2(from) | RD(to), ctx);
}
/* Emit 32-bit constant, zero extended. */
static void emit_set_const(s32 K, u32 reg, struct jit_ctx *ctx)
{
emit(SETHI(K, reg), ctx);
emit(OR_LO(K, reg), ctx);
}
/* Emit 32-bit constant, sign extended. */
static void emit_set_const_sext(s32 K, u32 reg, struct jit_ctx *ctx)
{
if (K >= 0) {
emit(SETHI(K, reg), ctx);
emit(OR_LO(K, reg), ctx);
Annotation
- Immediate include surface: `linux/moduleloader.h`, `linux/workqueue.h`, `linux/netdevice.h`, `linux/filter.h`, `linux/bpf.h`, `linux/cache.h`, `linux/if_vlan.h`, `asm/cacheflush.h`.
- Detected declarations: `struct jit_ctx`, `struct sparc64_jit_data`, `function is_simm13`, `function is_simm10`, `function is_simm5`, `function is_sethi`, `function bpf_flush_icache`, `function WDISP10`, `function emit`, `function emit_call`.
- Atlas domain: Architecture Layer / arch/sparc.
- 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.