Live Patching
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: sashiko-reviews@lists.linux.dev
Cc: Sasha Levin <sashal@kernel.org>,
	Josh Poimboeuf <jpoimboe@kernel.org>,
	Miroslav Benes <mbenes@suse.cz>,
	Joe Lawrence <joe.lawrence@redhat.com>,
	Song Liu <song@kernel.org>,
	Marcos Paulo de Souza <mpdesouza@suse.com>,
	Eva Kurchatova <eva.kurchatova@virtuozzo.com>,
	Yafang Shao <laoar.shao@gmail.com>, Shuah Khan <shuah@kernel.org>,
	live-patching@vger.kernel.org
Subject: Re: [PATCH v4 3/4] selftests/livepatch: build the test modules against the kernel in O=
Date: Mon, 23 Nov 2026 15:08:32 +0100	[thread overview]
Message-ID: <awRI4PbBHGtnNijI@pathway.suse.cz> (raw)
In-Reply-To: <sashiko-outbox-207425@kernel.org>

On Tue 2026-11-10 16:53:01, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Medium] selftests/livepatch: KDIR fallback ignores builds without
>   Module.symvers
> --
> 
> commit 62f70537bbca33262ec62f1273becbdf534f58fc
> Author: Sasha Levin <sashal@kernel.org>
> 
> selftests/livepatch: build the test modules against the kernel in O=
> 
> This commit selects KDIR from O= or KBUILD_OUTPUT (or the kernel source
> tree) before falling back to the running kernel's build directory, and
> strips O= and KBUILD_OUTPUT when invoking the kernel Makefile for the
> livepatch test modules.
> 
> > diff --git a/tools/testing/selftests/livepatch/Makefile b/tools/testing/selftests/livepatch/Makefile
> > index a080eb54a215d..97478ef90945c 100644
> > --- a/tools/testing/selftests/livepatch/Makefile
> > +++ b/tools/testing/selftests/livepatch/Makefile
> > @@ -1,5 +1,31 @@
> >  # SPDX-License-Identifier: GPL-2.0
> >  
> > +# The test modules are built against the kernel in KDIR. When KDIR is not
> > +# set, use the output directory given with O= or KBUILD_OUTPUT if a kernel
> > +# was built there, as with
> > +#   make O=/tmp/kselftest TARGETS=livepatch kselftest
> > +# otherwise the kernel source tree if the kernel was built in it, as with
> > +#   cd tools/testing/selftests/livepatch; make
> > +# and otherwise the build directory of the running kernel, which its
> > +# devel files provide. A kernel was built in a directory if it has a
> > +# Module.symvers.
> > +ifndef KDIR
> > +KBUILD_DIR := $(firstword $(O) $(KBUILD_OUTPUT))
> > +ifneq ($(and $(KBUILD_DIR),$(wildcard $(KBUILD_DIR)/Module.symvers)),)
> > +KDIR := $(KBUILD_DIR)
> > +else ifneq ($(wildcard ../../../../Module.symvers),)
> > +KDIR := ../../../..
> > +else
> > +KDIR := /lib/modules/$(shell uname -r)/build
> > +endif
> > +endif
> 
> [Severity: Medium]
> Does checking only for Module.symvers cause KDIR to fall back to the host's
> /lib/modules/$(uname -r)/build when the target kernel in O= or the source
> tree was built with CONFIG_MODULES=n or an image-only target (which
> produces vmlinux.symvers instead of Module.symvers)?
> 
> When that happens and the host has kernel headers with CONFIG_LIVEPATCH=y,
> test_modules/Makefile reads the host's include/config/auto.conf and builds
> the test modules against the running host kernel instead of skipping them
> for the target kernel, which breaks cross-compiled builds or builds where
> the in-tree test modules use newer kernel APIs than the host.

The problem looks real. But I would consider it a corner case.
IMHO, there are only few users using CONFIG_MODULES=n. They
might use SKIP_TARGETS="livepatch".

By other words, we could fix hit later when there is a demand.
You would not block this patch because of this. It fixes
some scenarios and goes in the right direction...

Best Regards,
Petr

  reply	other threads:[~2026-11-23 14:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10 16:10 [PATCH v4 0/4] selftests/livepatch: build and run the tests outside the running kernel Sasha Levin
2026-11-10 16:10 ` [PATCH v4 1/4] selftests/livepatch: skip the tests on kernels without livepatch Sasha Levin
2026-11-23 10:15   ` Petr Mladek
2026-11-10 16:10 ` [PATCH v4 2/4] selftests/livepatch: clean the test modules without a kernel build directory Sasha Levin
2026-11-10 16:35   ` sashiko-bot
2026-11-23 10:23   ` Petr Mladek
2026-11-23 15:44     ` Sasha Levin
2026-11-10 16:10 ` [PATCH v4 3/4] selftests/livepatch: build the test modules against the kernel in O= Sasha Levin
2026-11-10 16:53   ` sashiko-bot
2026-11-23 14:08     ` Petr Mladek [this message]
2026-11-23 14:09   ` Petr Mladek
2026-11-10 16:10 ` [PATCH v4 4/4] selftests/livepatch: run the tests with prebuilt test modules Sasha Levin
2026-11-23 14:10   ` Petr Mladek
2026-11-23 14:16 ` [PATCH v4 0/4] selftests/livepatch: build and run the tests outside the running kernel Petr Mladek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=awRI4PbBHGtnNijI@pathway.suse.cz \
    --to=pmladek@suse.com \
    --cc=eva.kurchatova@virtuozzo.com \
    --cc=joe.lawrence@redhat.com \
    --cc=jpoimboe@kernel.org \
    --cc=laoar.shao@gmail.com \
    --cc=live-patching@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=mpdesouza@suse.com \
    --cc=sashal@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox