]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftest/bpf: Adapt inline asm operand constraint for GCC support
authorCupertino Miranda <cupertino.miranda@oracle.com>
Mon, 19 Aug 2024 15:11:29 +0000 (16:11 +0100)
committerAndrii Nakryiko <andrii@kernel.org>
Mon, 19 Aug 2024 22:30:29 +0000 (15:30 -0700)
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 <cupertino.miranda@oracle.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240819151129.1366484-4-cupertino.miranda@oracle.com
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy2.c
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy3.c

index 37604b0b97aff7eadf36b85c989821bb6242092e..72fd0d577506a21f41be92f083a3fed4711f73af 100644 (file)
@@ -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;
 }
 
index 0cdbb781fcbc5b6dfb101bdcd0b9a4fe798200a7..a7fb91cb05b736d863fd57aeaf1275c3447578b4 100644 (file)
@@ -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;
 }