From nobody Mon Apr 6 18:55:58 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 672CD37F744; Wed, 18 Mar 2026 08:25:24 +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=1773822326; cv=none; b=ENLuIm1YoyYMANNpLUmr0S8guriXn2rnbMHjBieMzu3U5jGeoR/d0X2CLwMFC2EOm+3prTmvpXVypdlpCWphWYbtrz97NZsc+jB3TuXcNi0xjwNORbGkTpFVaitj3iFSMJbd+BnCCyJtZYCfoCnbZC++Jkjauwc4sJ/F7Kfn4YY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773822326; c=relaxed/simple; bh=LKefflas0K0T65KTMTRBbTZaydXd3fI1de4p8DH/t7I=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=AYFNKjaAo6iTkZltEaAq6N4m5MPnz/VbI39pRtktbvkXkQV10ryxRAgyqXr78lzKzQ1Vxw1Jea15oPG8j7xLdFhOJ0ogOxPpRvlJTTfowVouRwQ7KP+nywLyG9C8CJd/2J9T9J8hzvjiuI0wUkWUZXcr/2cNUzsGHNgqARhSOMQ= 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=IjNKC5eO; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=L1/uykYa; 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="IjNKC5eO"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="L1/uykYa" Date: Wed, 18 Mar 2026 08:25:20 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1773822321; 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: in-reply-to:in-reply-to:references:references; bh=jKh+xdKmU+CcsgsxVBst9JTDfcHFRtVa8MrLsCT1CHY=; b=IjNKC5eOZp/C8sFUSco9oZij3dGmC/4yZ+t1RwkUjv2s1dppBHRmngjY1vw4+vIxDKydzl wqb3pwjQOZWnJCwipdQkEethOf1uzGgB9ser0V89dqlgq8xa+hxidu2k2f1B+8KOyUQnQa cU2PbnLakp014/x0mUH0suV/l1cLqvJGTTahWRKjKAYPDIdjtkgkE+Pl6PnjeB+UrIQtCg pai66xs9T1vl+9nulKkIf15CoKuqRJ3K2rltfUNehFD6BVGPySiajBxilaR/8B40h/YTsw 63ibJauCEWfuLOxGvA0F+2UKLz3w9JAluh3OHEE3emKAAr0Itds5K7W0ZNHDgA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1773822321; 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: in-reply-to:in-reply-to:references:references; bh=jKh+xdKmU+CcsgsxVBst9JTDfcHFRtVa8MrLsCT1CHY=; b=L1/uykYa0z7cnkXYPHFU8t15SuyHBGXhQati6TmIxxpRHTEo++gXkWGKptJHtoRSU4SEBA klX9VgmlgpOtCFBQ== From: "tip-bot2 for Joe Lawrence" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: objtool/core] livepatch/klp-build: support patches that add/remove files Cc: Song Liu , Joe Lawrence , Josh Poimboeuf , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260310203751.1479229-4-joe.lawrence@redhat.com> References: <20260310203751.1479229-4-joe.lawrence@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177382232052.1647592.13052414580009849205.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: 757bd10ff0f015d83481d39a266eb752dbbfce33 Gitweb: https://git.kernel.org/tip/757bd10ff0f015d83481d39a266eb752d= bbfce33 Author: Joe Lawrence AuthorDate: Tue, 10 Mar 2026 16:37:42 -04:00 Committer: Josh Poimboeuf CommitterDate: Mon, 16 Mar 2026 12:46:48 -07:00 livepatch/klp-build: support patches that add/remove files The klp-build script prepares a clean patch by populating two temporary directories ('a' and 'b') with source files and diffing the result. However, this process fails when a patch introduces a new source file, as the script attempts to copy files that do not yet exist in the original source tree. Likewise, it fails when a patch removes a source file and the script attempts to copy a file that no longer exists. Refactor the file-gathering logic to distinguish between original input files and patched output files: - Split get_patch_files() into get_patch_input_files() and get_patch_output_files() to identify which files exist before and after patch application. - Filter out "/dev/null" from both to handle file creation/deletion. - Update refresh_patch() to only copy existing input files to the 'a' directory and the resulting output files to the 'b' directory. Acked-by: Song Liu Signed-off-by: Joe Lawrence Link: https://patch.msgid.link/20260310203751.1479229-4-joe.lawrence@redhat= .com Signed-off-by: Josh Poimboeuf --- scripts/livepatch/klp-build | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/scripts/livepatch/klp-build b/scripts/livepatch/klp-build index 809e198..94ed3b4 100755 --- a/scripts/livepatch/klp-build +++ b/scripts/livepatch/klp-build @@ -296,15 +296,33 @@ set_kernelversion() { sed -i "2i echo $localversion; exit 0" scripts/setlocalversion } =20 -get_patch_files() { +get_patch_input_files() { + local patch=3D"$1" + + grep0 -E '^--- ' "$patch" \ + | gawk '{print $2}' \ + | grep0 -v '^/dev/null$' \ + | sed 's|^[^/]*/||' \ + | sort -u +} + +get_patch_output_files() { local patch=3D"$1" =20 - grep0 -E '^(--- |\+\+\+ )' "$patch" \ + grep0 -E '^\+\+\+ ' "$patch" \ | gawk '{print $2}' \ + | grep0 -v '^/dev/null$' \ | sed 's|^[^/]*/||' \ | sort -u } =20 +get_patch_files() { + local patch=3D"$1" + + { get_patch_input_files "$patch"; get_patch_output_files "$patch"; } \ + | sort -u +} + # Make sure git re-stats the changed files git_refresh() { local patch=3D"$1" @@ -312,7 +330,7 @@ git_refresh() { =20 [[ ! -e "$SRC/.git" ]] && return =20 - get_patch_files "$patch" | mapfile -t files + get_patch_input_files "$patch" | mapfile -t files =20 ( cd "$SRC" @@ -426,21 +444,23 @@ do_init() { refresh_patch() { local patch=3D"$1" local tmpdir=3D"$PATCH_TMP_DIR" - local files=3D() + local input_files=3D() + local output_files=3D() =20 rm -rf "$tmpdir" mkdir -p "$tmpdir/a" mkdir -p "$tmpdir/b" =20 # Get all source files affected by the patch - get_patch_files "$patch" | mapfile -t files + get_patch_input_files "$patch" | mapfile -t input_files + get_patch_output_files "$patch" | mapfile -t output_files =20 # Copy orig source files to 'a' - ( cd "$SRC" && echo "${files[@]}" | xargs cp --parents --target-directory= =3D"$tmpdir/a" ) + ( cd "$SRC" && echo "${input_files[@]}" | xargs cp --parents --target-dir= ectory=3D"$tmpdir/a" ) =20 # Copy patched source files to 'b' apply_patch "$patch" --recount - ( cd "$SRC" && echo "${files[@]}" | xargs cp --parents --target-directory= =3D"$tmpdir/b" ) + ( cd "$SRC" && echo "${output_files[@]}" | xargs cp --parents --target-di= rectory=3D"$tmpdir/b" ) revert_patch "$patch" --recount =20 # Diff 'a' and 'b' to make a clean patch