Skip to content

Commit 7e6b9db

Browse files
ardbiesheuvelPeter Zijlstra
authored andcommitted
jump_label: make initial NOP patching the special case
Instead of defaulting to patching NOP opcodes at init time, and leaving it to the architectures to override this if this is not needed, switch to a model where doing nothing is the default. This is the common case by far, as only MIPS requires NOP patching at init time. On all other architectures, the correct encodings are emitted by the compiler and so no initial patching is needed. Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Mark Rutland <mark.rutland@arm.com> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/20220615154142.1574619-4-ardb@kernel.org
1 parent fdfd428 commit 7e6b9db

File tree

11 files changed

+7
-85
lines changed

11 files changed

+7
-85
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/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/kernel/jump_label.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,3 @@ void arch_jump_label_transform_apply(void)
8080
{
8181
text_poke_sync();
8282
}
83-
84-
void __init_or_module arch_jump_label_transform_static(struct jump_entry *entry,
85-
enum jump_label_type type)
86-
{
87-
}

arch/x86/kernel/jump_label.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,3 @@ void arch_jump_label_transform_apply(void)
146146
text_poke_finish();
147147
mutex_unlock(&text_mutex);
148148
}
149-
150-
static enum {
151-
JL_STATE_START,
152-
JL_STATE_NO_UPDATE,
153-
JL_STATE_UPDATE,
154-
} jlstate __initdata_or_module = JL_STATE_START;
155-
156-
__init_or_module void arch_jump_label_transform_static(struct jump_entry *entry,
157-
enum jump_label_type type)
158-
{
159-
if (jlstate == JL_STATE_UPDATE)
160-
jump_label_transform(entry, type, 1);
161-
}

include/linux/jump_label.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,6 @@ extern void jump_label_lock(void);
220220
extern void jump_label_unlock(void);
221221
extern void arch_jump_label_transform(struct jump_entry *entry,
222222
enum jump_label_type type);
223-
extern void arch_jump_label_transform_static(struct jump_entry *entry,
224-
enum jump_label_type type);
225223
extern bool arch_jump_label_transform_queue(struct jump_entry *entry,
226224
enum jump_label_type type);
227225
extern void arch_jump_label_transform_apply(void);

0 commit comments

Comments
 (0)