From patchwork Sat Nov 3 21:41:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 196935 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id B745D2C00D6 for ; Sun, 4 Nov 2012 08:42:29 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 371A54A184; Sat, 3 Nov 2012 22:42:28 +0100 (CET) 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 2p9r2Jq2d0MZ; Sat, 3 Nov 2012 22:42:27 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 14CFE4A142; Sat, 3 Nov 2012 22:42:10 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8EBCC4A160 for ; Sat, 3 Nov 2012 22:42:07 +0100 (CET) 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 oLeVDTqPvQtm for ; Sat, 3 Nov 2012 22:42:06 +0100 (CET) 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 mail-ea0-f202.google.com (mail-ea0-f202.google.com [209.85.215.202]) by theia.denx.de (Postfix) with ESMTPS id 793A44A13F for ; Sat, 3 Nov 2012 22:42:03 +0100 (CET) Received: by mail-ea0-f202.google.com with SMTP id q10so289727eaa.3 for ; Sat, 03 Nov 2012 14:42:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=jfshzBA/djsBGZb2nLy3kN1e9vJTV3SVhLDEkarEkSE=; b=P06K4d0dmb0gogm9LtIGY3uarRV3d44skm8YarIiMjTDfX8v3e3cyxA1V415ePZog/ C016XZU7mZW/I5V9RBIfzdkzHARd58Jztge9J5Z+JHkl35tjXuvEQz8k/qo1nsutv2wj 0krqGzQ8GttiyllWe9HHJmIR00aYMHq7+/b1Pj4h982d9QxRICalHH/ugr39aL+sRdge krFIB52fMFQlQ7SkZql2BKud+P+w5IfFqMl3J2WDB0Kfq/RNRp/xoVCqswFUgI9HKcWX XEJmIZ8esko1qdv0DH5t1cIjQCyxSp3iZ2JnWMOs1Ez/22Lq+SIw7gOZemK7dsYM3jnL u/qA== Received: by 10.14.213.135 with SMTP id a7mr5857447eep.2.1351978923132; Sat, 03 Nov 2012 14:42:03 -0700 (PDT) Received: from hpza10.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id u8si2320498een.1.2012.11.03.14.42.03 (version=TLSv1/SSLv3 cipher=AES128-SHA); Sat, 03 Nov 2012 14:42:03 -0700 (PDT) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by hpza10.eem.corp.google.com (Postfix) with ESMTP id BFAF3200057; Sat, 3 Nov 2012 14:42:02 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 239221618EB; Sat, 3 Nov 2012 14:42:02 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Sat, 3 Nov 2012 14:41:24 -0700 Message-Id: <1351978902-23719-3-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1351978902-23719-1-git-send-email-sjg@chromium.org> References: <1351978902-23719-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQmM96WNwZNETZPCB7cS0yI5jL9g1OFDKpGhRycop7Eq+hU+hNxb+TM8bYmQdgur07cZuiJfDFDe0wBaJX1nNu61qbjVZuiaBSnBFTU6n/z+/6oEmQUr5N+ybqrqIxp2qP5GgGwmInsQZ/p63DARvp/g7a/jzE4xvem4HXHnmggv8pscQ/gyrfS87c+Sn4F6UPa80GGJ Cc: Gabe Black Subject: [U-Boot] [PATCH 02/20] x86: Reorder x86's post relocation memory layout X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion 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 From: Gabe Black This changes the layout in decreasing addresses from: 1. Stack 2. Sections in the image 3. Heap to 1. Sections in the image 2. Heap 3. Stack This allows the stack to grow significantly more since it isn't constrained by the other u-boot areas. More importantly, the generic memory wipe code assumes that the stack is the lowest addressed area used by the main part of u-boot. In the original layout, that means that u-boot tramples all over itself. In the new layout, it works. Signed-off-by: Gabe Black Signed-off-by: Simon Glass --- arch/x86/lib/init_helpers.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-) diff --git a/arch/x86/lib/init_helpers.c b/arch/x86/lib/init_helpers.c index 4a6d9f3..6032ee5 100644 --- a/arch/x86/lib/init_helpers.c +++ b/arch/x86/lib/init_helpers.c @@ -96,16 +96,15 @@ int calculate_relocation_address(void) dest_addr &= ~15; gd->gdt_addr = dest_addr; - /* Stack is below GDT */ - gd->start_addr_sp = dest_addr; - - /* U-Boot is below the stack */ - dest_addr -= CONFIG_SYS_STACK_SIZE; + /* U-Boot is below Global Data */ dest_addr -= (bss_end - text_start); dest_addr &= ~15; gd->relocaddr = dest_addr; gd->reloc_off = (dest_addr - text_start); + /* Stack is at the bottom, so it can grow down */ + gd->start_addr_sp = dest_addr - CONFIG_SYS_MALLOC_LEN; + return 0; }