Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753528Ab1CNQ6x (ORCPT ); Mon, 14 Mar 2011 12:58:53 -0400 Received: from mout.perfora.net ([74.208.4.195]:59532 "EHLO mout.perfora.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751715Ab1CNQ6w (ORCPT ); Mon, 14 Mar 2011 12:58:52 -0400 Date: Mon, 14 Mar 2011 12:58:18 -0400 From: Stephen Wilson To: Srikar Dronamraju Cc: Peter Zijlstra , Ingo Molnar , Steven Rostedt , Linux-mm , Arnaldo Carvalho de Melo , Linus Torvalds , Ananth N Mavinakayanahalli , Christoph Hellwig , Andi Kleen , Masami Hiramatsu , Oleg Nesterov , LKML , Jim Keniston , Roland McGrath , SystemTap , Andrew Morton , "Paul E. McKenney" Subject: Re: [PATCH v2 2.6.38-rc8-tip 3/20] 3: uprobes: Breakground page replacement. Message-ID: <20110314165818.GA18507@fibrous.localdomain> References: <20110314133403.27435.7901.sendpatchset@localhost6.localdomain6> <20110314133433.27435.49566.sendpatchset@localhost6.localdomain6> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110314133433.27435.49566.sendpatchset@localhost6.localdomain6> User-Agent: Mutt/1.5.19 (2009-01-05) X-Provags-ID: V02:K0:7opqTtGS+C7b4BQlxh5dxyEEHiNxRj1LHJ0Fo+7UTEg hf1rz0Fnv4uNaaARRqV9U/6lczbBljxZx/lAg8H8VlIMOmX2AH PKQUBSmemXsctuIDKwomLbOac4jJEJ3q4NEMw770m6XkPAf2gV UHrRDsdYe007vpziNyhTZ10maSvnLp/mznIe20DHJFaoI5KIla uu9Xf30HdYPqHNhF3W4LNd4IE8Sg7cXxYRGDs99FEo= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1699 Lines: 56 On Mon, Mar 14, 2011 at 07:04:33PM +0530, Srikar Dronamraju wrote: > +/** > + * read_opcode - read the opcode at a given virtual address. > + * @tsk: the probed task. > + * @vaddr: the virtual address to store the opcode. > + * @opcode: location to store the read opcode. > + * > + * For task @tsk, read the opcode at @vaddr and store it in @opcode. > + * Return 0 (success) or a negative errno. > + */ > +int __weak read_opcode(struct task_struct *tsk, unsigned long vaddr, > + uprobe_opcode_t *opcode) > +{ > + struct vm_area_struct *vma; > + struct page *page; > + void *vaddr_new; > + int ret; > + > + ret = get_user_pages(tsk, tsk->mm, vaddr, 1, 0, 0, &page, &vma); > + if (ret <= 0) > + return -EFAULT; > + ret = -EFAULT; > + > + /* > + * check if the page we are interested is read-only mapped > + * Since we are interested in text pages, Our pages of interest > + * should be mapped read-only. > + */ > + if ((vma->vm_flags & (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)) == > + (VM_READ|VM_EXEC)) > + goto put_out; > + > + lock_page(page); > + vaddr_new = kmap_atomic(page, KM_USER0); > + vaddr &= ~PAGE_MASK; > + memcpy(&opcode, vaddr_new + vaddr, uprobe_opcode_sz); > + kunmap_atomic(vaddr_new, KM_USER0); > + unlock_page(page); > + ret = uprobe_opcode_sz; This looks wrong. We should be setting ret = 0 on success here? > + > +put_out: > + put_page(page); /* we did a get_page in the beginning */ > + return ret; > +} -- steve -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/