From nobody Sat Jun 13 22:01:38 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C6E14611C5; Tue, 5 May 2026 10:56:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777978581; cv=none; b=LTMOkKBoaPEsapDqEuFL2a/e7lOzS6O+QT7B3hxxnqjkTpryVaMmHYJqCFLSYQljd+wd2DcMxEm7qTgWyqmSVBWERHk5WFSuFIx7TLhXxeIZoqx3Hd3Yef+TVmWDpRSS+CPsfKu7v/Vl1XUTQIpz2HQl9Flz2R3bs6xqOkP3KhQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777978581; c=relaxed/simple; bh=KW1PPhuFnqvnJs9szHOtbOUXwFwy01puO+DKYXg6j5Q=; h=Date:From:To:Subject:Cc:MIME-Version:Message-ID:Content-Type; b=rEVbQgHXE8grTdBtk/F0Z1WmLR0m8bS/1h/42Nbl5pU5RfSgX8bsdC69Eg4+9il0TYN+aICQ6gxnFYk0kd5H89GrsabgUzdQGQIcMkF7rE/LI8yvJFZFXDRV87A6mKQNdXhBRRaRXntcU3S2x96KPiUQQTI7hTDifBAOaX9A9V0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ZaJnklRj; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=WUUEEAoj; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ZaJnklRj"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="WUUEEAoj" Date: Tue, 05 May 2026 10:56:16 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1777978578; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=M4icY4xP/J7LDofZ+HnrtDxqkGmDxdPJs1p7vebjaXo=; b=ZaJnklRjad52ef64uUAUv5hWGjoR4Zk4hmqw9m8mEYPWSOx88903FFMTrdA0E5k1SUpKvy dbJCDFEekvOXkBe8iz4DK5D1NS+tEYIAHVgVwAMvRMDFxm0jZ1DwWKYoOAR6eBSdJUWZ+F nuf8c5MMwS1geRPqpEN2IAivLFOTltCERDM+RTI84QG5Tws4zwBqA1ngrV4j5rj3wSOI2I QqM7MrDSr0hsP7cG3nEcegUkZBsJ9L7I9wUR8QpgTpZM1pvWsLwsK64rXtfqUqRKJ2F9UX LX62MMUyDclUotqreMlJfyNTNkPwvf7tGPWflIMSo0UbOrxpRo5mjq4DXxv+ug== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1777978578; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=M4icY4xP/J7LDofZ+HnrtDxqkGmDxdPJs1p7vebjaXo=; b=WUUEEAojGVpoZ+ZRRv+5iKXo7wZZK027XodpFCUHg26qBeZWzjJmHtoC3DPV6bazb6Q3Ek qOQqN7QxV4eq6jCw== From: "tip-bot2 for Josh Poimboeuf" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: objtool/core] klp-build: Remove redundant SRC and OBJ variables Cc: Song Liu , Josh Poimboeuf , x86@kernel.org, linux-kernel@vger.kernel.org Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177797857689.424702.8643674063683835573.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the objtool/core branch of tip: Commit-ID: b6480aaedf3cbdd0a8e4b75c77434423eb52e3b8 Gitweb: https://git.kernel.org/tip/b6480aaedf3cbdd0a8e4b75c77434423e= b52e3b8 Author: Josh Poimboeuf AuthorDate: Thu, 30 Apr 2026 08:54:57 -07:00 Committer: Josh Poimboeuf CommitterDate: Mon, 04 May 2026 21:16:04 -07:00 klp-build: Remove redundant SRC and OBJ variables SRC and OBJ are both set to $(pwd) and are always identical. The script already enforces that klp-build runs from the kernel root directory, and builds are done in-place, making these variables unnecessary. Suggested-by: Song Liu Acked-by: Song Liu Signed-off-by: Josh Poimboeuf --- scripts/livepatch/klp-build | 67 +++++++++++++++--------------------- 1 file changed, 28 insertions(+), 39 deletions(-) diff --git a/scripts/livepatch/klp-build b/scripts/livepatch/klp-build index 327aef4..215d230 100755 --- a/scripts/livepatch/klp-build +++ b/scripts/livepatch/klp-build @@ -33,11 +33,9 @@ SCRIPT=3D"$(basename "$0")" SCRIPT_DIR=3D"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" FIX_PATCH_LINES=3D"$SCRIPT_DIR/fix-patch-lines" =20 -SRC=3D"$(pwd)" -OBJ=3D"$(pwd)" - -CONFIG=3D"$OBJ/.config" -TMP_DIR=3D"$OBJ/klp-tmp" +OBJTOOL=3D"$PWD/tools/objtool/objtool" +CONFIG=3D"$PWD/.config" +TMP_DIR=3D"$PWD/klp-tmp" =20 ORIG_DIR=3D"$TMP_DIR/orig" PATCHED_DIR=3D"$TMP_DIR/patched" @@ -88,7 +86,7 @@ declare -a STASHED_FILES =20 stash_file() { local file=3D"$1" - local rel_file=3D"${file#"$SRC"/}" + local rel_file=3D"${file#"$PWD"/}" =20 [[ ! -e "$file" ]] && die "no file to stash: $file" =20 @@ -102,7 +100,7 @@ restore_files() { local file =20 for file in "${STASHED_FILES[@]}"; do - mv -f "$STASH_DIR/$file" "$SRC/$file" || warn "can't restore file: $file" + mv -f "$STASH_DIR/$file" "$PWD/$file" || warn "can't restore file: $file" done =20 STASHED_FILES=3D() @@ -304,7 +302,7 @@ set_module_name() { # Hardcode the value printed by the localversion script to prevent patch # application from appending it with '+' due to a dirty working tree. set_kernelversion() { - local file=3D"$SRC/scripts/setlocalversion" + local file=3D"$PWD/scripts/setlocalversion" local kernelrelease =20 stash_file "$file" @@ -375,7 +373,7 @@ apply_patch() { =20 [[ ! -f "$patch" ]] && die "$patch doesn't exist" status=3D0 - output=3D$(patch -d "$SRC" -p1 --dry-run --no-backup-if-mismatch -r /dev/= null "${extra_args[@]}" < "$patch" 2>&1) || status=3D$? + output=3D$(patch -p1 --dry-run --no-backup-if-mismatch -r /dev/null "${ex= tra_args[@]}" < "$patch" 2>&1) || status=3D$? if [[ "$status" -ne 0 ]]; then echo "$output" >&2 die "$patch did not apply" @@ -385,14 +383,14 @@ apply_patch() { fi =20 APPLIED_PATCHES+=3D("$patch") - patch -d "$SRC" -p1 --no-backup-if-mismatch -r /dev/null "${extra_args[@]= }" --silent < "$patch" + patch -p1 --no-backup-if-mismatch -r /dev/null "${extra_args[@]}" --silen= t < "$patch" } =20 revert_patch() { local patch=3D"$1" local tmp=3D() =20 - patch -d "$SRC" -p1 -R --force --no-backup-if-mismatch -r /dev/null &> /d= ev/null < "$patch" || true + patch -p1 -R --force --no-backup-if-mismatch -r /dev/null &> /dev/null < = "$patch" || true =20 for p in "${APPLIED_PATCHES[@]}"; do [[ "$p" =3D=3D "$patch" ]] && continue @@ -430,8 +428,7 @@ validate_patches() { do_init() { # We're not yet smart enough to handle anything other than in-tree # builds in pwd. - [[ ! "$SRC" -ef "$SCRIPT_DIR/../.." ]] && die "please run from the kernel= root directory" - [[ ! "$OBJ" -ef "$SCRIPT_DIR/../.." ]] && die "please run from the kernel= root directory" + [[ ! "$PWD" -ef "$SCRIPT_DIR/../.." ]] && die "please run from the kernel= root directory" =20 (( SHORT_CIRCUIT <=3D 1 )) && rm -rf "$TMP_DIR" mkdir -p "$TMP_DIR" @@ -462,11 +459,11 @@ refresh_patch() { get_patch_output_files "$patch" | mapfile -t output_files =20 # Copy orig source files to 'a' - ( cd "$SRC" && echo "${input_files[@]}" | xargs cp --parents --target-dir= ectory=3D"$tmpdir/a" ) + echo "${input_files[@]}" | xargs cp --parents --target-directory=3D"$tmpd= ir/a" =20 # Copy patched source files to 'b' apply_patch "$patch" "--silent" - ( cd "$SRC" && echo "${output_files[@]}" | xargs cp --parents --target-di= rectory=3D"$tmpdir/b" ) + echo "${output_files[@]}" | xargs cp --parents --target-directory=3D"$tmp= dir/b" revert_patch "$patch" =20 # Diff 'a' and 'b' to make a clean patch @@ -510,10 +507,7 @@ clean_kernel() { cmd+=3D("-j$JOBS") cmd+=3D("clean") =20 - ( - cd "$SRC" - "${cmd[@]}" - ) + "${cmd[@]}" } =20 build_kernel() { @@ -554,12 +548,10 @@ build_kernel() { cmd+=3D("vmlinux") cmd+=3D("modules") =20 - ( - cd "$SRC" - "${cmd[@]}" \ - 1> >(tee -a "$log") \ - 2> >(tee -a "$log" | grep0 -v "modpost.*undefined!" >&2) - ) || die "$build kernel build failed" + "${cmd[@]}" \ + 1> >(tee -a "$log") \ + 2> >(tee -a "$log" | grep0 -v "modpost.*undefined!" >&2) \ + || die "$build kernel build failed" } =20 find_objects() { @@ -567,9 +559,9 @@ find_objects() { =20 # Find root-level vmlinux.o and non-root-level .ko files, # excluding klp-tmp/ and .git/ - find "$OBJ" \( -path "$TMP_DIR" -o -path "$OBJ/.git" -o -regex "$OBJ/[^/]= [^/]*\.ko" \) -prune -o \ + find "$PWD" \( -path "$TMP_DIR" -o -path "$PWD/.git" -o -regex "$PWD/[^/]= [^/]*\.ko" \) -prune -o \ -type f "${opts[@]}" \ - \( -name "*.ko" -o -path "$OBJ/vmlinux.o" \) \ + \( -name "*.ko" -o -path "$PWD/vmlinux.o" \) \ -printf '%P\n' } =20 @@ -585,7 +577,7 @@ copy_orig_objects() { xtrace_save "copying orig objects" for _file in "${files[@]}"; do local rel_file=3D"${_file/.ko/.o}" - local file=3D"$OBJ/$rel_file" + local file=3D"$PWD/$rel_file" local orig_file=3D"$ORIG_DIR/$rel_file" local orig_dir=3D"$(dirname "$orig_file")" =20 @@ -618,7 +610,7 @@ copy_patched_objects() { xtrace_save "copying changed objects" for _file in "${files[@]}"; do local rel_file=3D"${_file/.ko/.o}" - local file=3D"$OBJ/$rel_file" + local file=3D"$PWD/$rel_file" local orig_file=3D"$ORIG_DIR/$rel_file" local patched_file=3D"$PATCHED_DIR/$rel_file" local patched_dir=3D"$(dirname "$patched_file")" @@ -663,7 +655,7 @@ diff_objects() { =20 mkdir -p "$(dirname "$out_file")" =20 - cmd=3D("$SRC/tools/objtool/objtool") + cmd=3D("$OBJTOOL") cmd+=3D("klp") cmd+=3D("diff") (( ${#opts[@]} > 0 )) && cmd+=3D("${opts[@]}") @@ -716,7 +708,7 @@ diff_checksums() { fi done =20 - cmd=3D("$SRC/tools/objtool/objtool") + cmd=3D("$OBJTOOL") cmd+=3D("--checksum") cmd+=3D("--link") cmd+=3D("--dry-run") @@ -774,7 +766,7 @@ build_patch_module() { rm -rf "$KMOD_DIR" mkdir -p "$KMOD_DIR" =20 - cp -f "$SRC/scripts/livepatch/init.c" "$KMOD_DIR" + cp -f "$SCRIPT_DIR/init.c" "$KMOD_DIR" =20 echo "obj-m :=3D $NAME.o" > "$makefile" echo -n "$NAME-y :=3D init.o" >> "$makefile" @@ -820,12 +812,9 @@ build_patch_module() { cmd+=3D("KCFLAGS=3D${cflags[*]}") =20 # Build a "normal" kernel module with init.c and the diffed objects - ( - cd "$SRC" - "${cmd[@]}" \ - 1> >(tee -a "$log") \ - 2> >(tee -a "$log" >&2) - ) + "${cmd[@]}" \ + 1> >(tee -a "$log") \ + 2> >(tee -a "$log" >&2) =20 kmod_file=3D"$KMOD_DIR/$NAME.ko" =20 @@ -836,7 +825,7 @@ build_patch_module() { objcopy --remove-section=3D.BTF "$kmod_file" =20 # Fix (and work around) linker wreckage for klp syms / relocs - "$SRC/tools/objtool/objtool" klp post-link "$kmod_file" || die "objtool k= lp post-link failed" + "$OBJTOOL" klp post-link "$kmod_file" || die "objtool klp post-link faile= d" =20 cp -f "$kmod_file" "$OUTFILE" }