Received: from list by lists.gnu.org with archive (Exim 4.71) id 1VnXMX-0004RS-NQ for mharc-grub-devel@gnu.org; Mon, 02 Dec 2013 12:32:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VnXMQ-0004Ll-Oi for grub-devel@gnu.org; Mon, 02 Dec 2013 12:32:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VnXMK-0002mE-PW for grub-devel@gnu.org; Mon, 02 Dec 2013 12:32:42 -0500 Received: from mail-wi0-f180.google.com ([209.85.212.180]:44612) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VnXMK-0002mA-JE for grub-devel@gnu.org; Mon, 02 Dec 2013 12:32:36 -0500 Received: by mail-wi0-f180.google.com with SMTP id hn9so798053wib.13 for ; Mon, 02 Dec 2013 09:32:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=NJLxmI0HhDVAibTAXHMn2Sh0oFCFfOe5woGmuhax66g=; b=J7NKCQE1GEAY56cVzAqAIPLV5iz3Y308u7gp3vZR0USSId+9l4/rbM+zwE9+zQ0rtj WcXc6ghogpYMD4aSH2Dyw4IJ7QrnlyyggZXnAORLgciXGboJLIoI9ElT+QscxZdGCLDE +rlBN9gd/b9BUWkjQR1QtsMm9l2ZFIZbsdPsvEzkEAqK0XZ9WNv6XSAP5jsWPBmOcu9O FCVWnWCF9/DcYY/rezL76o0C453jFJYpZzcCZEHh3Z0VBo4GawUpcHY85o2UsLkGyyR3 qN70vdm/Hf/Q4Ik9ZY/Jr6pJ8oZkI7oR704j8HVnHx7Xp7k+L9oXi21WlMr9bRRHl+3d PLSg== X-Gm-Message-State: ALoCoQmu3LjV1Fg96S1hO38ShyakoYfFnem0zzd8Dqe7Q1vE3P5AbPYYKfhJelYZfnTsVVN2G/AI X-Received: by 10.180.211.71 with SMTP id na7mr19438736wic.5.1386005555728; Mon, 02 Dec 2013 09:32:35 -0800 (PST) Received: from rocoto.smurfnet.nu ([2001:4b98:dc0:41:216:3eff:fea7:75f3]) by mx.google.com with ESMTPSA id n6sm104456312wix.3.2013.12.02.09.32.32 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 02 Dec 2013 09:32:32 -0800 (PST) Date: Mon, 2 Dec 2013 18:32:47 +0100 From: Leif Lindholm To: The development of GNU GRUB Subject: Re: [PATCH, RFC, RFT] ARM relocation fixes Message-ID: <20131202173247.GJ24997@rocoto.smurfnet.nu> References: <529AD1E8.8010305@gmail.com> <20131202105330.GA24997@rocoto.smurfnet.nu> <529C6820.9090902@gmail.com> <20131202112846.GC24997@rocoto.smurfnet.nu> <529C7305.5070002@gmail.com> <20131202133051.GE24997@rocoto.smurfnet.nu> <20131202141450.GG24997@rocoto.smurfnet.nu> <20131202143306.GI24997@rocoto.smurfnet.nu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20131202143306.GI24997@rocoto.smurfnet.nu> User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.212.180 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: Mon, 02 Dec 2013 17:32:48 -0000 On Mon, Dec 02, 2013 at 03:33:06PM +0100, Leif Lindholm wrote: > > > Ok, so I've tested this on arm64, and it works on the commercial FVP > > > Base model (which does not trigger veneer generation due to its runtime > > > memory map), but crashes on the Foundation model (which does). > > > So the generic dl refactoring seems correct, but somehing about the > > > veneers is fishy. > > > > Well, this one seems to be because mod->trampptr is never initilised > > (which should be a problem also on the other archs?). > > > > With > > diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c > > index 33ccc98..92027e0 100644 > > --- a/grub-core/kern/dl.c > > +++ b/grub-core/kern/dl.c > > @@ -317,6 +317,7 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) > > #if !defined (__i386__) && !defined (__x86_64__) && !defined (__sparc__) > > ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, GRUB_ARCH_DL_TRAMP_ALIGN); > > mod->tramp = ptr; > > + mod->trampptr = (ptr + tramp); > > ptr += tramp; > > ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, GRUB_ARCH_DL_GOT_ALIGN); > > mod->got = ptr; > > > > This runs successfully on my foundation model. > > Umm, that's obviously not correct. But it did work :) > > What is needed is to store the size of the module before adding > trampoline and got sizes. So - after some much needed Lunch, and coffee, I think the below would be correct? diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c index 33ccc98..a83b744 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c @@ -316,10 +316,10 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) } #if !defined (__i386__) && !defined (__x86_64__) && !defined (__sparc__) ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, GRUB_ARCH_DL_TRAMP_ALIGN); - mod->tramp = ptr; + mod->tramp = mod->trampptr = ptr; ptr += tramp; ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, GRUB_ARCH_DL_GOT_ALIGN); - mod->got = ptr; + mod->got = mod->gotptr = ptr; ptr += got; #endif / Leif