[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20171113125956.GA11516@redhat.com>
Date: Mon, 13 Nov 2017 13:59:56 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: Yonghong Song <yhs@...com>
Cc: mingo@...nel.org, tglx@...utronix.de, peterz@...radead.org,
linux-kernel@...r.kernel.org, x86@...nel.org,
netdev@...r.kernel.org, ast@...com, kernel-team@...com
Subject: Re: [PATCH][v2] uprobes/x86: emulate push insns for uprobe on x86
The patch looks good to me, but I have a question because I know nothing
about insn encoding,
On 11/10, Yonghong Song wrote:
>
> +static int push_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn)
> +{
> + u8 opc1 = OPCODE1(insn), reg_offset = 0;
> +
> + if (opc1 < 0x50 || opc1 > 0x57)
> + return -ENOSYS;
> +
> + if (insn->length > 2)
> + return -ENOSYS;
> + if (insn->length == 2) {
> + /* only support rex_prefix 0x41 (x64 only) */
> +#ifdef CONFIG_X86_64
> + if (insn->rex_prefix.nbytes != 1 ||
> + insn->rex_prefix.bytes[0] != 0x41)
> + return -ENOSYS;
> +
> + auprobe->push.ilen = 2;
and the "else" branch does
auprobe->push.ilen = 1;
you could add
auprobe->push.ilen = insn->length;
at the end of push_setup_xol_ops() instead, but this is minor/cosmetic,
> + switch (opc1) {
> + case 0x50:
> + reg_offset = offsetof(struct pt_regs, r8);
> + break;
> + case 0x51:
> + reg_offset = offsetof(struct pt_regs, r9);
> + break;
> + case 0x52:
> + reg_offset = offsetof(struct pt_regs, r10);
> + break;
> + case 0x53:
> + reg_offset = offsetof(struct pt_regs, r11);
> + break;
> + case 0x54:
> + reg_offset = offsetof(struct pt_regs, r12);
> + break;
> + case 0x55:
> + reg_offset = offsetof(struct pt_regs, r13);
> + break;
> + case 0x56:
> + reg_offset = offsetof(struct pt_regs, r14);
> + break;
> + case 0x57:
> + reg_offset = offsetof(struct pt_regs, r15);
> + break;
> + }
> +#else
> + return -ENOSYS;
> +#endif
OK, but shouldn't we also return ENOSYS if CONFIG_X86_64=y but the probed task is 32bit?
Or in this case uprobe_init_insn(x86_64 => false) should fail and push_setup_xol_ops()
won't be called?
Oleg.
Powered by blists - more mailing lists