lkml.org 
[lkml]   [2020]   [Jul]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v6 13/17] static_call: Add static_call_cond()
On Fri, 10 Jul 2020 15:38:44 +0200
Peter Zijlstra <peterz@infradead.org> wrote:

> +static void __static_call_transform(void *insn, enum insn_type type, void *func)
> {
> - const void *code = text_gen_insn(opcode, insn, func);
> + int size = CALL_INSN_SIZE;
> + const void *code;
>
> - if (WARN_ONCE(*(u8 *)insn != opcode,
> - "unexpected static call insn opcode 0x%x at %pS\n",
> - opcode, insn))

I would still feel better if we did some sort of sanity check before
just writing to the text. Confirm this is a jmp, call, ret or nop?

-- Steve


> - return;
> + switch (type) {
> + case CALL:
> + code = text_gen_insn(CALL_INSN_OPCODE, insn, func);
> + break;
> +
> + case NOP:
> + code = ideal_nops[NOP_ATOMIC5];
> + break;
> +
> + case JMP:
> + code = text_gen_insn(JMP32_INSN_OPCODE, insn, func);
> + break;
> +
> + case RET:
> + code = text_gen_insn(RET_INSN_OPCODE, insn, func);
> + size = RET_INSN_SIZE;
> + break;
> + }
>
> - if (memcmp(insn, code, CALL_INSN_SIZE) == 0)
> + if (memcmp(insn, code, size) == 0)
> return;
>
> - text_poke_bp(insn, code, CALL_INSN_SIZE, NULL);
> + text_poke_bp(insn, code, size, NULL);
> }
>

\
 
 \ /
  Last update: 2020-07-11 01:09    [W:0.311 / U:0.156 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site