Skip to content

Commit

Permalink
selftest/bpf: Adapt inline asm operand constraint for GCC support
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
cupermir authored and anakryiko committed Aug 19, 2024
1 parent 2aa9369 commit d9075ac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ __retval(33)
SEC("tc")
int tailcall_bpf2bpf_hierarchy_2(struct __sk_buff *skb)
{
volatile int ret = 0;
int ret = 0;

subprog_tail0(skb);
subprog_tail1(skb);

asm volatile (""::"r+"(ret));
__sink(ret);
return (count1 << 16) | count0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ __retval(33)
SEC("tc")
int tailcall_bpf2bpf_hierarchy_3(struct __sk_buff *skb)
{
volatile int ret = 0;
int ret = 0;

bpf_tail_call_static(skb, &jmp_table0, 0);

asm volatile (""::"r+"(ret));
__sink(ret);
return ret;
}

Expand Down

0 comments on commit d9075ac

Please sign in to comment.