2023-01-27 13:58:22

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 00/34] 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(-)

--
2.25.1



2023-01-27 13:58:24

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 01/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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
tools/testing/selftests/arm64/fp/Makefile | 2 +-
tools/testing/selftests/arm64/tags/Makefile | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/arm64/fp/Makefile b/tools/testing/selftests/arm64/fp/Makefile
index 36db61358ed5..932ec8792316 100644
--- a/tools/testing/selftests/arm64/fp/Makefile
+++ b/tools/testing/selftests/arm64/fp/Makefile
@@ -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 \
diff --git a/tools/testing/selftests/arm64/tags/Makefile b/tools/testing/selftests/arm64/tags/Makefile
index 41cb75070511..6d29cfde43a2 100644
--- a/tools/testing/selftests/arm64/tags/Makefile
+++ b/tools/testing/selftests/arm64/tags/Makefile
@@ -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

--
2.25.1


2023-01-27 13:58:27

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 09/34] selftests: futex: 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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
tools/testing/selftests/futex/functional/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/testing/selftests/futex/functional/Makefile
index 5a0e0df8de9b..a392d0917b4e 100644
--- a/tools/testing/selftests/futex/functional/Makefile
+++ b/tools/testing/selftests/futex/functional/Makefile
@@ -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

--
2.25.1


2023-01-27 13:58:29

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 06/34] selftests: dmabuf-heaps: 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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
tools/testing/selftests/dmabuf-heaps/Makefile | 2 +-
tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/dmabuf-heaps/Makefile b/tools/testing/selftests/dmabuf-heaps/Makefile
index 604b43ece15f..9e7e158d5fa3 100644
--- a/tools/testing/selftests/dmabuf-heaps/Makefile
+++ b/tools/testing/selftests/dmabuf-heaps/Makefile
@@ -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

diff --git a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
index 29af27acd40e..890a8236a8ba 100644
--- a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
+++ b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
@@ -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)
--
2.25.1


2023-01-27 13:58:32

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 08/34] selftests: filesystems: 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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
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(-)

diff --git a/tools/testing/selftests/filesystems/Makefile b/tools/testing/selftests/filesystems/Makefile
index 129880fb42d3..c647fd6a0446 100644
--- a/tools/testing/selftests/filesystems/Makefile
+++ b/tools/testing/selftests/filesystems/Makefile
@@ -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

diff --git a/tools/testing/selftests/filesystems/binderfs/Makefile b/tools/testing/selftests/filesystems/binderfs/Makefile
index 8af25ae96049..c2f7cef919c0 100644
--- a/tools/testing/selftests/filesystems/binderfs/Makefile
+++ b/tools/testing/selftests/filesystems/binderfs/Makefile
@@ -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
diff --git a/tools/testing/selftests/filesystems/epoll/Makefile b/tools/testing/selftests/filesystems/epoll/Makefile
index 78ae4aaf7141..0788a7dc8004 100644
--- a/tools/testing/selftests/filesystems/epoll/Makefile
+++ b/tools/testing/selftests/filesystems/epoll/Makefile
@@ -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

--
2.25.1


2023-01-27 13:58:35

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 14/34] selftests: membarrier: 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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
tools/testing/selftests/membarrier/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/membarrier/Makefile b/tools/testing/selftests/membarrier/Makefile
index 34d1c81a2324..fc840e06ff56 100644
--- a/tools/testing/selftests/membarrier/Makefile
+++ b/tools/testing/selftests/membarrier/Makefile
@@ -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 \
--
2.25.1


2023-01-27 13:58:38

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 11/34] selftests: ipc: 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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
tools/testing/selftests/ipc/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/ipc/Makefile b/tools/testing/selftests/ipc/Makefile
index 1c4448a843a4..50e9c299fc4a 100644
--- a/tools/testing/selftests/ipc/Makefile
+++ b/tools/testing/selftests/ipc/Makefile
@@ -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

--
2.25.1


2023-01-27 13:58:41

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 12/34] selftests: kcmp: 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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
tools/testing/selftests/kcmp/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kcmp/Makefile b/tools/testing/selftests/kcmp/Makefile
index b4d39f6b5124..59a1e5379018 100644
--- a/tools/testing/selftests/kcmp/Makefile
+++ b/tools/testing/selftests/kcmp/Makefile
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-2.0-only
-CFLAGS += -I../../../../usr/include/
+CFLAGS += $(KHDR_INCLUDES)

TEST_GEN_PROGS := kcmp_test

--
2.25.1


2023-01-27 13:58:45

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 05/34] selftests: dma: 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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
tools/testing/selftests/dma/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/dma/Makefile b/tools/testing/selftests/dma/Makefile
index cd8c5ece1cba..dd7f746f3e84 100644
--- a/tools/testing/selftests/dma/Makefile
+++ b/tools/testing/selftests/dma/Makefile
@@ -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
--
2.25.1


2023-01-27 13:58:48

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 13/34] selftests: media_tests: 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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
tools/testing/selftests/media_tests/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/media_tests/Makefile b/tools/testing/selftests/media_tests/Makefile
index 60826d7d37d4..471d83e61d95 100644
--- a/tools/testing/selftests/media_tests/Makefile
+++ b/tools/testing/selftests/media_tests/Makefile
@@ -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
--
2.25.1


2023-01-27 13:58:52

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 04/34] selftests: core: 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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
tools/testing/selftests/core/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/core/Makefile b/tools/testing/selftests/core/Makefile
index f6f2d6f473c6..ce262d097269 100644
--- a/tools/testing/selftests/core/Makefile
+++ b/tools/testing/selftests/core/Makefile
@@ -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

--
2.25.1


2023-01-27 13:58:55

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 10/34] selftests: gpio: 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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
tools/testing/selftests/gpio/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile
index 616ed4019655..e0884390447d 100644
--- a/tools/testing/selftests/gpio/Makefile
+++ b/tools/testing/selftests/gpio/Makefile
@@ -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
--
2.25.1


2023-01-27 13:58:58

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 07/34] selftests: drivers: 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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
tools/testing/selftests/drivers/dma-buf/Makefile | 2 +-
tools/testing/selftests/drivers/s390x/uvdevice/Makefile | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/drivers/dma-buf/Makefile b/tools/testing/selftests/drivers/dma-buf/Makefile
index 79cb16b4e01a..441407bb0e80 100644
--- a/tools/testing/selftests/drivers/dma-buf/Makefile
+++ b/tools/testing/selftests/drivers/dma-buf/Makefile
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-2.0-only
-CFLAGS += -I../../../../../usr/include/
+CFLAGS += $(KHDR_INCLUDES)

TEST_GEN_PROGS := udmabuf

diff --git a/tools/testing/selftests/drivers/s390x/uvdevice/Makefile b/tools/testing/selftests/drivers/s390x/uvdevice/Makefile
index 891215a7dc8a..755d164384c4 100644
--- a/tools/testing/selftests/drivers/s390x/uvdevice/Makefile
+++ b/tools/testing/selftests/drivers/s390x/uvdevice/Makefile
@@ -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

--
2.25.1


2023-01-27 13:59:01

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 15/34] selftests: mount_setattr: 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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
tools/testing/selftests/mount_setattr/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/mount_setattr/Makefile b/tools/testing/selftests/mount_setattr/Makefile
index 2250f7dcb81e..fde72df01b11 100644
--- a/tools/testing/selftests/mount_setattr/Makefile
+++ b/tools/testing/selftests/mount_setattr/Makefile
@@ -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

--
2.25.1


2023-01-27 13:59:03

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 18/34] selftests: perf_events: 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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
tools/testing/selftests/perf_events/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/perf_events/Makefile b/tools/testing/selftests/perf_events/Makefile
index fcafa5f0d34c..db93c4ff081a 100644
--- a/tools/testing/selftests/perf_events/Makefile
+++ b/tools/testing/selftests/perf_events/Makefile
@@ -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
--
2.25.1


2023-01-27 13:59:08

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 17/34] selftests: net: 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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
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(-)

diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index 3007e98a6d64..bab1222c7d50 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -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
diff --git a/tools/testing/selftests/net/bpf/Makefile b/tools/testing/selftests/net/bpf/Makefile
index 4abaf16d2077..207b6b958f66 100644
--- a/tools/testing/selftests/net/bpf/Makefile
+++ b/tools/testing/selftests/net/bpf/Makefile
@@ -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
diff --git a/tools/testing/selftests/net/mptcp/Makefile b/tools/testing/selftests/net/mptcp/Makefile
index 43a723626126..06bba013bcef 100644
--- a/tools/testing/selftests/net/mptcp/Makefile
+++ b/tools/testing/selftests/net/mptcp/Makefile
@@ -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
diff --git a/tools/testing/selftests/net/openvswitch/Makefile b/tools/testing/selftests/net/openvswitch/Makefile
index 2f1508abc826..41ddfa9fdd1d 100644
--- a/tools/testing/selftests/net/openvswitch/Makefile
+++ b/tools/testing/selftests/net/openvswitch/Makefile
@@ -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

--
2.25.1


2023-01-27 13:59:14

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 20/34] selftests: pidfd: 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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
tools/testing/selftests/pidfd/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/pidfd/Makefile b/tools/testing/selftests/pidfd/Makefile
index 778b6cdc8aed..d731e3e76d5b 100644
--- a/tools/testing/selftests/pidfd/Makefile
+++ b/tools/testing/selftests/pidfd/Makefile
@@ -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
--
2.25.1


2023-01-27 13:59:17

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 22/34] selftests: ptp: 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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
tools/testing/selftests/ptp/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/ptp/Makefile b/tools/testing/selftests/ptp/Makefile
index ef06de0898b7..eeab44cc6863 100644
--- a/tools/testing/selftests/ptp/Makefile
+++ b/tools/testing/selftests/ptp/Makefile
@@ -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)
--
2.25.1


2023-01-27 13:59:19

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 16/34] selftests: move_mount_set_group: 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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
tools/testing/selftests/move_mount_set_group/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/move_mount_set_group/Makefile b/tools/testing/selftests/move_mount_set_group/Makefile
index 80c2d86812b0..94235846b6f9 100644
--- a/tools/testing/selftests/move_mount_set_group/Makefile
+++ b/tools/testing/selftests/move_mount_set_group/Makefile
@@ -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

--
2.25.1


2023-01-27 13:59:21

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 27/34] selftests: user_events: 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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
tools/testing/selftests/user_events/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/user_events/Makefile b/tools/testing/selftests/user_events/Makefile
index c765d8635d9a..87d54c640068 100644
--- a/tools/testing/selftests/user_events/Makefile
+++ b/tools/testing/selftests/user_events/Makefile
@@ -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
--
2.25.1


2023-01-27 13:59:23

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 19/34] selftests: pid_namespace: 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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
tools/testing/selftests/pid_namespace/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/pid_namespace/Makefile b/tools/testing/selftests/pid_namespace/Makefile
index edafaca1aeb3..9286a1d22cd3 100644
--- a/tools/testing/selftests/pid_namespace/Makefile
+++ b/tools/testing/selftests/pid_namespace/Makefile
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-2.0
-CFLAGS += -g -I../../../../usr/include/
+CFLAGS += -g $(KHDR_INCLUDES)

TEST_GEN_PROGS = regression_enomem

--
2.25.1


2023-01-27 13:59:26

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 26/34] selftests: sync: 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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
tools/testing/selftests/sync/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/sync/Makefile b/tools/testing/selftests/sync/Makefile
index d0121a8a3523..df0f91bf6890 100644
--- a/tools/testing/selftests/sync/Makefile
+++ b/tools/testing/selftests/sync/Makefile
@@ -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
--
2.25.1


2023-01-27 13:59:29

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 21/34] selftests: powerpc: 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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
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(-)

diff --git a/tools/testing/selftests/powerpc/ptrace/Makefile b/tools/testing/selftests/powerpc/ptrace/Makefile
index 2f02cb54224d..cbeeaeae8837 100644
--- a/tools/testing/selftests/powerpc/ptrace/Makefile
+++ b/tools/testing/selftests/powerpc/ptrace/Makefile
@@ -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
diff --git a/tools/testing/selftests/powerpc/security/Makefile b/tools/testing/selftests/powerpc/security/Makefile
index 7488315fd847..e0d979ab0204 100644
--- a/tools/testing/selftests/powerpc/security/Makefile
+++ b/tools/testing/selftests/powerpc/security/Makefile
@@ -5,7 +5,7 @@ TEST_PROGS := mitigation-patching.sh

top_srcdir = ../../../../..

-CFLAGS += -I../../../../../usr/include
+CFLAGS += $(KHDR_INCLUDES)

include ../../lib.mk

diff --git a/tools/testing/selftests/powerpc/syscalls/Makefile b/tools/testing/selftests/powerpc/syscalls/Makefile
index b63f8459c704..d1f2648b112b 100644
--- a/tools/testing/selftests/powerpc/syscalls/Makefile
+++ b/tools/testing/selftests/powerpc/syscalls/Makefile
@@ -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
diff --git a/tools/testing/selftests/powerpc/tm/Makefile b/tools/testing/selftests/powerpc/tm/Makefile
index 5881e97c73c1..3876805c2f31 100644
--- a/tools/testing/selftests/powerpc/tm/Makefile
+++ b/tools/testing/selftests/powerpc/tm/Makefile
@@ -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
--
2.25.1


2023-01-27 13:59:33

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 23/34] selftests: rseq: 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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
tools/testing/selftests/rseq/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/rseq/Makefile b/tools/testing/selftests/rseq/Makefile
index 215e1067f037..3a173e184566 100644
--- a/tools/testing/selftests/rseq/Makefile
+++ b/tools/testing/selftests/rseq/Makefile
@@ -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

--
2.25.1


2023-01-27 13:59:35

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 31/34] selftests: iommu: Use installed kernel headers search path

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).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
---
tools/testing/selftests/iommu/Makefile | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/testing/selftests/iommu/Makefile b/tools/testing/selftests/iommu/Makefile
index 7cb74d26f141..32c5fdfd0eef 100644
--- a/tools/testing/selftests/iommu/Makefile
+++ b/tools/testing/selftests/iommu/Makefile
@@ -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

--
2.25.1


2023-01-27 13:59:37

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 25/34] selftests: seccomp: 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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
tools/testing/selftests/seccomp/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/seccomp/Makefile b/tools/testing/selftests/seccomp/Makefile
index f017c382c036..584fba487037 100644
--- a/tools/testing/selftests/seccomp/Makefile
+++ b/tools/testing/selftests/seccomp/Makefile
@@ -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

--
2.25.1


2023-01-27 13:59:40

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 33/34] selftests: ptrace: Use installed kernel headers search path

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.

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
---
tools/testing/selftests/ptrace/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/ptrace/Makefile b/tools/testing/selftests/ptrace/Makefile
index 2f1f532c39db..96ffa94afb91 100644
--- a/tools/testing/selftests/ptrace/Makefile
+++ b/tools/testing/selftests/ptrace/Makefile
@@ -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

--
2.25.1


2023-01-27 13:59:45

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 24/34] selftests: sched: 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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
tools/testing/selftests/sched/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/sched/Makefile b/tools/testing/selftests/sched/Makefile
index 10c72f14fea9..099ee9213557 100644
--- a/tools/testing/selftests/sched/Makefile
+++ b/tools/testing/selftests/sched/Makefile
@@ -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

--
2.25.1


2023-01-27 13:59:50

by Mathieu Desnoyers

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

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.

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
---
tools/testing/selftests/bpf/Makefile.docs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/Makefile.docs b/tools/testing/selftests/bpf/Makefile.docs
index eb6a4fea8c79..0a538d873def 100644
--- a/tools/testing/selftests/bpf/Makefile.docs
+++ b/tools/testing/selftests/bpf/Makefile.docs
@@ -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 $$< > $$@

--
2.25.1


2023-01-27 14:00:07

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 34/34] selftests: tdx: Use installed kernel headers search path

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.

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
---
tools/testing/selftests/tdx/Makefile | 2 +-
tools/testing/selftests/tdx/tdx_guest_test.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/tdx/Makefile b/tools/testing/selftests/tdx/Makefile
index 8dd43517cd55..306e9c4d5ef7 100644
--- a/tools/testing/selftests/tdx/Makefile
+++ b/tools/testing/selftests/tdx/Makefile
@@ -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

diff --git a/tools/testing/selftests/tdx/tdx_guest_test.c b/tools/testing/selftests/tdx/tdx_guest_test.c
index 2a2afd856798..81d8cb88ea1a 100644
--- a/tools/testing/selftests/tdx/tdx_guest_test.c
+++ b/tools/testing/selftests/tdx/tdx_guest_test.c
@@ -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
--
2.25.1


2023-01-27 14:00:09

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 28/34] selftests: vm: 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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
tools/testing/selftests/vm/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
index 89c14e41bd43..ac9366065fd2 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -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
--
2.25.1


2023-01-27 14:00:08

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 29/34] selftests: x86: 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=...).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> [5.18+]
---
tools/testing/selftests/x86/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/x86/Makefile b/tools/testing/selftests/x86/Makefile
index 0388c4d60af0..ca9374b56ead 100644
--- a/tools/testing/selftests/x86/Makefile
+++ b/tools/testing/selftests/x86/Makefile
@@ -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)
--
2.25.1


2023-01-27 14:00:09

by Mathieu Desnoyers

[permalink] [raw]
Subject: [PATCH 32/34] selftests: memfd: Use installed kernel headers search path

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).

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: Ingo Molnar <[email protected]>
---
tools/testing/selftests/memfd/Makefile | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/tools/testing/selftests/memfd/Makefile b/tools/testing/selftests/memfd/Makefile
index 4da8b565fa32..163b6f68631c 100644
--- a/tools/testing/selftests/memfd/Makefile
+++ b/tools/testing/selftests/memfd/Makefile
@@ -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
--
2.25.1


2023-01-27 16:22:04

by Matthieu Baerts

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

Hi Mathieu,

On 27/01/2023 14:57, Mathieu Desnoyers wrote:
> 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!

> Signed-off-by: Mathieu Desnoyers <[email protected]>
> Cc: Shuah Khan <[email protected]>
> Cc: [email protected]
> Cc: Ingo Molnar <[email protected]>
> Cc: <[email protected]> [5.18+]

(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 ;-) )

(...)

> diff --git a/tools/testing/selftests/net/mptcp/Makefile b/tools/testing/selftests/net/mptcp/Makefile
> index 43a723626126..06bba013bcef 100644
> --- a/tools/testing/selftests/net/mptcp/Makefile
> +++ b/tools/testing/selftests/net/mptcp/Makefile
> @@ -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
--
Tessares | Belgium | Hybrid Access Solutions
http://www.tessares.net

2023-01-27 16:43:13

by Mathieu Desnoyers

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

On 2023-01-27 11:21, Matthieu Baerts wrote:
> Hi Mathieu,
>
> On 27/01/2023 14:57, Mathieu Desnoyers wrote:
>> 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 :)

>
>> Signed-off-by: Mathieu Desnoyers <[email protected]>
>> Cc: Shuah Khan <[email protected]>
>> Cc: [email protected]
>> Cc: Ingo Molnar <[email protected]>
>> Cc: <[email protected]> [5.18+]
>
> (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 ?

>
> (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 ?

>
> (...)
>
>> diff --git a/tools/testing/selftests/net/mptcp/Makefile b/tools/testing/selftests/net/mptcp/Makefile
>> index 43a723626126..06bba013bcef 100644
>> --- a/tools/testing/selftests/net/mptcp/Makefile
>> +++ b/tools/testing/selftests/net/mptcp/Makefile
>> @@ -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/*/
>

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 ?

> 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

>
> Cheers,
> Matt

--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com


2023-01-30 16:10:05

by Shuah Khan

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

On 1/27/23 06:57, Mathieu Desnoyers wrote:
> 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=...).
>
> Signed-off-by: Mathieu Desnoyers <[email protected]>
> Cc: Shuah Khan <[email protected]>
> Cc: [email protected]
> Cc: Ingo Molnar <[email protected]>
> Cc: <[email protected]> [5.18+]
> ---
> 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:

Acked-by: Shuah Khan <[email protected]>

thanks,
-- Shuah


2023-01-30 16:25:15

by Shuah Khan

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

On 1/27/23 06:57, Mathieu Desnoyers wrote:
> 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=...).
>
> Signed-off-by: Mathieu Desnoyers <[email protected]>
> Cc: Shuah Khan <[email protected]>
> Cc: [email protected]
> Cc: Ingo Molnar <[email protected]>
> Cc: <[email protected]> [5.18+]
> ---
> 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:

Acked-by: Shuah Khan <[email protected]>

thanks,
-- Shuah

2023-01-30 16:32:22

by Shuah Khan

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

On 1/27/23 06:57, Mathieu Desnoyers wrote:
> 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=...).
>
> Signed-off-by: Mathieu Desnoyers <[email protected]>
> Cc: Shuah Khan <[email protected]>
> Cc: [email protected]
> Cc: Ingo Molnar <[email protected]>
> Cc: <[email protected]> [5.18+]
> ---
> 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(-)
>
> diff --git a/tools/testing/selftests/powerpc/ptrace/Makefile b/tools/testing/selftests/powerpc/ptrace/Makefile
> index 2f02cb54224d..cbeeaeae8837 100644
> --- a/tools/testing/selftests/powerpc/ptrace/Makefile
> +++ b/tools/testing/selftests/powerpc/ptrace/Makefile
> @@ -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
> diff --git a/tools/testing/selftests/powerpc/security/Makefile b/tools/testing/selftests/powerpc/security/Makefile
> index 7488315fd847..e0d979ab0204 100644
> --- a/tools/testing/selftests/powerpc/security/Makefile
> +++ b/tools/testing/selftests/powerpc/security/Makefile
> @@ -5,7 +5,7 @@ TEST_PROGS := mitigation-patching.sh
>
> top_srcdir = ../../../../..
>
> -CFLAGS += -I../../../../../usr/include
> +CFLAGS += $(KHDR_INCLUDES)
>
> include ../../lib.mk
>
> diff --git a/tools/testing/selftests/powerpc/syscalls/Makefile b/tools/testing/selftests/powerpc/syscalls/Makefile
> index b63f8459c704..d1f2648b112b 100644
> --- a/tools/testing/selftests/powerpc/syscalls/Makefile
> +++ b/tools/testing/selftests/powerpc/syscalls/Makefile
> @@ -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
> diff --git a/tools/testing/selftests/powerpc/tm/Makefile b/tools/testing/selftests/powerpc/tm/Makefile
> index 5881e97c73c1..3876805c2f31 100644
> --- a/tools/testing/selftests/powerpc/tm/Makefile
> +++ b/tools/testing/selftests/powerpc/tm/Makefile
> @@ -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:

Acked-by: Shuah Khan <[email protected]>

thanks,
-- Shuah

2023-01-30 16:44:37

by Shuah Khan

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

On 1/27/23 06:57, Mathieu Desnoyers wrote:
> 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=...).
>
> Signed-off-by: Mathieu Desnoyers <[email protected]>
> Cc: Shuah Khan <[email protected]>
> Cc: [email protected]
> Cc: Ingo Molnar <[email protected]>
> Cc: <[email protected]> [5.18+]
> ---
> tools/testing/selftests/sync/Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/sync/Makefile b/tools/testing/selftests/sync/Makefile
> index d0121a8a3523..df0f91bf6890 100644
> --- a/tools/testing/selftests/sync/Makefile
> +++ b/tools/testing/selftests/sync/Makefile
> @@ -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

Acked-by: Shuah Khan <[email protected]>

thanks,
-- Shuah

2023-01-30 16:51:26

by Shuah Khan

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

On 1/30/23 09:44, Shuah Khan wrote:
> On 1/27/23 06:57, Mathieu Desnoyers wrote:
>> 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=...).
>>
>> Signed-off-by: Mathieu Desnoyers <[email protected]>
>> Cc: Shuah Khan <[email protected]>
>> Cc: [email protected]
>> Cc: Ingo Molnar <[email protected]>
>> Cc: <[email protected]>    [5.18+]
>> ---
>>   tools/testing/selftests/sync/Makefile | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/testing/selftests/sync/Makefile b/tools/testing/selftests/sync/Makefile
>> index d0121a8a3523..df0f91bf6890 100644
>> --- a/tools/testing/selftests/sync/Makefile
>> +++ b/tools/testing/selftests/sync/Makefile
>> @@ -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
>
> Acked-by: Shuah Khan <[email protected]>
>
Sorry wrong message. I am taking this one through mine.

-- Shuah


2023-01-30 16:52:07

by Shuah Khan

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

On 1/27/23 06:57, Mathieu Desnoyers wrote:
> 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=...).
>
> Signed-off-by: Mathieu Desnoyers <[email protected]>
> Cc: Shuah Khan <[email protected]>
> Cc: [email protected]
> Cc: Ingo Molnar <[email protected]>
> Cc: <[email protected]> [5.18+]
> ---
> tools/testing/selftests/seccomp/Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/seccomp/Makefile b/tools/testing/selftests/seccomp/Makefile
> index f017c382c036..584fba487037 100644
> --- a/tools/testing/selftests/seccomp/Makefile
> +++ b/tools/testing/selftests/seccomp/Makefile
> @@ -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

Acked-by: Shuah Khan <[email protected]>

thanks,
-- Shuah

2023-01-30 16:55:37

by Shuah Khan

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

On 1/27/23 06:57, Mathieu Desnoyers wrote:
> 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=...).
>
> Signed-off-by: Mathieu Desnoyers <[email protected]>
> Cc: Shuah Khan <[email protected]>
> Cc: [email protected]
> Cc: Ingo Molnar <[email protected]>
> Cc: <[email protected]> [5.18+]
> ---
> tools/testing/selftests/vm/Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
> index 89c14e41bd43..ac9366065fd2 100644
> --- a/tools/testing/selftests/vm/Makefile
> +++ b/tools/testing/selftests/vm/Makefile
> @@ -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:

Acked-by: Shuah Khan <[email protected]>

thanks,
-- Shuah

2023-01-30 16:57:57

by Shuah Khan

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

On 1/27/23 06:57, Mathieu Desnoyers wrote:
> 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.
>
> Signed-off-by: Mathieu Desnoyers <[email protected]>
> Cc: Shuah Khan <[email protected]>
> Cc: [email protected]
> Cc: Ingo Molnar <[email protected]>
> ---
> tools/testing/selftests/bpf/Makefile.docs | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/bpf/Makefile.docs b/tools/testing/selftests/bpf/Makefile.docs
> index eb6a4fea8c79..0a538d873def 100644
> --- a/tools/testing/selftests/bpf/Makefile.docs
> +++ b/tools/testing/selftests/bpf/Makefile.docs
> @@ -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:

Acked-by: Shuah Khan <[email protected]>

thanks,
-- Shuah

2023-01-30 17:01:32

by Shuah Khan

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

On 1/27/23 06:57, Mathieu Desnoyers wrote:
> 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).
>
> Signed-off-by: Mathieu Desnoyers <[email protected]>
> Cc: Shuah Khan <[email protected]>
> Cc: [email protected]
> Cc: Ingo Molnar <[email protected]>
> ---
> tools/testing/selftests/iommu/Makefile | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/iommu/Makefile b/tools/testing/selftests/iommu/Makefile
> index 7cb74d26f141..32c5fdfd0eef 100644
> --- a/tools/testing/selftests/iommu/Makefile
> +++ b/tools/testing/selftests/iommu/Makefile
> @@ -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

Acked-by: Shuah Khan <[email protected]>

thanks,
-- Shuah

2023-01-30 17:06:21

by Jason Gunthorpe

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

On Mon, Jan 30, 2023 at 10:01:23AM -0700, Shuah Khan wrote:
> On 1/27/23 06:57, Mathieu Desnoyers wrote:
> > 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).
> >
> > Signed-off-by: Mathieu Desnoyers <[email protected]>
> > Cc: Shuah Khan <[email protected]>
> > Cc: [email protected]
> > Cc: Ingo Molnar <[email protected]>
> > ---
> > tools/testing/selftests/iommu/Makefile | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/tools/testing/selftests/iommu/Makefile b/tools/testing/selftests/iommu/Makefile
> > index 7cb74d26f141..32c5fdfd0eef 100644
> > --- a/tools/testing/selftests/iommu/Makefile
> > +++ b/tools/testing/selftests/iommu/Makefile
> > @@ -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
>
> Acked-by: Shuah Khan <[email protected]>

Go ahead please

Jason

2023-01-30 17:14:45

by Catalin Marinas

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

Hi Shuah,

On Mon, Jan 30, 2023 at 09:09:42AM -0700, Shuah Khan wrote:
> On 1/27/23 06:57, Mathieu Desnoyers wrote:
> > 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=...).
> >
> > Signed-off-by: Mathieu Desnoyers <[email protected]>
> > Cc: Shuah Khan <[email protected]>
> > Cc: [email protected]
> > Cc: Ingo Molnar <[email protected]>
> > Cc: <[email protected]> [5.18+]
> > ---
> > 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:

Are you taking the whole series? If yes:

Acked-by: Catalin Marinas <[email protected]>

(otherwise I can pick this up)

--
Catalin

2023-01-30 17:20:59

by Shuah Khan

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

On 1/30/23 10:14, Catalin Marinas wrote:
> Hi Shuah,
>
> On Mon, Jan 30, 2023 at 09:09:42AM -0700, Shuah Khan wrote:
>> On 1/27/23 06:57, Mathieu Desnoyers wrote:
>>> 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=...).
>>>
>>> Signed-off-by: Mathieu Desnoyers <[email protected]>
>>> Cc: Shuah Khan <[email protected]>
>>> Cc: [email protected]
>>> Cc: Ingo Molnar <[email protected]>
>>> Cc: <[email protected]> [5.18+]
>>> ---
>>> 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:
>
> Are you taking the whole series? If yes:
>
> Acked-by: Catalin Marinas <[email protected]>
>
> (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

2023-01-30 22:29:29

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH 00/34] selftests: Fix incorrect kernel headers search path

On 1/27/23 06:57, Mathieu Desnoyers wrote:
> 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):

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

> 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
>

These will be applied by maintainers to their trees.

> 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

2023-01-30 23:45:59

by Alexei Starovoitov

[permalink] [raw]
Subject: Re: [PATCH 00/34] selftests: Fix incorrect kernel headers search path

On Mon, Jan 30, 2023 at 2:46 PM Shuah Khan <[email protected]> wrote:
>
> On 1/27/23 06:57, Mathieu Desnoyers wrote:
> > 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):
>
> The below patches are now applied to linux-kselftest next for Linux 6.3-rc1
>
> > 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
> >
>
> These will be applied by maintainers to their trees.

Not in this form. They break the build.

> > 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

2023-01-30 23:49:05

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH 00/34] selftests: Fix incorrect kernel headers search path

On 1/30/23 16:45, Alexei Starovoitov wrote:
> On Mon, Jan 30, 2023 at 2:46 PM Shuah Khan <[email protected]> wrote:
>>
>> On 1/27/23 06:57, Mathieu Desnoyers wrote:
>>> 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):
>>
>> The below patches are now applied to linux-kselftest next for Linux 6.3-rc1
>>
>>> 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
>>>
>>
>> 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

2023-01-30 23:50:20

by Alexei Starovoitov

[permalink] [raw]
Subject: Re: [PATCH 00/34] selftests: Fix incorrect kernel headers search path

On Mon, Jan 30, 2023 at 3:48 PM Shuah Khan <[email protected]> wrote:
>
> >>
> >> 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.

2023-02-02 02:08:08

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH 00/34] selftests: Fix incorrect kernel headers search path

Hi Mathieu,

On 1/30/23 15:29, Shuah Khan wrote:
> On 1/27/23 06:57, Mathieu Desnoyers wrote:
>> 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 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.

>> 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.

>> 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.

>> 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

2023-02-04 01:06:25

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH 00/34] selftests: Fix incorrect kernel headers search path

On 2/1/23 19:07, Shuah Khan wrote:
> Hi Mathieu,
>
> On 1/30/23 15:29, Shuah Khan wrote:
>> On 1/27/23 06:57, Mathieu Desnoyers wrote:
>>> 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 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.
>
>>>    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.
>
>>>    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

2023-02-11 00:15:49

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH 00/34] selftests: Fix incorrect kernel headers search path

On 2/3/23 18:06, Shuah Khan wrote:
> On 2/1/23 19:07, Shuah Khan wrote:
>> Hi Mathieu,
>>
>> On 1/30/23 15:29, Shuah Khan wrote:
>>> On 1/27/23 06:57, Mathieu Desnoyers wrote:
>>>> 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 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.
>>
>>>>    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.
>>
>>>>    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






2023-02-20 03:51:51

by Michael Ellerman

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

On Fri, 27 Jan 2023 08:57:21 -0500, Mathieu Desnoyers wrote:
> 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