Skip to content

Commit be55219

Browse files
iii-iAlexei Starovoitov
authored and
Alexei Starovoitov
committed
selftests/bpf: Fix endianness issue in __qspinlock declaration
Copy the big-endian field declarations from qspinlock_types.h, otherwise some properties won't hold on big-endian systems. For example, assigning lock->val = 1 should result in lock->locked == 1, which is not the case there. Signed-off-by: Ilya Leoshkevich <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 0240e5a commit be55219

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tools/testing/selftests/bpf/progs/bpf_arena_spin_lock.h

+12
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ extern unsigned long CONFIG_NR_CPUS __kconfig;
3232
struct __qspinlock {
3333
union {
3434
atomic_t val;
35+
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
3536
struct {
3637
u8 locked;
3738
u8 pending;
@@ -40,6 +41,17 @@ struct __qspinlock {
4041
u16 locked_pending;
4142
u16 tail;
4243
};
44+
#else
45+
struct {
46+
u16 tail;
47+
u16 locked_pending;
48+
};
49+
struct {
50+
u8 reserved[2];
51+
u8 pending;
52+
u8 locked;
53+
};
54+
#endif
4355
};
4456
};
4557

0 commit comments

Comments
 (0)