From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932242AbbFDV7O (ORCPT ); Thu, 4 Jun 2015 17:59:14 -0400 Received: from mail9.hitachi.co.jp ([133.145.228.44]:59146 "EHLO mail9.hitachi.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753450AbbFDV7M (ORCPT ); Thu, 4 Jun 2015 17:59:12 -0400 Message-ID: <5570CA29.6040005@hitachi.com> Date: Fri, 05 Jun 2015 06:59:05 +0900 From: Masami Hiramatsu Organization: Hitachi, Ltd., Japan User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Andy Lutomirski , Ananth N Mavinakayanahalli CC: Ingo Molnar , Eugene Shatokhin , Ingo Molnar , LKML Subject: Re: Re: [PATCH 2/2] kprobes/x86: Use 16 bytes for each instruction slot again References: <1433176331-479-1-git-send-email-eugene.shatokhin@rosalab.ru> <1433176331-479-3-git-send-email-eugene.shatokhin@rosalab.ru> <556CD37E.9000501@hitachi.com> <20150602054431.GA21382@gmail.com> <556E2448.6060801@hitachi.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2015/06/03 6:55, Andy Lutomirski wrote: > On Tue, Jun 2, 2015 at 2:46 PM, Masami Hiramatsu > wrote: >> On 2015/06/02 14:44, Ingo Molnar wrote: >>> >>> * Masami Hiramatsu wrote: >>> >>>> On 2015/06/02 2:04, Andy Lutomirski wrote: >>>>> On Mon, Jun 1, 2015 at 9:32 AM, Eugene Shatokhin >>>>> wrote: >>>>>> Commit 91e5ed49fca0 ("x86/asm/decoder: Fix and enforce max instruction >>>>>> size in the insn decoder") has changed MAX_INSN_SIZE from 16 to 15 bytes >>>>>> on x86. >>>>>> >>>>>> As a side effect, the slots Kprobes use to store the instructions became >>>>>> 1 byte shorter. This is unfortunate because, for example, the Kprobes' >>>>>> "boost" feature can not be used now for the instructions of length 11, >>>>>> like a quite common kind of MOV: >>>>>> * movq $0xffffffffffffffff,-0x3fe8(%rax) (48 c7 80 18 c0 ff ff ff ff ff ff) >>>>>> * movq $0x0,0x88(%rdi) (48 c7 87 88 00 00 00 00 00 00 00) >>>>>> and so on. >>>>>> >>>>>> This patch makes the insn slots 16 bytes long, like they were before while >>>>>> keeping MAX_INSN_SIZE intact. >>>>>> >>>>>> Other tools may benefit from this change as well. >>>>> >>>>> What is a "slot" and why does this patch make sense? Naively, I'd >>>>> expect that the check you're patching is entirely unnecessary -- I >>>>> don't see what the size of the instruction being probed has to do with >>>>> the safety of executing it out of line and then jumping back. >>>>> >>>>> Is there another magic 16 somewhere that this is enforcing that we >>>>> don't overrun? >>>> >>>> The kprobe-"booster" adds a jump back code (jmp ) >>>> right after the instruction in the out-of-code buffer(slot). So we need at least >>>> the insn-length + 5 bytes for the slot, it's the trick of the magic :) >>> >>> Please at minimum rename it to 'dynamic code buffer' or some other sensible name - >>> the name 'slot' is pretty meaningless at best and misleading at worst. >> >> OK, would 'exec_buffer' is sensible? or just a 'code_buffer' is better? > > redirected_code_buffer_size? > > Anyway, regardless of the exact name, I also think it should be > measured in bytes instead of weird per-arch units. OK, will try to use u8 and void *. Thanks! -- Masami HIRAMATSU Linux Technology Research Center, System Productivity Research Dept. Center for Technology Innovation - Systems Engineering Hitachi, Ltd., Research & Development Group E-mail: masami.hiramatsu.pt@hitachi.com