From: Moon Hee Lee moonhee.lee.ca@gmail.com
[ Upstream commit 661e9cd196598c7d2502260ebbe60970546cca35 ]
The test_kexec_jump program builds correctly when invoked from the top-level selftests/Makefile, which explicitly sets the OUTPUT variable. However, building directly in tools/testing/selftests/kexec fails with:
make: *** No rule to make target '/test_kexec_jump', needed by 'test_kexec_jump.sh'. Stop.
This failure occurs because the Makefile rule relies on $(OUTPUT), which is undefined in direct builds.
Fix this by listing test_kexec_jump in TEST_GEN_PROGS, the standard way to declare generated test binaries in the kselftest framework. This ensures the binary is built regardless of invocation context and properly removed by make clean.
Link: https://lore.kernel.org/r/20250702171704.22559-2-moonhee.lee.ca@gmail.com Acked-by: Shuah Khan skhan@linuxfoundation.org Signed-off-by: Moon Hee Lee moonhee.lee.ca@gmail.com Acked-by: Baoquan He bhe@redhat.com Acked-by: David Woodhouse dwmw@amazon.co.uk Signed-off-by: Shuah Khan skhan@linuxfoundation.org Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
Perfect! This confirms the exact build issue described in the commit message. The problem is that `$(OUTPUT)` is undefined when building directly in the kexec directory.
**Backport Status: YES**
This commit should be backported to stable kernel trees for the following reasons:
1. **Fixes a real bug**: The commit fixes a build failure that prevents the kexec selftests from building when invoked directly from `tools/testing/selftests/kexec/`. The error message confirms this: `make: *** No rule to make target '/test_kexec_jump', needed by 'test_kexec_jump.sh'. Stop.`
2. **Small and contained fix**: The change is minimal - it simply replaces the custom Makefile rule: ```makefile test_kexec_jump.sh: $(OUTPUT)/test_kexec_jump ``` with the standard kselftest framework approach: ```makefile TEST_GEN_PROGS := test_kexec_jump ```
3. **No architectural changes**: This is purely a build system fix that doesn't change any kernel functionality or introduce new features. It just fixes the Makefile to use the standard kselftest variables.
4. **Minimal risk**: The change uses the established kselftest framework pattern (`TEST_GEN_PROGS`) which is well-tested and widely used throughout the kernel selftests. From examining `lib.mk`, we can see that `TEST_GEN_PROGS` automatically handles the `$(OUTPUT)` prefix and proper clean targets.
5. **Fixes testing infrastructure**: Having working selftests is important for kernel stability testing. This fix ensures that the kexec jump functionality can be properly tested in stable kernels, which is particularly important given that kexec is a critical feature for system reliability.
6. **Clear regression**: The bug prevents a previously working test from building in certain scenarios. While the test builds correctly when invoked from the top-level selftests Makefile (which sets OUTPUT), direct builds fail. This is a regression in usability that affects developers and CI systems.
The fix follows the documented pattern for kselftest Makefiles and will ensure consistent behavior regardless of how the tests are invoked. This is exactly the type of targeted bug fix that belongs in stable kernels - it fixes a specific issue without introducing new functionality or risk.
tools/testing/selftests/kexec/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/kexec/Makefile b/tools/testing/selftests/kexec/Makefile index e3000ccb9a5d..874cfdd3b75b 100644 --- a/tools/testing/selftests/kexec/Makefile +++ b/tools/testing/selftests/kexec/Makefile @@ -12,7 +12,7 @@ include ../../../scripts/Makefile.arch
ifeq ($(IS_64_BIT)$(ARCH_PROCESSED),1x86) TEST_PROGS += test_kexec_jump.sh -test_kexec_jump.sh: $(OUTPUT)/test_kexec_jump +TEST_GEN_PROGS := test_kexec_jump endif
include ../lib.mk