Skip to content

Commit d9075ac

Browse files
cupermiranakryiko
authored andcommitted
selftest/bpf: Adapt inline asm operand constraint for GCC support
GCC errors when compiling tailcall_bpf2bpf_hierarchy2.c and tailcall_bpf2bpf_hierarchy3.c with the following error: progs/tailcall_bpf2bpf_hierarchy2.c: In function 'tailcall_bpf2bpf_hierarchy_2': progs/tailcall_bpf2bpf_hierarchy2.c:66:9: error: input operand constraint contains '+' 66 | asm volatile (""::"r+"(ret)); | ^~~ Changed implementation to make use of __sink macro that abstracts the desired behaviour. The proposed change seems valid for both GCC and CLANG. Signed-off-by: Cupertino Miranda <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 2aa9369 commit d9075ac

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy2.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ __retval(33)
5858
SEC("tc")
5959
int tailcall_bpf2bpf_hierarchy_2(struct __sk_buff *skb)
6060
{
61-
volatile int ret = 0;
61+
int ret = 0;
6262

6363
subprog_tail0(skb);
6464
subprog_tail1(skb);
6565

66-
asm volatile (""::"r+"(ret));
66+
__sink(ret);
6767
return (count1 << 16) | count0;
6868
}
6969

tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy3.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ __retval(33)
5151
SEC("tc")
5252
int tailcall_bpf2bpf_hierarchy_3(struct __sk_buff *skb)
5353
{
54-
volatile int ret = 0;
54+
int ret = 0;
5555

5656
bpf_tail_call_static(skb, &jmp_table0, 0);
5757

58-
asm volatile (""::"r+"(ret));
58+
__sink(ret);
5959
return ret;
6060
}
6161

0 commit comments

Comments
 (0)