Skip to content

Commit 22a39c3

Browse files
committed
Merge tag 'locking-core-2022-08-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull locking updates from Ingo Molnar: "This was a fairly quiet cycle for the locking subsystem: - lockdep: Fix a handful of the more complex lockdep_init_map_*() primitives that can lose the lock_type & cause false reports. No such mishap was observed in the wild. - jump_label improvements: simplify the cross-arch support of initial NOP patching by making it arch-specific code (used on MIPS only), and remove the s390 initial NOP patching that was superfluous" * tag 'locking-core-2022-08-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: locking/lockdep: Fix lockdep_init_map_*() confusion jump_label: make initial NOP patching the special case jump_label: mips: move module NOP patching into arch code jump_label: s390: avoid pointless initial NOP patching
2 parents b167fdf + eae6d58 commit 22a39c3

File tree

19 files changed

+59
-163
lines changed

19 files changed

+59
-163
lines changed

Documentation/staging/static-keys.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,6 @@ static_key->entry field makes use of the two least significant bits.
201201
* ``void arch_jump_label_transform(struct jump_entry *entry, enum jump_label_type type)``,
202202
see: arch/x86/kernel/jump_label.c
203203

204-
* ``__init_or_module void arch_jump_label_transform_static(struct jump_entry *entry, enum jump_label_type type)``,
205-
see: arch/x86/kernel/jump_label.c
206-
207204
* ``struct jump_entry``,
208205
see: arch/x86/include/asm/jump_label.h
209206

arch/arc/kernel/jump_label.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,6 @@ void arch_jump_label_transform(struct jump_entry *entry,
9696
flush_icache_range(entry->code, entry->code + JUMP_LABEL_NOP_SIZE);
9797
}
9898

99-
void arch_jump_label_transform_static(struct jump_entry *entry,
100-
enum jump_label_type type)
101-
{
102-
/*
103-
* We use only one NOP type (1x, 4 byte) in arch_static_branch, so
104-
* there's no need to patch an identical NOP over the top of it here.
105-
* The generic code calls 'arch_jump_label_transform' if the NOP needs
106-
* to be replaced by a branch, so 'arch_jump_label_transform_static' is
107-
* never called with type other than JUMP_LABEL_NOP.
108-
*/
109-
BUG_ON(type != JUMP_LABEL_NOP);
110-
}
111-
11299
#ifdef CONFIG_ARC_DBG_JUMP_LABEL
113100
#define SELFTEST_MSG "ARC: instruction generation self-test: "
114101

arch/arm/kernel/jump_label.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,3 @@ void arch_jump_label_transform(struct jump_entry *entry,
2727
{
2828
__arch_jump_label_transform(entry, type, false);
2929
}
30-
31-
void arch_jump_label_transform_static(struct jump_entry *entry,
32-
enum jump_label_type type)
33-
{
34-
__arch_jump_label_transform(entry, type, true);
35-
}

arch/arm64/kernel/jump_label.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,3 @@ void arch_jump_label_transform(struct jump_entry *entry,
2626

2727
aarch64_insn_patch_text_nosync(addr, insn);
2828
}
29-
30-
void arch_jump_label_transform_static(struct jump_entry *entry,
31-
enum jump_label_type type)
32-
{
33-
/*
34-
* We use the architected A64 NOP in arch_static_branch, so there's no
35-
* need to patch an identical A64 NOP over the top of it here. The core
36-
* will call arch_jump_label_transform from a module notifier if the
37-
* NOP needs to be replaced by a branch.
38-
*/
39-
}

arch/mips/include/asm/jump_label.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#ifndef _ASM_MIPS_JUMP_LABEL_H
99
#define _ASM_MIPS_JUMP_LABEL_H
1010

11+
#define arch_jump_label_transform_static arch_jump_label_transform
12+
1113
#ifndef __ASSEMBLY__
1214

1315
#include <linux/types.h>

arch/mips/kernel/jump_label.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,22 @@ void arch_jump_label_transform(struct jump_entry *e,
8888

8989
mutex_unlock(&text_mutex);
9090
}
91+
92+
#ifdef CONFIG_MODULES
93+
void jump_label_apply_nops(struct module *mod)
94+
{
95+
struct jump_entry *iter_start = mod->jump_entries;
96+
struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
97+
struct jump_entry *iter;
98+
99+
/* if the module doesn't have jump label entries, just return */
100+
if (iter_start == iter_stop)
101+
return;
102+
103+
for (iter = iter_start; iter < iter_stop; iter++) {
104+
/* Only write NOPs for arch_branch_static(). */
105+
if (jump_label_init_type(iter) == JUMP_LABEL_NOP)
106+
arch_jump_label_transform(iter, JUMP_LABEL_NOP);
107+
}
108+
}
109+
#endif

arch/mips/kernel/module.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/spinlock.h>
2222
#include <linux/jump_label.h>
2323

24+
extern void jump_label_apply_nops(struct module *mod);
2425

2526
struct mips_hi16 {
2627
struct mips_hi16 *next;
@@ -428,8 +429,8 @@ int module_finalize(const Elf_Ehdr *hdr,
428429
const Elf_Shdr *s;
429430
char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
430431

431-
/* Make jump label nops. */
432-
jump_label_apply_nops(me);
432+
if (IS_ENABLED(CONFIG_JUMP_LABEL))
433+
jump_label_apply_nops(me);
433434

434435
INIT_LIST_HEAD(&me->arch.dbe_list);
435436
for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) {

arch/parisc/kernel/jump_label.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,3 @@ void arch_jump_label_transform(struct jump_entry *entry,
4242

4343
patch_text(addr, insn);
4444
}
45-
46-
void arch_jump_label_transform_static(struct jump_entry *entry,
47-
enum jump_label_type type)
48-
{
49-
/*
50-
* We use the architected NOP in arch_static_branch, so there's no
51-
* need to patch an identical NOP over the top of it here. The core
52-
* will call arch_jump_label_transform from a module notifier if the
53-
* NOP needs to be replaced by a branch.
54-
*/
55-
}

arch/riscv/kernel/jump_label.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,3 @@ void arch_jump_label_transform(struct jump_entry *entry,
3939
patch_text_nosync(addr, &insn, sizeof(insn));
4040
mutex_unlock(&text_mutex);
4141
}
42-
43-
void arch_jump_label_transform_static(struct jump_entry *entry,
44-
enum jump_label_type type)
45-
{
46-
/*
47-
* We use the same instructions in the arch_static_branch and
48-
* arch_static_branch_jump inline functions, so there's no
49-
* need to patch them up here.
50-
* The core will call arch_jump_label_transform when those
51-
* instructions need to be replaced.
52-
*/
53-
}

arch/s390/include/asm/jump_label.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <linux/stringify.h>
1111

1212
#define JUMP_LABEL_NOP_SIZE 6
13-
#define JUMP_LABEL_NOP_OFFSET 2
1413

1514
#ifdef CONFIG_CC_IS_CLANG
1615
#define JUMP_LABEL_STATIC_KEY_CONSTRAINT "i"
@@ -21,12 +20,12 @@
2120
#endif
2221

2322
/*
24-
* We use a brcl 0,2 instruction for jump labels at compile time so it
23+
* We use a brcl 0,<offset> instruction for jump labels so it
2524
* can be easily distinguished from a hotpatch generated instruction.
2625
*/
2726
static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
2827
{
29-
asm_volatile_goto("0: brcl 0,"__stringify(JUMP_LABEL_NOP_OFFSET)"\n"
28+
asm_volatile_goto("0: brcl 0,%l[label]\n"
3029
".pushsection __jump_table,\"aw\"\n"
3130
".balign 8\n"
3231
".long 0b-.,%l[label]-.\n"

0 commit comments

Comments
 (0)