Skip to content

Commit 38c9358

Browse files
author
Peter Zijlstra
committed
static_call: Fix static_call_update() sanity check
Sites that match init_section_contains() get marked as INIT. For built-in code init_sections contains both __init and __exit text. OTOH kernel_text_address() only explicitly includes __init text (and there are no __exit text markers). Match what jump_label already does and ignore the warning for INIT sites. Also see the excellent changelog for commit: 8f35eaa ("jump_label: Don't warn on __exit jump entries") Fixes: 9183c3f ("static_call: Add inline static call infrastructure") Reported-by: Sumit Garg <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Jarkko Sakkinen <[email protected]> Tested-by: Sumit Garg <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 698bace commit 38c9358

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

kernel/jump_label.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,14 @@ static bool jump_label_can_update(struct jump_entry *entry, bool init)
407407
return false;
408408

409409
if (!kernel_text_address(jump_entry_code(entry))) {
410+
/*
411+
* This skips patching built-in __exit, which
412+
* is part of init_section_contains() but is
413+
* not part of kernel_text_address().
414+
*
415+
* Skipping built-in __exit is fine since it
416+
* will never be executed.
417+
*/
410418
WARN_ONCE(!jump_entry_is_init(entry),
411419
"can't patch jump_label at %pS",
412420
(void *)jump_entry_code(entry));

kernel/static_call.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,16 @@ void __static_call_update(struct static_call_key *key, void *tramp, void *func)
181181
continue;
182182

183183
if (!kernel_text_address((unsigned long)site_addr)) {
184-
WARN_ONCE(1, "can't patch static call site at %pS",
184+
/*
185+
* This skips patching built-in __exit, which
186+
* is part of init_section_contains() but is
187+
* not part of kernel_text_address().
188+
*
189+
* Skipping built-in __exit is fine since it
190+
* will never be executed.
191+
*/
192+
WARN_ONCE(!static_call_is_init(site),
193+
"can't patch static call site at %pS",
185194
site_addr);
186195
continue;
187196
}

0 commit comments

Comments
 (0)