[PATCH v2 0/3] selftests/hid: fix building for older kernels

From: Justin Stitt
Date: Fri Sep 08 2023 - 18:22:48 EST


Hi, I am sending this series on behalf of myself and Benjamin Tissoires. There
existed an initial n=3 patch series which was later expanded to n=4 and
is now back to n=3 with some fixes added in and rebased against
mainline.

This patch series aims to ensure that the hid/bpf selftests can be built
without errors.

Here's Benjamin's initial cover letter for context:
| These fixes have been triggered by [0]:
| basically, if you do not recompile the kernel first, and are
| running on an old kernel, vmlinux.h doesn't have the required
| symbols and the compilation fails.
|
| The tests will fail if you run them on that very same machine,
| of course, but the binary should compile.
|
| And while I was sorting out why it was failing, I realized I
| could do a couple of improvements on the Makefile.
|
| [0] https://lore.kernel.org/linux-input/56ba8125-2c6f-a9c9-d498-0ca1c153dcb2@xxxxxxxxxx/T/#t

Changes from v1 -> v2:
- roll Justin's fix into patch 1/3
- add __attribute__((preserve_access_index)) (thanks Eduard)
- rebased onto mainline (2dde18cd1d8fac735875f2e4987f11817cc0bc2c)
- Link to v1: https://lore.kernel.org/all/20230825-wip-selftests-v1-0-c862769020a8@xxxxxxxxxx/

Link: https://github.com/ClangBuiltLinux/linux/issues/1698
Link: https://github.com/ClangBuiltLinux/continuous-integration2/issues/61
---
Benjamin Tissoires (3):
selftests/hid: ensure we can compile the tests on kernels pre-6.3
selftests/hid: do not manually call headers_install
selftests/hid: force using our compiled libbpf headers

tools/testing/selftests/hid/Makefile | 10 ++---
tools/testing/selftests/hid/progs/hid.c | 3 --
.../testing/selftests/hid/progs/hid_bpf_helpers.h | 49 ++++++++++++++++++++++
3 files changed, 53 insertions(+), 9 deletions(-)
---
base-commit: 2dde18cd1d8fac735875f2e4987f11817cc0bc2c
change-id: 20230908-kselftest-09-08-56d7f4a8d5c4

Best regards,
--
Justin Stitt <justinstitt@xxxxxxxxxx>