mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [tip: objtool/core] objtool/klp: Add test for newly introduced functions
       [not found] <20260916184351.2720310-15-song@kernel.org>
@ 2026-09-18 10:15 ` tip-bot2 for Puranjay Mohan
  2026-09-21  9:28 ` tip-bot2 for Puranjay Mohan
  1 sibling, 0 replies; 2+ messages in thread
From: tip-bot2 for Puranjay Mohan @ 2026-09-18 10:15 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Puranjay Mohan, Song Liu, Josh Poimboeuf, x86, linux-kernel

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

Commit-ID:     10aedc2ce2edc1a95e83da123ba76ea2eba07480
Gitweb:        https://git.kernel.org/tip/10aedc2ce2edc1a95e83da123ba76ea2eba07480
Author:        Puranjay Mohan <puranjay@kernel.org>
AuthorDate:    Wed, 16 Sep 2026 11:43:07 -07:00
Committer:     Josh Poimboeuf <jpoimboe@kernel.org>
CommitterDate: Wed, 16 Sep 2026 17:13:27 -07:00

objtool/klp: Add test for newly introduced functions

A function added by the patch has no original to correlate against, and
still has to be carried into the livepatch or the changed caller ends up
referencing something which does not exist.

The helper is noinline so the case survives the optimiser; otherwise the
compiler folds it into its only caller and the test covers nothing.

Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
Assisted-by: Claude:claude-opus-5
Signed-off-by: Song Liu <song@kernel.org>
Link: https://patch.msgid.link/20260916184351.2720310-15-song@kernel.org
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 tools/objtool/tests/generic/fixtures/new_function.c | 21 ++++++++++++-
 tools/objtool/tests/generic/test-new-function.sh    | 16 +++++++++-
 2 files changed, 37 insertions(+)
 create mode 100644 tools/objtool/tests/generic/fixtures/new_function.c
 create mode 100755 tools/objtool/tests/generic/test-new-function.sh

diff --git a/tools/objtool/tests/generic/fixtures/new_function.c b/tools/objtool/tests/generic/fixtures/new_function.c
new file mode 100644
index 0000000..e7886ea
--- /dev/null
+++ b/tools/objtool/tests/generic/fixtures/new_function.c
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Function introduced by the patch.  noinline keeps it from being folded. */
+
+static const char __modinfo[]
+	__attribute__((section(".modinfo"), used, aligned(1))) = "\0name=vmlinux";
+
+#ifdef PATCHED
+static __attribute__((noinline)) int klp_new_helper(int x)
+{
+	return x * 7;
+}
+#endif
+
+int target(int x)
+{
+#ifdef PATCHED
+	return klp_new_helper(x);
+#else
+	return x;
+#endif
+}
diff --git a/tools/objtool/tests/generic/test-new-function.sh b/tools/objtool/tests/generic/test-new-function.sh
new file mode 100755
index 0000000..b0b7f64
--- /dev/null
+++ b/tools/objtool/tests/generic/test-new-function.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# A function added by the patch has no original to correlate against and must
+# still be carried into the livepatch.
+
+. "$(dirname "$0")/../lib.sh"
+
+setup
+build_pair new_function.c
+run_diff
+
+assert_patched target
+assert_symbol klp_new_helper
+
+pass "new function carried into the patch with its caller"

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [tip: objtool/core] objtool/klp: Add test for newly introduced functions
       [not found] <20260916184351.2720310-15-song@kernel.org>
  2026-09-18 10:15 ` [tip: objtool/core] objtool/klp: Add test for newly introduced functions tip-bot2 for Puranjay Mohan
@ 2026-09-21  9:28 ` tip-bot2 for Puranjay Mohan
  1 sibling, 0 replies; 2+ messages in thread
From: tip-bot2 for Puranjay Mohan @ 2026-09-21  9:28 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Puranjay Mohan, Song Liu, Josh Poimboeuf, Ingo Molnar, x86, linux-kernel

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

Commit-ID:     960c3e352bac749c35041d683f32bdde467a2960
Gitweb:        https://git.kernel.org/tip/960c3e352bac749c35041d683f32bdde467a2960
Author:        Puranjay Mohan <puranjay@kernel.org>
AuthorDate:    Wed, 16 Sep 2026 11:43:07 -07:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Mon, 21 Sep 2026 11:02:40 +02:00

objtool/klp: Add test for newly introduced functions

A function added by the patch has no original to correlate against, and
still has to be carried into the livepatch or the changed caller ends up
referencing something which does not exist.

The helper is noinline so the case survives the optimiser; otherwise the
compiler folds it into its only caller and the test covers nothing.

Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
Signed-off-by: Song Liu <song@kernel.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Assisted-by: Claude:claude-opus-5
Link: https://patch.msgid.link/20260916184351.2720310-15-song@kernel.org
---
 tools/objtool/tests/generic/fixtures/new_function.c | 21 ++++++++++++-
 tools/objtool/tests/generic/test-new-function.sh    | 16 +++++++++-
 2 files changed, 37 insertions(+)
 create mode 100644 tools/objtool/tests/generic/fixtures/new_function.c
 create mode 100755 tools/objtool/tests/generic/test-new-function.sh

diff --git a/tools/objtool/tests/generic/fixtures/new_function.c b/tools/objtool/tests/generic/fixtures/new_function.c
new file mode 100644
index 0000000..e7886ea
--- /dev/null
+++ b/tools/objtool/tests/generic/fixtures/new_function.c
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Function introduced by the patch.  noinline keeps it from being folded. */
+
+static const char __modinfo[]
+	__attribute__((section(".modinfo"), used, aligned(1))) = "\0name=vmlinux";
+
+#ifdef PATCHED
+static __attribute__((noinline)) int klp_new_helper(int x)
+{
+	return x * 7;
+}
+#endif
+
+int target(int x)
+{
+#ifdef PATCHED
+	return klp_new_helper(x);
+#else
+	return x;
+#endif
+}
diff --git a/tools/objtool/tests/generic/test-new-function.sh b/tools/objtool/tests/generic/test-new-function.sh
new file mode 100755
index 0000000..b0b7f64
--- /dev/null
+++ b/tools/objtool/tests/generic/test-new-function.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# A function added by the patch has no original to correlate against and must
+# still be carried into the livepatch.
+
+. "$(dirname "$0")/../lib.sh"
+
+setup
+build_pair new_function.c
+run_diff
+
+assert_patched target
+assert_symbol klp_new_helper
+
+pass "new function carried into the patch with its caller"

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-21  9:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20260916184351.2720310-15-song@kernel.org>
2026-09-18 10:15 ` [tip: objtool/core] objtool/klp: Add test for newly introduced functions tip-bot2 for Puranjay Mohan
2026-09-21  9:28 ` tip-bot2 for Puranjay Mohan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®