/* * Jump address mask for immediate jumps. The four most significant bits * must be equal to PC.
*/ #define MIPS_JMP_MASK 0x0fffffffUL
/* Maximum number of iterations in offset table computation */ #define JIT_MAX_ITERATIONS 8
/* * Jump pseudo-instructions used internally * for branch conversion and branch optimization.
*/ #define JIT_JNSET 0xe0 #define JIT_JNOP 0xf0
/* Descriptor flag for PC-relative branch conversion */ #define JIT_DESC_CONVERT BIT(31)
/* JIT context for an eBPF program */ struct jit_context { struct bpf_prog *program; /* The eBPF program being JITed */
u32 *descriptors; /* eBPF to JITed CPU insn descriptors */
u32 *target; /* JITed code buffer */
u32 bpf_index; /* Index of current BPF program insn */
u32 jit_index; /* Index of current JIT target insn */
u32 changes; /* Number of PC-relative branch conv */
u32 accessed; /* Bit mask of read eBPF registers */
u32 clobbered; /* Bit mask of modified CPU registers */
u32 stack_size; /* Total allocated stack size in bytes */
u32 saved_size; /* Size of callee-saved registers */
u32 stack_used; /* Stack size used for function calls */
};
/* Emit the instruction if the JIT memory space has been allocated */ #define __emit(ctx, func, ...) \ do { \ if ((ctx)->target != NULL) { \
u32 *p = &(ctx)->target[ctx->jit_index]; \
uasm_i_##func(&p, ##__VA_ARGS__); \
} \
(ctx)->jit_index++; \
} while (0) #define emit(...) __emit(__VA_ARGS__)
/* * Mark a BPF register as accessed, it needs to be * initialized by the program if expected, e.g. FP.
*/ staticinlinevoid access_reg(struct jit_context *ctx, u8 reg)
{
ctx->accessed |= BIT(reg);
}
/* * Mark a CPU register as clobbered, it needs to be * saved/restored by the program if callee-saved.
*/ staticinlinevoid clobber_reg(struct jit_context *ctx, u8 reg)
{
ctx->clobbered |= BIT(reg);
}
/* * Push registers on the stack, starting at a given depth from the stack * pointer and increasing. The next depth to be written is returned.
*/ int push_regs(struct jit_context *ctx, u32 mask, u32 excl, int depth);
/* * Pop registers from the stack, starting at a given depth from the stack * pointer and increasing. The next depth to be read is returned.
*/ int pop_regs(struct jit_context *ctx, u32 mask, u32 excl, int depth);
/* Compute the 28-bit jump target address from a BPF program location */ int get_target(struct jit_context *ctx, u32 loc);
/* Compute the PC-relative offset to relative BPF program offset */ int get_offset(conststruct jit_context *ctx, int off);
/* Jump always */ int emit_ja(struct jit_context *ctx, s16 off);
/* Jump to epilogue */ int emit_exit(struct jit_context *ctx);
/* * Build program prologue to set up the stack and registers. * This function is implemented separately for 32-bit and 64-bit JITs.
*/ void build_prologue(struct jit_context *ctx);
/* * Build the program epilogue to restore the stack and registers. * This function is implemented separately for 32-bit and 64-bit JITs.
*/ void build_epilogue(struct jit_context *ctx, int dest_reg);
/* * Convert an eBPF instruction to native instruction, i.e * JITs an eBPF instruction. * Returns : * 0 - Successfully JITed an 8-byte eBPF instruction * >0 - Successfully JITed a 16-byte eBPF instruction * <0 - Failed to JIT. * This function is implemented separately for 32-bit and 64-bit JITs.
*/ int build_insn(conststruct bpf_insn *insn, struct jit_context *ctx);
#endif/* _BPF_JIT_COMP_H */
Messung V0.5
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.