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: 2902221 Return-Path: X-Original-To: patchwork-linux-omap@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 B918E9F1BF for ; Tue, 17 Sep 2013 12:45:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 18D5920379 for ; Tue, 17 Sep 2013 12:45:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4C1112037E for ; Tue, 17 Sep 2013 12:45:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752993Ab3IQMoM (ORCPT ); Tue, 17 Sep 2013 08:44:12 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:39040 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752977Ab3IQMoJ (ORCPT ); Tue, 17 Sep 2013 08:44:09 -0400 Received: by mail-pa0-f49.google.com with SMTP id ld10so6687599pab.8 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 Cc: linux-kbuild@vger.kernel.org, Ard Biesheuvel , mans@mansr.com, Shawn Guo , Dave Martin , Russell King - ARM Linux 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> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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