From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx155.postini.com [74.125.245.155]) by kanga.kvack.org (Postfix) with SMTP id BB2826B005A for ; Wed, 25 Jan 2012 10:32:31 -0500 (EST) Received: by wgbdt12 with SMTP id dt12so4697934wgb.26 for ; Wed, 25 Jan 2012 07:32:30 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <20120110114821.17610.9188.sendpatchset@srdronam.in.ibm.com> <20120110114831.17610.88468.sendpatchset@srdronam.in.ibm.com> From: Denys Vlasenko Date: Wed, 25 Jan 2012 16:32:08 +0100 Message-ID: Subject: Re: [PATCH v9 3.2 1/9] uprobes: Install and remove breakpoints. Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Sender: owner-linux-mm@kvack.org List-ID: To: Srikar Dronamraju Cc: Peter Zijlstra , Linus Torvalds , Oleg Nesterov , Ingo Molnar , Andrew Morton , LKML , Linux-mm , Andi Kleen , Christoph Hellwig , Steven Rostedt , Roland McGrath , Thomas Gleixner , Masami Hiramatsu , Arnaldo Carvalho de Melo , Anton Arapov , Ananth N Mavinakayanahalli , Jim Keniston , Stephen Rothwell On Wed, Jan 25, 2012 at 4:13 PM, Denys Vlasenko wrote: >> + =A0 =A0 =A0 /* >> + =A0 =A0 =A0 =A0* Convert from rip-relative addressing to indirect addr= essing >> + =A0 =A0 =A0 =A0* via a scratch register. =A0Change the r/m field from = 0x5 (%rip) >> + =A0 =A0 =A0 =A0* to 0x0 (%rax) or 0x1 (%rcx), and squeeze out the offs= et field. >> + =A0 =A0 =A0 =A0*/ >> + =A0 =A0 =A0 reg =3D MODRM_REG(insn); >> + =A0 =A0 =A0 if (reg =3D=3D 0) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* The register operand (if any) is eith= er the A register >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* (%rax, %eax, etc.) or (if the 0x4 bit= is set in the >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* REX prefix) %r8. =A0In any case, we k= now the C register >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* is NOT the register operand, so we us= e %rcx (register >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* #1) for the scratch register. >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*/ >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 uprobe->arch_info.fixups =3D UPROBES_FIX_R= IP_CX; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Change modrm from 00 000 101 to 00 000 = 001. */ >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 *cursor =3D 0x1; Hmm. I think we have a bug here. What if this instruction has REX.B =3D 1? Granted, REX.B =3D 1 has no effec= t 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 con= vert 0x12345678(%rip) reference to (%rcx), but if REX.B =3D 1, then you in fact converted it to (%r9)! --=20 vda -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org