Received: from list by lists.gnu.org with archive (Exim 4.71) id 1UZeoZ-0008T7-SJ for mharc-grub-devel@gnu.org; Tue, 07 May 2013 06:08:07 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZeoU-0008MF-Km for grub-devel@gnu.org; Tue, 07 May 2013 06:08:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UZeoO-0002bD-2I for grub-devel@gnu.org; Tue, 07 May 2013 06:08:02 -0400 Received: from mail-ee0-f46.google.com ([74.125.83.46]:60698) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZeoN-0002az-T0 for grub-devel@gnu.org; Tue, 07 May 2013 06:07:56 -0400 Received: by mail-ee0-f46.google.com with SMTP id b57so199652eek.19 for ; Tue, 07 May 2013 03:07:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition :content-transfer-encoding:in-reply-to:user-agent:x-gm-message-state; bh=RwNXIzBvHOX7xWvai132r5e6Qwc1yyZ/KEZw2ASexJg=; b=X1Ym1bbMbhJGaD847fuRdjYcWdMjCPYNo5H9XsoADHARVXf4P9BfE8FmVMRdSjlBko 4cHjtkssZtI3Uy64EtKpAdBS0zcCZ/4lH3WXudhfzCeYHj2W6swGIgMmfVlqHFPPmBpC pkq2DHzO8Njs6ymzU9LDHI63aeXyOj1hydxA3EQywCFiqsEv1XconfDhl5rqpjfICGpH wg0WPUAtDS3yv0TqGeovJ+0tGh0g4j+92JL9xfNyh54yA5FObhKUHj/6ok9hRCMKFpwJ 5DzBlGDto6hmnZ9FMYpoII6Hpvy0k72NHzJOS8/3pqwieauLJ6sfRUxy7ryn3EndbHyU GNVA== X-Received: by 10.14.88.196 with SMTP id a44mr3900974eef.8.1367921274482; Tue, 07 May 2013 03:07:54 -0700 (PDT) Received: from rocoto.smurfnet.nu ([2001:4b98:dc0:41:216:3eff:fea7:75f3]) by mx.google.com with ESMTPSA id e50sm38274268eev.13.2013.05.07.03.07.52 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 07 May 2013 03:07:53 -0700 (PDT) Date: Tue, 7 May 2013 10:08:27 +0000 From: Leif Lindholm To: Vladimir =?utf-8?Q?'=CF=86-coder=2Fphcoder'?= Serbinenko Subject: Re: ARM branch Message-ID: <20130507100826.GE28516@rocoto.smurfnet.nu> References: <51684561.1040002@gmail.com> <20130501183258.GB28516@rocoto.smurfnet.nu> <5183AEC3.50408@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ieNMXl1Fr3cevapt" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5183AEC3.50408@gmail.com> User-Agent: Mutt/1.5.20 (2009-06-14) X-Gm-Message-State: ALoCoQkykLBen/KtAHYxfy12OOIVrCWKZiRcooJq0jzMQkHzeSMgAzCs7H/bwC+Nt47Fae7D4Cvn X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 74.125.83.46 Cc: The development of GNU GRUB X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 May 2013 10:08:06 -0000 --ieNMXl1Fr3cevapt Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Fri, May 03, 2013 at 02:34:11PM +0200, Vladimir 'φ-coder/phcoder' Serbinenko wrote: > > It does also revert the removal of uboot_get_real_bss_start, since > > this causes GRUB to fail even reaching "Welcome to GRUB!" on my > > Trimslice. It may not be the best solution, but it is in there for a > > reason. > > Why was this revert necessary? The C code and asm code seem to mirror > each other The diference is in the assigning of grub_modbase, which ends up pointing at an unaligned address, since __bss_start is not pointing to the first variable allocated in BSS, but at the byte immediately following the preceding segment. Since the preceding segment is the license one, containing only strings, that segment may end on any alignment - and currently my build includes license statements in the kernel, since (for example) term/terminfo.c has a GRUB_MOD_LICENSE unconditionally included, even when built into the kernel. I should however simply have moved this assignment into startup.S. Patch attached. / Leif --ieNMXl1Fr3cevapt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="grub_modbase_fix.patch" === modified file 'grub-core/kern/arm/uboot/startup.S' --- grub-core/kern/arm/uboot/startup.S 2013-04-28 23:59:17 +0000 +++ grub-core/kern/arm/uboot/startup.S 2013-04-30 20:55:46 +0000 @@ -79,6 +79,8 @@ add r3, r0, r2 @ blob end cmp r1, r3 @ _end < blob end? movlt r1, r3 @ dst = blob end + blob size + ldr r12, =EXT_C(grub_modbase) + str r1, [r12] @ grub_modbase = dst 1: ldr r3, [r0], #4 @ r3 = *src++ str r3, [r1], #4 @ *dst++ = r3 === modified file 'grub-core/kern/uboot/init.c' --- grub-core/kern/uboot/init.c 2013-04-28 22:14:05 +0000 +++ grub-core/kern/uboot/init.c 2013-04-30 20:59:19 +0000 @@ -31,8 +31,6 @@ #include #include -extern char __bss_start[]; -extern char _end[]; extern grub_size_t grub_total_module_size; extern int (*grub_uboot_syscall_ptr) (int, int *, ...); @@ -70,7 +68,6 @@ void grub_machine_init (void) { - grub_addr_t end, real_bss_start; int ver; /* First of all - establish connection with U-Boot */ @@ -86,26 +83,12 @@ grub_uboot_puts ("invalid U-Boot API version\n"); } - /* - * Modules were relocated to _end, or __bss_start + grub_total_module_size, - * whichever greater. (And __bss_start may not point to actual BSS start...) - */ - real_bss_start = grub_uboot_get_real_bss_start (); - end = real_bss_start + grub_total_module_size; - if (end < (grub_addr_t) _end) - end = (grub_addr_t) _end; - grub_modbase = end; - /* Initialize the console so that GRUB can display messages. */ grub_console_init_early (); /* Enumerate memory and initialize the memory management system. */ grub_uboot_mm_init (); - grub_dprintf ("init", "__bss_start: 0x%08x, real_bss_start: 0x%08x\n", - (grub_addr_t) __bss_start, real_bss_start); - grub_dprintf ("init", "end: 0x%08x, _end: 0x%08x\n", - (grub_addr_t) end, (grub_addr_t) _end); grub_dprintf ("init", "grub_modbase: %p\n", (void *) grub_modbase); grub_dprintf ("init", "grub_modules_get_end(): %p\n", (void *) grub_modules_get_end ()); --ieNMXl1Fr3cevapt--