From patchwork Sat Apr 26 12:17:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 29154 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f200.google.com (mail-ob0-f200.google.com [209.85.214.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 63152202E6 for ; Sat, 26 Apr 2014 12:18:51 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id vb8sf28631454obc.7 for ; Sat, 26 Apr 2014 05:18:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=G9JT5CrPzdDtJg8gm/8wXxmKy2KNugAixGbPRqVqkMk=; b=j/wh+/3G5fn6QXPYc7ybDuvQOz35Nq0S2uZ6skX0+wP3tIvCWRTSRRXTifECjV8ZOV V9LbY47XS+0ZGkC1G1VRZq8YA8GMUL8e4n7ZOiaRNgORFVEAmAfjZQI199EKu6zl9Kag 9B00kxWP5F1hrAYbvZ/nCqctd21T1LLpTLWLm73SlnUMwc7cF0iaknUPL8BIL5E7mSLo SuT+X6COXAQ4nnV0FNT6O/eftqE7CroeOEuMawHFk8W0KJ42wCFe4cw2Y/pYcdd7Al8w FcDJAlfDJn7ahqDOchT1g5rocYKK9zLF4fLgHN9QAG89TSawAMWRKWbY8nOkJ2r4EU/9 uUCA== X-Gm-Message-State: ALoCoQmCdaXK0mdFzITqGME2rpmaYR1cuWftiVg0xAA6+2JOSTp+ldtrRAF1aqnS9zOwv4JdCmwk X-Received: by 10.182.28.99 with SMTP id a3mr7561326obh.40.1398514730969; Sat, 26 Apr 2014 05:18:50 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.102.180 with SMTP id w49ls1998882qge.3.gmail; Sat, 26 Apr 2014 05:18:50 -0700 (PDT) X-Received: by 10.52.175.166 with SMTP id cb6mr10131006vdc.1.1398514730759; Sat, 26 Apr 2014 05:18:50 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id vg8si2407284veb.39.2014.04.26.05.18.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 26 Apr 2014 05:18:50 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id lg15so6063801vcb.16 for ; Sat, 26 Apr 2014 05:18:50 -0700 (PDT) X-Received: by 10.52.53.101 with SMTP id a5mr10416050vdp.14.1398514730670; Sat, 26 Apr 2014 05:18:50 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp164819vcb; Sat, 26 Apr 2014 05:18:50 -0700 (PDT) X-Received: by 10.14.213.6 with SMTP id z6mr270018eeo.98.1398514729831; Sat, 26 Apr 2014 05:18:49 -0700 (PDT) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id z2si16518643eeo.124.2014.04.26.05.18.48 for ; Sat, 26 Apr 2014 05:18:49 -0700 (PDT) Received-SPF: none (google.com: u-boot-bounces@lists.denx.de does not designate permitted sender hosts) client-ip=85.214.87.163; Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A7DF2A73EF; Sat, 26 Apr 2014 14:18:23 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JY+qwnTVkW8F; Sat, 26 Apr 2014 14:18:23 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7A6BDA7437; Sat, 26 Apr 2014 14:17:40 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 551F34BF5B for ; Sat, 26 Apr 2014 14:17:33 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id H+1RXjRCj5yL for ; Sat, 26 Apr 2014 14:17:33 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from inca-roads.misterjones.org (inca-roads.misterjones.org [213.251.177.50]) by theia.denx.de (Postfix) with ESMTPS id 9703E4BFC1 for ; Sat, 26 Apr 2014 14:17:20 +0200 (CEST) Received: from [2.125.202.75] (helo=why.wild-wind.fr.eu.org) by cheepnis.misterjones.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA256:128) (Exim 4.80) (envelope-from ) id 1We1Xk-0003DF-5F; Sat, 26 Apr 2014 14:17:20 +0200 From: Marc Zyngier To: u-boot@lists.denx.de Date: Sat, 26 Apr 2014 13:17:06 +0100 Message-Id: <1398514631-23956-6-git-send-email-marc.zyngier@arm.com> X-Mailer: git-send-email 1.9.2 In-Reply-To: <1398514631-23956-1-git-send-email-marc.zyngier@arm.com> References: <1398514631-23956-1-git-send-email-marc.zyngier@arm.com> X-SA-Exim-Connect-IP: 2.125.202.75 X-SA-Exim-Rcpt-To: u-boot@lists.denx.de, albert.u.boot@aribaud.net X-SA-Exim-Mail-From: marc.zyngier@arm.com X-SA-Exim-Scanned: No (on cheepnis.misterjones.org); SAEximRunCond expanded to false Subject: [U-Boot] [PATCH v4 05/10] ARM: HYP/non-sec: add separate section for secure code X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: marc.zyngier@arm.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 In anticipation of refactoring the HYP/non-secure code to run from secure RAM, add a new linker section that will contain that code. Nothing is using it just yet. Signed-off-by: Marc Zyngier --- arch/arm/config.mk | 2 +- arch/arm/cpu/u-boot.lds | 30 ++++++++++++++++++++++++++++++ arch/arm/lib/sections.c | 2 ++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/arch/arm/config.mk b/arch/arm/config.mk index 66ecc2e..a729ed2 100644 --- a/arch/arm/config.mk +++ b/arch/arm/config.mk @@ -113,7 +113,7 @@ endif ifdef CONFIG_ARM64 OBJCOPYFLAGS += -j .text -j .rodata -j .data -j .u_boot_list -j .rela.dyn else -OBJCOPYFLAGS += -j .text -j .rodata -j .hash -j .data -j .got.plt -j .u_boot_list -j .rel.dyn +OBJCFLAGS += -j .text -j .secure_text -j .rodata -j .hash -j .data -j .got.plt -j .u_boot_list -j .rel.dyn endif ifneq ($(CONFIG_IMX_CONFIG),) diff --git a/arch/arm/cpu/u-boot.lds b/arch/arm/cpu/u-boot.lds index 33c1f99..f45885d 100644 --- a/arch/arm/cpu/u-boot.lds +++ b/arch/arm/cpu/u-boot.lds @@ -7,6 +7,8 @@ * SPDX-License-Identifier: GPL-2.0+ */ +#include + OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") OUTPUT_ARCH(arm) ENTRY(_start) @@ -22,6 +24,34 @@ SECTIONS *(.text*) } +#if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_ARMV7_VIRT) || defined(CONFIG_ARMV7_PSCI) + +#ifndef CONFIG_ARMV7_SECURE_BASE +#define CONFIG_ARMV7_SECURE_BASE +#endif + + .__secure_start : { + . = ALIGN(0x1000); + *(.__secure_start) + } + + .secure_text CONFIG_ARMV7_SECURE_BASE : + AT(ADDR(.__secure_start) + SIZEOF(.__secure_start)) + { + *(._secure.text) + } + + . = LOADADDR(.__secure_start) + + SIZEOF(.__secure_start) + + SIZEOF(.secure_text); + + __secure_end_lma = .; + .__secure_end : AT(__secure_end_lma) { + *(.__secure_end) + LONG(0x1d1071c); /* Must output something to reset LMA */ + } +#endif + . = ALIGN(4); .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) } diff --git a/arch/arm/lib/sections.c b/arch/arm/lib/sections.c index 5b30bcb..a1205c3 100644 --- a/arch/arm/lib/sections.c +++ b/arch/arm/lib/sections.c @@ -25,4 +25,6 @@ char __image_copy_start[0] __attribute__((section(".__image_copy_start"))); char __image_copy_end[0] __attribute__((section(".__image_copy_end"))); char __rel_dyn_start[0] __attribute__((section(".__rel_dyn_start"))); char __rel_dyn_end[0] __attribute__((section(".__rel_dyn_end"))); +char __secure_start[0] __attribute__((section(".__secure_start"))); +char __secure_end[0] __attribute__((section(".__secure_end"))); char _end[0] __attribute__((section(".__end")));