From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1YGcGd-0004Qw-Dj for mharc-grub-devel@gnu.org; Wed, 28 Jan 2015 18:43:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42985) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGcGZ-0004Ox-Pi for grub-devel@gnu.org; Wed, 28 Jan 2015 18:43:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGcGU-0005BF-V0 for grub-devel@gnu.org; Wed, 28 Jan 2015 18:43:23 -0500 Received: from cheddar.halon.org.uk ([217.10.144.130]:47388) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGcGU-0005AB-On for grub-devel@gnu.org; Wed, 28 Jan 2015 18:43:18 -0500 Received: from bsmtp by cheddar.halon.org.uk with local-bsmtp (Exim 4.80) (envelope-from ) id 1YGcGM-0003dh-Ru; Wed, 28 Jan 2015 23:43:11 +0000 Received: from steve by tack.local with local (Exim 4.80) (envelope-from ) id 1YGcFS-0004wO-Mb; Wed, 28 Jan 2015 23:42:14 +0000 Date: Wed, 28 Jan 2015 23:42:14 +0000 From: Steve McIntyre To: Andrei Borzenkov Subject: Re: [PATCH] Add support for running a 64-bit Linux kernel on a 32-bit EFI Message-ID: <20150128234208.GK20325@einval.com> References: <20150128005625.GC20325@einval.com> <20150128064201.644640cc@opensuse.site> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20150128064201.644640cc@opensuse.site> X-attached: none User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 217.10.144.130 Cc: grub-devel@gnu.org 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: Wed, 28 Jan 2015 23:43:24 -0000 On Wed, Jan 28, 2015 at 06:42:01AM +0300, Andrei Borzenkov wrote: >В Wed, 28 Jan 2015 00:56:30 +0000 >Steve McIntyre пишет: > >> >> ===================================================================== >> Some platforms might be capable of running a 64-bit Linux kernel but >> only use a 32-bit EFI. To support such systems, it is necessary to >> work out the size of the firmware rather than just the size of the >> kernel. To enable that, there is now an extra EFI sysfs file to >> describe the underlying firmware. Read that if possible, otherwise >> fall back to the kernel type as before. >> >> Signed-off-by: Steve McIntyre >> --- >> grub-core/osdep/linux/platform.c | 38 +++++++++++++++++++++++++++++++++++++- >> 1 file changed, 37 insertions(+), 1 deletion(-) >> >> diff --git a/grub-core/osdep/linux/platform.c b/grub-core/osdep/linux/platform.c >> index 4b9f6ef..5668ae5 100644 >> --- a/grub-core/osdep/linux/platform.c >> +++ b/grub-core/osdep/linux/platform.c >> @@ -60,6 +60,42 @@ is_64_kernel (void) >> return strcmp (un.machine, "x86_64") == 0; >> } >> >> +static int >> +read_platform_size (void) >> +{ >> + FILE *fp; >> + char *buf = NULL; >> + size_t len = 0; >> + int ret = 0; >> + >> + /* Newer kernels can tell us directly about the size of the >> + * underlying firmware - let's see if that interface is there. */ >> + fp = grub_util_fopen ("/sys/firmware/efi/fw_platform_size", "r"); >> + if (fp != NULL) >> + { >> + if (getline (&buf, &len, fp) > 0) > >size >= 2 Yup. >> + { >> + if (strncmp (buf, "32", 2) == 0) >> + ret = 32; >> + else if (strncmp (buf, "64", 2) == 0) >> + ret = 64; >> + } >> + free (buf); >> + fclose (fp); >> + } >> + >> + if (ret == 0) >> + /* Unrecognised - fall back to matching the kernel size instead */ >> + { > >I usually prefer comments inside braces and indented accordingly. OK, cool. >Could you send it suitable for git am? Mentioning platforms in commit >message would be useful for reference. BTW, re subject - this is >about installing 32 bit EFI grub on 64 bit Linux, not running, right? >It already should be able to run kernel if installed appropriately >manually. Correct, yes. v2 coming shortly. -- Steve McIntyre, Cambridge, UK. steve@einval.com Welcome my son, welcome to the machine.