diff options
| author | Eduard Zingerman <[email protected]> | 2023-03-25 02:54:43 +0000 |
|---|---|---|
| committer | Alexei Starovoitov <[email protected]> | 2023-03-26 00:02:02 +0000 |
| commit | 207b1ba3019100d862931e97b49f76ff1e0a89f2 (patch) | |
| tree | e3be60c0708851eb931e9b300bae9f86aa5ddf33 /tools/testing/selftests/bpf/progs/bpf_misc.h | |
| parent | selftests/bpf: Report program name on parse_test_spec error (diff) | |
| download | kernel-207b1ba3019100d862931e97b49f76ff1e0a89f2.tar.gz kernel-207b1ba3019100d862931e97b49f76ff1e0a89f2.zip | |
selftests/bpf: __imm_insn & __imm_const macro for bpf_misc.h
Add two convenience macro for BPF test cases,
allowing the following usage:
#include <linux/filter.h>
...
asm volatile (
...
".8byte %[raw_insn];"
...
"r1 += %[st_foo_offset];"
...
:
: __imm_insn(raw_insn, BPF_RAW_INSN(...)),
__imm_const(st_foo_offset, offsetof(struct st, foo))
: __clobber_all);
Signed-off-by: Eduard Zingerman <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>
Diffstat (limited to 'tools/testing/selftests/bpf/progs/bpf_misc.h')
| -rw-r--r-- | tools/testing/selftests/bpf/progs/bpf_misc.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/bpf_misc.h b/tools/testing/selftests/bpf/progs/bpf_misc.h index 3c03ec8056ce..8b4681a96f89 100644 --- a/tools/testing/selftests/bpf/progs/bpf_misc.h +++ b/tools/testing/selftests/bpf/progs/bpf_misc.h @@ -35,8 +35,10 @@ #define __clobber_all "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "memory" #define __clobber_common "r0", "r1", "r2", "r3", "r4", "r5", "memory" #define __imm(name) [name]"i"(name) +#define __imm_const(name, expr) [name]"i"(expr) #define __imm_addr(name) [name]"i"(&name) #define __imm_ptr(name) [name]"p"(&name) +#define __imm_insn(name, expr) [name]"i"(*(long *)&(expr)) #if defined(__TARGET_ARCH_x86) #define SYSCALL_WRAPPER 1 |
