[PATCH] selftests/mm: fix dependency on pkey_util.c

From: Kevin Brodsky
Date: Mon Dec 16 2024 - 04:29:28 EST


The pkey* files can only be built on architectures that support
pkeys (pkey-helpers.h #error's otherwise). Adding pkey_util.c as
dependency to all $(TEST_GEN_FILES) is therefore a bad idea. Make it
a dependency of the pkeys tests only.

Those tests are built in 32/64-bit variants on x86_64 so we need to
add an explicit dependency there as well.

Signed-off-by: Kevin Brodsky <kevin.brodsky@xxxxxxx>
---

Hi Alexander,

Thank you for the bug report, that patch indeed breaks all
architectures that don't support pkeys, I should have realised that!
This patch should fix it.

Andrew, it would make sense to squash this patch into the original
("selftests/mm: Use sys_pkey helpers consistently").

Cheers,
- Kevin

Cc: akpm@xxxxxxxxxxxxxxxxxxxx
Cc: aruna.ramakrishna@xxxxxxxxxx
Cc: catalin.marinas@xxxxxxx
Cc: dave.hansen@xxxxxxxxxxxxxxx
Cc: joey.gouly@xxxxxxx
Cc: keith.lucas@xxxxxxxxxx
Cc: ryan.roberts@xxxxxxx
Cc: shuah@xxxxxxxxxx
Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
Cc: linux-kselftest@xxxxxxxxxxxxxxx
Cc: linux-mm@xxxxxxxxx
Cc: x86@xxxxxxxxxx
Cc: linux-s390@xxxxxxxxxxxxxxx
---
tools/testing/selftests/mm/Makefile | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile
index 1f0743d9459d..18041de1aebf 100644
--- a/tools/testing/selftests/mm/Makefile
+++ b/tools/testing/selftests/mm/Makefile
@@ -147,16 +147,20 @@ TEST_FILES += write_hugetlb_memory.sh

include ../lib.mk

-$(TEST_GEN_PROGS): vm_util.c thp_settings.c pkey_util.c
-$(TEST_GEN_FILES): vm_util.c thp_settings.c pkey_util.c
+$(TEST_GEN_PROGS): vm_util.c thp_settings.c
+$(TEST_GEN_FILES): vm_util.c thp_settings.c

$(OUTPUT)/uffd-stress: uffd-common.c
$(OUTPUT)/uffd-unit-tests: uffd-common.c
+$(OUTPUT)/protection_keys: pkey_util.c
+$(OUTPUT)/pkey_sighandler_tests: pkey_util.c

ifeq ($(ARCH),x86_64)
BINARIES_32 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_32))
BINARIES_64 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_64))

+$(BINARIES_32) $(BINARIES_64): pkey_util.c
+
define gen-target-rule-32
$(1) $(1)_32: $(OUTPUT)/$(1)_32
.PHONY: $(1) $(1)_32
--
2.47.0