1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __BPF_MISC_H__ 3 #define __BPF_MISC_H__ 4 5 #define __msg(msg) __attribute__((btf_decl_tag("comment:test_expect_msg=" msg))) 6 #define __failure __attribute__((btf_decl_tag("comment:test_expect_failure"))) 7 #define __success __attribute__((btf_decl_tag("comment:test_expect_success"))) 8 #define __log_level(lvl) __attribute__((btf_decl_tag("comment:test_log_level="#lvl))) 9 10 /* Convenience macro for use with 'asm volatile' blocks */ 11 #define __naked __attribute__((naked)) 12 #define __clobber_all "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "memory" 13 #define __clobber_common "r0", "r1", "r2", "r3", "r4", "r5", "memory" 14 #define __imm(name) [name]"i"(name) 15 #define __imm_addr(name) [name]"i"(&name) 16 17 #if defined(__TARGET_ARCH_x86) 18 #define SYSCALL_WRAPPER 1 19 #define SYS_PREFIX "__x64_" 20 #elif defined(__TARGET_ARCH_s390) 21 #define SYSCALL_WRAPPER 1 22 #define SYS_PREFIX "__s390x_" 23 #elif defined(__TARGET_ARCH_arm64) 24 #define SYSCALL_WRAPPER 1 25 #define SYS_PREFIX "__arm64_" 26 #else 27 #define SYSCALL_WRAPPER 0 28 #define SYS_PREFIX "__se_" 29 #endif 30 31 /* How many arguments are passed to function in register */ 32 #if defined(__TARGET_ARCH_x86) || defined(__x86_64__) 33 #define FUNC_REG_ARG_CNT 6 34 #elif defined(__i386__) 35 #define FUNC_REG_ARG_CNT 3 36 #elif defined(__TARGET_ARCH_s390) || defined(__s390x__) 37 #define FUNC_REG_ARG_CNT 5 38 #elif defined(__TARGET_ARCH_arm) || defined(__arm__) 39 #define FUNC_REG_ARG_CNT 4 40 #elif defined(__TARGET_ARCH_arm64) || defined(__aarch64__) 41 #define FUNC_REG_ARG_CNT 8 42 #elif defined(__TARGET_ARCH_mips) || defined(__mips__) 43 #define FUNC_REG_ARG_CNT 8 44 #elif defined(__TARGET_ARCH_powerpc) || defined(__powerpc__) || defined(__powerpc64__) 45 #define FUNC_REG_ARG_CNT 8 46 #elif defined(__TARGET_ARCH_sparc) || defined(__sparc__) 47 #define FUNC_REG_ARG_CNT 6 48 #elif defined(__TARGET_ARCH_riscv) || defined(__riscv__) 49 #define FUNC_REG_ARG_CNT 8 50 #else 51 /* default to 5 for others */ 52 #define FUNC_REG_ARG_CNT 5 53 #endif 54 55 56 #endif 57