arch/s390/net/bpf_jit_comp.c
Source file repositories/reference/linux-study-clean/arch/s390/net/bpf_jit_comp.c
File Facts
- System
- Linux kernel
- Corpus path
arch/s390/net/bpf_jit_comp.c- Extension
.c- Size
- 85292 bytes
- Lines
- 3097
- Domain
- Architecture Layer
- Bucket
- arch/s390
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/netdevice.hlinux/filter.hlinux/init.hlinux/bpf.hlinux/mm.hlinux/kernel.hasm/cacheflush.hasm/extable.hasm/dis.hasm/facility.hasm/lowcore.hasm/nospec-branch.hasm/set_memory.hasm/text-patching.hasm/unwind.h
Detected Declarations
struct bpf_jitstruct prog_framestruct bpf_pltstruct bpf_jit_probestruct s390_jit_datastruct bpf_tramp_jitfunction regfunction reg_highfunction reg_set_seenfunction off_to_pcrelfunction ptr_to_pcrelfunction emit6_pcrel_rilfunction emit6_pcrel_rilbfunction emit6_pcrel_rilcfunction is_first_passfunction is_codegen_passfunction is_valid_relfunction can_use_relfunction is_valid_ldispfunction can_use_ldisp_for_lit32function can_use_ldisp_for_lit64function jit_fill_holefunction save_regsfunction restore_regsfunction registerfunction registerfunction registersfunction bpf_skipfunction bpf_jit_pltfunction bpf_jit_prologuefunction bpf_jit_epiloguefunction ex_handler_bpffunction bpf_jit_probe_initfunction bpf_jit_probe_emit_nopfunction bpf_jit_probe_load_prefunction bpf_jit_probe_store_prefunction bpf_jit_probe_atomic_prefunction bpf_jit_probe_postfunction sign_zero_extendfunction bpf_jit_insnfunction bpf_is_new_addr_sanefunction bpf_set_addrfunction bpf_jit_progfunction bpf_jit_needs_zextfunction bpf_jit_supports_kfunc_callfunction bpf_jit_supports_far_kfunc_callfunction bpf_arch_text_pokefunction load_imm64
Annotated Snippet
struct bpf_jit {
u32 seen; /* Flags to remember seen eBPF instructions */
u16 seen_regs; /* Mask to remember which registers are used */
u32 *addrs; /* Array with relative instruction addresses */
u8 *prg_buf; /* Start of program */
int size; /* Size of program and literal pool */
int size_prg; /* Size of program */
int prg; /* Current position in program */
int lit32_start; /* Start of 32-bit literal pool */
int lit32; /* Current position in 32-bit literal pool */
int lit64_start; /* Start of 64-bit literal pool */
int lit64; /* Current position in 64-bit literal pool */
int base_ip; /* Base address for literal pool */
int exit_ip; /* Address of exit */
int tail_call_start; /* Tail call start offset */
int excnt; /* Number of exception table entries */
int prologue_plt_ret; /* Return address for prologue hotpatch PLT */
int prologue_plt; /* Start of prologue hotpatch PLT */
int kern_arena; /* Pool offset of kernel arena address */
u64 user_arena; /* User arena address */
u32 frame_off; /* Offset of struct bpf_prog from %r15 */
};
#define SEEN_MEM BIT(0) /* use mem[] for temporary storage */
#define SEEN_LITERAL BIT(1) /* code uses literals */
#define SEEN_FUNC BIT(2) /* calls C functions */
#define SEEN_STACK (SEEN_FUNC | SEEN_MEM)
#define NVREGS 0xffc0 /* %r6-%r15 */
/*
* s390 registers
*/
#define REG_W0 (MAX_BPF_JIT_REG + 0) /* Work register 1 (even) */
#define REG_W1 (MAX_BPF_JIT_REG + 1) /* Work register 2 (odd) */
#define REG_L (MAX_BPF_JIT_REG + 2) /* Literal pool register */
#define REG_15 (MAX_BPF_JIT_REG + 3) /* Register 15 */
#define REG_0 REG_W0 /* Register 0 */
#define REG_1 REG_W1 /* Register 1 */
#define REG_2 BPF_REG_1 /* Register 2 */
#define REG_3 BPF_REG_2 /* Register 3 */
#define REG_4 BPF_REG_3 /* Register 4 */
#define REG_7 BPF_REG_6 /* Register 7 */
#define REG_8 BPF_REG_7 /* Register 8 */
#define REG_14 BPF_REG_0 /* Register 14 */
/*
* Mapping of BPF registers to s390 registers
*/
static const int reg2hex[] = {
/* Return code */
[BPF_REG_0] = 14,
/* Function parameters */
[BPF_REG_1] = 2,
[BPF_REG_2] = 3,
[BPF_REG_3] = 4,
[BPF_REG_4] = 5,
[BPF_REG_5] = 6,
/* Call saved registers */
[BPF_REG_6] = 7,
[BPF_REG_7] = 8,
[BPF_REG_8] = 9,
[BPF_REG_9] = 10,
/* BPF stack pointer */
[BPF_REG_FP] = 13,
/* Register for blinding */
[BPF_REG_AX] = 12,
/* Work registers for s390x backend */
[REG_W0] = 0,
[REG_W1] = 1,
[REG_L] = 11,
[REG_15] = 15,
};
static inline u32 reg(u32 dst_reg, u32 src_reg)
{
return reg2hex[dst_reg] << 4 | reg2hex[src_reg];
}
static inline u32 reg_high(u32 reg)
{
return reg2hex[reg] << 4;
}
static inline void reg_set_seen(struct bpf_jit *jit, u32 b1)
{
u32 r1 = reg2hex[b1];
if (r1 >= 6 && r1 <= 15)
jit->seen_regs |= (1 << r1);
Annotation
- Immediate include surface: `linux/netdevice.h`, `linux/filter.h`, `linux/init.h`, `linux/bpf.h`, `linux/mm.h`, `linux/kernel.h`, `asm/cacheflush.h`, `asm/extable.h`.
- Detected declarations: `struct bpf_jit`, `struct prog_frame`, `struct bpf_plt`, `struct bpf_jit_probe`, `struct s390_jit_data`, `struct bpf_tramp_jit`, `function reg`, `function reg_high`, `function reg_set_seen`, `function off_to_pcrel`.
- Atlas domain: Architecture Layer / arch/s390.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.