]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
selftests/bpf: Fix endianness issue in __qspinlock declaration
authorIlya Leoshkevich <iii@linux.ibm.com>
Thu, 24 Apr 2025 16:41:27 +0000 (18:41 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 25 Apr 2025 00:24:28 +0000 (17:24 -0700)
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 <iii@linux.ibm.com>
Link: https://lore.kernel.org/r/20250424165525.154403-4-iii@linux.ibm.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/progs/bpf_arena_spin_lock.h

index 4e29c31c4ef80bf2920bb7f9b3426a092279cb82..d67466c1ff77540160d9e50bc383a78569f452f9 100644 (file)
@@ -32,6 +32,7 @@ extern unsigned long CONFIG_NR_CPUS __kconfig;
 struct __qspinlock {
        union {
                atomic_t val;
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
                struct {
                        u8 locked;
                        u8 pending;
@@ -40,6 +41,17 @@ struct __qspinlock {
                        u16 locked_pending;
                        u16 tail;
                };
+#else
+               struct {
+                       u16 tail;
+                       u16 locked_pending;
+               };
+               struct {
+                       u8 reserved[2];
+                       u8 pending;
+                       u8 locked;
+               };
+#endif
        };
 };