All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@kernel.org>
To: Joe Lawrence <joe.lawrence@redhat.com>
Cc: live-patching@vger.kernel.org, Song Liu <song@kernel.org>,
	 Miroslav Benes <mbenes@suse.cz>, Petr Mladek <pmladek@suse.com>,
	 Yafang Shao <laoar.shao@gmail.com>
Subject: Re: [RFC PATCH v2 5/7] livepatch/klp-build: add basic out-of-tree module support
Date: Thu, 27 Aug 2026 14:21:52 -0700	[thread overview]
Message-ID: <apCnuKgI1Rt_XVYS@jpoimboe> (raw)
In-Reply-To: <20260826195000.455905-6-joe.lawrence@redhat.com>

On Wed, Aug 26, 2026 at 03:49:58PM -0400, Joe Lawrence wrote:
> @@ -579,13 +610,20 @@ build_kernel() {
>  find_objects() {
>  	local opts=("$@")
>  
> -	# Find root-level vmlinux.o and non-root-level .ko files,
> -	# excluding klp-tmp/ and hidden directories.
> -	find "$PWD" -mindepth 1 \
> -		    \( -path "$TMP_DIR" -o -name ".*" -o -regex "$PWD/[^/][^/]*\.ko" \) -prune -o \
> -		    -type f "${opts[@]}"				\
> -		    \( -name "*.ko" -o -path "$PWD/vmlinux.o" \)	\
> -		    -printf '%P\n'
> +	if [[ -z "$OOT_DIR" ]]; then
> +		# In-tree: find root-level vmlinux.o and non-root-level .ko files,
> +		# excluding klp-tmp/ and hidden directories.
> +		find "$PWD" -mindepth 1 \
> +			    \( -path "$TMP_DIR" -o -name ".*" -o -regex "$PWD/[^/][^/]*\.ko" \) -prune -o \
> +			    -type f "${opts[@]}"				\
> +			    \( -name "*.ko" -o -path "$PWD/vmlinux.o" \)	\
> +			    -printf '%P\n'
> +	else
> +		# OOT: find .ko at any depth under the module dir
> +		find "$OOT_DIR" -path "$OOT_DIR/.git" -prune -o \
> +			-type f "${opts[@]}" \
> +			-name "*.ko" -printf '%P\n'

Can these be unified?  Something like:

	if [[ -n "$OOT_DIR ]]; then
		path="$OOT_DIR"
	else
		path="$PWD"
	fi

	find "$path" -mindepth 1 \
		    \( -path "$TMP_DIR" -o -name ".*" -o -regex "$PWD/[^/][^/]*\.ko" \) -prune -o \
		    -type f "${opts[@]}"				\
		    \( -name "*.ko" -o -path "$PWD/vmlinux.o" \)	\
		    -printf '%P\n'

That way we get consistent behavior and the two paths with $PWD would
get silently ignored for the OOT case anyway.

> @@ -717,6 +757,7 @@ diff_objects() {
>  		cmd+=("klp")
>  		cmd+=("diff")
>  		(( ${#opts[@]} > 0 )) && cmd+=("${opts[@]}")
> +		[[ -n "$OOT_DIR" ]] && cmd+=("--symvers" "$PWD/Module.symvers")

Even with OOT_DIR it still runs in the kernel build dir, which is where
objtool looks for this file anyway, so I don't think this line is
needed?

>  		cmd+=("$orig_file")
>  		cmd+=("$patched_file")
>  		cmd+=("$out_file")
> @@ -895,13 +936,16 @@ build_patch_module() {
>  process_args "$@"
>  do_init
>  
> +BUILD_TARGET="kernel"
> +[[ -n "$OOT_DIR" ]] && BUILD_TARGET="module ${OOT_DIR##*/}"
> +
>  if (( SHORT_CIRCUIT <= 2 )); then
>  	status "Validating patch(es)"
>  	validate_patches
>  fi
>  
>  if (( SHORT_CIRCUIT <= 1 )); then
> -	status "Building original kernel"
> +	status "Building original $BUILD_TARGET"

I think we can simplify this to just "Building original objects" or so...

>  	clean_kernel
>  	build_kernel "original"
>  	status "Copying original object files"
> @@ -912,7 +956,7 @@ if (( SHORT_CIRCUIT <= 2 )); then
>  	status "Fixing patch(es)"
>  	fix_patches
>  	apply_patches "--silent"
> -	status "Building patched kernel"
> +	status "Building patched $BUILD_TARGET"

... and "Building patched objects".

-- 
Josh

  parent reply	other threads:[~2026-08-27 21:21 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-26 19:49 [RFC PATCH v2 0/7] klp-build: OOT module support Joe Lawrence
2026-08-26 19:49 ` [RFC PATCH v2 1/7] objtool/klp: simplify read_exports file handling Joe Lawrence
2026-08-26 23:31   ` Song Liu
2026-09-10 14:35   ` Miroslav Benes
2026-08-26 19:49 ` [RFC PATCH v2 2/7] objtool/klp: add --symvers option to klp diff Joe Lawrence
2026-08-26 23:31   ` Song Liu
2026-09-10 14:35   ` Miroslav Benes
2026-08-26 19:49 ` [RFC PATCH v2 3/7] objtool/klp: allow special section entry size overrides Joe Lawrence
2026-08-27 19:17   ` Josh Poimboeuf
2026-08-26 19:49 ` [RFC PATCH v2 4/7] objtool: add target architecture to usage Joe Lawrence
2026-08-26 19:57   ` sashiko-bot
2026-08-27 19:23   ` Josh Poimboeuf
2026-08-26 19:49 ` [RFC PATCH v2 5/7] livepatch/klp-build: add basic out-of-tree module support Joe Lawrence
2026-08-26 20:00   ` sashiko-bot
2026-08-27 21:21   ` Josh Poimboeuf [this message]
2026-08-26 19:49 ` [RFC PATCH v2 6/7] livepatch/klp-build: add pre-built object support for advanced OOT workflows Joe Lawrence
2026-08-26 20:01   ` sashiko-bot
2026-08-27 21:45   ` Josh Poimboeuf
2026-08-26 19:50 ` [RFC PATCH v2 7/7] livepatch/klp-build: add validation for user-supplied OOT objects Joe Lawrence

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=apCnuKgI1Rt_XVYS@jpoimboe \
    --to=jpoimboe@kernel.org \
    --cc=joe.lawrence@redhat.com \
    --cc=laoar.shao@gmail.com \
    --cc=live-patching@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=pmladek@suse.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.