Package: src:grub2 Severity: important Tags: patch Hi folks,
I've got a patch accepted for the kernel to expose the size of the underlying UEFI firmware for x86, and Ben's happy to take it for the Debian kernel (#775191). I've written and tested a grub patch to match (see http://blog.einval.com/2015/01/11#Jessie-EFI_5) which adds support for this extra interface. Here it is. I'd appreciate it if we can get this in for Jessie, and and of course it'd be lovely if this went upstream too as it's generic. There's another related patch for grub-installer to make sure that the right grub packages get installed, too. -- Steve McIntyre, Cambridge, UK. [email protected] < liw> everything I know about UK hotels I learned from "Fawlty Towers"
From: Steve McIntyre <[email protected]> Subject: Add support for running a 64-bit Linux kernel on a 32-bit EFI 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 <[email protected]> Bug-Debian: https://bugs.debian.org/XXXXXX Forwarded: Not yet Last-Update: 2015-01-10 Patch-Name: mixed-size-efi.patch --- a/grub-core/osdep/linux/platform.c 2015-01-10 00:44:06.905703004 +0000 +++ b/grub-core/osdep/linux/platform.c 2015-01-10 01:25:11.742486599 +0000 @@ -63,2 +63,2 @@ 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; + + fp = grub_util_fopen ("/sys/firmware/efi/fw_platform_size", "r"); + if (! fp) + return 0; /* Can't read, fall through to other methods */ + + if (getline (&buf, &len, fp) > 0) + { + if (strncmp (buf, "32", 2) == 0) + ret = 32; + else if (strncmp (buf, "64", 2) == 0) + ret = 64; + else + ret = 0; /* Not recognised / supported! */ + } + + free (buf); + fclose (fp); + return ret; +} + const char * grub_install_get_default_x86_platform (void) { @@ -83,12 +110,35 @@ const char *platform; char *pd; int found; + int platform_size = 0; grub_util_info ("...found"); - if (is_64_kernel ()) - platform = "x86_64-efi"; - else - platform = "i386-efi"; + + /* Are we running on a 64-bit EFI? */ + platform_size = read_platform_size(); + + switch (platform_size) + { + case 32: + { + platform = "i386-efi"; + break; + } + case 64: + { + platform = "x86_64-efi"; + break; + } + default: + { + /* We can't tell; fall back to detecting the kernel + * config instead */ + if (is_64_kernel ()) + platform = "x86_64-efi"; + else + platform = "i386-efi"; + } + } pd = grub_util_path_concat (2, pkglibdir, platform); found = grub_util_is_directory (pd);

