From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756699Ab1JYPyB (ORCPT ); Tue, 25 Oct 2011 11:54:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11755 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751807Ab1JYPyA (ORCPT ); Tue, 25 Oct 2011 11:54:00 -0400 Date: Tue, 25 Oct 2011 17:49:06 +0200 From: Oleg Nesterov To: Srikar Dronamraju Cc: Ananth N Mavinakayanahalli , Peter Zijlstra , Ingo Molnar , Steven Rostedt , Linux-mm , Arnaldo Carvalho de Melo , Linus Torvalds , Jonathan Corbet , Masami Hiramatsu , Hugh Dickins , Christoph Hellwig , Thomas Gleixner , Andi Kleen , Andrew Morton , Jim Keniston , Roland McGrath , LKML Subject: Re: test-case (Was: [PATCH 12/X] uprobes: x86: introduce abort_xol()) Message-ID: <20111025154906.GA17067@redhat.com> References: <20110920115938.25326.93059.sendpatchset@srdronam.in.ibm.com> <20111015190007.GA30243@redhat.com> <20111019215139.GA16395@redhat.com> <20111019215326.GF16395@redhat.com> <20111021144207.GN11831@linux.vnet.ibm.com> <20111021162631.GB2552@in.ibm.com> <20111021164221.GA30770@redhat.com> <20111021175915.GA1705@redhat.com> <20111025140613.GA17914@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20111025140613.GA17914@linux.vnet.ibm.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/25, Srikar Dronamraju wrote: > > > > static inline void *uc_ip(struct ucontext *ctxt) > > { > > return (void*)ctxt->uc_mcontext.gregs[16]; > > } > > ... > > > I have tested this on both x86_32 and x86_64 and can confirm that the > behaviour is same with or without uprobes placed at that instruction. > This is on the uprobes code with your changes. Great, thanks. > However on x86_32; the output is different from x86_64. > > On x86_32 (I have additionally printed the uc_ip and fault_insn. > > SIGSEGV! ip=0x10246 addr=0x12345678 > ERR!! wrong ip uc_ip(ctxt) = 10246 fault_insn = 804856c Yep. uc_ip() is not correct on x86_32. Sorry, I forgot to mention this. I was really surprised when I wrote this test. I simply can't understand how can I play with ucontext in the user-space. I guess uc_ip() should use REG_EIP instead of 16, but I wasn't able to compile it even if I added __USE_GNU. It would be even better to use sigcontext instead of the ugly mcontext_t, but this looks "impossible". The kernel is much simpler ;) > I still trying to dig up what uc_ip is and why its different on x86_32. See above. I guess it needs ctxt->uc_mcontext.gregs[14]. Or REG_EIP. uc_ip() simply reads sigcontext->ip passed by setup_sigcontext(). > Also I was thinking on your suggestion of making abort_xol a weak > function. In which case we could have architecture independent function > in kernel/uprobes.c which is just a wrapper for set_instruction_pointer. > > void __weak abort_xol(struct pt_regs *regs, struct uprobe_task *utask) > { > set_instruction_pointer(regs, utask->vaddr); > } > > where it would called from uprobe_notify_resume() as > > abort_xol(regs, utask); > > If other archs would want to do something else, they could override > abort_xol definition. I didn't suggest this ;) But looks reasonable to me. And afaics x86_32 can use this arch-independent function. Oleg.