From patchwork Tue Sep 17 12:43:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russ Dill X-Patchwork-Id: 2902421 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 09208BFF05 for ; Tue, 17 Sep 2013 12:47:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 04DCF20377 for ; Tue, 17 Sep 2013 12:47:25 +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 F36FE2037E for ; Tue, 17 Sep 2013 12:47:19 +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 1VLufB-0000wR-Hw; Tue, 17 Sep 2013 12:45:55 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VLuef-0004Eo-3O; Tue, 17 Sep 2013 12:45:21 +0000 Received: from mail-pa0-x234.google.com ([2607:f8b0:400e:c03::234]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VLudq-00045u-Mo for linux-arm-kernel@lists.infradead.org; Tue, 17 Sep 2013 12:44:36 +0000 Received: by mail-pa0-f52.google.com with SMTP id kq13so6708139pab.25 for ; Tue, 17 Sep 2013 05:44:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=LA5CZppmTEY79+lXdlidVjAs2Eq/sFO9MozD5l7IB7E=; b=XHn46deS5cKxTTkqEFEUYco5+e8RiLGxezZdeHtBSdf/E1cVP9hSg9zTS50ucWpekf fuudPo5kEryFVkYyhlY+CT4TKzLZWzkVoR1cPI2iQiY6HtJNQwyFiARGDv7h1kux0JHV 9JEpJGYcyU6YlEFZsCaAkJZKtOKYIm0lNRP5tQfFyhIvWdH+mvi/MY0YUXlz+397CxxY OHBzejgRmp0LniRaFUujfPnYnDoayAX8o0OLFBPOE6ORPrgUaCDIAWtwbUtCEkEAGyHX DzsNxZ1F/HuYB6V53sOxwydrGtCtG8m4c7TOd7YGSaMEPylSA57suLfBiLcWbryZQTtb sxEg== X-Received: by 10.66.140.40 with SMTP id rd8mr13390528pab.119.1379421849179; Tue, 17 Sep 2013 05:44:09 -0700 (PDT) Received: from localhost (pool-71-189-49-9.lsanca.fios.verizon.net. [71.189.49.9]) by mx.google.com with ESMTPSA id ha10sm38034177pbc.23.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 17 Sep 2013 05:44:08 -0700 (PDT) From: Russ Dill To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org Subject: [RFC PATCH 08/11] ARM: PIE: Add macro for generating PIE resume trampoline Date: Tue, 17 Sep 2013 05:43:34 -0700 Message-Id: <1379421817-15759-9-git-send-email-Russ.Dill@ti.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1379421817-15759-1-git-send-email-Russ.Dill@ti.com> References: <1379421817-15759-1-git-send-email-Russ.Dill@ti.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130917_084430_923615_CCB50037 X-CRM114-Status: GOOD ( 11.02 ) X-Spam-Score: -1.9 (-) Cc: mans@mansr.com, Russell King - ARM Linux , Ard Biesheuvel , linux-kbuild@vger.kernel.org, Shawn Guo , Dave Martin 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: , MIME-Version: 1.0 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,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,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 Add a helper that generates a short snippet of code that updates PIE relocations, loads the stack pointer and calls a C (or asm) function. The code gets placed into a PIE section. Signed-off-by: Russ Dill --- arch/arm/include/asm/suspend.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/arch/arm/include/asm/suspend.h b/arch/arm/include/asm/suspend.h index cd20029..92996f0 100644 --- a/arch/arm/include/asm/suspend.h +++ b/arch/arm/include/asm/suspend.h @@ -1,6 +1,8 @@ #ifndef __ASM_ARM_SUSPEND_H #define __ASM_ARM_SUSPEND_H +#include + struct sleep_save_sp { u32 *save_ptr_stash; u32 save_ptr_stash_phys; @@ -9,4 +11,27 @@ struct sleep_save_sp { extern void cpu_resume(void); extern int cpu_suspend(unsigned long, int (*)(unsigned long)); +/** + * ARM_PIE_RESUME - generate a PIE trampoline for resume + * @proc: SoC, should match argument used with PIE_OVERLAY_SECTION() + * @func: C or asm function to call at resume + * @stack: stack to use before calling func + */ +#define ARM_PIE_RESUME(proc, func, stack) \ +static void __naked __noreturn __pie(proc) proc##_resume_trampoline2(void) \ +{ \ + __asm__ __volatile__( \ + " mov sp, %0\n" \ + : : "r"((stack)) : "sp"); \ + \ + func(); \ +} \ + \ +void __naked __noreturn __pie(proc) proc##_resume_trampoline(void) \ +{ \ + pie_relocate_from_pie(); \ + proc##_resume_trampoline2(); \ +} \ +EXPORT_PIE_SYMBOL(proc##_resume_trampoline) + #endif