lkml.org 
[lkml]   [2012]   [Apr]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Subject[RFC PATCH -tip 10/16] x86/disasm: Indicate modified instructions
    From
    Date
    Show modified comment instead of disassembled code when
    given instruction has been modified by kprobes or kdb.

    Signed-off-by: Masami Hiramatsu <masami.hiramatsu@gmail.com>
    ---
    arch/x86/kernel/kdebugfs.c | 23 +++++++++++++++++++++--
    1 files changed, 21 insertions(+), 2 deletions(-)

    diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
    index 5da917d..eccd718 100644
    --- a/arch/x86/kernel/kdebugfs.c
    +++ b/arch/x86/kernel/kdebugfs.c
    @@ -296,13 +296,32 @@ static int disasm_seq_show(struct seq_file *m, void *v)
    u8 kbuf[MAX_INSN_SIZE];
    struct insn insn;
    void *p;
    + int i, ret;

    + /* recover if the instruction is probed */
    p = (void *)recover_probed_instruction(kbuf, (unsigned long)v);
    kernel_insn_init(&insn, p);
    insn_get_length(&insn);
    insn.kaddr = v;
    - snprint_assembly(buf, DISASM_BUF_LEN, &insn, DISASM_PR_ALL);
    - seq_printf(m, "%s", buf);
    +
    + seq_printf(m, "%p: ", v);
    + for (i = 0; i < MAX_INSN_SIZE / 2 && i < insn.length; i++)
    + seq_printf(m, "%02x ", ((u8 *)v)[i]);
    + if (i != MAX_INSN_SIZE / 2)
    + seq_printf(m, "%*s", 3 * (MAX_INSN_SIZE / 2 - i), " ");
    +
    + /* print assembly code */
    + ret = disassemble(buf, DISASM_BUF_LEN, &insn);
    + if (ret < 0)
    + return ret;
    + seq_printf(m, "%s%s\n", (p != v) ? "(probed)" : "", buf);
    +
    + if (i < insn.length) {
    + seq_printf(m, "%p: ", v + i);
    + for (; i < insn.length - 1; i++)
    + seq_printf(m, "%02x ", ((u8 *)v)[i]);
    + seq_printf(m, "%02x\n", ((u8 *)v)[i]);
    + }

    return 0;
    }


    \
     
     \ /
      Last update: 2012-04-01 18:07    [W:0.023 / U:0.040 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site