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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9FFBC433EF for ; Sun, 17 Oct 2021 13:21:46 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B02FB61261 for ; Sun, 17 Oct 2021 13:21:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B02FB61261 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=bTAcFp3i/MBU5ObVa7UjUy6BS3x+QYFVlzJLsm8ebfM=; b=Olw30VviSEgOe0 9nxurwKZCqP3G+uK8K2/azg1JAHbh5G+CtSfnjcS4E/PryMO+wEBsYBeUyRg2lQceUtT/B4WdOezr jz70yCE1MNENsQWxqZ6T2M5M5oM6YrPN4ev60PIQB4/XDSaCpkRq4VkMjs1nXytlbOQhPq7e7Fs30 lqtdxbY7tWn3+e5qixzK39Jg6lq4sC2kNqB4AOUeJjMQ15E9ehO9jP6/rdnFqpE7AimVgMkZBdGkQ zkvp2BtZDeDTGypHMi9rGy+nJJ7QidT2anOxZ8/NTlgQlUpQtp+yh/Coc6CyoAaLSYMGdrFCSPcxD JiJl9NUNGZKbNtBuL4nA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mc65H-00Cbi6-KU; Sun, 17 Oct 2021 13:20:16 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mc631-00Caed-IO for linux-arm-kernel@lists.infradead.org; Sun, 17 Oct 2021 13:17:56 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1F02661260; Sun, 17 Oct 2021 13:17:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634476675; bh=LFNmcmbv8AoeZVVEZ/A7okfwBcaUiFosuYCBLoolcgs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IN2fJxGkvcuZCXZvBoi+GFH85HlDhgUm1TzmeIwIvp8tKc7u0FfKIVZkEKpny05Jz UG9gQKi2Npa6FpMpQbcZ48Un3DuaC3q4mKdROCvqEc9BkTlZVUu5hpnZhgJeru055G oZe9keCRAZKlKLJYAaTshhBBI2qkMpOVtQXC5zHZ7hOSahPNIP251uKYfVL7ynCCRw aVuldsOvw9bvku3ym7zd8tZPQriH8PrC+pxgpVMQZCic+UsWrm7mQK7YVKSNA7ByeS oqbf0pwcKH4MVW671WO4mWxm+DL9mdz01n/2025cQM9/gmSU1ClKwDig7JFddrz4RH 5Cou79wjKXHEw== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Russell King , Arnd Bergmann , Kees Cook , Keith Packard , Linus Walleij , Nick Desaulniers , Nicolas Pitre Subject: [PATCH v3 09/10] ARM: call_with_stack: add unwind support Date: Sun, 17 Oct 2021 15:17:22 +0200 Message-Id: <20211017131723.4034662-10-ardb@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211017131723.4034662-1-ardb@kernel.org> References: <20211017131723.4034662-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2139; h=from:subject; bh=LFNmcmbv8AoeZVVEZ/A7okfwBcaUiFosuYCBLoolcgs=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBhbCJgoXCFc4tegZoYCByVzjMsEuVgnkzmO1opDNAD Aes/lwyJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYWwiYAAKCRDDTyI5ktmPJNW/C/ 9hImfV2oAOcboNYnUn1/eFs4BnpZEL83KJ2iS1hS7JaIcWuZfwT73rzcXRLlGCbEQ7u2QU1w7z7ui3 UfmXjQ1EhE0HOe2IBimdf2cctmaBqiJMZfZASbn4ZC+LRXhmdSgeoNO1gp4kms8U98nvLHt/0Oza5D zW+IVMCys6heQHhs5HtUkbakluhsh0zZELFqlsf5H51o9PYsJmfK5AurV0zw34Rg/6B1sQNwy0WTyP cpUVuA2H1bK/p4tTibylIy2fAIKsMHk5SC6PCcfc2MjV9Mk6+Z4KWzjX6VTcDCx+hcVGMPrlHin9VB MZ/NjDdQgit0O/Hi/v4uPGL+dj6+IiJ6DuNyXPCli6tJ03yA7Nn+hqG7noyuegTTi1xZxV25tCylYl EFCKxTXpPlqj7nXReiBMVVM8j00iQX/JsRLjBF0vIlqTMT6HECHpeKvTLdFjCWuH2txiY5cRSXddD4 P953A/5+akVGyg2A93BOhDMcZ8/No4U0h3VTviluJ6+KU= 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-20211017_061755_679165_C627C506 X-CRM114-Status: GOOD ( 13.38 ) 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 Restructure the code and add the unwind annotations so that both the frame pointer unwinder as well as the EHABI unwind info based unwinder will be able to follow the call stack through call_with_stack(). Since GCC and Clang use different formats for the stack frame, two methods are implemented: a GCC version that pushes fp, sp, lr and pc for compatibility with the frame pointer unwinder, and a second version that works with Clang, as well as with the EHABI unwinder both in ARM and Thumb2 modes. Signed-off-by: Ard Biesheuvel Acked-by: Linus Walleij Tested-by: Keith Packard --- arch/arm/lib/call_with_stack.S | 33 +++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/arch/arm/lib/call_with_stack.S b/arch/arm/lib/call_with_stack.S index 28b0341ae786..0a268a6c513c 100644 --- a/arch/arm/lib/call_with_stack.S +++ b/arch/arm/lib/call_with_stack.S @@ -8,25 +8,42 @@ #include #include +#include /* * void call_with_stack(void (*fn)(void *), void *arg, void *sp) * * Change the stack to that pointed at by sp, then invoke fn(arg) with * the new stack. + * + * The sequence below follows the APCS frame convention for frame pointer + * unwinding, and implements the unwinder annotations needed by the EABI + * unwinder. */ -ENTRY(call_with_stack) - str sp, [r2, #-4]! - str lr, [r2, #-4]! +ENTRY(call_with_stack) +#if defined(CONFIG_UNWINDER_FRAME_POINTER) && defined(CONFIG_CC_IS_GCC) + mov ip, sp + push {fp, ip, lr, pc} + sub fp, ip, #4 +#else +UNWIND( .fnstart ) +UNWIND( .save {fpreg, lr} ) + push {fpreg, lr} +UNWIND( .setfp fpreg, sp ) + mov fpreg, sp +#endif mov sp, r2 mov r2, r0 mov r0, r1 - badr lr, 1f - ret r2 + bl_r r2 -1: ldr lr, [sp] - ldr sp, [sp, #4] - ret lr +#if defined(CONFIG_UNWINDER_FRAME_POINTER) && defined(CONFIG_CC_IS_GCC) + ldmdb fp, {fp, sp, pc} +#else + mov sp, fpreg + pop {fpreg, pc} +UNWIND( .fnend ) +#endif ENDPROC(call_with_stack) -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel