Re: [PATCH v5 6/9] selftests: livepatch: Adapt atomic replace tests to provides/obsoletes
| Newsgroups | org.kernel.vger.live-patching |
|---|---|
| Message-ID | <[email protected]> |
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The 'replace' feature detection in test_modules/Makefile fails for out-of-tree (O=) kernel builds, breaking tests on older kernels. -- --- Patch [6]: [PATCH v5 6/9] selftests: livepatch: Adapt atomic replace tests to provides/obsoletes --- commit e4d15e9f2792340ea543b405f9d074e729665c9b Author: Yafang Shao <[email protected]> selftests: livepatch: Adapt atomic replace tests to provides/obsoletes The legacy "replace" field in struct klp_patch was replaced by the provides/obsoletes mechanism. This commit adapts selftests to build and run on both old and new kernels by detecting the presence of the "replace" field. > diff --git a/tools/testing/selftests/livepatch/test_modules/Makefile b/tools/testing/selftests/livepatch/test_modules/Makefile > index a13d398585dcb..29c55df360467 100644 > --- a/tools/testing/selftests/livepatch/test_modules/Makefile > +++ b/tools/testing/selftests/livepatch/test_modules/Makefile > @@ -16,6 +16,16 @@ obj-m += test_klp_atomic_replace.o \ > test_klp_state3.o \ > test_klp_syscall.o > > +# The legacy "replace" field was replaced by provides/obsoletes. When the > +# kernel (KDIR) still supports "replace", pass KLP_HAS_REPLACE to the > +# modules so that they can #ifdef the legacy "replace" code. Otherwise > +# the modules are built with the provides/obsoletes based code (to be > +# added later). > +KLP_HAS_REPLACE := $(shell grep -q 'bool replace' $(KDIR)/include/linux/livepatch.h 2>/dev/null && echo y) [Severity: Medium] Will this grep fail for out-of-tree (O=...) kernel builds? If $(KDIR) points to the build directory rather than the source directory, $(KDIR)/include/linux/livepatch.h might not exist. When tests are run, detect_replace_attr() will still correctly identify the replace sysfs attribute on the running kernel and set HAS_REPLACE_ATTR=1. However, since the module would be compiled without KLP_HAS_REPLACE, it lacks the replace module parameter. When the test scripts attempt to load the module with replace=1, insmod will fail, causing the test suite to abort. -- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6