/* SPDX-License-Identifier: GPL-2.0 */ /* * The interface that a back-end should provide to bpf_jit_core.c. * * Copyright (c) 2024 Synopsys Inc. * Author: Shahab Vahedi <shahab@synopsys.com>
*/
#ifndef _ARC_BPF_JIT_H #define _ARC_BPF_JIT_H
#include <linux/bpf.h> #include <linux/filter.h>
/* Print debug info and assert. */ //#define ARC_BPF_JIT_DEBUG
/* Determine the address type of the target. */ #ifdef CONFIG_ISA_ARCV2 #define ARC_ADDR u32 #endif
/* * For the translation of some BPF instructions, a temporary register * might be needed for some interim data.
*/ #define JIT_REG_TMP MAX_BPF_JIT_REG
/* * Buffer access: If buffer "b" is not NULL, advance by "n" bytes. * * This macro must be used in any place that potentially requires a * "buf + len". This way, we make sure that the "buf" argument for * the underlying "arc_*(buf, ...)" ends up as NULL instead of something * like "0+4" or "0+8", etc. Those "arc_*()" functions check their "buf" * value to decide if instructions should be emitted or not.
*/ #define BUF(b, n) (((b) != NULL) ? ((b) + (n)) : (b))
/* * A few notes: * * - check_jmp_*() are prerequisites before calling the gen_jmp_*(). * They return "true" if the jump is possible and "false" otherwise. * * - The notion of "*_off" is to emphasize that these parameters are * merely offsets in the JIT stream and not absolute addresses. One * can look at them as addresses if the JIT code would start from * address 0x0000_0000. Nonetheless, since the buffer address for the * JIT is on a word-aligned address, this works and actually makes * things simpler (offsets are in the range of u32 which is more than * enough).
*/ bool check_jmp_32(u32 curr_off, u32 targ_off, u8 cond); bool check_jmp_64(u32 curr_off, u32 targ_off, u8 cond);
u8 gen_jmp_32(u8 *buf, u8 rd, u8 rs, u8 cond, u32 c_off, u32 t_off);
u8 gen_jmp_64(u8 *buf, u8 rd, u8 rs, u8 cond, u32 c_off, u32 t_off); /***** Miscellaneous *****/
u8 gen_func_call(u8 *buf, ARC_ADDR func_addr, bool external_func);
u8 arc_to_bpf_return(u8 *buf); /* * - Perform byte swaps on "rd" based on the "size". * - If "force" is set, do it unconditionally. Otherwise, consider the * desired "endian"ness and the host endianness. * - For data "size"s up to 32 bits, perform a zero-extension if asked * by the "do_zext" boolean.
*/
u8 gen_swap(u8 *buf, u8 rd, u8 size, u8 endian, bool force, bool do_zext);
#endif/* _ARC_BPF_JIT_H */
Messung V0.5
¤ Dauer der Verarbeitung: 0.12 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.