Skip to contentSkip to conversation

selftests: Fix incorrect kernel headers search path

PATCH Applied Mathieu Desnoyers 8 participants 63 messages Jan 27, 2023 – Feb 20, 2023

Subsystems (23)
lore
Share & tools
lore

Mathieu Desnoyers

author maintainer
#0 lore raw

cover selftests: Fix incorrect kernel headers search path

Hi,

This series fixes incorrect kernel header search path in kernel selftests.

Near the end of the series, a few changes are not tagged as "Fixes" because the current behavior is to rely on the kernel sources uapi files rather than on the installed kernel header files. Nevertheless, those are updated for consistency.

There are situations where "../../../../include/" was added to -I search path, which is bogus for userspace tests and caused issues with types.h. Those are removed.

Thanks,

Mathieu

Mathieu Desnoyers (34):
selftests: arm64: Fix incorrect kernel headers search path
selftests: bpf: Fix incorrect kernel headers search path
selftests: clone3: Fix incorrect kernel headers search path
selftests: core: Fix incorrect kernel headers search path
selftests: dma: Fix incorrect kernel headers search path
selftests: dmabuf-heaps: Fix incorrect kernel headers search path
selftests: drivers: Fix incorrect kernel headers search path
selftests: filesystems: Fix incorrect kernel headers search path
selftests: futex: Fix incorrect kernel headers search path
selftests: gpio: Fix incorrect kernel headers search path
selftests: ipc: Fix incorrect kernel headers search path
selftests: kcmp: Fix incorrect kernel headers search path
selftests: media_tests: Fix incorrect kernel headers search path
selftests: membarrier: Fix incorrect kernel headers search path
selftests: mount_setattr: Fix incorrect kernel headers search path
selftests: move_mount_set_group: Fix incorrect kernel headers search
path
selftests: net: Fix incorrect kernel headers search path
selftests: perf_events: Fix incorrect kernel headers search path
selftests: pid_namespace: Fix incorrect kernel headers search path
selftests: pidfd: Fix incorrect kernel headers search path
selftests: powerpc: Fix incorrect kernel headers search path
selftests: ptp: Fix incorrect kernel headers search path
selftests: rseq: Fix incorrect kernel headers search path
selftests: sched: Fix incorrect kernel headers search path
selftests: seccomp: Fix incorrect kernel headers search path
selftests: sync: Fix incorrect kernel headers search path
selftests: user_events: Fix incorrect kernel headers search path
selftests: vm: Fix incorrect kernel headers search path
selftests: x86: Fix incorrect kernel headers search path
selftests: bpf docs: Use installed kernel headers search path
selftests: iommu: Use installed kernel headers search path
selftests: memfd: Use installed kernel headers search path
selftests: ptrace: Use installed kernel headers search path
selftests: tdx: Use installed kernel headers search path

 tools/testing/selftests/arm64/fp/Makefile               | 2 +-
 tools/testing/selftests/arm64/tags/Makefile             | 2 +-
 tools/testing/selftests/bpf/Makefile                    | 2 +-
 tools/testing/selftests/bpf/Makefile.docs               | 2 +-
 tools/testing/selftests/clone3/Makefile                 | 2 +-
 tools/testing/selftests/core/Makefile                   | 2 +-
 tools/testing/selftests/dma/Makefile                    | 2 +-
 tools/testing/selftests/dmabuf-heaps/Makefile           | 2 +-
 tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c      | 3 +--
 tools/testing/selftests/drivers/dma-buf/Makefile        | 2 +-
 tools/testing/selftests/drivers/s390x/uvdevice/Makefile | 3 +--
 tools/testing/selftests/filesystems/Makefile            | 2 +-
 tools/testing/selftests/filesystems/binderfs/Makefile   | 2 +-
 tools/testing/selftests/filesystems/epoll/Makefile      | 2 +-
 tools/testing/selftests/futex/functional/Makefile       | 2 +-
 tools/testing/selftests/gpio/Makefile                   | 2 +-
 tools/testing/selftests/iommu/Makefile                  | 3 +--
 tools/testing/selftests/ipc/Makefile                    | 2 +-
 tools/testing/selftests/kcmp/Makefile                   | 2 +-
 tools/testing/selftests/media_tests/Makefile            | 2 +-
 tools/testing/selftests/membarrier/Makefile             | 2 +-
 tools/testing/selftests/memfd/Makefile                  | 4 +---
 tools/testing/selftests/mount_setattr/Makefile          | 2 +-
 tools/testing/selftests/move_mount_set_group/Makefile   | 2 +-
 tools/testing/selftests/net/Makefile                    | 2 +-
 tools/testing/selftests/net/bpf/Makefile                | 2 +-
 tools/testing/selftests/net/mptcp/Makefile              | 2 +-
 tools/testing/selftests/net/openvswitch/Makefile        | 2 +-
 tools/testing/selftests/perf_events/Makefile            | 2 +-
 tools/testing/selftests/pid_namespace/Makefile          | 2 +-
 tools/testing/selftests/pidfd/Makefile                  | 2 +-
 tools/testing/selftests/powerpc/ptrace/Makefile         | 2 +-
 tools/testing/selftests/powerpc/security/Makefile       | 2 +-
 tools/testing/selftests/powerpc/syscalls/Makefile       | 2 +-
 tools/testing/selftests/powerpc/tm/Makefile             | 2 +-
 tools/testing/selftests/ptp/Makefile                    | 2 +-
 tools/testing/selftests/ptrace/Makefile                 | 2 +-
 tools/testing/selftests/rseq/Makefile                   | 2 +-
 tools/testing/selftests/sched/Makefile                  | 2 +-
 tools/testing/selftests/seccomp/Makefile                | 2 +-
 tools/testing/selftests/sync/Makefile                   | 2 +-
 tools/testing/selftests/tdx/Makefile                    | 2 +-
 tools/testing/selftests/tdx/tdx_guest_test.c            | 2 +-
 tools/testing/selftests/user_events/Makefile            | 2 +-
 tools/testing/selftests/vm/Makefile                     | 2 +-
 tools/testing/selftests/x86/Makefile                    | 2 +-
 46 files changed, 46 insertions(+), 51 deletions(-)
Signature · 1 line
2.25.1
author maintainer
#1 lore raw

PATCH 1/34 selftests: arm64: Fix incorrect kernel headers search path

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/arm64/fp/Makefile   | 2 +-
 tools/testing/selftests/arm64/tags/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/arm64/fp/Makefile +1 -1
index 36db61358ed5..932ec8792316 100644
@@ -3,7 +3,7 @@
 # A proper top_srcdir is needed by KSFT(lib.mk)
 top_srcdir = $(realpath ../../../../../)
 
-CFLAGS += -I$(top_srcdir)/usr/include/
+CFLAGS += $(KHDR_INCLUDES)
 
 TEST_GEN_PROGS := fp-stress \
 	sve-ptrace sve-probe-vls \
tools/testing/selftests/arm64/tags/Makefile +1 -1
index 41cb75070511..6d29cfde43a2 100644
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 
-CFLAGS += -I../../../../../usr/include/
+CFLAGS += $(KHDR_INCLUDES)
 TEST_GEN_PROGS := tags_test
 TEST_PROGS := run_tags_test.sh
 
Signature · 1 line
2.25.1
maintainer Acked-by on v1 1/34
#2 lore raw

Re: [PATCH 01/34] selftests: arm64: Fix incorrect kernel headers search path

Quoted 10 lines · Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

Quoted 5 lines
---
  tools/testing/selftests/arm64/fp/Makefile   | 2 +-
  tools/testing/selftests/arm64/tags/Makefile | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)

Adding arm maintainers.

Would you me to take this patch through kselftest tree? If you decide to take this through yours:

thanks,
-- Shuah

maintainer Acked-by
#3 lore raw

Re: [PATCH 01/34] selftests: arm64: Fix incorrect kernel headers search path

Hi Shuah,

Quoted 17 lines · Shuah Khan
Quoted 10 lines · Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

Quoted 5 lines
---
  tools/testing/selftests/arm64/fp/Makefile   | 2 +-
  tools/testing/selftests/arm64/tags/Makefile | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
Quoted 4 lines

Adding arm maintainers.

Would you me to take this patch through kselftest tree? If you decide to take this through yours:

Are you taking the whole series? If yes:

(otherwise I can pick this up)

Signature · 1 line
Catalin
maintainer
#4 lore raw

Re: [PATCH 01/34] selftests: arm64: Fix incorrect kernel headers search path

Quoted 22 lines · Catalin Marinas

Hi Shuah,

Quoted 19 lines · Shuah Khan
Quoted 10 lines · Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

Quoted 5 lines
---
   tools/testing/selftests/arm64/fp/Makefile   | 2 +-
   tools/testing/selftests/arm64/tags/Makefile | 2 +-
   2 files changed, 2 insertions(+), 2 deletions(-)

Adding arm maintainers.

Quoted 9 lines
Quoted 2 lines

Would you me to take this patch through kselftest tree? If you decide to take this through yours:

Are you taking the whole series? If yes:

(otherwise I can pick this up)

I am taking several patches in the series with an exception when maintainers want to take them through theirs.

I will apply to mine and take this through.

thanks,
-- Shuah

author maintainer
#5 lore raw

PATCH 2/34 selftests: bpf: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/bpf/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/Makefile +1 -1
index c22c43bbee19..6998c816afef 100644
@@ -327,7 +327,7 @@ endif
 CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH))
 BPF_CFLAGS = -g -Werror -D__TARGET_ARCH_$(SRCARCH) $(MENDIAN) 		\
 	     -I$(INCLUDE_DIR) -I$(CURDIR) -I$(APIDIR)			\
-	     -I$(abspath $(OUTPUT)/../usr/include)
+	     $(KHDR_INCLUDES)
 
 CLANG_CFLAGS = $(CLANG_SYS_INCLUDES) \
 	       -Wno-compare-distinct-pointer-types
Signature · 1 line
2.25.1
maintainer Acked-by on v1 2/34
#6 lore raw

Re: [PATCH 02/34] selftests: bpf: Fix incorrect kernel headers search path

Quoted 19 lines · Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
  tools/testing/selftests/bpf/Makefile | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/Makefile +0 -0
index c22c43bbee19..6998c816afef 100644

tools/testing/selftests/bpf/Makefile endif · line 333

Quoted 8 lines
tools/testing/selftests/bpf/Makefile +1 -1
@@ -327,7 +327,7 @@ endif
  CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH))
  BPF_CFLAGS = -g -Werror -D__TARGET_ARCH_$(SRCARCH) $(MENDIAN) 		\
  	     -I$(INCLUDE_DIR) -I$(CURDIR) -I$(APIDIR)			\
-	     -I$(abspath $(OUTPUT)/../usr/include)
+	     $(KHDR_INCLUDES)
 
  CLANG_CFLAGS = $(CLANG_SYS_INCLUDES) \
  	       -Wno-compare-distinct-pointer-types

Adding bpf maintainers - bpf patches usually go through bpf tree.

thanks,
-- Shuah

#7 lore raw

Re: [PATCH 02/34] selftests: bpf: Fix incorrect kernel headers search path

Quoted 27 lines · Shuah Khan
Quoted 25 lines · Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
  tools/testing/selftests/bpf/Makefile | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/Makefile +1 -1
index c22c43bbee19..6998c816afef 100644
@@ -327,7 +327,7 @@ endif
  CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH))
  BPF_CFLAGS = -g -Werror -D__TARGET_ARCH_$(SRCARCH) $(MENDIAN)               \
           -I$(INCLUDE_DIR) -I$(CURDIR) -I$(APIDIR)                   \
-          -I$(abspath $(OUTPUT)/../usr/include)
+          $(KHDR_INCLUDES)
 
Quoted 8 lines

tools/testing/selftests/bpf/Makefile endif · line 333

Quoted 2 lines
tools/testing/selftests/bpf/Makefile +0 -0
  CLANG_CFLAGS = $(CLANG_SYS_INCLUDES) \
             -Wno-compare-distinct-pointer-types

Adding bpf maintainers - bpf patches usually go through bpf tree.

Please resubmit as separate patch with [PATCH bpf-next] subj and cc bpf@vger, so that BPF CI can test it on various architectures and config combinations.

author maintainer
#8 lore raw

Re: [PATCH 02/34] selftests: bpf: Fix incorrect kernel headers search path

Quoted 35 lines · Alexei Starovoitov
Quoted 34 lines · Shuah Khan
Quoted 19 lines · Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
   tools/testing/selftests/bpf/Makefile | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/Makefile +0 -0
index c22c43bbee19..6998c816afef 100644

tools/testing/selftests/bpf/Makefile endif · line 333

Quoted 8 lines
tools/testing/selftests/bpf/Makefile +1 -1
@@ -327,7 +327,7 @@ endif
   CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH))
   BPF_CFLAGS = -g -Werror -D__TARGET_ARCH_$(SRCARCH) $(MENDIAN)               \
            -I$(INCLUDE_DIR) -I$(CURDIR) -I$(APIDIR)                   \
-          -I$(abspath $(OUTPUT)/../usr/include)
+          $(KHDR_INCLUDES)
 
   CLANG_CFLAGS = $(CLANG_SYS_INCLUDES) \
              -Wno-compare-distinct-pointer-types

Adding bpf maintainers - bpf patches usually go through bpf tree.

Quoted 5 lines
Quoted 1 line

Please resubmit as separate patch with [PATCH bpf-next] subj and cc bpf@vger, so that BPF CI can test it on various architectures and config combinations.

Hi Shuah,

Do you have means to resubmit it on your end, or should I do it ?

Thanks,

Mathieu

Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
maintainer
#9 lore raw

Re: [PATCH 02/34] selftests: bpf: Fix incorrect kernel headers search path

Quoted 38 lines · Mathieu Desnoyers
Quoted 37 lines · Alexei Starovoitov
Quoted 35 lines · Shuah Khan
Quoted 26 lines · Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
   tools/testing/selftests/bpf/Makefile | 2 +-

   1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/Makefile +1 -1
index c22c43bbee19..6998c816afef 100644
@@ -327,7 +327,7 @@ endif
    CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH))
    BPF_CFLAGS = -g -Werror -D__TARGET_ARCH_$(SRCARCH) $(MENDIAN)               \
             -I$(INCLUDE_DIR) -I$(CURDIR) -I$(APIDIR)                   \
-          -I$(abspath $(OUTPUT)/../usr/include)
+          $(KHDR_INCLUDES)
 
    CLANG_CFLAGS = $(CLANG_SYS_INCLUDES) \
Quoted 1 line

              -Wno-compare-distinct-pointer-types

Adding bpf maintainers - bpf patches usually go through bpf tree.

Quoted 8 lines
Quoted 3 lines

Please resubmit as separate patch with [PATCH bpf-next] subj and cc bpf@vger, so that BPF CI can test it on various architectures and config combinations.

Hi Shuah,

Do you have means to resubmit it on your end, or should I do it ?

Hi Mathieu,

Please go ahead and resubmit.

thanks,
-- Shuah

author maintainer
#10 lore raw

PATCH 3/34 selftests: clone3: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/clone3/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/clone3/Makefile +1 -1
index 79b19a2863a0..84832c369a2e 100644
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-CFLAGS += -g -std=gnu99 -I../../../../usr/include/
+CFLAGS += -g -std=gnu99 $(KHDR_INCLUDES)
 LDLIBS += -lcap
 
 TEST_GEN_PROGS := clone3 clone3_clear_sighand clone3_set_tid \
Signature · 1 line
2.25.1
maintainer Acked-by on v1 3/34
#11 lore raw

Re: [PATCH 03/34] selftests: clone3: Fix incorrect kernel headers search path

Quoted 19 lines · Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
  tools/testing/selftests/clone3/Makefile | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/clone3/Makefile +0 -0
index 79b19a2863a0..84832c369a2e 100644

tools/testing/selftests/clone3/Makefile line 5

Quoted 6 lines
tools/testing/selftests/clone3/Makefile +1 -1
@@ -1,5 +1,5 @@
  # SPDX-License-Identifier: GPL-2.0
-CFLAGS += -g -std=gnu99 -I../../../../usr/include/
+CFLAGS += -g -std=gnu99 $(KHDR_INCLUDES)
  LDLIBS += -lcap
 
  TEST_GEN_PROGS := clone3 clone3_clear_sighand clone3_set_tid \

+ [email protected]

Hi Christian,

Would you me to take this patch through kselftest tree? If you decide to take this through yours:

thanks,
-- Shuah

maintainer Acked-by
#12 lore raw

Re: [PATCH 03/34] selftests: clone3: Fix incorrect kernel headers search path

Quoted 6 lines · Shuah Khan
Quoted 5 lines · Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

Quoted 6 lines
Quoted 6 lines

---

Looks good to me,

Quoted 16 lines

tools/testing/selftests/clone3/Makefile line 4

Quoted 13 lines
  tools/testing/selftests/clone3/Makefile | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/clone3/Makefile +1 -1
index 79b19a2863a0..84832c369a2e 100644
@@ -1,5 +1,5 @@
  # SPDX-License-Identifier: GPL-2.0
-CFLAGS += -g -std=gnu99 -I../../../../usr/include/
+CFLAGS += -g -std=gnu99 $(KHDR_INCLUDES)
  LDLIBS += -lcap
  TEST_GEN_PROGS := clone3 clone3_clear_sighand clone3_set_tid \

+ [email protected]

Quoted 1 line

Hi Christian,

Hey Shuah,

Quoted 2 lines

Would you me to take this patch through kselftest tree? If you

Feel free to take it through the kselftest tree. Thank you! Christian

author maintainer
#13 lore raw

PATCH 4/34 selftests: core: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/core/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/core/Makefile +1 -1
index f6f2d6f473c6..ce262d097269 100644
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
-CFLAGS += -g -I../../../../usr/include/
+CFLAGS += -g $(KHDR_INCLUDES)
 
 TEST_GEN_PROGS := close_range_test
 
Signature · 1 line
2.25.1
author maintainer
#14 lore raw

PATCH 5/34 selftests: dma: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/dma/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/dma/Makefile +1 -1
index cd8c5ece1cba..dd7f746f3e84 100644
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-CFLAGS += -I../../../../usr/include/
+CFLAGS += $(KHDR_INCLUDES)
 CFLAGS += -I../../../../include/
 
 TEST_GEN_PROGS := dma_map_benchmark
Signature · 1 line
2.25.1
author maintainer
#15 lore raw

PATCH 6/34 selftests: dmabuf-heaps: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/dmabuf-heaps/Makefile      | 2 +-
 tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)
tools/testing/selftests/dmabuf-heaps/Makefile +1 -1
index 604b43ece15f..9e7e158d5fa3 100644
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-CFLAGS += -static -O3 -Wl,-no-as-needed -Wall
+CFLAGS += -static -O3 -Wl,-no-as-needed -Wall $(KHDR_INCLUDES)
 
 TEST_GEN_PROGS = dmabuf-heap
 
tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c +1 -2
index 29af27acd40e..890a8236a8ba 100644
@@ -13,10 +13,9 @@
 #include <sys/types.h>
 
 #include <linux/dma-buf.h>
+#include <linux/dma-heap.h>
 #include <drm/drm.h>
 
-#include "../../../../include/uapi/linux/dma-heap.h"
-
 #define DEVPATH "/dev/dma_heap"
 
 static int check_vgem(int fd)
Signature · 1 line
2.25.1
author maintainer
#16 lore raw

PATCH 7/34 selftests: drivers: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/drivers/dma-buf/Makefile        | 2 +-
 tools/testing/selftests/drivers/s390x/uvdevice/Makefile | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)
tools/testing/selftests/drivers/dma-buf/Makefile +1 -1
index 79cb16b4e01a..441407bb0e80 100644
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
-CFLAGS += -I../../../../../usr/include/
+CFLAGS += $(KHDR_INCLUDES)
 
 TEST_GEN_PROGS := udmabuf
 
tools/testing/selftests/drivers/s390x/uvdevice/Makefile +1 -2
index 891215a7dc8a..755d164384c4 100644
@@ -11,10 +11,9 @@ else
 TEST_GEN_PROGS := test_uvdevice
 
 top_srcdir ?= ../../../../../..
-khdr_dir = $(top_srcdir)/usr/include
 LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/$(ARCH)/include
 
-CFLAGS += -Wall -Werror -static -I$(khdr_dir) -I$(LINUX_TOOL_ARCH_INCLUDE)
+CFLAGS += -Wall -Werror -static $(KHDR_INCLUDES) -I$(LINUX_TOOL_ARCH_INCLUDE)
 
 include ../../../lib.mk
 
Signature · 1 line
2.25.1
author maintainer
#17 lore raw

PATCH 8/34 selftests: filesystems: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/filesystems/Makefile          | 2 +-
 tools/testing/selftests/filesystems/binderfs/Makefile | 2 +-
 tools/testing/selftests/filesystems/epoll/Makefile    | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/filesystems/Makefile +1 -1
index 129880fb42d3..c647fd6a0446 100644
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 
-CFLAGS += -I../../../../usr/include/
+CFLAGS += $(KHDR_INCLUDES)
 TEST_GEN_PROGS := devpts_pts
 TEST_GEN_PROGS_EXTENDED := dnotify_test
 
tools/testing/selftests/filesystems/binderfs/Makefile +1 -1
index 8af25ae96049..c2f7cef919c0 100644
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 
-CFLAGS += -I../../../../../usr/include/ -pthread
+CFLAGS += $(KHDR_INCLUDES) -pthread
 TEST_GEN_PROGS := binderfs_test
 
 binderfs_test: binderfs_test.c ../../kselftest.h ../../kselftest_harness.h
tools/testing/selftests/filesystems/epoll/Makefile +1 -1
index 78ae4aaf7141..0788a7dc8004 100644
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 
-CFLAGS += -I../../../../../usr/include/
+CFLAGS += $(KHDR_INCLUDES)
 LDLIBS += -lpthread
 TEST_GEN_PROGS := epoll_wakeup_test
 
Signature · 1 line
2.25.1
author maintainer
#18 lore raw

PATCH 9/34 selftests: futex: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/futex/functional/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/futex/functional/Makefile +1 -1
index 5a0e0df8de9b..a392d0917b4e 100644
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-INCLUDES := -I../include -I../../ -I../../../../../usr/include/
+INCLUDES := -I../include -I../../ $(KHDR_INCLUDES)
 CFLAGS := $(CFLAGS) -g -O2 -Wall -D_GNU_SOURCE -pthread $(INCLUDES) $(KHDR_INCLUDES)
 LDLIBS := -lpthread -lrt
 
Signature · 1 line
2.25.1
author maintainer
#19 lore raw

PATCH 10/34 selftests: gpio: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/gpio/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/gpio/Makefile +1 -1
index 616ed4019655..e0884390447d 100644
@@ -3,6 +3,6 @@
 TEST_PROGS := gpio-mockup.sh gpio-sim.sh
 TEST_FILES := gpio-mockup-sysfs.sh
 TEST_GEN_PROGS_EXTENDED := gpio-mockup-cdev gpio-chip-info gpio-line-name
-CFLAGS += -O2 -g -Wall -I../../../../usr/include/ $(KHDR_INCLUDES)
+CFLAGS += -O2 -g -Wall $(KHDR_INCLUDES)
 
 include ../lib.mk
Signature · 1 line
2.25.1
author maintainer
#20 lore raw

PATCH 11/34 selftests: ipc: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/ipc/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/ipc/Makefile +1 -1
index 1c4448a843a4..50e9c299fc4a 100644
@@ -10,7 +10,7 @@ ifeq ($(ARCH),x86_64)
 	CFLAGS := -DCONFIG_X86_64 -D__x86_64__
 endif
 
-CFLAGS += -I../../../../usr/include/
+CFLAGS += $(KHDR_INCLUDES)
 
 TEST_GEN_PROGS := msgque
 
Signature · 1 line
2.25.1
author maintainer
#21 lore raw

PATCH 12/34 selftests: kcmp: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/kcmp/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kcmp/Makefile +1 -1
index b4d39f6b5124..59a1e5379018 100644
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
-CFLAGS += -I../../../../usr/include/
+CFLAGS += $(KHDR_INCLUDES)
 
 TEST_GEN_PROGS := kcmp_test
 
Signature · 1 line
2.25.1
author maintainer
#22 lore raw

PATCH 13/34 selftests: media_tests: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/media_tests/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/media_tests/Makefile +1 -1
index 60826d7d37d4..471d83e61d95 100644
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 #
-CFLAGS += -I../ -I../../../../usr/include/
+CFLAGS += -I../ $(KHDR_INCLUDES)
 TEST_GEN_PROGS := media_device_test media_device_open video_device_test
 
 include ../lib.mk
Signature · 1 line
2.25.1
author maintainer
#23 lore raw

PATCH 14/34 selftests: membarrier: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/membarrier/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/membarrier/Makefile +1 -1
index 34d1c81a2324..fc840e06ff56 100644
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
-CFLAGS += -g -I../../../../usr/include/
+CFLAGS += -g $(KHDR_INCLUDES)
 LDLIBS += -lpthread
 
 TEST_GEN_PROGS := membarrier_test_single_thread \
Signature · 1 line
2.25.1
author maintainer
#24 lore raw

PATCH 15/34 selftests: mount_setattr: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/mount_setattr/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/mount_setattr/Makefile +1 -1
index 2250f7dcb81e..fde72df01b11 100644
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 # Makefile for mount selftests.
-CFLAGS = -g -I../../../../usr/include/ -Wall -O2 -pthread
+CFLAGS = -g $(KHDR_INCLUDES) -Wall -O2 -pthread
 
 TEST_GEN_FILES += mount_setattr_test
 
Signature · 1 line
2.25.1
author maintainer
#25 lore raw

PATCH 16/34 selftests: move_mount_set_group: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/move_mount_set_group/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/move_mount_set_group/Makefile +1 -1
index 80c2d86812b0..94235846b6f9 100644
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 # Makefile for mount selftests.
-CFLAGS = -g -I../../../../usr/include/ -Wall -O2
+CFLAGS = -g $(KHDR_INCLUDES) -Wall -O2
 
 TEST_GEN_FILES += move_mount_set_group_test
 
Signature · 1 line
2.25.1
author maintainer
#26 lore raw

PATCH 17/34 selftests: net: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/net/Makefile             | 2 +-
 tools/testing/selftests/net/bpf/Makefile         | 2 +-
 tools/testing/selftests/net/mptcp/Makefile       | 2 +-
 tools/testing/selftests/net/openvswitch/Makefile | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/net/Makefile +1 -1
index 3007e98a6d64..bab1222c7d50 100644
@@ -2,7 +2,7 @@
 # Makefile for net selftests
 
 CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g
-CFLAGS += -I../../../../usr/include/ $(KHDR_INCLUDES)
+CFLAGS += $(KHDR_INCLUDES)
 
 TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh netdevice.sh \
 	      rtnetlink.sh xfrm_policy.sh test_blackhole_dev.sh
tools/testing/selftests/net/bpf/Makefile +1 -1
index 4abaf16d2077..207b6b958f66 100644
@@ -7,7 +7,7 @@ BPFDIR := $(abspath ../../../lib/bpf)
 APIDIR := $(abspath ../../../include/uapi)
 
 CCINCLUDE += -I../../bpf
-CCINCLUDE += -I../../../../../usr/include/
+CCINCLUDE += $(KHDR_INCLUDES)
 CCINCLUDE += -I$(SCRATCH_DIR)/include
 
 BPFOBJ := $(BUILD_DIR)/libbpf/libbpf.a
tools/testing/selftests/net/mptcp/Makefile +1 -1
index 43a723626126..06bba013bcef 100644
@@ -2,7 +2,7 @@
 
 top_srcdir = ../../../../..
 
-CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g -I$(top_srcdir)/usr/include $(KHDR_INCLUDES)
+CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g $(KHDR_INCLUDES)
 
 TEST_PROGS := mptcp_connect.sh pm_netlink.sh mptcp_join.sh diag.sh \
 	      simult_flows.sh mptcp_sockopt.sh userspace_pm.sh
tools/testing/selftests/net/openvswitch/Makefile +1 -1
index 2f1508abc826..41ddfa9fdd1d 100644
@@ -2,7 +2,7 @@
 
 top_srcdir = ../../../../..
 
-CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g -I$(top_srcdir)/usr/include $(KHDR_INCLUDES)
+CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g $(KHDR_INCLUDES)
 
 TEST_PROGS := openvswitch.sh
 
Signature · 1 line
2.25.1
#27 lore raw

Re: [PATCH 17/34] selftests: net: Fix incorrect kernel headers search path

Hi Mathieu,

Quoted 4 lines · Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

Thank you for the patch!

Quoted 5 lines

(It might be useful to add a "Fixes" tag as well to clearly indicate the dependence with a specific commit and better understand the fix.)

(and add all the individual maintainers of the files you modify -- feel free to use 'b4' to help you for this task ;-) )

(...)

tools/testing/selftests/net/mptcp/Makefile line 5

Quoted 10 lines
tools/testing/selftests/net/mptcp/Makefile +1 -1
index 43a723626126..06bba013bcef 100644
@@ -2,7 +2,7 @@
 
 top_srcdir = ../../../../..
 
-CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g -I$(top_srcdir)/usr/include $(KHDR_INCLUDES)
+CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g $(KHDR_INCLUDES)

I only looked at the modification here with MPTCP selftests and it looks good to me. It makes sense because if KHDR_INCLUDES is not set, it will be set later by lib.mk I suppose.

Just one small thing: I guess you can also remove "top_srcdir" variable that is no longer used, right? I see that "lib.mk" uses a variable with the same name but it overrides its value anyway. But it is likely I missed something there :)

If indeed it is no longer needed, I guess a few Makefile can be adapted according to:

git grep top_srcdir -- tools/testing/selftests/*/

I guess most of these Makefile are very similar, no? For MPTCP, we simply looked at what was done elsewhere :)

Cheers,
Matt

Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net
author maintainer
#28 lore raw

Re: [PATCH 17/34] selftests: net: Fix incorrect kernel headers search path

Quoted 9 lines · Matthieu Baerts

Hi Mathieu,

Quoted 4 lines · Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

Thank you for the patch!

You're welcome :)

Quoted 9 lines
Quoted 6 lines

(It might be useful to add a "Fixes" tag as well to clearly indicate the dependence with a specific commit and better understand the fix.)

Just a bit of context: I found this problematic pattern in my own selftests (rseq and membarrier), and figured that it was an issue all across the board. I did an initial single-patch fix, and then split it up in 34 patches based on feedback from Shuah Khan.

I know it should have a Fixed ... tag, but I simply don't have time to do the historical investigation work for all the 34 patches form this patchset. Perhaps someone else is up to the task ?

Quoted 3 lines

(and add all the individual maintainers of the files you modify -- feel free to use 'b4' to help you for this task ;-) )

If this can be automated, then perhaps Shuah can use it to append the relevant information ?

Quoted 23 lines

(...)

tools/testing/selftests/net/mptcp/Makefile line 5

Quoted 10 lines
tools/testing/selftests/net/mptcp/Makefile +1 -1
index 43a723626126..06bba013bcef 100644
@@ -2,7 +2,7 @@
 
  top_srcdir = ../../../../..
 
-CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g -I$(top_srcdir)/usr/include $(KHDR_INCLUDES)
+CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g $(KHDR_INCLUDES)

I only looked at the modification here with MPTCP selftests and it looks good to me. It makes sense because if KHDR_INCLUDES is not set, it will be set later by lib.mk I suppose.

Just one small thing: I guess you can also remove "top_srcdir" variable that is no longer used, right? I see that "lib.mk" uses a variable with the same name but it overrides its value anyway. But it is likely I missed something there :)

Quoted 5 lines

If indeed it is no longer needed, I guess a few Makefile can be adapted according to:

git grep top_srcdir -- tools/testing/selftests/*/

Yes, this should perhaps come as additional fixes on top of my series. I don't have time to do it myself though.

Anyone willing to contribute it ?

Quoted 2 lines

I guess most of these Makefile are very similar, no? For MPTCP, we simply looked at what was done elsewhere :)

Yes, I did likewise.

Thanks for the feedback,

Mathieu

Quoted 3 lines

Cheers,
Matt

Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
maintainer Acked-by on v1 17/34
#29 lore raw

Re: [PATCH 17/34] selftests: net: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers
Quoted 10 lines · Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

Quoted 7 lines
---
  tools/testing/selftests/net/Makefile             | 2 +-
  tools/testing/selftests/net/bpf/Makefile         | 2 +-
  tools/testing/selftests/net/mptcp/Makefile       | 2 +-
  tools/testing/selftests/net/openvswitch/Makefile | 2 +-
  4 files changed, 4 insertions(+), 4 deletions(-)

Adding net maintainers:

Would you me to take this patch through kselftest tree? If you decide to take this through yours:

thanks,
-- Shuah

author maintainer
#30 lore raw

PATCH 18/34 selftests: perf_events: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/perf_events/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/perf_events/Makefile +1 -1
index fcafa5f0d34c..db93c4ff081a 100644
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-CFLAGS += -Wl,-no-as-needed -Wall -I../../../../usr/include
+CFLAGS += -Wl,-no-as-needed -Wall $(KHDR_INCLUDES)
 LDFLAGS += -lpthread
 
 TEST_GEN_PROGS := sigtrap_threads remove_on_exec
Signature · 1 line
2.25.1
author maintainer
#31 lore raw

PATCH 19/34 selftests: pid_namespace: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/pid_namespace/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/pid_namespace/Makefile +1 -1
index edafaca1aeb3..9286a1d22cd3 100644
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-CFLAGS += -g -I../../../../usr/include/
+CFLAGS += -g $(KHDR_INCLUDES)
 
 TEST_GEN_PROGS = regression_enomem
 
Signature · 1 line
2.25.1
author maintainer
#32 lore raw

PATCH 20/34 selftests: pidfd: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/pidfd/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/pidfd/Makefile +1 -1
index 778b6cdc8aed..d731e3e76d5b 100644
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
-CFLAGS += -g -I../../../../usr/include/ -pthread -Wall
+CFLAGS += -g $(KHDR_INCLUDES) -pthread -Wall
 
 TEST_GEN_PROGS := pidfd_test pidfd_fdinfo_test pidfd_open_test \
 	pidfd_poll_test pidfd_wait pidfd_getfd_test pidfd_setns_test
Signature · 1 line
2.25.1
author maintainer
#33 lore raw

PATCH 21/34 selftests: powerpc: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/powerpc/ptrace/Makefile   | 2 +-
 tools/testing/selftests/powerpc/security/Makefile | 2 +-
 tools/testing/selftests/powerpc/syscalls/Makefile | 2 +-
 tools/testing/selftests/powerpc/tm/Makefile       | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/powerpc/ptrace/Makefile +1 -1
index 2f02cb54224d..cbeeaeae8837 100644
@@ -33,7 +33,7 @@ TESTS_64 := $(patsubst %,$(OUTPUT)/%,$(TESTS_64))
 $(TESTS_64): CFLAGS += -m64
 $(TM_TESTS): CFLAGS += -I../tm -mhtm
 
-CFLAGS += -I../../../../../usr/include -fno-pie
+CFLAGS += $(KHDR_INCLUDES) -fno-pie
 
 $(OUTPUT)/ptrace-gpr: ptrace-gpr.S
 $(OUTPUT)/ptrace-pkey $(OUTPUT)/core-pkey: LDLIBS += -pthread
tools/testing/selftests/powerpc/security/Makefile +1 -1
index 7488315fd847..e0d979ab0204 100644
@@ -5,7 +5,7 @@ TEST_PROGS := mitigation-patching.sh
 
 top_srcdir = ../../../../..
 
-CFLAGS += -I../../../../../usr/include
+CFLAGS += $(KHDR_INCLUDES)
 
 include ../../lib.mk
 
tools/testing/selftests/powerpc/syscalls/Makefile +1 -1
index b63f8459c704..d1f2648b112b 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 TEST_GEN_PROGS := ipc_unmuxed rtas_filter
 
-CFLAGS += -I../../../../../usr/include
+CFLAGS += $(KHDR_INCLUDES)
 
 top_srcdir = ../../../../..
 include ../../lib.mk
tools/testing/selftests/powerpc/tm/Makefile +1 -1
index 5881e97c73c1..3876805c2f31 100644
@@ -17,7 +17,7 @@ $(TEST_GEN_PROGS): ../harness.c ../utils.c
 CFLAGS += -mhtm
 
 $(OUTPUT)/tm-syscall: tm-syscall-asm.S
-$(OUTPUT)/tm-syscall: CFLAGS += -I../../../../../usr/include
+$(OUTPUT)/tm-syscall: CFLAGS += $(KHDR_INCLUDES)
 $(OUTPUT)/tm-tmspr: CFLAGS += -pthread
 $(OUTPUT)/tm-vmx-unavail: CFLAGS += -pthread -m64
 $(OUTPUT)/tm-resched-dscr: ../pmu/lib.c
Signature · 1 line
2.25.1
maintainer Acked-by on v1 21/34
#34 lore raw

Re: [PATCH 21/34] selftests: powerpc: Fix incorrect kernel headers search path

Quoted 61 lines · Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
  tools/testing/selftests/powerpc/ptrace/Makefile   | 2 +-
  tools/testing/selftests/powerpc/security/Makefile | 2 +-
  tools/testing/selftests/powerpc/syscalls/Makefile | 2 +-
  tools/testing/selftests/powerpc/tm/Makefile       | 2 +-
  4 files changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/powerpc/ptrace/Makefile +1 -1
index 2f02cb54224d..cbeeaeae8837 100644
@@ -33,7 +33,7 @@ TESTS_64 := $(patsubst %,$(OUTPUT)/%,$(TESTS_64))
  $(TESTS_64): CFLAGS += -m64
  $(TM_TESTS): CFLAGS += -I../tm -mhtm
 
-CFLAGS += -I../../../../../usr/include -fno-pie
+CFLAGS += $(KHDR_INCLUDES) -fno-pie
 
  $(OUTPUT)/ptrace-gpr: ptrace-gpr.S
  $(OUTPUT)/ptrace-pkey $(OUTPUT)/core-pkey: LDLIBS += -pthread
tools/testing/selftests/powerpc/security/Makefile +1 -1
index 7488315fd847..e0d979ab0204 100644
@@ -5,7 +5,7 @@ TEST_PROGS := mitigation-patching.sh
 
  top_srcdir = ../../../../..
 
-CFLAGS += -I../../../../../usr/include
+CFLAGS += $(KHDR_INCLUDES)
 
  include ../../lib.mk
 
tools/testing/selftests/powerpc/syscalls/Makefile +1 -1
index b63f8459c704..d1f2648b112b 100644
@@ -1,7 +1,7 @@
  # SPDX-License-Identifier: GPL-2.0-only
  TEST_GEN_PROGS := ipc_unmuxed rtas_filter
 
-CFLAGS += -I../../../../../usr/include
+CFLAGS += $(KHDR_INCLUDES)
 
  top_srcdir = ../../../../..
  include ../../lib.mk
tools/testing/selftests/powerpc/tm/Makefile +0 -0
index 5881e97c73c1..3876805c2f31 100644

tools/testing/selftests/powerpc/tm/Makefile $(TEST_GEN_PROGS): ../harness.c ../utils.c · line 23

Quoted 8 lines
tools/testing/selftests/powerpc/tm/Makefile +1 -1
@@ -17,7 +17,7 @@ $(TEST_GEN_PROGS): ../harness.c ../utils.c
  CFLAGS += -mhtm
 
  $(OUTPUT)/tm-syscall: tm-syscall-asm.S
-$(OUTPUT)/tm-syscall: CFLAGS += -I../../../../../usr/include
+$(OUTPUT)/tm-syscall: CFLAGS += $(KHDR_INCLUDES)
  $(OUTPUT)/tm-tmspr: CFLAGS += -pthread
  $(OUTPUT)/tm-vmx-unavail: CFLAGS += -pthread -m64
  $(OUTPUT)/tm-resched-dscr: ../pmu/lib.c

Adding powerpc maitainers.

Would you me to take this patch through kselftest tree? If you decide to take this through yours:

thanks,
-- Shuah

author maintainer
#35 lore raw

PATCH 22/34 selftests: ptp: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/ptp/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/ptp/Makefile +1 -1
index ef06de0898b7..eeab44cc6863 100644
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-CFLAGS += -I../../../../usr/include/
+CFLAGS += $(KHDR_INCLUDES)
 TEST_PROGS := testptp
 LDLIBS += -lrt
 all: $(TEST_PROGS)
Signature · 1 line
2.25.1
author maintainer
#36 lore raw

PATCH 23/34 selftests: rseq: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/rseq/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/rseq/Makefile +1 -1
index 215e1067f037..3a173e184566 100644
@@ -4,7 +4,7 @@ ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
 CLANG_FLAGS += -no-integrated-as
 endif
 
-CFLAGS += -O2 -Wall -g -I./ -I../../../../usr/include/ -L$(OUTPUT) -Wl,-rpath=./ \
+CFLAGS += -O2 -Wall -g -I./ $(KHDR_INCLUDES) -L$(OUTPUT) -Wl,-rpath=./ \
 	  $(CLANG_FLAGS)
 LDLIBS += -lpthread -ldl
 
Signature · 1 line
2.25.1
author maintainer
#37 lore raw

PATCH 24/34 selftests: sched: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/sched/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/sched/Makefile +1 -1
index 10c72f14fea9..099ee9213557 100644
@@ -4,7 +4,7 @@ ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
 CLANG_FLAGS += -no-integrated-as
 endif
 
-CFLAGS += -O2 -Wall -g -I./ -I../../../../usr/include/  -Wl,-rpath=./ \
+CFLAGS += -O2 -Wall -g -I./ $(KHDR_INCLUDES) -Wl,-rpath=./ \
 	  $(CLANG_FLAGS)
 LDLIBS += -lpthread
 
Signature · 1 line
2.25.1
author maintainer
#38 lore raw

PATCH 25/34 selftests: seccomp: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/seccomp/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/seccomp/Makefile +1 -1
index f017c382c036..584fba487037 100644
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-CFLAGS += -Wl,-no-as-needed -Wall -isystem ../../../../usr/include/
+CFLAGS += -Wl,-no-as-needed -Wall $(KHDR_INCLUDES)
 LDFLAGS += -lpthread
 LDLIBS += -lcap
 
Signature · 1 line
2.25.1
maintainer Acked-by on v1 25/34
#39 lore raw

Re: [PATCH 25/34] selftests: seccomp: Fix incorrect kernel headers search path

Quoted 19 lines · Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
  tools/testing/selftests/seccomp/Makefile | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/seccomp/Makefile +0 -0
index f017c382c036..584fba487037 100644

tools/testing/selftests/seccomp/Makefile line 5

Quoted 6 lines
tools/testing/selftests/seccomp/Makefile +1 -1
@@ -1,5 +1,5 @@
  # SPDX-License-Identifier: GPL-2.0
-CFLAGS += -Wl,-no-as-needed -Wall -isystem ../../../../usr/include/
+CFLAGS += -Wl,-no-as-needed -Wall $(KHDR_INCLUDES)
  LDFLAGS += -lpthread
  LDLIBS += -lcap
 

Now the right one.

Kees,

I plan to take this through kselftest unless there are conflicts. In case there are conflicts and you want to take this through yours

thanks,
-- Shuah

author maintainer
#40 lore raw

PATCH 26/34 selftests: sync: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/sync/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/sync/Makefile +1 -1
index d0121a8a3523..df0f91bf6890 100644
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 CFLAGS += -O2 -g -std=gnu89 -pthread -Wall -Wextra
-CFLAGS += -I../../../../usr/include/
+CFLAGS += $(KHDR_INCLUDES)
 LDFLAGS += -pthread
 
 .PHONY: all clean
Signature · 1 line
2.25.1
maintainer Acked-by on v1 26/34
#41 lore raw

Re: [PATCH 26/34] selftests: sync: Fix incorrect kernel headers search path

Quoted 19 lines · Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
  tools/testing/selftests/sync/Makefile | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/sync/Makefile +0 -0
index d0121a8a3523..df0f91bf6890 100644

tools/testing/selftests/sync/Makefile line 6

Quoted 7 lines
tools/testing/selftests/sync/Makefile +1 -1
@@ -1,6 +1,6 @@
  # SPDX-License-Identifier: GPL-2.0
  CFLAGS += -O2 -g -std=gnu89 -pthread -Wall -Wextra
-CFLAGS += -I../../../../usr/include/
+CFLAGS += $(KHDR_INCLUDES)
  LDFLAGS += -pthread
 
  .PHONY: all clean

Adding seccomp maintainers:

kees,

I plan to take this through kselftest unless there are conflicts. In case there are conflicts and you want to take this through yours

thanks,
-- Shuah

maintainer
#42 lore raw

Re: [PATCH 26/34] selftests: sync: Fix incorrect kernel headers search path

Quoted 29 lines · Shuah Khan
Quoted 23 lines · Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
  tools/testing/selftests/sync/Makefile | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/sync/Makefile +0 -0
index d0121a8a3523..df0f91bf6890 100644
@@ -1,6 +1,6 @@
   # SPDX-License-Identifier: GPL-2.0

  CFLAGS += -O2 -g -std=gnu89 -pthread -Wall -Wextra

tools/testing/selftests/sync/Makefile +1 -1
-CFLAGS += -I../../../../usr/include/
+CFLAGS += $(KHDR_INCLUDES)
Quoted 2 lines

  LDFLAGS += -pthread
  .PHONY: all clean

Adding seccomp maintainers:

Quoted 7 lines

kees,

I plan to take this through kselftest unless there are conflicts. In case there are conflicts and you want to take this through yours

Sorry wrong message. I am taking this one through mine.

-- Shuah

author maintainer
#43 lore raw

PATCH 27/34 selftests: user_events: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/user_events/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/user_events/Makefile +1 -1
index c765d8635d9a..87d54c640068 100644
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-CFLAGS += -Wl,-no-as-needed -Wall -I../../../../usr/include
+CFLAGS += -Wl,-no-as-needed -Wall $(KHDR_INCLUDES)
 LDLIBS += -lrt -lpthread -lm
 
 TEST_GEN_PROGS = ftrace_test dyn_test perf_test
Signature · 1 line
2.25.1
author maintainer
#44 lore raw

PATCH 28/34 selftests: vm: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/vm/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/vm/Makefile +1 -1
index 89c14e41bd43..ac9366065fd2 100644
@@ -25,7 +25,7 @@ MACHINE ?= $(shell echo $(uname_M) | sed -e 's/aarch64.*/arm64/' -e 's/ppc64.*/p
 # LDLIBS.
 MAKEFLAGS += --no-builtin-rules
 
-CFLAGS = -Wall -I $(top_srcdir) -I $(top_srcdir)/usr/include $(EXTRA_CFLAGS) $(KHDR_INCLUDES)
+CFLAGS = -Wall -I $(top_srcdir) $(EXTRA_CFLAGS) $(KHDR_INCLUDES)
 LDLIBS = -lrt -lpthread
 TEST_GEN_FILES = cow
 TEST_GEN_FILES += compaction_test
Signature · 1 line
2.25.1
maintainer Acked-by on v1 28/34
#45 lore raw

Re: [PATCH 28/34] selftests: vm: Fix incorrect kernel headers search path

Quoted 19 lines · Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
  tools/testing/selftests/vm/Makefile | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/vm/Makefile +0 -0
index 89c14e41bd43..ac9366065fd2 100644

tools/testing/selftests/vm/Makefile MACHINE ?= $(shell echo $(uname_M) | sed -e 's/aarch64.*/arm64/' -e 's/ppc64.*/p · line 31

Quoted 8 lines
tools/testing/selftests/vm/Makefile +1 -1
@@ -25,7 +25,7 @@ MACHINE ?= $(shell echo $(uname_M) | sed -e 's/aarch64.*/arm64/' -e 's/ppc64.*/p
  # LDLIBS.
  MAKEFLAGS += --no-builtin-rules
 
-CFLAGS = -Wall -I $(top_srcdir) -I $(top_srcdir)/usr/include $(EXTRA_CFLAGS) $(KHDR_INCLUDES)
+CFLAGS = -Wall -I $(top_srcdir) $(EXTRA_CFLAGS) $(KHDR_INCLUDES)
  LDLIBS = -lrt -lpthread
  TEST_GEN_FILES = cow
  TEST_GEN_FILES += compaction_test

Adding mm maintainers.

Andrew,

Would you me to take this patch through kselftest tree? If you decide to take this through yours:

thanks,
-- Shuah

author maintainer
#46 lore raw

PATCH 29/34 selftests: x86: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...).

---
 tools/testing/selftests/x86/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/x86/Makefile +1 -1
index 0388c4d60af0..ca9374b56ead 100644
@@ -34,7 +34,7 @@ BINARIES_64 := $(TARGETS_C_64BIT_ALL:%=%_64)
 BINARIES_32 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_32))
 BINARIES_64 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_64))
 
-CFLAGS := -O2 -g -std=gnu99 -pthread -Wall
+CFLAGS := -O2 -g -std=gnu99 -pthread -Wall $(KHDR_INCLUDES)
 
 # call32_from_64 in thunks.S uses absolute addresses.
 ifeq ($(CAN_BUILD_WITH_NOPIE),1)
Signature · 1 line
2.25.1
author maintainer
#47 lore raw

PATCH 30/34 selftests: bpf docs: Use installed kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for installed kernel headers rather than using kernel headers in include/uapi from the source kernel tree kernel headers.

---
 tools/testing/selftests/bpf/Makefile.docs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/Makefile.docs +1 -1
index eb6a4fea8c79..0a538d873def 100644
@@ -44,7 +44,7 @@ RST2MAN_DEP := $(shell command -v rst2man 2>/dev/null)
 # $1 - target for scripts/bpf_doc.py
 # $2 - man page section to generate the troff file
 define DOCS_RULES =
-$(OUTPUT)bpf-$1.rst: ../../../../include/uapi/linux/bpf.h
+$(OUTPUT)bpf-$1.rst: $(KHDR_INCLUDES)/linux/bpf.h
 	$$(QUIET_GEN)../../../../scripts/bpf_doc.py $1 \
 		--filename $$< > $$@
 
Signature · 1 line
2.25.1
maintainer Acked-by on v1 30/34
#48 lore raw

Re: [PATCH 30/34] selftests: bpf docs: Use installed kernel headers search path

Quoted 17 lines · Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for installed kernel headers rather than using kernel headers in include/uapi from the source kernel tree kernel headers.

---
  tools/testing/selftests/bpf/Makefile.docs | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/Makefile.docs +0 -0
index eb6a4fea8c79..0a538d873def 100644

tools/testing/selftests/bpf/Makefile.docs RST2MAN_DEP := $(shell command -v rst2man 2>/dev/null) · line 50

Quoted 8 lines
tools/testing/selftests/bpf/Makefile.docs +1 -1
@@ -44,7 +44,7 @@ RST2MAN_DEP := $(shell command -v rst2man 2>/dev/null)
  # $1 - target for scripts/bpf_doc.py
  # $2 - man page section to generate the troff file
  define DOCS_RULES =
-$(OUTPUT)bpf-$1.rst: ../../../../include/uapi/linux/bpf.h
+$(OUTPUT)bpf-$1.rst: $(KHDR_INCLUDES)/linux/bpf.h
  	$$(QUIET_GEN)../../../../scripts/bpf_doc.py $1 \
  		--filename $$< > $$@
 

Adding bpf maintainers.

Here is my ack:

thanks,
-- Shuah

author maintainer
#49 lore raw

PATCH 31/34 selftests: iommu: Use installed kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for installed kernel headers rather than using kernel headers in include/uapi from the source kernel tree kernel headers.

Remove bogus ../../../../include/ from the search path, because kernel source headers are not needed by those user-space selftests, and it causes issues because -I paths are searched before -isystem paths, and conflicts for files appearing both in kernel sources and in uapi headers with incompatible semantics (e.g. types.h).

---
 tools/testing/selftests/iommu/Makefile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/testing/selftests/iommu/Makefile +1 -2
index 7cb74d26f141..32c5fdfd0eef 100644
@@ -1,7 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 CFLAGS += -Wall -O2 -Wno-unused-function
-CFLAGS += -I../../../../include/uapi/
-CFLAGS += -I../../../../include/
+CFLAGS += $(KHDR_INCLUDES)
 
 CFLAGS += -D_GNU_SOURCE
 
Signature · 1 line
2.25.1
maintainer Acked-by on v1 31/34
#50 lore raw

Re: [PATCH 31/34] selftests: iommu: Use installed kernel headers search path

Quoted 23 lines · Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for installed kernel headers rather than using kernel headers in include/uapi from the source kernel tree kernel headers.

Remove bogus ../../../../include/ from the search path, because kernel source headers are not needed by those user-space selftests, and it causes issues because -I paths are searched before -isystem paths, and conflicts for files appearing both in kernel sources and in uapi headers with incompatible semantics (e.g. types.h).

---
  tools/testing/selftests/iommu/Makefile | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
tools/testing/selftests/iommu/Makefile +0 -0
index 7cb74d26f141..32c5fdfd0eef 100644

tools/testing/selftests/iommu/Makefile line 6

Quoted 8 lines
tools/testing/selftests/iommu/Makefile +1 -2
@@ -1,7 +1,6 @@
  # SPDX-License-Identifier: GPL-2.0-only
  CFLAGS += -Wall -O2 -Wno-unused-function
-CFLAGS += -I../../../../include/uapi/
-CFLAGS += -I../../../../include/
+CFLAGS += $(KHDR_INCLUDES)
 
  CFLAGS += -D_GNU_SOURCE
 

Adding iommu test maintainers:

I plan to take this through kselftest unless there are conflicts. In case there are conflicts and you want to take this through yours

thanks,
-- Shuah

#51 lore raw

Re: [PATCH 31/34] selftests: iommu: Use installed kernel headers search path

Quoted 33 lines · Shuah Khan
Quoted 23 lines · Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for installed kernel headers rather than using kernel headers in include/uapi from the source kernel tree kernel headers.

Remove bogus ../../../../include/ from the search path, because kernel source headers are not needed by those user-space selftests, and it causes issues because -I paths are searched before -isystem paths, and conflicts for files appearing both in kernel sources and in uapi headers with incompatible semantics (e.g. types.h).

---
  tools/testing/selftests/iommu/Makefile | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
tools/testing/selftests/iommu/Makefile +0 -0
index 7cb74d26f141..32c5fdfd0eef 100644

tools/testing/selftests/iommu/Makefile line 4

Quoted 6 lines
tools/testing/selftests/iommu/Makefile +1 -2
@@ -1,7 +1,6 @@
  # SPDX-License-Identifier: GPL-2.0-only
  CFLAGS += -Wall -O2 -Wno-unused-function
-CFLAGS += -I../../../../include/uapi/
-CFLAGS += -I../../../../include/
+CFLAGS += $(KHDR_INCLUDES)
  CFLAGS += -D_GNU_SOURCE

Adding iommu test maintainers:

Quoted 4 lines

I plan to take this through kselftest unless there are conflicts. In case there are conflicts and you want to take this through yours

Go ahead please

Jason

author maintainer
#52 lore raw

PATCH 32/34 selftests: memfd: Use installed kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for installed kernel headers rather than using kernel headers in include/uapi from the source kernel tree kernel headers.

Remove bogus ../../../../include/ from the search path, because kernel source headers are not needed by those user-space selftests, and it causes issues because -I paths are searched before -isystem paths, and conflicts for files appearing both in kernel sources and in uapi headers with incompatible semantics (e.g. types.h).

---
 tools/testing/selftests/memfd/Makefile | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
tools/testing/selftests/memfd/Makefile +1 -3
index 4da8b565fa32..163b6f68631c 100644
@@ -1,8 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 CFLAGS += -D_FILE_OFFSET_BITS=64
-CFLAGS += -I../../../../include/uapi/
-CFLAGS += -I../../../../include/
-CFLAGS += -I../../../../usr/include/
+CFLAGS += $(KHDR_INCLUDES)
 
 TEST_GEN_PROGS := memfd_test
 TEST_PROGS := run_fuse_test.sh run_hugetlbfs_test.sh
Signature · 1 line
2.25.1
author maintainer
#53 lore raw

PATCH 33/34 selftests: ptrace: Use installed kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for installed kernel headers rather than using kernel headers in include/uapi from the source kernel tree kernel headers.

---
 tools/testing/selftests/ptrace/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/ptrace/Makefile +1 -1
index 2f1f532c39db..96ffa94afb91 100644
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
-CFLAGS += -std=c99 -pthread -iquote../../../../include/uapi -Wall
+CFLAGS += -std=c99 -pthread -Wall $(KHDR_INCLUDES)
 
 TEST_GEN_PROGS := get_syscall_info peeksiginfo vmaccess
 
Signature · 1 line
2.25.1
author maintainer
#54 lore raw

PATCH 34/34 selftests: tdx: Use installed kernel headers search path

In reply to Mathieu Desnoyers

Use $(KHDR_INCLUDES) as lookup path for installed kernel headers rather than using kernel headers in include/uapi from the source kernel tree kernel headers.

---
 tools/testing/selftests/tdx/Makefile         | 2 +-
 tools/testing/selftests/tdx/tdx_guest_test.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/tdx/Makefile +1 -1
index 8dd43517cd55..306e9c4d5ef7 100644
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 
-CFLAGS += -O3 -Wl,-no-as-needed -Wall -static
+CFLAGS += -O3 -Wl,-no-as-needed -Wall $(KHDR_INCLUDES) -static
 
 TEST_GEN_PROGS := tdx_guest_test
 
tools/testing/selftests/tdx/tdx_guest_test.c +1 -1
index 2a2afd856798..81d8cb88ea1a 100644
@@ -12,8 +12,8 @@
 #include <errno.h>
 #include <fcntl.h>
 
+#include <linux/tdx-guest.h>
 #include "../kselftest_harness.h"
-#include "../../../../include/uapi/linux/tdx-guest.h"
 
 #define TDX_GUEST_DEVNAME "/dev/tdx_guest"
 #define HEX_DUMP_SIZE 8
Signature · 1 line
2.25.1
maintainer
#55 lore raw
In reply to Mathieu Desnoyers
Quoted 14 lines · Mathieu Desnoyers

Hi,

This series fixes incorrect kernel header search path in kernel selftests.

Near the end of the series, a few changes are not tagged as "Fixes" because the current behavior is to rely on the kernel sources uapi files rather than on the installed kernel header files. Nevertheless, those are updated for consistency.

There are situations where "../../../../include/" was added to -I search path, which is bogus for userspace tests and caused issues with types.h. Those are removed.

Quoted 5 lines

Thanks,

Mathieu

Mathieu Desnoyers (34):

The below patches are now applied to linux-kselftest next for Linux 6.3-rc1

Quoted 23 lines

selftests: arm64: Fix incorrect kernel headers search path
selftests: clone3: Fix incorrect kernel headers search path
selftests: core: Fix incorrect kernel headers search path
selftests: dma: Fix incorrect kernel headers search path
selftests: dmabuf-heaps: Fix incorrect kernel headers search path
selftests: drivers: Fix incorrect kernel headers search path
selftests: filesystems: Fix incorrect kernel headers search path
selftests: futex: Fix incorrect kernel headers search path
selftests: gpio: Fix incorrect kernel headers search path
selftests: ipc: Fix incorrect kernel headers search path
selftests: kcmp: Fix incorrect kernel headers search path
selftests: media_tests: Fix incorrect kernel headers search path
selftests: membarrier: Fix incorrect kernel headers search path
selftests: mount_setattr: Fix incorrect kernel headers search path
selftests: move_mount_set_group: Fix incorrect kernel headers search
path
selftests: perf_events: Fix incorrect kernel headers search path
selftests: pid_namespace: Fix incorrect kernel headers search path
selftests: pidfd: Fix incorrect kernel headers search path
selftests: ptp: Fix incorrect kernel headers search path
selftests: rseq: Fix incorrect kernel headers search path
selftests: sched: Fix incorrect kernel headers search path
selftests: seccomp: Fix incorrect kernel headers search path

Quoted 9 lines

selftests: sync: Fix incorrect kernel headers search path
selftests: user_events: Fix incorrect kernel headers search path
selftests: vm: Fix incorrect kernel headers search path
selftests: x86: Fix incorrect kernel headers search path
selftests: iommu: Use installed kernel headers search path
selftests: memfd: Use installed kernel headers search path
selftests: ptrace: Use installed kernel headers search path
selftests: tdx: Use installed kernel headers search path

These will be applied by maintainers to their trees.

Quoted 4 lines

selftests: bpf: Fix incorrect kernel headers search path # 02/34
selftests: net: Fix incorrect kernel headers search path # 17/34
selftests: powerpc: Fix incorrect kernel headers search path # 21/34
selftests: bpf docs: Use installed kernel headers search path # 30/34

thanks,
-- Shuah

#56 lore raw
Quoted 57 lines · Shuah Khan
Quoted 14 lines · Mathieu Desnoyers

Hi,

This series fixes incorrect kernel header search path in kernel selftests.

Near the end of the series, a few changes are not tagged as "Fixes" because the current behavior is to rely on the kernel sources uapi files rather than on the installed kernel header files. Nevertheless, those are updated for consistency.

There are situations where "../../../../include/" was added to -I search path, which is bogus for userspace tests and caused issues with types.h. Those are removed.

Quoted 5 lines

Thanks,

Mathieu

Mathieu Desnoyers (34):

The below patches are now applied to linux-kselftest next for Linux 6.3-rc1

Quoted 23 lines

selftests: arm64: Fix incorrect kernel headers search path
selftests: clone3: Fix incorrect kernel headers search path
selftests: core: Fix incorrect kernel headers search path
selftests: dma: Fix incorrect kernel headers search path
selftests: dmabuf-heaps: Fix incorrect kernel headers search path
selftests: drivers: Fix incorrect kernel headers search path
selftests: filesystems: Fix incorrect kernel headers search path
selftests: futex: Fix incorrect kernel headers search path
selftests: gpio: Fix incorrect kernel headers search path
selftests: ipc: Fix incorrect kernel headers search path
selftests: kcmp: Fix incorrect kernel headers search path
selftests: media_tests: Fix incorrect kernel headers search path
selftests: membarrier: Fix incorrect kernel headers search path
selftests: mount_setattr: Fix incorrect kernel headers search path
selftests: move_mount_set_group: Fix incorrect kernel headers search
path
selftests: perf_events: Fix incorrect kernel headers search path
selftests: pid_namespace: Fix incorrect kernel headers search path
selftests: pidfd: Fix incorrect kernel headers search path
selftests: ptp: Fix incorrect kernel headers search path
selftests: rseq: Fix incorrect kernel headers search path
selftests: sched: Fix incorrect kernel headers search path
selftests: seccomp: Fix incorrect kernel headers search path

Quoted 9 lines

selftests: sync: Fix incorrect kernel headers search path
selftests: user_events: Fix incorrect kernel headers search path
selftests: vm: Fix incorrect kernel headers search path
selftests: x86: Fix incorrect kernel headers search path
selftests: iommu: Use installed kernel headers search path
selftests: memfd: Use installed kernel headers search path
selftests: ptrace: Use installed kernel headers search path
selftests: tdx: Use installed kernel headers search path

Quoted 1 line

These will be applied by maintainers to their trees.

Not in this form. They break the build.

Quoted 7 lines
Quoted 4 lines

selftests: bpf: Fix incorrect kernel headers search path # 02/34
selftests: net: Fix incorrect kernel headers search path # 17/34
selftests: powerpc: Fix incorrect kernel headers search path # 21/34
selftests: bpf docs: Use installed kernel headers search path # 30/34

thanks,
-- Shuah

maintainer
#57 lore raw
Quoted 58 lines · Alexei Starovoitov
Quoted 57 lines · Shuah Khan
Quoted 14 lines · Mathieu Desnoyers

Hi,

This series fixes incorrect kernel header search path in kernel selftests.

Near the end of the series, a few changes are not tagged as "Fixes" because the current behavior is to rely on the kernel sources uapi files rather than on the installed kernel header files. Nevertheless, those are updated for consistency.

There are situations where "../../../../include/" was added to -I search path, which is bogus for userspace tests and caused issues with types.h. Those are removed.

Quoted 5 lines

Thanks,

Mathieu

Mathieu Desnoyers (34):

The below patches are now applied to linux-kselftest next for Linux 6.3-rc1

Quoted 32 lines

selftests: arm64: Fix incorrect kernel headers search path
selftests: clone3: Fix incorrect kernel headers search path
selftests: core: Fix incorrect kernel headers search path
selftests: dma: Fix incorrect kernel headers search path
selftests: dmabuf-heaps: Fix incorrect kernel headers search path
selftests: drivers: Fix incorrect kernel headers search path
selftests: filesystems: Fix incorrect kernel headers search path
selftests: futex: Fix incorrect kernel headers search path
selftests: gpio: Fix incorrect kernel headers search path
selftests: ipc: Fix incorrect kernel headers search path
selftests: kcmp: Fix incorrect kernel headers search path
selftests: media_tests: Fix incorrect kernel headers search path
selftests: membarrier: Fix incorrect kernel headers search path
selftests: mount_setattr: Fix incorrect kernel headers search path
selftests: move_mount_set_group: Fix incorrect kernel headers search
path
selftests: perf_events: Fix incorrect kernel headers search path
selftests: pid_namespace: Fix incorrect kernel headers search path
selftests: pidfd: Fix incorrect kernel headers search path
selftests: ptp: Fix incorrect kernel headers search path
selftests: rseq: Fix incorrect kernel headers search path
selftests: sched: Fix incorrect kernel headers search path
selftests: seccomp: Fix incorrect kernel headers search path
selftests: sync: Fix incorrect kernel headers search path
selftests: user_events: Fix incorrect kernel headers search path
selftests: vm: Fix incorrect kernel headers search path
selftests: x86: Fix incorrect kernel headers search path
selftests: iommu: Use installed kernel headers search path
selftests: memfd: Use installed kernel headers search path
selftests: ptrace: Use installed kernel headers search path
selftests: tdx: Use installed kernel headers search path

Quoted 3 lines
Quoted 1 line

These will be applied by maintainers to their trees.

Not in this form. They break the build.

Mathieu is sending you the patches in the format you requested in the thread on this patch.

thanks,
-- Shuah

#58 lore raw
Quoted 8 lines · Shuah Khan
Quoted 5 lines
Quoted 3 lines

These will be applied by maintainers to their trees.

Not in this form. They break the build.

Mathieu is sending you the patches in the format you requested in the thread on this patch.

It's not the format, but the patch itself is incorrect.

maintainer
#59 lore raw
In reply to Shuah Khan

Hi Mathieu,

Quoted 11 lines · Shuah Khan
Quoted 10 lines · Mathieu Desnoyers

Hi,

This series fixes incorrect kernel header search path in kernel selftests.

Near the end of the series, a few changes are not tagged as "Fixes" because the current behavior is to rely on the kernel sources uapi files rather than on the installed kernel header files. Nevertheless, those are updated for consistency.

Quoted 4 lines
Quoted 4 lines

There are situations where "../../../../include/" was added to -I search path, which is bogus for userspace tests and caused issues with types.h. Those are removed.

Thanks again for taking care of this. I did out of tree build testing on x86 on linux-kselftest next with these patches below. I haven't seen any problems introduced by the patch set.

Quoted 1 line
Quoted 1 line

selftests: dma: Fix incorrect kernel headers search path

This one needs a change and I will send a patch on top of yours. Even with that this test depends on unexported header from the repo and won't build out of tree. This is not related to your change.

Quoted 1 line
Quoted 1 line

selftests: mount_setattr: Fix incorrect kernel headers search path

This one fails to build with our without patch - an existing error.

I have to do cross-build tests on arm64 and other arch patches still. This will happen later this week.

Quoted 1 line
Quoted 1 line

selftests: arm64: Fix incorrect kernel headers search path

drivers patch below had arch specific tests - testing todo

The rest looks good. I will try to run bpf patches on my system. I do have clang, llvm installed on mine. TODO

thanks,
-- Shuah

maintainer
#60 lore raw
Quoted 29 lines · Shuah Khan

Hi Mathieu,

Quoted 11 lines · Shuah Khan
Quoted 10 lines · Mathieu Desnoyers

Hi,

This series fixes incorrect kernel header search path in kernel selftests.

Near the end of the series, a few changes are not tagged as "Fixes" because the current behavior is to rely on the kernel sources uapi files rather than on the installed kernel header files. Nevertheless, those are updated for consistency.

Quoted 4 lines
Quoted 4 lines

There are situations where "../../../../include/" was added to -I search path, which is bogus for userspace tests and caused issues with types.h. Those are removed.

Thanks again for taking care of this. I did out of tree build testing on x86 on linux-kselftest next with these patches below. I haven't seen any problems introduced by the patch set.

Quoted 1 line
Quoted 1 line

   selftests: dma: Fix incorrect kernel headers search path

This one needs a change and I will send a patch on top of yours. Even with that this test depends on unexported header from the repo and won't build out of tree. This is not related to your change.

Quoted 5 lines
Quoted 1 line
Quoted 1 line

   selftests: mount_setattr: Fix incorrect kernel headers search path

This one fails to build with our without patch - an existing error.

I have to do cross-build tests on arm64 and other arch patches still. This will happen later this week.

arm64, s390 patches look good.

thanks,
-- Shuah

maintainer
#61 lore raw
Quoted 30 lines · Shuah Khan
Quoted 29 lines · Shuah Khan

Hi Mathieu,

Quoted 11 lines · Shuah Khan
Quoted 10 lines · Mathieu Desnoyers

Hi,

This series fixes incorrect kernel header search path in kernel selftests.

Near the end of the series, a few changes are not tagged as "Fixes" because the current behavior is to rely on the kernel sources uapi files rather than on the installed kernel header files. Nevertheless, those are updated for consistency.

Quoted 4 lines
Quoted 4 lines

There are situations where "../../../../include/" was added to -I search path, which is bogus for userspace tests and caused issues with types.h. Those are removed.

Thanks again for taking care of this. I did out of tree build testing on x86 on linux-kselftest next with these patches below. I haven't seen any problems introduced by the patch set.

Quoted 1 line
Quoted 1 line

   selftests: dma: Fix incorrect kernel headers search path

This one needs a change and I will send a patch on top of yours. Even with that this test depends on unexported header from the repo and won't build out of tree. This is not related to your change.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line

   selftests: mount_setattr: Fix incorrect kernel headers search path

This one fails to build with our without patch - an existing error.

I have to do cross-build tests on arm64 and other arch patches still. This will happen later this week.

arm64, s390 patches look good.

I am seeing problem with selftests/dma and selfttests/user_events.

1. selftests: dma: Fix incorrect kernel headers search path

dma test no longer builds. This test depends on linux/map_benchmark.h which is not included in uapi

The order of include directorries -isystem followed by installed kernel headers, breaks the test build with the change to use KHDR_INCLUDES

I am going to revert this patch for now and figure a longer term fix. The problem is the dependency on a non-uapi file: linux/map_benchmark.h

Fixes 8ddde07a3d28 ("dma-mapping: benchmark: extract a common

header file for map_benchmark definition") change added this dependency on including linux/map_benchmark.h

Christoph, Do you see this map_benchmark.h as part of uapi?

2. selftests: user_events: Fix incorrect kernel headers search path This one depends on linux/user_events.h which has bee removed from uapi in this commit:

commit 5cfff569cab8bf544bab62c911c5d6efd5af5e05

Author: Steven Rostedt (Google) <[email protected]>
Date:   Fri Apr 1 14:39:03 2022 -0400

tracing: Move user_events.h temporarily out of include/uapi

This isn't a regression from 6.2 - this test stopped building once user_events.h has been removed from uapi. I will add a note that this test depends on a non-uapi header and can't be built at the moment.

thanks,
-- Shuah

#62 lore raw

Re: (subset) [PATCH 00/34] selftests: Fix incorrect kernel headers search path

In reply to Mathieu Desnoyers
Quoted 9 lines · Mathieu Desnoyers

This series fixes incorrect kernel header search path in kernel selftests.

Near the end of the series, a few changes are not tagged as "Fixes" because the current behavior is to rely on the kernel sources uapi files rather than on the installed kernel header files. Nevertheless, those are updated for consistency.

[...]

Applied to powerpc/next.

[21/34] selftests: powerpc: Fix incorrect kernel headers search path

        https://git.kernel.org/powerpc/c/4f11410bf6da87defe8fd59b0413f0d9f71744da

cheers