diff mbox series

[v1,1/5] jump_label: Don't warn on __exit jump entries

Message ID 20190516155344.24060-2-andrew.murray@arm.com (mailing list archive)
State New, archived
Headers show
Series arm64: avoid out-of-line ll/sc atomics | expand

Commit Message

Andrew Murray May 16, 2019, 3:53 p.m. UTC
On architectures that discard .exit.* sections at runtime, a
warning is printed for each jump label that is used within an
in-kernel __exit annotated function:

can't patch jump_label at ehci_hcd_cleanup+0x8/0x3c
WARNING: CPU: 0 PID: 1 at kernel/jump_label.c:395 __jump_label_update+0x140/0x168

As these functions will never get executed (they are free'd along
with the rest of initmem) - we do not need to patch them and should
not display any warnings.

The warning is displayed because the test required to satisfy
jump_entry_is_init is based on init_section_contains (__init_begin to
__init_end) whereas the test in __jump_label_update is based on
init_kernel_text (_sinittext to _einittext) via kernel_text_address).

In addition to fixing this, we also remove an out-of-date comment
and use a WARN instead of a WARN_ONCE.

Fixes: 19483677684b ("jump_label: Annotate entries that operate on __init code earlier")
Signed-off-by: Andrew Murray <andrew.murray@arm.com>
---
 kernel/jump_label.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index bad96b476eb6..f2e36b4b06a7 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -380,16 +380,18 @@  static void __jump_label_update(struct static_key *key,
 				bool init)
 {
 	for (; (entry < stop) && (jump_entry_key(entry) == key); entry++) {
-		/*
-		 * An entry->code of 0 indicates an entry which has been
-		 * disabled because it was in an init text area.
-		 */
 		if (init || !jump_entry_is_init(entry)) {
 			if (kernel_text_address(jump_entry_code(entry)))
 				arch_jump_label_transform(entry, jump_label_type(entry));
-			else
-				WARN_ONCE(1, "can't patch jump_label at %pS",
-					  (void *)jump_entry_code(entry));
+
+			/*
+			 * kernel_text_address will return 0 for .exit.text
+			 * symbols, we don't need to patch these so suppress
+			 * this warning.
+			 */
+			else if (!jump_entry_is_init(entry))
+				WARN(1, "can't patch jump_label at %pS",
+				     (void *)jump_entry_code(entry));
 		}
 	}
 }