diff options
author | Peter Zijlstra <peterz@infradead.org> | 2022-03-08 16:30:20 +0100 |
---|---|---|
committer | Peter Zijlstra <peterz@infradead.org> | 2022-03-15 10:32:34 +0100 |
commit | ba27d1a80871eb8dbeddf34ec7d396c149cbb8d7 (patch) | |
tree | 93ba8f18ff513a2f74fdff43e436752d0cbb2d25 /arch/x86/kernel/paravirt.c | |
parent | x86/text-patching: Make text_gen_insn() play nice with ANNOTATE_NOENDBR (diff) | |
download | linux-ba27d1a80871eb8dbeddf34ec7d396c149cbb8d7.tar.xz linux-ba27d1a80871eb8dbeddf34ec7d396c149cbb8d7.zip |
x86/ibt,paravirt: Use text_gen_insn() for paravirt_patch()
Less duplication is more better.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20220308154317.697253958@infradead.org
Diffstat (limited to 'arch/x86/kernel/paravirt.c')
-rw-r--r-- | arch/x86/kernel/paravirt.c | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c index 4420499f7bb4..06af2cf5181c 100644 --- a/arch/x86/kernel/paravirt.c +++ b/arch/x86/kernel/paravirt.c @@ -69,29 +69,12 @@ noinstr void paravirt_BUG(void) BUG(); } -struct branch { - unsigned char opcode; - u32 delta; -} __attribute__((packed)); - static unsigned paravirt_patch_call(void *insn_buff, const void *target, unsigned long addr, unsigned len) { - const int call_len = 5; - struct branch *b = insn_buff; - unsigned long delta = (unsigned long)target - (addr+call_len); - - if (len < call_len) { - pr_warn("paravirt: Failed to patch indirect CALL at %ps\n", (void *)addr); - /* Kernel might not be viable if patching fails, bail out: */ - BUG_ON(1); - } - - b->opcode = 0xe8; /* call */ - b->delta = delta; - BUILD_BUG_ON(sizeof(*b) != call_len); - - return call_len; + __text_gen_insn(insn_buff, CALL_INSN_OPCODE, + (void *)addr, target, CALL_INSN_SIZE); + return CALL_INSN_SIZE; } #ifdef CONFIG_PARAVIRT_XXL |