Re: [PATCH 52/58] objtool/klp: Add test for alternative replacement code in checksums
From: sashiko-bot@kernel.org
Date: 2026-09-11 19:30:27
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The test fixture defines a replacement instruction that is larger than the original instruction, violating x86 alternative constraints. -- commit 509cbfff90fd6a32748a4ce13dc568b4181b4904 Author: Song Liu [off-list ref] objtool/klp: Add test for alternative replacement code in checksums checksum_update_insn() walks insn->alts after hashing the instruction itself: the alternative's type, and where the replacement forms a group, its feature number and every instruction in it. A patch which edits only the replacement -- code that runs on some CPUs and not others -- still has to move the function's checksum.
quoted hunk ↗ jump to hunk
diff --git a/tools/objtool/tests/x86/fixtures/checksum_alt.c b/tools/objtool/tests/x86/fixtures/checksum_alt.c new file mode 100644 index 0000000000000..47ff93bc77556 --- /dev/null +++ b/tools/objtool/tests/x86/fixtures/checksum_alt.c@@ -0,0 +1,60 @@
[ ... ]
quoted hunk ↗ jump to hunk
+#if defined(PATCHED) && defined(ALT_REPL) +#define REPL_INSN " xchg %ax, %ax\n\t" +#else +#define REPL_INSN " nop\n\t" +#endif
[ ... ]
quoted hunk ↗ jump to hunk
+int target(int x) +{ + asm volatile( + "661: nop\n\t" + "662:\n\t" + ".pushsection .altinstr_replacement, \"ax\"\n\t" + ".globl target_repl\n\t" + "target_repl:\n\t" + REPL_INSN
[Severity: Low] Since the original instruction defined at label 661 in target() is a 1-byte nop, and REPL_INSN can be defined as xchg %ax, %ax (which is 2 bytes), does this replacement exceed the original instruction's size? x86 alternatives strictly require the replacement instruction length to be less than or equal to the original instruction length. While this test fixture in checksum_alt.c does not execute at runtime, emitting structurally invalid metadata into the object file could cause failures if objtool adds stricter size validation in the future.
+ "target_repl_end:\n\t" + ".popsection\n\t"
-- Sashiko AI review · https://sashiko.dev/#/patchset/20260911185031.1534046-1-song@kernel.org?part=52