]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
jump_label: Rename JUMP_LABEL_{EN,DIS}ABLE to JUMP_LABEL_{JMP,NOP}
authorPeter Zijlstra <peterz@infradead.org>
Fri, 24 Jul 2015 12:45:44 +0000 (14:45 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 22 May 2019 22:15:03 +0000 (23:15 +0100)
commit 76b235c6bcb16062d663e2ee96db0b69f2e6bc14 upstream.

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>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
arch/arm/kernel/jump_label.c
arch/arm64/kernel/jump_label.c
arch/mips/kernel/jump_label.c
arch/powerpc/kernel/jump_label.c
arch/s390/kernel/jump_label.c
arch/sparc/kernel/jump_label.c
arch/x86/kernel/jump_label.c
include/linux/jump_label.h
kernel/jump_label.c

index 4ce4f789446da5844b86f929e276453424d9a808..d0514adc7e2dd3ff62acaa73fb2b2936e858edec 100644 (file)
@@ -13,7 +13,7 @@ static void __arch_jump_label_transform(struct jump_entry *entry,
        void *addr = (void *)entry->code;
        unsigned int insn;
 
-       if (type == JUMP_LABEL_ENABLE)
+       if (type == JUMP_LABEL_JMP)
                insn = arm_gen_branch(entry->code, entry->target);
        else
                insn = arm_gen_nop();
index 263a166291fbd96691c01f5d81554b4471d13d79..df23752b4f502ce9b7e4f816a241ab37b505f584 100644 (file)
@@ -29,7 +29,7 @@ static void __arch_jump_label_transform(struct jump_entry *entry,
        void *addr = (void *)entry->code;
        u32 insn;
 
-       if (type == JUMP_LABEL_ENABLE) {
+       if (type == JUMP_LABEL_JMP) {
                insn = aarch64_insn_gen_branch_imm(entry->code,
                                                   entry->target,
                                                   AARCH64_INSN_BRANCH_NOLINK);
index dda800e9e73167d3637f972516743b12e25a9ddc..3e586daa3a324763cc63599ee2396f5de9322c6a 100644 (file)
@@ -51,7 +51,7 @@ void arch_jump_label_transform(struct jump_entry *e,
        /* Target must have the right alignment and ISA must be preserved. */
        BUG_ON((e->target & J_ALIGN_MASK) != J_ISA_BIT);
 
-       if (type == JUMP_LABEL_ENABLE) {
+       if (type == JUMP_LABEL_JMP) {
                insn.j_format.opcode = J_ISA_BIT ? mm_j32_op : j_op;
                insn.j_format.target = e->target >> J_RANGE_SHIFT;
        } else {
index a1ed8a8c7cb42c83fc61c674735f1f7d6bbe3842..6472472093d084a01d2aaac7f2fa53f6a332f4da 100644 (file)
@@ -17,7 +17,7 @@ void arch_jump_label_transform(struct jump_entry *entry,
 {
        u32 *addr = (u32 *)(unsigned long)entry->code;
 
-       if (type == JUMP_LABEL_ENABLE)
+       if (type == JUMP_LABEL_JMP)
                patch_branch(addr, entry->target, 0);
        else
                patch_instruction(addr, PPC_INST_NOP);
index cb2d51e779dfafe0bf02077bdd68918dde731511..e66c0896a32d0196e13e589db8021cf00b97530a 100644 (file)
@@ -60,7 +60,7 @@ static void __jump_label_transform(struct jump_entry *entry,
 {
        struct insn old, new;
 
-       if (type == JUMP_LABEL_ENABLE) {
+       if (type == JUMP_LABEL_JMP) {
                jump_label_make_nop(entry, &old);
                jump_label_make_branch(entry, &new);
        } else {
index 48565c11e82ae2fcc4ef3627abe67ba38ca811b2..59bbeff550243dc10ea558a013d09825303e4793 100644 (file)
@@ -16,7 +16,7 @@ void arch_jump_label_transform(struct jump_entry *entry,
        u32 val;
        u32 *insn = (u32 *) (unsigned long) entry->code;
 
-       if (type == JUMP_LABEL_ENABLE) {
+       if (type == JUMP_LABEL_JMP) {
                s32 off = (s32)entry->target - (s32)entry->code;
 
 #ifdef CONFIG_SPARC64
index 26d5a55a273610b8d49da975a006f156adb4e482..e565e0e4d21698c40297d01991a74ff659fca5c3 100644 (file)
@@ -45,7 +45,7 @@ static void __jump_label_transform(struct jump_entry *entry,
        const unsigned char default_nop[] = { STATIC_KEY_INIT_NOP };
        const unsigned char *ideal_nop = ideal_nops[NOP_ATOMIC5];
 
-       if (type == JUMP_LABEL_ENABLE) {
+       if (type == JUMP_LABEL_JMP) {
                if (init) {
                        /*
                         * Jump label is enabled for the first time.
index 6d80f843eb5bc01745bc28c02c187ba095d8f01b..e261b8600b3734c2e83cb9786d51f8fcc52d603e 100644 (file)
@@ -86,8 +86,8 @@ struct static_key {
 #ifndef __ASSEMBLY__
 
 enum jump_label_type {
-       JUMP_LABEL_DISABLE = 0,
-       JUMP_LABEL_ENABLE,
+       JUMP_LABEL_NOP = 0,
+       JUMP_LABEL_JMP,
 };
 
 struct module;
index f0653ccc3d862254ba87c26bbc3fdc4631c2010f..5249ecf1718c27a47ec71114f8d5d0dbd231652e 100644 (file)
@@ -65,9 +65,9 @@ void static_key_slow_inc(struct static_key *key)
        jump_label_lock();
        if (atomic_read(&key->enabled) == 0) {
                if (!jump_label_get_branch_default(key))
-                       jump_label_update(key, JUMP_LABEL_ENABLE);
+                       jump_label_update(key, JUMP_LABEL_JMP);
                else
-                       jump_label_update(key, JUMP_LABEL_DISABLE);
+                       jump_label_update(key, JUMP_LABEL_NOP);
        }
        atomic_inc(&key->enabled);
        jump_label_unlock();
@@ -88,9 +88,9 @@ static void __static_key_slow_dec(struct static_key *key,
                schedule_delayed_work(work, rate_limit);
        } else {
                if (!jump_label_get_branch_default(key))
-                       jump_label_update(key, JUMP_LABEL_DISABLE);
+                       jump_label_update(key, JUMP_LABEL_NOP);
                else
-                       jump_label_update(key, JUMP_LABEL_ENABLE);
+                       jump_label_update(key, JUMP_LABEL_JMP);
        }
        jump_label_unlock();
 }
@@ -191,9 +191,9 @@ static enum jump_label_type jump_label_type(struct static_key *key)
        bool state = static_key_enabled(key);
 
        if ((!true_branch && state) || (true_branch && !state))
-               return JUMP_LABEL_ENABLE;
+               return JUMP_LABEL_JMP;
 
-       return JUMP_LABEL_DISABLE;
+       return JUMP_LABEL_NOP;
 }
 
 void __init jump_label_init(void)
@@ -283,7 +283,7 @@ void jump_label_apply_nops(struct module *mod)
                return;
 
        for (iter = iter_start; iter < iter_stop; iter++) {
-               arch_jump_label_transform_static(iter, JUMP_LABEL_DISABLE);
+               arch_jump_label_transform_static(iter, JUMP_LABEL_NOP);
        }
 }
 
@@ -325,8 +325,8 @@ static int jump_label_add_module(struct module *mod)
                jlm->next = key->next;
                key->next = jlm;
 
-               if (jump_label_type(key) == JUMP_LABEL_ENABLE)
-                       __jump_label_update(key, iter, iter_stop, JUMP_LABEL_ENABLE);
+               if (jump_label_type(key) == JUMP_LABEL_JMP)
+                       __jump_label_update(key, iter, iter_stop, JUMP_LABEL_JMP);
        }
 
        return 0;