From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751772Ab2AZOOp (ORCPT ); Thu, 26 Jan 2012 09:14:45 -0500 Received: from mail4.hitachi.co.jp ([133.145.228.5]:33053 "EHLO mail4.hitachi.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751113Ab2AZOOo (ORCPT ); Thu, 26 Jan 2012 09:14:44 -0500 X-AuditID: b753bd60-95b8eba000007b1b-0f-4f215fd1d3ff X-AuditID: b753bd60-95b8eba000007b1b-0f-4f215fd1d3ff Message-ID: <4F215FCE.8010209@hitachi.com> Date: Thu, 26 Jan 2012 23:14:38 +0900 From: Masami Hiramatsu Organization: Hitachi, Ltd., Japan User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: Denys Vlasenko Cc: Srikar Dronamraju , Peter Zijlstra , Linus Torvalds , Oleg Nesterov , Ingo Molnar , Andrew Morton , LKML , Linux-mm , Andi Kleen , Christoph Hellwig , Steven Rostedt , Roland McGrath , Thomas Gleixner , Arnaldo Carvalho de Melo , Anton Arapov , Ananth N Mavinakayanahalli , Jim Keniston , Stephen Rothwell , yrl.pp-manager.tt@hitachi.com Subject: Re: [PATCH v9 3.2 1/9] uprobes: Install and remove breakpoints. References: <20120110114821.17610.9188.sendpatchset@srdronam.in.ibm.com> <20120110114831.17610.88468.sendpatchset@srdronam.in.ibm.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: AAAAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (2012/01/26 0:32), Denys Vlasenko wrote: > On Wed, Jan 25, 2012 at 4:13 PM, Denys Vlasenko > wrote: >>> + /* >>> + * Convert from rip-relative addressing to indirect addressing >>> + * via a scratch register. Change the r/m field from 0x5 (%rip) >>> + * to 0x0 (%rax) or 0x1 (%rcx), and squeeze out the offset field. >>> + */ >>> + reg = MODRM_REG(insn); >>> + if (reg == 0) { >>> + /* >>> + * The register operand (if any) is either the A register >>> + * (%rax, %eax, etc.) or (if the 0x4 bit is set in the >>> + * REX prefix) %r8. In any case, we know the C register >>> + * is NOT the register operand, so we use %rcx (register >>> + * #1) for the scratch register. >>> + */ >>> + uprobe->arch_info.fixups = UPROBES_FIX_RIP_CX; >>> + /* Change modrm from 00 000 101 to 00 000 001. */ >>> + *cursor = 0x1; > > Hmm. I think we have a bug here. > > What if this instruction has REX.B = 1? Granted, REX.B = 1 has no effect on > rip-relative addressing and therefore normally won't be generated by gcc/as, > but still. If you replace md and r/m fields as above, you are trying to convert > 0x12345678(%rip) reference to (%rcx), but if REX.B = 1, then you in fact > converted it to (%r9)! Right, thanks for finding :) And %rax register reference encoding has same problem, doesn't it? Thank you, -- Masami HIRAMATSU Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: masami.hiramatsu.pt@hitachi.com