Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

jump_label: Rename JUMP_LABEL_{EN,DIS}ABLE to JUMP_LABEL_{JMP,NOP}

Since we've already stepped away from ENABLE is a JMP and DISABLE is a
NOP with the branch_default bits, and are going to make it even worse,
rename it to make it all clearer.

This way we don't mix multiple levels of logic attributes, but have a
plain 'physical' name for what the current instruction patching status
of a jump label is.

This is a first step in removing the naming confusion that has led to
a stream of avoidable bugs such as:

a833581e372a ("x86, perf: Fix static_key bug in load_mm_cr4()")

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
[ Beefed up the changelog. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Peter Zijlstra and committed by
Ingo Molnar
76b235c6 f320ead7

+18 -18
+1 -1
arch/arm/kernel/jump_label.c
··· 12 12 void *addr = (void *)entry->code; 13 13 unsigned int insn; 14 14 15 - if (type == JUMP_LABEL_ENABLE) 15 + if (type == JUMP_LABEL_JMP) 16 16 insn = arm_gen_branch(entry->code, entry->target); 17 17 else 18 18 insn = arm_gen_nop();
+1 -1
arch/arm64/kernel/jump_label.c
··· 28 28 void *addr = (void *)entry->code; 29 29 u32 insn; 30 30 31 - if (type == JUMP_LABEL_ENABLE) { 31 + if (type == JUMP_LABEL_JMP) { 32 32 insn = aarch64_insn_gen_branch_imm(entry->code, 33 33 entry->target, 34 34 AARCH64_INSN_BRANCH_NOLINK);
+1 -1
arch/mips/kernel/jump_label.c
··· 51 51 /* Target must have the right alignment and ISA must be preserved. */ 52 52 BUG_ON((e->target & J_ALIGN_MASK) != J_ISA_BIT); 53 53 54 - if (type == JUMP_LABEL_ENABLE) { 54 + if (type == JUMP_LABEL_JMP) { 55 55 insn.j_format.opcode = J_ISA_BIT ? mm_j32_op : j_op; 56 56 insn.j_format.target = e->target >> J_RANGE_SHIFT; 57 57 } else {
+1 -1
arch/powerpc/kernel/jump_label.c
··· 17 17 { 18 18 u32 *addr = (u32 *)(unsigned long)entry->code; 19 19 20 - if (type == JUMP_LABEL_ENABLE) 20 + if (type == JUMP_LABEL_JMP) 21 21 patch_branch(addr, entry->target, 0); 22 22 else 23 23 patch_instruction(addr, PPC_INST_NOP);
+1 -1
arch/s390/kernel/jump_label.c
··· 64 64 { 65 65 struct insn old, new; 66 66 67 - if (type == JUMP_LABEL_ENABLE) { 67 + if (type == JUMP_LABEL_JMP) { 68 68 jump_label_make_nop(entry, &old); 69 69 jump_label_make_branch(entry, &new); 70 70 } else {
+1 -1
arch/sparc/kernel/jump_label.c
··· 16 16 u32 val; 17 17 u32 *insn = (u32 *) (unsigned long) entry->code; 18 18 19 - if (type == JUMP_LABEL_ENABLE) { 19 + if (type == JUMP_LABEL_JMP) { 20 20 s32 off = (s32)entry->target - (s32)entry->code; 21 21 22 22 #ifdef CONFIG_SPARC64
+1 -1
arch/x86/kernel/jump_label.c
··· 45 45 const unsigned char default_nop[] = { STATIC_KEY_INIT_NOP }; 46 46 const unsigned char *ideal_nop = ideal_nops[NOP_ATOMIC5]; 47 47 48 - if (type == JUMP_LABEL_ENABLE) { 48 + if (type == JUMP_LABEL_JMP) { 49 49 if (init) { 50 50 /* 51 51 * Jump label is enabled for the first time.
+2 -2
include/linux/jump_label.h
··· 86 86 #ifndef __ASSEMBLY__ 87 87 88 88 enum jump_label_type { 89 - JUMP_LABEL_DISABLE = 0, 90 - JUMP_LABEL_ENABLE, 89 + JUMP_LABEL_NOP = 0, 90 + JUMP_LABEL_JMP, 91 91 }; 92 92 93 93 struct module;
+9 -9
kernel/jump_label.c
··· 65 65 jump_label_lock(); 66 66 if (atomic_read(&key->enabled) == 0) { 67 67 if (!jump_label_get_branch_default(key)) 68 - jump_label_update(key, JUMP_LABEL_ENABLE); 68 + jump_label_update(key, JUMP_LABEL_JMP); 69 69 else 70 - jump_label_update(key, JUMP_LABEL_DISABLE); 70 + jump_label_update(key, JUMP_LABEL_NOP); 71 71 } 72 72 atomic_inc(&key->enabled); 73 73 jump_label_unlock(); ··· 88 88 schedule_delayed_work(work, rate_limit); 89 89 } else { 90 90 if (!jump_label_get_branch_default(key)) 91 - jump_label_update(key, JUMP_LABEL_DISABLE); 91 + jump_label_update(key, JUMP_LABEL_NOP); 92 92 else 93 - jump_label_update(key, JUMP_LABEL_ENABLE); 93 + jump_label_update(key, JUMP_LABEL_JMP); 94 94 } 95 95 jump_label_unlock(); 96 96 } ··· 184 184 bool state = static_key_enabled(key); 185 185 186 186 if ((!true_branch && state) || (true_branch && !state)) 187 - return JUMP_LABEL_ENABLE; 187 + return JUMP_LABEL_JMP; 188 188 189 - return JUMP_LABEL_DISABLE; 189 + return JUMP_LABEL_NOP; 190 190 } 191 191 192 192 void __init jump_label_init(void) ··· 276 276 return; 277 277 278 278 for (iter = iter_start; iter < iter_stop; iter++) { 279 - arch_jump_label_transform_static(iter, JUMP_LABEL_DISABLE); 279 + arch_jump_label_transform_static(iter, JUMP_LABEL_NOP); 280 280 } 281 281 } 282 282 ··· 318 318 jlm->next = key->next; 319 319 key->next = jlm; 320 320 321 - if (jump_label_type(key) == JUMP_LABEL_ENABLE) 322 - __jump_label_update(key, iter, iter_stop, JUMP_LABEL_ENABLE); 321 + if (jump_label_type(key) == JUMP_LABEL_JMP) 322 + __jump_label_update(key, iter, iter_stop, JUMP_LABEL_JMP); 323 323 } 324 324 325 325 return 0;