From patchwork Tue Dec 6 17:06:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 9462933 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A121A60231 for ; Tue, 6 Dec 2016 17:09:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B35D28480 for ; Tue, 6 Dec 2016 17:09:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7FD7328486; Tue, 6 Dec 2016 17:09:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3B2F828480 for ; Tue, 6 Dec 2016 17:09:49 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cEJDX-0004ky-ST; Tue, 06 Dec 2016 17:07:47 +0000 Received: from mail-wj0-f195.google.com ([209.85.210.195]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cEJCf-00045o-Hg for linux-arm-kernel@lists.infradead.org; Tue, 06 Dec 2016 17:06:55 +0000 Received: by mail-wj0-f195.google.com with SMTP id kp2so45046862wjc.0 for ; Tue, 06 Dec 2016 09:06:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HNUsAPnoohbK+w69if/9PNjzx9ma+ARZhtvJ5JM8QWA=; b=lE49Xs1UrNc1KjOIQQqZ24a1lePBM4CQH7zr7ovqqwG0La/f60zMox3V+9O5cFT65N RqepV9+6vBIQjFuhVUlbWG/hfJ2vRehG8Rqt1pQ5EeXSXmqTyhVI36bEsYlS58SGZqur lBxWtVma9KhMuoLOfYeSHVbh4zr6hFOM/mNNBz7I8tzf1dEQs4xJ/400bL/MDyJPPbxG D6vsPzplWoSx/ZREgNevf5Bahd1LlrmgV8zKvfGck6FuvVK3Q/KDd+yxNm+GcbAhyVe2 L33S6cQVf+tIBbsjPWj3PPyaTU0/ikE0OxEb9qVEMSr/lPUMXmRerbSFIgMSDYNb1OXB ftZg== X-Gm-Message-State: AKaTC02u8IIgL7TzERjIA4kfoLZ1ynGczUre72wsIV43OCiiugouB0Ps6mXt9uUIu6k5PQ== X-Received: by 10.194.111.102 with SMTP id ih6mr54000471wjb.214.1481043987955; Tue, 06 Dec 2016 09:06:27 -0800 (PST) Received: from gce.c.kernel-work.internal (115.57.155.104.bc.googleusercontent.com. [104.155.57.115]) by smtp.gmail.com with ESMTPSA id l67sm4942458wmf.20.2016.12.06.09.06.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Dec 2016 09:06:26 -0800 (PST) From: Abel Vesa To: linux@armlinux.org.uk, jpoimboe@redhat.com, jeyu@redhat.com, jikos@kernel.org, mbenes@suse.cz, pmladek@suse.com Subject: [PATCH 4/7] arm: Add ftrace with regs support Date: Tue, 6 Dec 2016 17:06:04 +0000 Message-Id: <1481043967-15602-5-git-send-email-abelvesa@linux.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481043967-15602-1-git-send-email-abelvesa@linux.com> References: <1481043967-15602-1-git-send-email-abelvesa@linux.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161206_090653_904561_DCBCEC65 X-CRM114-Status: UNSURE ( 8.71 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, geert+renesas@glider.be, ard.biesheuvel@linaro.org, jean-philippe.brucker@arm.com, gregkh@linuxfoundation.org, stefano.stabellini@eu.citrix.com, emil.l.velikov@gmail.com, linux-kernel@vger.kernel.org, rostedt@goodmis.org, jens.wiklander@linaro.org, Abel Vesa , chris.brandt@renesas.com, mingo@redhat.com, viro@zeniv.linux.org.uk, live-patching@vger.kernel.org, akpm@linux-foundation.org, mchehab@kernel.org, davem@davemloft.net, linux@roeck-us.net MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This adds __ftrace_regs_caller which, unlike __ftrace_caller, adds register saving/restoring and livepatch handling if the pc register gets modified by klp_ftrace_handler. Signed-off-by: Abel Vesa --- arch/arm/kernel/entry-ftrace.S | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/arch/arm/kernel/entry-ftrace.S b/arch/arm/kernel/entry-ftrace.S index c73c403..b6ada5c 100644 --- a/arch/arm/kernel/entry-ftrace.S +++ b/arch/arm/kernel/entry-ftrace.S @@ -92,6 +92,46 @@ 2: mcount_exit .endm +#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS + +.macro __ftrace_regs_caller suffix + + stmdb sp!, {r0-r15} + mov r3, sp + + ldr r10, [sp, #60] + + mcount_get_lr r1 @ lr of instrumented func + mcount_adjust_addr r0, lr @ instrumented function + + .globl ftrace_regs_call\suffix +ftrace_regs_call\suffix: + bl ftrace_stub + +#ifdef CONFIG_FUNCTION_GRAPH_TRACER + .globl ftrace_regs_graph_call\suffix +ftrace_regs_graph_call\suffix: + mov r0, r0 +#endif +#ifdef CONFIG_LIVEPATCH + ldr r0, [sp, #60] + cmp r0, r10 + beq ftrace_regs_caller_end + ldmia sp!, {r0-r12} + add sp, sp, #8 + ldmia sp!, {r11} + sub sp, r12, #16 + str r11, [sp, #12] + ldmia sp!, {r11, r12, lr, pc} +#endif +ftrace_regs_caller_end\suffix: + ldmia sp!, {r0-r14} + add sp, sp, #4 + mov pc, lr +.endm + +#endif + .macro __ftrace_caller suffix mcount_enter @@ -212,6 +252,15 @@ UNWIND(.fnstart) __ftrace_caller UNWIND(.fnend) ENDPROC(ftrace_caller) + +#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS +ENTRY(ftrace_regs_caller) +UNWIND(.fnstart) + __ftrace_regs_caller +UNWIND(.fnend) +ENDPROC(ftrace_regs_caller) +#endif + #endif #ifdef CONFIG_FUNCTION_GRAPH_TRACER