Skip to content

Commit bab7963

Browse files
committed
selftests/bpf: Fix kfunc_call/kfunc_call_test4 on 32-bit
This test currently fails on armhf: verify_success:PASS:skel 0 nsec verify_success:PASS:bpf_object__find_program_by_name 0 nsec verify_success:PASS:kfunc_call_test4 0 nsec verify_success:FAIL:retval unexpected retval: actual 4294966063 != expected -1234 torvalds#143/11 kfunc_call/kfunc_call_test4:FAIL The problem can be traced to using 'long' as a 64-bit type in bpf_testmod function bpf_kfunc_call_test4(), to force 64-bit signed arithmetic, which breaks down on 32-bit systems. Fix by explicitly using 's64' rather than long. Signed-off-by: Tony Ambardar <[email protected]>
1 parent 7f36642 commit bab7963

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ SEC("tc")
88
int kfunc_call_test4(struct __sk_buff *skb)
99
{
1010
struct bpf_sock *sk = skb->sk;
11-
long tmp;
11+
s64 tmp;
1212

1313
if (!sk)
1414
return -1;

tools/testing/selftests/bpf/test_kmods/bpf_testmod.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,12 +696,12 @@ __bpf_kfunc struct sock *bpf_kfunc_call_test3(struct sock *sk)
696696
return sk;
697697
}
698698

699-
__bpf_kfunc long noinline bpf_kfunc_call_test4(signed char a, short b, int c, long d)
699+
__bpf_kfunc s64 noinline bpf_kfunc_call_test4(signed char a, short b, int c, s64 d)
700700
{
701701
/* Provoke the compiler to assume that the caller has sign-extended a,
702702
* b and c on platforms where this is required (e.g. s390x).
703703
*/
704-
return (long)a + (long)b + (long)c + d;
704+
return (s64)a + (s64)b + (s64)c + d;
705705
}
706706

707707
static struct prog_test_ref_kfunc prog_test_struct = {

tools/testing/selftests/bpf/test_kmods/bpf_testmod_kfunc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ __u64 bpf_kfunc_call_test1(struct sock *sk, __u32 a, __u64 b,
109109
__u32 c, __u64 d) __ksym;
110110
int bpf_kfunc_call_test2(struct sock *sk, __u32 a, __u32 b) __ksym;
111111
struct sock *bpf_kfunc_call_test3(struct sock *sk) __ksym;
112-
long bpf_kfunc_call_test4(signed char a, short b, int c, long d) __ksym;
112+
s64 bpf_kfunc_call_test4(signed char a, short b, int c, s64 d) __ksym;
113113

114114
void bpf_kfunc_call_test_pass_ctx(struct __sk_buff *skb) __ksym;
115115
void bpf_kfunc_call_test_pass1(struct prog_test_pass1 *p) __ksym;

0 commit comments

Comments
 (0)