From patchwork Wed Dec 4 17:51:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taras Kondratiuk X-Patchwork-Id: 3284001 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C48239F37A for ; Wed, 4 Dec 2013 17:51:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8AC14201FA for ; Wed, 4 Dec 2013 17:51:42 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2726820134 for ; Wed, 4 Dec 2013 17:51:41 +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 1VoGbm-0007S1-SL; Wed, 04 Dec 2013 17:51:35 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VoGbk-0003jO-D9; Wed, 04 Dec 2013 17:51:32 +0000 Received: from mail-lb0-f176.google.com ([209.85.217.176]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VoGbh-0003j2-29 for linux-arm-kernel@lists.infradead.org; Wed, 04 Dec 2013 17:51:29 +0000 Received: by mail-lb0-f176.google.com with SMTP id x18so9388222lbi.21 for ; Wed, 04 Dec 2013 09:51:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=McFQZAOTOovnKB0IfsElXPSseW3AWqnaVQ8fMsjMQh8=; b=WBc7g36Pa/wtNSahCsgTrF4dOZhaIMoj2eTq5V4BPnU0bE2OFmfGVcA3tLGV846WPa N1j5Y3UwP5qfzSrnKV+/78J85vdT9Euuq6Gz/Wa6q0u9dAujF1UVzC9sgxqI0iVzihDj /XsgoYMcMgSrAA2kXIhjwfdx+lPGiirKbXVP3tSvpXj103wRVKBEqq33Fe/l24qn5qM2 Qy0tEr9z24RD1JjsS/k20kULKzfA7yg0fSFnRmXYXm+1dc9kyw3TMpcUyLm+QHj9VX/u M4p+SJJ9KL/g2R9rJh0A/Sc4QCmM8F8ujq7DL7XJcZNsWktIvQ5c21I1rm5YUTf3uhvD fhmw== X-Gm-Message-State: ALoCoQnFGLZ0cIxoRRj6s4PZzLDpBjUJ5gkxu3EcDnZ9sZywcLNXmRpqk3hqWo/mj/KGLUODb7K6 X-Received: by 10.112.219.99 with SMTP id pn3mr2175107lbc.24.1386179466207; Wed, 04 Dec 2013 09:51:06 -0800 (PST) Received: from [172.22.109.229] ([195.238.93.36]) by mx.google.com with ESMTPSA id i8sm40560304lbh.2.2013.12.04.09.51.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 04 Dec 2013 09:51:05 -0800 (PST) Message-ID: <529F6B88.2050005@linaro.org> Date: Wed, 04 Dec 2013 19:51:04 +0200 From: Taras Kondratiuk User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 MIME-Version: 1.0 To: David Long , linux-arm-kernel@lists.infradead.org, Russell King Subject: Re: [PATCH v3 00/15] uprobes: Add uprobes support for ARM References: <1385520814-10663-1-git-send-email-dave.long@linaro.org> In-Reply-To: <1385520814-10663-1-git-send-email-dave.long@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131204_125129_381578_00EE036F X-CRM114-Status: GOOD ( 26.01 ) X-Spam-Score: -2.6 (--) Cc: "Jon Medhurst \(Tixy\)" , Peter Zijlstra , Srikar Dronamraju , Oleg Nesterov , Anil S Keshavamurthy , linux-kernel@vger.kernel.org, Rabin Vincent , Ingo Molnar , Paul Mackerras , Arnaldo Carvalho de Melo , Masami Hiramatsu , Linaro Networking , davem@davemloft.net, Ananth N Mavinakayanahalli 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.2 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 11/27/2013 04:53 AM, David Long wrote: > From: "David A. Long" > > This patch series adds basic uprobes support to ARM. It is based on patches > developed earlier by Rabin Vincent. That approach of adding hooks into > the kprobes instruction parsing code was not well received. This approach > separates the ARM instruction parsing code in kprobes out into a separate set > of functions which can be used by both kprobes and uprobes. Both kprobes and > uprobes then provide their own semantic action tables to process the results of > the parsing. > > The following are noteworthy changes made for v3: > > 1) The ARM uprobes functionality no longer depends on kprobes. As > a side effect of this there are no longer any changes to the common > kprobes include file (or any other common kprobes files). > 2) A couple large patches have been broken down into more smaller > patches. > 3) A problem with uretprobes has been fixed. > 4) The kprobes-test module has been made more useable for thumb tests. > 5) The argument list to the "action" functions has been shrunk. > 6) Alignment with a few recent patches that were made to common > uprobes code specifically to support this patchset. > > This patchset is based on v3.13-rc1 Hi Dave I've tested this series in big-endian mode. There is an issue within __create_xol_area() function. It writes UPROBE_SWBP_INSN directly to memory, but UPROBE_SWBP_INSN stores canonical opcode, which leads to a wrong instruction endianness if CPU runs in BE. I think the easies way to fix it without touching generic uprobes code is to store opcode in native endianness in UPROBE_SWBP_INSN, and use another macro for canonical form in ARM specific code. Please check a diff below. With this diff plus addressed comment for patch 14/15 plus fixed Ben's BE kprobes series I have uprobes working on LE and BE. diff --git a/arch/arm/include/asm/uprobes.h b/arch/arm/include/asm/uprobes.h index e5acaa3..5313418 100644 --- a/arch/arm/include/asm/uprobes.h +++ b/arch/arm/include/asm/uprobes.h @@ -2,14 +2,16 @@ #define _ASM_UPROBES_H #include +#include typedef u32 uprobe_opcode_t; #define MAX_UINSN_BYTES 4 #define UPROBE_XOL_SLOT_BYTES 64 -#define UPROBE_SWBP_INSN 0xe7f001f9 -#define UPROBE_SS_INSN 0xe7f001fa +#define UPROBE_SWBP_ARM_INSN 0xe7f001f9 +#define UPROBE_SS_ARM_INSN 0xe7f001fa +#define UPROBE_SWBP_INSN __opcode_to_mem_arm(UPROBE_SWBP_ARM_INSN) #define UPROBE_SWBP_INSN_SIZE 4 struct arch_uprobe_task { diff --git a/arch/arm/kernel/uprobes.c b/arch/arm/kernel/uprobes.c index d9873ef..ae18549 100644 --- a/arch/arm/kernel/uprobes.c +++ b/arch/arm/kernel/uprobes.c @@ -22,7 +22,7 @@ bool is_swbp_insn(uprobe_opcode_t *insn) { return (__mem_to_opcode_arm(*insn) & 0x0fffffff) == - (UPROBE_SWBP_INSN & 0x0fffffff); + (UPROBE_SWBP_ARM_INSN & 0x0fffffff); } int set_swbp(struct arch_uprobe *auprobe, struct mm_struct *mm, @@ -83,7 +83,7 @@ int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, insn = __mem_to_opcode_arm(*(unsigned int *)auprobe->insn); auprobe->ixol[0] = __opcode_to_mem_arm(insn); - auprobe->ixol[1] = __opcode_to_mem_arm(UPROBE_SS_INSN); + auprobe->ixol[1] = __opcode_to_mem_arm(UPROBE_SS_ARM_INSN); ret = arm_probes_decode_insn(insn, &auprobe->asi, false, uprobes_probes_actions); @@ -100,7 +100,7 @@ int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, break; } - bpinsn = UPROBE_SWBP_INSN & 0x0fffffff; + bpinsn = UPROBE_SWBP_ARM_INSN & 0x0fffffff; if (insn >= 0xe0000000) bpinsn |= 0xe0000000; /* Unconditional instruction */ else @@ -158,9 +158,9 @@ static int uprobe_trap_handler(struct pt_regs *regs, unsigned int instr) local_irq_save(flags); instr &= 0x0fffffff; - if (instr == (UPROBE_SWBP_INSN & 0x0fffffff)) + if (instr == (UPROBE_SWBP_ARM_INSN & 0x0fffffff)) uprobe_pre_sstep_notifier(regs); - else if (instr == (UPROBE_SS_INSN & 0x0fffffff)) + else if (instr == (UPROBE_SS_ARM_INSN & 0x0fffffff)) uprobe_post_sstep_notifier(regs); local_irq_restore(flags); @@ -174,7 +174,7 @@ unsigned long uprobe_get_swbp_addr(struct pt_regs *regs) static struct undef_hook uprobes_arm_break_hook = { .instr_mask = 0x0fffffff, - .instr_val = (UPROBE_SWBP_INSN & 0x0fffffff), + .instr_val = (UPROBE_SWBP_ARM_INSN & 0x0fffffff), .cpsr_mask = MODE_MASK, .cpsr_val = USR_MODE, .fn = uprobe_trap_handler, @@ -182,7 +182,7 @@ static struct undef_hook uprobes_arm_break_hook = { static struct undef_hook uprobes_arm_ss_hook = { .instr_mask = 0x0fffffff, - .instr_val = (UPROBE_SS_INSN & 0x0fffffff), + .instr_val = (UPROBE_SS_ARM_INSN & 0x0fffffff), .cpsr_mask = MODE_MASK, .cpsr_val = USR_MODE, .fn = uprobe_trap_handler,