projects
/
linux.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
3e5329e
)
selftests/bpf: __imm_insn & __imm_const macro for bpf_misc.h
author
Eduard Zingerman
<eddyz87@gmail.com>
Sat, 25 Mar 2023 02:54:43 +0000
(
04:54
+0200)
committer
Alexei Starovoitov
<ast@kernel.org>
Sun, 26 Mar 2023 00:02:02 +0000
(17:02 -0700)
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 <eddyz87@gmail.com>
Link:
https://lore.kernel.org/r/20230325025524.144043-3-eddyz87@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/progs/bpf_misc.h
patch
|
blob
|
history
diff --git
a/tools/testing/selftests/bpf/progs/bpf_misc.h
b/tools/testing/selftests/bpf/progs/bpf_misc.h
index 3c03ec8056ce79805d5c0ef60fa0b61d3cb04c42..8b4681a96f89e51362c8eb4839e8064ef8b3948f 100644
(file)
--- 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