jump_label: explicitly annotate inittext labels as init
PATCH 1/1 jump_label: explicitly annotate inittext labels as init
inittext code may be out of [__init_begin, __init_end] range on some architectures. Yet, the jump_label_init() only calls init_section_contains() function to check if a label needs to be annotated as init and inittext code is left behind.
--- kernel/jump_label.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/jump_label.c +4 -1
@@ -481,13 +481,16 @@ void __init jump_label_init(void)for (iter = iter_start; iter < iter_stop; iter++) {struct static_key *iterk; +unsigned long addr;bool in_init;/* rewrite NOPs */ if (jump_label_type (iter) ==JUMP_LABEL_NOP )arch_jump_label_transform_static (iter,JUMP_LABEL_NOP ); - in_init =init_section_contains ((void *)jump_entry_code (iter),1 ); + addr =jump_entry_code (iter); + in_init =init_section_contains ((void *)addr,1 ) || +is_kernel_inittext (addr);jump_entry_set_init (iter, in_init); iterk =jump_entry_key (iter);
Signature · 1 line
2.34.1
Ard Biesheuvel
reviewerQuoted 22 lines · Alexander Gordeev
inittext code may be out of [
__init_begin,__init_end] range on some architectures. Yet, thejump_label_init()only callsinit_section_contains()function to check if a label needs to be annotated as init and inittext code is left behind.Fixes 19483677684b ("jump_label: Annotate entries that operate on __init code earlier")Signed-off-by Alexander Gordeev <[email protected]>--- kernel/jump_label.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)kernel/jump_label.c +1
-0@@ -481,13 +481,16 @@ void __init jump_label_init(void)for (iter = iter_start; iter < iter_stop; iter++) {struct static_key *iterk; +unsigned long addr;
kernel/jump_label.c void __init jump_label_init(void) · line 493
Quoted 10 lines
kernel/jump_label.c +3
-1bool in_init;/* rewrite NOPs */ if (jump_label_type (iter) ==JUMP_LABEL_NOP )arch_jump_label_transform_static (iter,JUMP_LABEL_NOP ); - in_init =init_section_contains ((void *)jump_entry_code (iter),1 ); + addr =jump_entry_code (iter); + in_init =init_section_contains ((void *)addr,1 ) || +is_kernel_inittext (addr);
Isn't it sufficient to only call is_kenel_inittext here?
Quoted 6 lines
kernel/jump_label.c +0
-1jump_entry_set_init (iter, in_init); iterk =jump_entry_key (iter); --2.34.1
Quoted 15 lines · Ard Biesheuvel
Quoted 15 lines
kernel/jump_label.c +1
-0@@ -481,13 +481,16 @@ void __init jump_label_init(void)for (iter = iter_start; iter < iter_stop; iter++) {struct static_key *iterk; +unsigned long addr;bool in_init;/* rewrite NOPs */ if (jump_label_type (iter) ==JUMP_LABEL_NOP )arch_jump_label_transform_static (iter,JUMP_LABEL_NOP );
Quoted 6 lines
kernel/jump_label.c void __init jump_label_init(void) · line 493
Quoted 4 lines
kernel/jump_label.c +3
-1- in_init =init_section_contains ((void *)jump_entry_code (iter),1 ); + addr =jump_entry_code (iter); + in_init =init_section_contains ((void *)addr,1 ) || +is_kernel_inittext (addr);Isn't it sufficient to only call
is_kenel_inittexthere?
I am not sure every arch out there would stick to putting init code to inittext only.
However, should not is_kernel_exittext() (which does not exist) also get checked here?
Ard Biesheuvel
reviewerQuoted 24 lines · Alexander Gordeev
Quoted 15 lines · Ard Biesheuvel
Quoted 15 lines
kernel/jump_label.c +1
-0@@ -481,13 +481,16 @@ void __init jump_label_init(void)for (iter = iter_start; iter < iter_stop; iter++) {struct static_key *iterk; +unsigned long addr;bool in_init;/* rewrite NOPs */ if (jump_label_type (iter) ==JUMP_LABEL_NOP )arch_jump_label_transform_static (iter,JUMP_LABEL_NOP );Quoted 6 lines
kernel/jump_label.c void __init jump_label_init(void) · line 493
Quoted 4 lines
kernel/jump_label.c +3
-1- in_init =init_section_contains ((void *)jump_entry_code (iter),1 ); + addr =jump_entry_code (iter); + in_init =init_section_contains ((void *)addr,1 ) || +is_kernel_inittext (addr);Isn't it sufficient to only call
is_kenel_inittexthere?
Quoted 5 lines
I am not sure every arch out there would stick to putting init code to inittext only.
However, should not
is_kernel_exittext()(which does not exist) also get checked here?
No, exittext either exists or it doesn't, rather than disappearing at runtime like inittext.
Quoted 25 lines · Ard Biesheuvel
Quoted 24 lines · Alexander Gordeev
Quoted 21 lines · Ard Biesheuvel
Quoted 9 lines
kernel/jump_label.c +1
-0@@ -481,13 +481,16 @@ void __init jump_label_init(void)for (iter = iter_start; iter < iter_stop; iter++) {struct static_key *iterk; +unsigned long addr;kernel/jump_label.c void __init jump_label_init(void) · line 493
Quoted 10 lines
kernel/jump_label.c +3
-1bool in_init;/* rewrite NOPs */ if (jump_label_type (iter) ==JUMP_LABEL_NOP )arch_jump_label_transform_static (iter,JUMP_LABEL_NOP ); - in_init =init_section_contains ((void *)jump_entry_code (iter),1 ); + addr =jump_entry_code (iter); + in_init =init_section_contains ((void *)addr,1 ) || +is_kernel_inittext (addr);Isn't it sufficient to only call
is_kenel_inittexthere?
Quoted 8 lines
Quoted 5 lines
I am not sure every arch out there would stick to putting init code to inittext only.
However, should not
is_kernel_exittext()(which does not exist) also get checked here?No, exittext either exists or it doesn't, rather than disappearing at runtime like inittext.
May be just swap the order of init_section_contains() and is_kernel_inittext() checks then?
Ard Biesheuvel
reviewerQuoted 30 lines · Alexander Gordeev
Quoted 28 lines · Ard Biesheuvel
Quoted 27 lines · Alexander Gordeev
Quoted 15 lines · Ard Biesheuvel
Quoted 15 lines
kernel/jump_label.c +1
-0@@ -481,13 +481,16 @@ void __init jump_label_init(void)for (iter = iter_start; iter < iter_stop; iter++) {struct static_key *iterk; +unsigned long addr;bool in_init;/* rewrite NOPs */ if (jump_label_type (iter) ==JUMP_LABEL_NOP )arch_jump_label_transform_static (iter,JUMP_LABEL_NOP );Quoted 6 lines
kernel/jump_label.c void __init jump_label_init(void) · line 493
Quoted 4 lines
kernel/jump_label.c +3
-1- in_init =init_section_contains ((void *)jump_entry_code (iter),1 ); + addr =jump_entry_code (iter); + in_init =init_section_contains ((void *)addr,1 ) || +is_kernel_inittext (addr);Isn't it sufficient to only call
is_kenel_inittexthere?I am not sure every arch out there would stick to putting init code to inittext only.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
However, should not
is_kernel_exittext()(which does not exist) also get checked here?No, exittext either exists or it doesn't, rather than disappearing at runtime like inittext.
May be just swap the order of
init_section_contains()andis_kernel_inittext()checks then?
No I don't think we need both.