From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0359BC433EF for ; Mon, 31 Jan 2022 17:17:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8wWMYkbjhGl5ElQiFenRanCv5j8O1gKiq07l6JtCX8s=; b=EsWu6m6msKjKY2 hIgaRwqk+Hdv4hgHSHXqKlTFZ/WDSii2R5/XiePySFiytFemUZRRy2Fl9jJMTRnvdbig7vjjNSAGu svHwe4tQxkoErfzUmVbxcIEZF+4Ra98eyOYu76pAvhgNNGVBkJySSG2HmOLpKUTHRyb4Kq7FnBXIU 5n0GEA8HsdqMN9TarG0wm46JN/Mab51AosQKWLmHsSJIKGcauumjL2BV3HyDXh5fPaXBxszCqcc44 l3f8c9uNuPU5FVe+Tba+cjeGSo6Dec9jK0ylE/1y/ENeRTXlZRvqm58kwCxsuXotMl7RKgW6bQCBg pUkhD4BO1HmcRejKPI6Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nEaGg-00A2WC-6S; Mon, 31 Jan 2022 17:15:07 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nEa5w-009zEi-UW for linux-arm-kernel@lists.infradead.org; Mon, 31 Jan 2022 17:04:02 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 62BB960C85; Mon, 31 Jan 2022 17:04:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8725DC340ED; Mon, 31 Jan 2022 17:03:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643648639; bh=HclYpXTSNqJKBzgBzXyjv9CWkzj7W8kHLWS9fA6oM2Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SdVvQvyJx1rHg4fm2b5vnaZoibGmuJvdN1SNvg6AwIJBgJsjOVo9PYAWqMlLyj1aA xOeDQnKedf+VX25C7ye9awUKl/o5Ix8q7+kqeqrLVb4ufY6K5gL2i5NuACHjuA2UJM C5i1GC2oDQ9/FLh5cpZjgqNijM1nb0q3H2T3x8LQz/wpFd2LG4viUOOx35xx/NmyZt W2gC/SjJs/tpf4XmVZQLexckDdkx/GzNvOXAa5a5U9tBc+0Nt+v79Mt7PMean4kzUN 67al5aKrPUK/kGafEILpE2gPqdr2eanh7R4R82R+cNg8HDaYt/831pAdgyUhQVUMcZ 2E0sB9mjBoOMw== From: Ard Biesheuvel To: linux@armlinux.org.uk Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Steven Rostedt , Sudeep Holla , Cristian Marussi , Nathan Chancellor , Nick Desaulniers , Arnd Bergmann , Linus Walleij , Masami Hiramatsu Subject: [PATCH v2 02/12] ARM: ftrace: use ADD not POP to counter PUSH at entry Date: Mon, 31 Jan 2022 18:03:37 +0100 Message-Id: <20220131170347.381551-3-ardb@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220131170347.381551-1-ardb@kernel.org> References: <20220131170347.381551-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1805; h=from:subject; bh=HclYpXTSNqJKBzgBzXyjv9CWkzj7W8kHLWS9fA6oM2Q=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBh+BZf+zEixdSfwQwbVqA9YM8m4Oq/RdshGBQcvTJW M7/TObqJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYfgWXwAKCRDDTyI5ktmPJJnhC/ 9acH0sctW6rOWzKmEP05p/j7U8AMCkixtnYgoRxn2YZmOUbQzkLt02zadzTvQSUs7aHRPtzYCG0teU FvjDy0bYazAbuPLoE57ILf9Dq3HjO9v7jeEcB7hDcLhjN53Mq0uDDZoYKNVVbWGmzp8TAiTjCcu/dA 6ka1FxY1IKFMysVEId5A5UZ924tghbRy9VMJBA0UuwNxTp4sJ/TBEiUqqyUEnn0qjg62h7UGTQ1qRS doFk1GEWvo4R1PXisWU3oW1qUcchZKz07I0g+6cLryy/DT5ETrBAnrLn2Tf+NKFH3zDWzVJWg7OXUY XLjlj/22uzc3RV9GcRMewRs5ufCbIUcmq1Ovnt1xCuIvUyINKXHiw5ywtwIs9jHXkggreeJ+sJ5Iy1 4uBHJw/ZoT+YODW+H5h2LPitvDjBGVHXXQYbz5BbpghsipEz72dwubj/cZsTsOBoraV9vCtB3Ez5fU irJe71f2FfYMY80IcBiGEHkWjs5FgYbs5ytdJtvyBqV2o= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220131_090401_106296_84EB4BCD X-CRM114-Status: GOOD ( 18.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The compiler emitted hook used for ftrace consists of a PUSH {LR} to preserve the link register, followed by a branch-and-link (BL) to __gnu_mount_nc. Dynamic ftrace patches away the latter to turn the combined sequence into a NOP, using a POP {LR} instruction. This is not necessary, since the link register does not get clobbered in this case, and simply adding #4 to the stack pointer is sufficient, and avoids a memory access that may take a few cycles to resolve depending on the micro-architecture. Signed-off-by: Ard Biesheuvel Reviewed-by: Nick Desaulniers --- arch/arm/kernel/entry-ftrace.S | 2 +- arch/arm/kernel/ftrace.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/kernel/entry-ftrace.S b/arch/arm/kernel/entry-ftrace.S index f4886fb6e9ba..dca12a09322a 100644 --- a/arch/arm/kernel/entry-ftrace.S +++ b/arch/arm/kernel/entry-ftrace.S @@ -27,7 +27,7 @@ * allows it to be clobbered in subroutines and doesn't use it to hold * parameters.) * - * When using dynamic ftrace, we patch out the mcount call by a "pop {lr}" + * When using dynamic ftrace, we patch out the mcount call by a "add sp, #4" * instead of the __gnu_mcount_nc call (see arch/arm/kernel/ftrace.c). */ diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c index a006585e1c09..db72d3a6522d 100644 --- a/arch/arm/kernel/ftrace.c +++ b/arch/arm/kernel/ftrace.c @@ -25,9 +25,9 @@ #include #ifdef CONFIG_THUMB2_KERNEL -#define NOP 0xf85deb04 /* pop.w {lr} */ +#define NOP 0xf10d0d04 /* add.w sp, sp, #4 */ #else -#define NOP 0xe8bd4000 /* pop {lr} */ +#define NOP 0xe28dd004 /* add sp, sp, #4 */ #endif #ifdef CONFIG_DYNAMIC_FTRACE -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel