Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: Fix test_core_reloc_mods on big-endian machines

This is the same as commit d164dd9a5c08 ("selftests/bpf: Fix
test_core_autosize on big-endian machines"), but for
test_core_reloc_mods.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211026010831.748682-7-iii@linux.ibm.com

authored by

Ilya Leoshkevich and committed by
Andrii Nakryiko
2e2c6d3f 3e7ed9ce

+9
+9
tools/testing/selftests/bpf/progs/test_core_reloc_mods.c
··· 42 42 core_reloc_mods_substruct_t h; 43 43 }; 44 44 45 + #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 45 46 #define CORE_READ(dst, src) bpf_core_read(dst, sizeof(*(dst)), src) 47 + #else 48 + #define CORE_READ(dst, src) ({ \ 49 + int __sz = sizeof(*(dst)) < sizeof(*(src)) ? sizeof(*(dst)) : \ 50 + sizeof(*(src)); \ 51 + bpf_core_read((char *)(dst) + sizeof(*(dst)) - __sz, __sz, \ 52 + (const char *)(src) + sizeof(*(src)) - __sz); \ 53 + }) 54 + #endif 46 55 47 56 SEC("raw_tracepoint/sys_enter") 48 57 int test_core_mods(void *ctx)