[tip: objtool/core] klp-build: Validate short-circuit prerequisites

From: tip-bot2 for Josh Poimboeuf

Date: Tue May 05 2026 - 07:04:51 EST


The following commit has been merged into the objtool/core branch of tip:

Commit-ID: 225d16dd510d92c8eaba8e6496cfaa7881a24827
Gitweb: https://git.kernel.org/tip/225d16dd510d92c8eaba8e6496cfaa7881a24827
Author: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
AuthorDate: Fri, 17 Apr 2026 13:33:55 -07:00
Committer: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
CommitterDate: Mon, 04 May 2026 21:16:06 -07:00

klp-build: Validate short-circuit prerequisites

The --short-circuit option implicitly requires that certain directories
are already in klp-tmp. Enforce that to prevent confusing errors.

Acked-by: Song Liu <song@xxxxxxxxxx>
Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
---
scripts/livepatch/klp-build | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)

diff --git a/scripts/livepatch/klp-build b/scripts/livepatch/klp-build
index c1475c0..c4a7acf 100755
--- a/scripts/livepatch/klp-build
+++ b/scripts/livepatch/klp-build
@@ -437,6 +437,20 @@ do_init() {
# builds in pwd.
[[ ! "$PWD" -ef "$SCRIPT_DIR/../.." ]] && die "please run from the kernel root directory"

+ if (( SHORT_CIRCUIT >= 2 )); then
+ [[ -f "$ORIG_DIR/.complete" ]] || die "-S $SHORT_CIRCUIT requires completed $ORIG_DIR"
+ fi
+ if (( SHORT_CIRCUIT >= 3 )); then
+ [[ -f "$PATCHED_DIR/.complete" ]] || die "-S $SHORT_CIRCUIT requires completed $PATCHED_DIR"
+ fi
+ if (( SHORT_CIRCUIT >= 4 )); then
+ [[ -f "$ORIG_CSUM_DIR/.complete" ]] || die "-S $SHORT_CIRCUIT requires completed $ORIG_CSUM_DIR"
+ [[ -f "$PATCHED_CSUM_DIR/.complete" ]] || die "-S $SHORT_CIRCUIT requires completed $PATCHED_CSUM_DIR"
+ fi
+ if (( SHORT_CIRCUIT >= 5 )); then
+ [[ -f "$DIFF_DIR/.complete" ]] || die "-S $SHORT_CIRCUIT requires completed $DIFF_DIR"
+ fi
+
(( SHORT_CIRCUIT <= 1 )) && rm -rf "$TMP_DIR"
mkdir -p "$TMP_DIR"

@@ -593,6 +607,7 @@ copy_orig_objects() {

mv -f "$TMP_DIR/build.log" "$ORIG_DIR"
touch "$TIMESTAMP"
+ touch "$ORIG_DIR/.complete"
}

# Copy all changed objects to $PATCHED_DIR
@@ -631,6 +646,7 @@ copy_patched_objects() {
(( found == 0 )) && die "no changes detected"

mv -f "$TMP_DIR/build.log" "$PATCHED_DIR"
+ touch "$PATCHED_DIR/.complete"
}

# Copy .o files to a separate directory and run "objtool klp checksum" on each
@@ -712,6 +728,8 @@ diff_objects() {
die "objtool klp diff failed"
)
done
+
+ touch "$DIFF_DIR/.complete"
}

# For each changed object, run "objtool klp checksum" with --debug-checksum to