Re: [PATCH 02/11] klp-build: Add --patch-only option

From: Josh Poimboeuf

Date: Mon Oct 26 2026 - 22:22:33 EST


On Fri, Oct 16, 2026 at 05:24:32PM -0700, Song Liu wrote:
> klp-build fixes the input patches before building the patched kernel:
> it combines them into a single patch against the original source and
> adds #line directives, so that unchanged functions further down a
> patched file keep their __LINE__ values. This only happens after the
> original kernel has been built, so seeing the result, or testing this
> step, takes a full kernel build and --keep-tmp.

Not sure how this last sentence is relevant, either way klp-build will
run to completion (or failure)?

Also the above feels like a strawman, I think the real justification for
this is the selftests?

> +++ b/scripts/livepatch/klp-build
> @@ -19,7 +19,7 @@ set -o nounset
> # This helps keep execution in pipes so pipefail+ERR trap can catch errors.
> shopt -s lastpipe
>
> -unset DEBUG_CLONE DIFF_CHECKSUM SKIP_CLEANUP VERBOSE XTRACE
> +unset DEBUG_CLONE DIFF_CHECKSUM PATCH_ONLY SKIP_CLEANUP VERBOSE XTRACE
>
> REPLACE=1
> SHORT_CIRCUIT=0
> @@ -137,6 +137,7 @@ Options:
>
> Advanced Options:
> -d, --debug Show symbol/reloc cloning decisions
> + --patch-only Print the fixed patch(es) and exit without building

This is basically bolting a test hook onto klp-build.

What if we move the patch validating/fixing into a self-contained
klp-prepare-patch script? There might be a small amount of duplication
for some of the patch handling but that would hopefully be minimal.

Then the selftests can run it directly and klp-build doesn't need the
new option and the PATCH_ONLY special casing.

--
Josh