From patchwork Mon Oct 28 19:49:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Nesterov X-Patchwork-Id: 3104191 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 498ECBF924 for ; Mon, 28 Oct 2013 19:48:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5E0A42037D for ; Mon, 28 Oct 2013 19:48:13 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3E3732039D for ; Mon, 28 Oct 2013 19:48:12 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VasnE-0007Hf-U7; Mon, 28 Oct 2013 19:48:05 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VasnC-0000ZL-Bc; Mon, 28 Oct 2013 19:48:02 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vasn7-0000Yt-VY for linux-arm-kernel@lists.infradead.org; Mon, 28 Oct 2013 19:47:59 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9SJlXKD031020 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 28 Oct 2013 15:47:33 -0400 Received: from tranklukator.brq.redhat.com (dhcp-1-188.brq.redhat.com [10.34.1.188]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id r9SJlTmk017445; Mon, 28 Oct 2013 15:47:30 -0400 Received: by tranklukator.brq.redhat.com (nbSMTP-1.00) for uid 500 oleg@redhat.com; Mon, 28 Oct 2013 20:49:16 +0100 (CET) Date: Mon, 28 Oct 2013 20:49:14 +0100 From: Oleg Nesterov To: David Long Subject: Re: [PATCH v2 05/13] uprobes: add arch write opcode hook Message-ID: <20131028194914.GA15103@redhat.com> References: <1381871068-27660-1-git-send-email-dave.long@linaro.org> <1381871068-27660-6-git-send-email-dave.long@linaro.org> <20131019165051.GC7837@redhat.com> <5268137F.3030809@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5268137F.3030809@linaro.org> User-Agent: Mutt/1.5.18 (2008-05-17) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131028_154758_145583_FF2C199C X-CRM114-Status: GOOD ( 16.97 ) X-Spam-Score: -7.4 (-------) Cc: "Jon Medhurst \(Tixy\)" , Srikar Dronamraju , linux-kernel@vger.kernel.org, Rabin Vincent , Ingo Molnar , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 10/23, David Long wrote: > > On 10/19/13 12:50, Oleg Nesterov wrote: >> On 10/15, David Long wrote: >>> >>> Allow arches to write the opcode with a custom function. ARM needs to >>> customize the swbp instruction depending on the condition code of the >>> instruction it replaces. >> >> Well, we already have "__weak set_swbp(auprobe, ...)", can't arm use it? >> >> If not, >> >>> +void __weak arch_uprobe_write_opcode(struct arch_uprobe *auprobe, void *vaddr, >>> + uprobe_opcode_t opcode) >>> +{ >>> + memcpy(vaddr, &opcode, UPROBE_SWBP_INSN_SIZE); >>> +} >>> ... >>> - copy_to_page(new_page, vaddr, &opcode, UPROBE_SWBP_INSN_SIZE); >>> + vaddr_new = kmap_atomic(new_page); >>> + arch_uprobe_write_opcode(auprobe, vaddr_new + (vaddr & ~PAGE_MASK), >>> + opcode); >>> + kunmap_atomic(vaddr_new); >> >> Again, if you need to add the new __weak helper, I think it should simply >> do copy_to_page(). >> >> Oleg. >> > > Unfortunately, providing an alternative set_swbp() would mean > duplicating a moderate chunk of code from kernel/uprobes.c. Yes, yes, sorry for confusion. What I actually tried to suggest is something like the trivial patch below. Then arm can do: uprobe_opcode_t arch_uprobe_swbp_insn(struct arch_uprobe *auprobe) { return __opcode_to_mem_arm(auprobe->bpinsn); } No? > I notice there don't seem to be any alternative set_swbp functions > in the (rc6) kernel tree Yes... I think we should simply make it "static". And set_orig_insn() too. Oleg. --- x/kernel/events/uprobes.c +++ x/kernel/events/uprobes.c @@ -304,6 +304,11 @@ put_old: return ret; } +uprobe_opcode_t __weak arch_uprobe_swbp_insn(struct arch_uprobe *auprobe) +{ + return UPROBE_SWBP_INSN; +} + /** * set_swbp - store breakpoint at a given address. * @auprobe: arch specific probepoint information. @@ -315,7 +320,7 @@ put_old: */ int __weak set_swbp(struct arch_uprobe *auprobe, struct mm_struct *mm, unsigned long vaddr) { - return write_opcode(mm, vaddr, UPROBE_SWBP_INSN); + return write_opcode(mm, vaddr, arch_uprobe_swbp_insn(auprobe)); } /**