8c6b1ac71e
Also include some minor fixes for gcc 5.1.1 Signed-off-by: Peter Jones <pjones@redhat.com>
82 lines
2.3 KiB
Diff
82 lines
2.3 KiB
Diff
From 1a33de8b5612f8d7ab344546f8a91fa814f712b5 Mon Sep 17 00:00:00 2001
|
|
From: Steve McIntyre <steve@einval.com>
|
|
Date: Fri, 27 Mar 2015 14:51:51 +0100
|
|
Subject: [PATCH 379/506] Recognize EFI platform even in case of mismatch
|
|
between Linux and EFI.
|
|
|
|
Some x86 systems might be capable of running a 64-bit Linux kernel but
|
|
only use a 32-bit EFI (e.g. Intel Bay Trail systems). It's useful for
|
|
grub-install to be able to recognise such systems, to set the default
|
|
x86 platform correctly.
|
|
|
|
To allow grub-install to know the size of the firmware rather than
|
|
just the size of the kernel, 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 <steve@einval.com>
|
|
---
|
|
grub-core/osdep/linux/platform.c | 39 ++++++++++++++++++++++++++++++++++++++-
|
|
1 file changed, 38 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/grub-core/osdep/linux/platform.c b/grub-core/osdep/linux/platform.c
|
|
index 4b9f6ef..775b6c0 100644
|
|
--- a/grub-core/osdep/linux/platform.c
|
|
+++ b/grub-core/osdep/linux/platform.c
|
|
@@ -60,6 +60,43 @@ 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) >= 3) /* 2 digits plus newline */
|
|
+ {
|
|
+ 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 */
|
|
+ if (is_64_kernel ())
|
|
+ ret = 64;
|
|
+ else
|
|
+ ret = 32;
|
|
+ }
|
|
+
|
|
+ return ret;
|
|
+}
|
|
+
|
|
const char *
|
|
grub_install_get_default_x86_platform (void)
|
|
{
|
|
@@ -77,7 +114,7 @@ grub_install_get_default_x86_platform (void)
|
|
if (is_not_empty_directory ("/sys/firmware/efi"))
|
|
{
|
|
grub_util_info ("...found");
|
|
- if (is_64_kernel ())
|
|
+ if (read_platform_size() == 64)
|
|
return "x86_64-efi";
|
|
else
|
|
return "i386-efi";
|
|
--
|
|
2.4.3
|
|
|