diff options
| author | Peter Zijlstra <peterz@infradead.org> | 2021-05-06 21:34:01 +0200 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2021-05-12 14:54:55 +0200 |
| commit | e7bf1ba97afdde75b0ef43e4bdb718bf843613f1 (patch) | |
| tree | 090e3ff09488c36c2becee9bc596f92d752ef6be /arch/x86/kernel | |
| parent | 5af0ea293d78c8b8f0b87ae2b13f7ac584057bc3 (diff) | |
| download | linux-e7bf1ba97afdde75b0ef43e4bdb718bf843613f1.tar.gz linux-e7bf1ba97afdde75b0ef43e4bdb718bf843613f1.tar.bz2 linux-e7bf1ba97afdde75b0ef43e4bdb718bf843613f1.zip | |
jump_label, x86: Emit short JMP
Now that we can patch short JMP/NOP, allow the compiler/assembler to
emit short JMP instructions.
There is no way to have the assembler emit short NOPs based on the
potential displacement, so leave those long for now.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20210506194157.967034497@infradead.org
Diffstat (limited to 'arch/x86/kernel')
| -rw-r--r-- | arch/x86/kernel/jump_label.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c index 190d810fa435..a762dc1c615e 100644 --- a/arch/x86/kernel/jump_label.c +++ b/arch/x86/kernel/jump_label.c @@ -15,12 +15,18 @@ #include <asm/kprobes.h> #include <asm/alternative.h> #include <asm/text-patching.h> +#include <asm/insn.h> #define JUMP_LABEL_NOP_SIZE JMP32_INSN_SIZE int arch_jump_entry_size(struct jump_entry *entry) { - return JMP32_INSN_SIZE; + struct insn insn = {}; + + insn_decode_kernel(&insn, (void *)jump_entry_code(entry)); + BUG_ON(insn.length != 2 && insn.length != 5); + + return insn.length; } struct jump_label_patch { |
