summaryrefslogtreecommitdiff
path: root/arch/x86/kernel/alternative.c
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2019-10-09 12:44:17 +0200
committerIngo Molnar <mingo@kernel.org>2019-11-27 07:44:24 +0100
commit254d2c04515ea4532a503cc5d8649e1513042e56 (patch)
treedb80da541648e4e40fe11f4b066425c4e2b51d62 /arch/x86/kernel/alternative.c
parentc12af4407fa5a3fc6396bde379e0882a132df49b (diff)
x86/alternative: Add text_opcode_size()
Introduce a common helper to map *_INSN_OPCODE to *_INSN_SIZE. Tested-by: Alexei Starovoitov <ast@kernel.org> Tested-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Alexei Starovoitov <ast@kernel.org> Cc: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: https://lkml.kernel.org/r/20191111132457.875666061@infradead.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/kernel/alternative.c')
-rw-r--r--arch/x86/kernel/alternative.c12
1 files changed, 1 insertions, 11 deletions
diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index ce737f1da834..f8f34f94d13d 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -1259,22 +1259,12 @@ union text_poke_insn {
void *text_gen_insn(u8 opcode, const void *addr, const void *dest)
{
static union text_poke_insn insn; /* text_mutex */
- int size = 0;
+ int size = text_opcode_size(opcode);
lockdep_assert_held(&text_mutex);
insn.opcode = opcode;
-#define __CASE(insn) \
- case insn##_INSN_OPCODE: size = insn##_INSN_SIZE; break
-
- switch(opcode) {
- __CASE(INT3);
- __CASE(CALL);
- __CASE(JMP32);
- __CASE(JMP8);
- }
-
if (size > 1) {
insn.disp = (long)dest - (long)(addr + size);
if (size == 2)