Skip to contentSkip to conversation

grub-install: check for arm-efi as a default target

PATCH In review Steve McIntyre 4 participants 14 messages Feb 11, 2019 – Feb 26, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 grub-install: check for arm-efi as a default target

Much like on x86, we can work out if the system is running on top of EFI firmware. If so, return "arm-efi". If not, fall back to "arm-uboot" as previously.

Heavily inspired by the existing code for x86.

---
 grub-core/osdep/basic/platform.c |  6 ++++++
 grub-core/osdep/linux/platform.c | 24 ++++++++++++++++++++++++
 include/grub/util/install.h      |  3 +++
 util/grub-install.c              |  2 +-
 4 files changed, 34 insertions(+), 1 deletion(-)
grub-core/osdep/basic/platform.c +6 -0
index 4b5502aeb..a7dafd85a 100644
@@ -19,6 +19,12 @@
 #include <grub/util/install.h>
 
 const char *
+grub_install_get_default_arm_platform (void)
+{
+  return "arm-uboot";
+}
+
+const char *
 grub_install_get_default_x86_platform (void)
 { 
   return "i386-pc";
grub-core/osdep/linux/platform.c +24 -0
index 775b6c031..a3f9e9d28 100644
@@ -98,6 +98,30 @@ read_platform_size (void)
 }
 
 const char *
+grub_install_get_default_arm_platform (void)
+{
+  /*
+     On Linux, we need the efivars kernel modules.
+     If no EFI is available this module just does nothing
+     besides a small hello and if we detect efi we'll load it
+     anyway later. So it should be safe to
+     try to load it here.
+   */
+  grub_util_exec_redirect_all ((const char * []){ "modprobe", "efivars", NULL },
+			       NULL, NULL, "/dev/null");
+
+  grub_util_info ("Looking for /sys/firmware/efi ..");
+  if (is_not_empty_directory ("/sys/firmware/efi"))
+    {
+      grub_util_info ("...found");
+      return "arm-efi";
+    }
+
+  grub_util_info ("... not found");
+  return "arm-uboot";
+}
+
+const char *
 grub_install_get_default_x86_platform (void)
 { 
   /*
include/grub/util/install.h +3 -0
index af2bf65d7..80a51fcb1 100644
@@ -209,6 +209,9 @@ void
 grub_install_create_envblk_file (const char *name);
 
 const char *
+grub_install_get_default_arm_platform (void);
+
+const char *
 grub_install_get_default_x86_platform (void);
 
 int
util/grub-install.c +1 -1
index 4a0a66168..1d68cc5bb 100644
@@ -319,7 +319,7 @@ get_default_platform (void)
 #elif defined (__ia64__)
    return "ia64-efi";
 #elif defined (__arm__)
-   return "arm-uboot";
+   return grub_install_get_default_arm_platform ();
 #elif defined (__aarch64__)
    return "arm64-efi";
 #elif defined (__amd64__) || defined (__x86_64__) || defined (__i386__)
Signature · 1 line
2.11.0
#1 lore raw

Ping?

Quoted 97 lines · Steve McIntyre

Much like on x86, we can work out if the system is running on top of EFI firmware. If so, return "arm-efi". If not, fall back to "arm-uboot" as previously.

Heavily inspired by the existing code for x86.

---

grub-core/osdep/basic/platform.c |  6 ++++++
grub-core/osdep/linux/platform.c | 24 ++++++++++++++++++++++++
include/grub/util/install.h      |  3 +++
util/grub-install.c              |  2 +-
4 files changed, 34 insertions(+), 1 deletion(-)
grub-core/osdep/basic/platform.c +0 -0
index 4b5502aeb..a7dafd85a 100644
@@ -19,6 +19,12 @@
 #include <grub/util/install.h>
 

const char *

grub-core/osdep/basic/platform.c +6 -0
+grub_install_get_default_arm_platform (void)
+{
+  return "arm-uboot";
+}
+
+const char *

grub_install_get_default_x86_platform (void)
{
return "i386-pc";

grub-core/osdep/linux/platform.c +0 -0
index 775b6c031..a3f9e9d28 100644
@@ -98,6 +98,30 @@ read_platform_size (void)
 }
 

const char *

grub-core/osdep/linux/platform.c +24 -0
+grub_install_get_default_arm_platform (void)
+{
+  /*
+     On Linux, we need the efivars kernel modules.
+     If no EFI is available this module just does nothing
+     besides a small hello and if we detect efi we'll load it
+     anyway later. So it should be safe to
+     try to load it here.
+   */
+  grub_util_exec_redirect_all ((const char * []){ "modprobe", "efivars", NULL },
+			       NULL, NULL, "/dev/null");
+
+  grub_util_info ("Looking for /sys/firmware/efi ..");
+  if (is_not_empty_directory ("/sys/firmware/efi"))
+    {
+      grub_util_info ("...found");
+      return "arm-efi";
+    }
+
+  grub_util_info ("... not found");
+  return "arm-uboot";
+}
+
+const char *

grub_install_get_default_x86_platform (void)
{
/*

include/grub/util/install.h +0 -0
index af2bf65d7..80a51fcb1 100644
@@ -209,6 +209,9 @@ void
 grub_install_create_envblk_file (const char *name);
 

const char *

include/grub/util/install.h +3 -0
+grub_install_get_default_arm_platform (void);
+
+const char *

grub_install_get_default_x86_platform (void);

int

util/grub-install.c +1 -1
index 4a0a66168..1d68cc5bb 100644
@@ -319,7 +319,7 @@ get_default_platform (void)
 #elif defined (__ia64__)
   return "ia64-efi";
 #elif defined (__arm__)
-   return "arm-uboot";
+   return grub_install_get_default_arm_platform ();
 #elif defined (__aarch64__)
   return "arm64-efi";
 #elif defined (__amd64__) || defined (__x86_64__) || defined (__i386__)
Signature · 1 line
2.11.0
Signature · 3 lines
Steve McIntyre, Cambridge, UK.                                [email protected]
"I used to be the first kid on the block wanting a cranial implant,
 now I want to be the first with a cranial firewall. " -- Charlie Stross
#2 lore raw
In reply to Steve McIntyre

Hi Steve,

Quoted 3 lines · Steve McIntyre

Much like on x86, we can work out if the system is running on top of EFI firmware. If so, return "arm-efi". If not, fall back to "arm-uboot" as previously.

Right, this clearly needs a fix.

Quoted 1 line

Heavily inspired by the existing code for x86.

Mmm. I would much prefer if we could break out the efi test in a separate helper function. And clean it up while we're at it.

Quoted 34 lines
---
 grub-core/osdep/basic/platform.c |  6 ++++++
 grub-core/osdep/linux/platform.c | 24 ++++++++++++++++++++++++
 include/grub/util/install.h      |  3 +++
 util/grub-install.c              |  2 +-
 4 files changed, 34 insertions(+), 1 deletion(-)
grub-core/osdep/basic/platform.c +6 -0
index 4b5502aeb..a7dafd85a 100644
@@ -19,6 +19,12 @@
 #include <grub/util/install.h>
 
 const char *
+grub_install_get_default_arm_platform (void)
+{
+  return "arm-uboot";
+}
+
+const char *
 grub_install_get_default_x86_platform (void)
 { 
   return "i386-pc";
grub-core/osdep/linux/platform.c +1 -0
index 775b6c031..a3f9e9d28 100644
@@ -98,6 +98,30 @@ read_platform_size (void)
 }
 
 const char *
+grub_install_get_default_arm_platform (void)

grub-core/osdep/linux/platform.c read_platform_size (void) · line 111

Quoted 10 lines
grub-core/osdep/linux/platform.c +10 -0
+{
+  /*
+     On Linux, we need the efivars kernel modules.
+     If no EFI is available this module just does nothing
+     besides a small hello and if we detect efi we'll load it
+     anyway later. So it should be safe to
+     try to load it here.
+   */
+  grub_util_exec_redirect_all ((const char * []){ "modprobe", "efivars", NULL },
+			       NULL, NULL, "/dev/null");

So, I guess this is a "safe" operation. But efivars isn't the interface that should be used these days - efivarfs is. The efivars library will always use efivarfs
(mounted on /sys/firmware/efi/efivars) in preference to efivars (available through /sys/firmware/efi/vars).

Since it's safe, we may leave it in for someone running bleeding edge grub on an ancient system, or just using a misconfigured kernel. But the comment is misleading. I would suggest changing it to something like:

/*
Linux uses efivarfs (mounted on /sys/firmware/efi/efivars) to access the EFI variable store.
Some legacy systems may still use the deprecated efivars interface (accessed through /sys/firmware/efi/vars). Where both are present, libefivar will use the former in preference, so attempting to load efivars will not interfere with later operations.
*/

/
Leif

Quoted 50 lines
grub-core/osdep/linux/platform.c +12 -0
+  grub_util_info ("Looking for /sys/firmware/efi ..");
+  if (is_not_empty_directory ("/sys/firmware/efi"))
+    {
+      grub_util_info ("...found");
+      return "arm-efi";
+    }
+
+  grub_util_info ("... not found");
+  return "arm-uboot";
+}
+
+const char *
 grub_install_get_default_x86_platform (void)
 { 
   /*
include/grub/util/install.h +3 -0
index af2bf65d7..80a51fcb1 100644
@@ -209,6 +209,9 @@ void
 grub_install_create_envblk_file (const char *name);
 
 const char *
+grub_install_get_default_arm_platform (void);
+
+const char *
 grub_install_get_default_x86_platform (void);
 
 int
util/grub-install.c +1 -1
index 4a0a66168..1d68cc5bb 100644
@@ -319,7 +319,7 @@ get_default_platform (void)
 #elif defined (__ia64__)
    return "ia64-efi";
 #elif defined (__arm__)
-   return "arm-uboot";
+   return grub_install_get_default_arm_platform ();
 #elif defined (__aarch64__)
    return "arm64-efi";
 #elif defined (__amd64__) || defined (__x86_64__) || defined (__i386__)
Signature · 7 lines
2.11.0


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#3 lore raw
Quoted 8 lines · Leif Lindholm

Hi Steve,

Quoted 3 lines · Steve McIntyre

Much like on x86, we can work out if the system is running on top of EFI firmware. If so, return "arm-efi". If not, fall back to "arm-uboot" as previously.

Quoted 6 lines

Right, this clearly needs a fix.

Quoted 1 line

Heavily inspired by the existing code for x86.

Mmm. I would much prefer if we could break out the efi test in a separate helper function. And clean it up while we're at it.

fyi, I made an attempt at this a while back:
http://lists.gnu.org/archive/html/grub-devel/2018-08/msg00082.html
http://lists.gnu.org/archive/html/grub-devel/2018-08/msg00081.html
http://lists.gnu.org/archive/html/grub-devel/2018-08/msg00083.html

-dann

Quoted 124 lines
Quoted 34 lines
---
 grub-core/osdep/basic/platform.c |  6 ++++++
 grub-core/osdep/linux/platform.c | 24 ++++++++++++++++++++++++
 include/grub/util/install.h      |  3 +++
 util/grub-install.c              |  2 +-
 4 files changed, 34 insertions(+), 1 deletion(-)
grub-core/osdep/basic/platform.c +6 -0
index 4b5502aeb..a7dafd85a 100644
@@ -19,6 +19,12 @@
 #include <grub/util/install.h>
 
 const char *
+grub_install_get_default_arm_platform (void)
+{
+  return "arm-uboot";
+}
+
+const char *
 grub_install_get_default_x86_platform (void)
 {
   return "i386-pc";
grub-core/osdep/linux/platform.c +1 -0
index 775b6c031..a3f9e9d28 100644
@@ -98,6 +98,30 @@ read_platform_size (void)
 }
 
 const char *
+grub_install_get_default_arm_platform (void)

grub-core/osdep/linux/platform.c read_platform_size (void) · line 111

Quoted 10 lines
grub-core/osdep/linux/platform.c +10 -0
+{
+  /*
+     On Linux, we need the efivars kernel modules.
+     If no EFI is available this module just does nothing
+     besides a small hello and if we detect efi we'll load it
+     anyway later. So it should be safe to
+     try to load it here.
+   */
+  grub_util_exec_redirect_all ((const char * []){ "modprobe", "efivars", NULL },
+                            NULL, NULL, "/dev/null");

So, I guess this is a "safe" operation. But efivars isn't the interface that should be used these days - efivarfs is. The efivars library will always use efivarfs
(mounted on /sys/firmware/efi/efivars) in preference to efivars (available through /sys/firmware/efi/vars).

Since it's safe, we may leave it in for someone running bleeding edge grub on an ancient system, or just using a misconfigured kernel. But the comment is misleading. I would suggest changing it to something like:

/*
Linux uses efivarfs (mounted on /sys/firmware/efi/efivars) to access the EFI variable store.
Some legacy systems may still use the deprecated efivars interface (accessed through /sys/firmware/efi/vars). Where both are present, libefivar will use the former in preference, so attempting to load efivars will not interfere with later operations.
*/

/
Leif

Quoted 46 lines
grub-core/osdep/linux/platform.c +12 -0
+  grub_util_info ("Looking for /sys/firmware/efi ..");
+  if (is_not_empty_directory ("/sys/firmware/efi"))
+    {
+      grub_util_info ("...found");
+      return "arm-efi";
+    }
+
+  grub_util_info ("... not found");
+  return "arm-uboot";
+}
+
+const char *
 grub_install_get_default_x86_platform (void)
 {
   /*
include/grub/util/install.h +3 -0
index af2bf65d7..80a51fcb1 100644
@@ -209,6 +209,9 @@ void
 grub_install_create_envblk_file (const char *name);
 
 const char *
+grub_install_get_default_arm_platform (void);
+
+const char *
 grub_install_get_default_x86_platform (void);
 
 int
util/grub-install.c +1 -2
index 4a0a66168..1d68cc5bb 100644
@@ -319,7 +319,7 @@ get_default_platform (void)
 #elif defined (__ia64__)
    return "ia64-efi";
 #elif defined (__arm__)
-   return "arm-uboot";
+   return grub_install_get_default_arm_platform ();
 #elif defined (__aarch64__)
    return "arm64-efi";
 #elif defined (__amd64__) || defined (__x86_64__) || defined (__i386__)
--

2.11.0

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#4 lore raw
Quoted 13 lines · dann frazier
Quoted 12 lines · Leif Lindholm

Hi Steve,

Quoted 3 lines · Steve McIntyre

Much like on x86, we can work out if the system is running on top of EFI firmware. If so, return "arm-efi". If not, fall back to "arm-uboot" as previously.

Right, this clearly needs a fix.

Quoted 1 line

Heavily inspired by the existing code for x86.

Quoted 7 lines
Quoted 2 lines

Mmm. I would much prefer if we could break out the efi test in a separate helper function. And clean it up while we're at it.

fyi, I made an attempt at this a while back:
http://lists.gnu.org/archive/html/grub-devel/2018-08/msg00082.html
http://lists.gnu.org/archive/html/grub-devel/2018-08/msg00081.html
http://lists.gnu.org/archive/html/grub-devel/2018-08/msg00083.html

Arg, sorry - never saw those or I'd have commented already. :-/

Looking now:

* I'm not sure I'd bother with the is_efi() change in the Windows-specific code but meh. :-)

* You're only allowing arm-efi as a default when is_virt() is true. While I'm also *initially* caring about armhf VMs myself, I think that changes in recent U-Boot mean that arm-efi is a sensible option on bare metal too?

Signature · 4 lines
Steve McIntyre, Cambridge, UK.                                [email protected]
You lock the door
And throw away the key
There's someone in my head but it's not me 
#5 lore raw
Quoted 16 lines · Steve McIntyre
Quoted 11 lines
Quoted 6 lines

Right, this clearly needs a fix.

Quoted 1 line

Heavily inspired by the existing code for x86.

Mmm. I would much prefer if we could break out the efi test in a separate helper function. And clean it up while we're at it.

fyi, I made an attempt at this a while back:
http://lists.gnu.org/archive/html/grub-devel/2018-08/msg00082.html
http://lists.gnu.org/archive/html/grub-devel/2018-08/msg00081.html
http://lists.gnu.org/archive/html/grub-devel/2018-08/msg00083.html

Arg, sorry - never saw those or I'd have commented already. :-/

Looking now:

Quoted 7 lines

* I'm not sure I'd bother with the is_efi() change in the Windows-specific code but meh. :-)

* You're only allowing arm-efi as a default when is_virt() is true. While I'm also *initially* caring about armhf VMs myself, I think that changes in recent U-Boot mean that arm-efi is a sensible option on bare metal too?

My take is that at some point _after_ the next release of GRUB, we should consider switching the default for arm. And at some later point we should probably nuke the U-Boot port completely.

The U-Boot API is not properly maintained, and the UEFI API in U-Boot is.

/
Leif

#6 lore raw
In reply to Steve McIntyre
Quoted 18 lines · Steve McIntyre
Quoted 16 lines · dann frazier
Quoted 14 lines · Leif Lindholm

Hi Steve,

Quoted 3 lines · Steve McIntyre

Much like on x86, we can work out if the system is running on top of EFI firmware. If so, return "arm-efi". If not, fall back to "arm-uboot" as previously.

Right, this clearly needs a fix.

Quoted 1 line

Heavily inspired by the existing code for x86.

Mmm. I would much prefer if we could break out the efi test in a separate helper function. And clean it up while we're at it.

Quoted 6 lines
Quoted 4 lines

fyi, I made an attempt at this a while back:
http://lists.gnu.org/archive/html/grub-devel/2018-08/msg00082.html
http://lists.gnu.org/archive/html/grub-devel/2018-08/msg00081.html
http://lists.gnu.org/archive/html/grub-devel/2018-08/msg00083.html

Arg, sorry - never saw those or I'd have commented already. :-/

No worries. Happy to let you run with it, just wanted to share in case there was anything worth stealing.

Quoted 4 lines

Looking now:

* I'm not sure I'd bother with the is_efi() change in the Windows-specific code but meh. :-)

Right, only done for consistency.

Quoted 4 lines

* You're only allowing arm-efi as a default when is_virt() is true. While I'm also *initially* caring about armhf VMs myself, I think that changes in recent U-Boot mean that arm-efi is a sensible option on bare metal too?

Yeah, at the time I was aware of the efi work on uboot, but it wasn't clear to me what the right build of GRUB would be in that case, so I left that for later. And later it has become! :)

-dann

Quoted 6 lines

--
Steve McIntyre, Cambridge, UK. [email protected]
You lock the door
And throw away the key
There's someone in my head but it's not me

#7 lore raw
In reply to Leif Lindholm

Hey Leif,

Quoted 6 lines · Leif Lindholm
Quoted 3 lines · Steve McIntyre

Much like on x86, we can work out if the system is running on top of EFI firmware. If so, return "arm-efi". If not, fall back to "arm-uboot" as previously.

Right, this clearly needs a fix.

Yup!

Quoted 4 lines
Quoted 1 line

Heavily inspired by the existing code for x86.

Mmm. I would much prefer if we could break out the efi test in a separate helper function. And clean it up while we're at it.

ACK. I was looking for a quick change, but I'll be less lazy. :-)

...

Quoted 24 lines

grub-core/osdep/linux/platform.c read_platform_size (void) · line 111

Quoted 12 lines

const char *

grub-core/osdep/linux/platform.c +11 -0
+grub_install_get_default_arm_platform (void)
+{
+  /*
+     On Linux, we need the efivars kernel modules.
+     If no EFI is available this module just does nothing
+     besides a small hello and if we detect efi we'll load it
+     anyway later. So it should be safe to
+     try to load it here.
+   */
+  grub_util_exec_redirect_all ((const char * []){ "modprobe", "efivars", NULL },
+			       NULL, NULL, "/dev/null");

So, I guess this is a "safe" operation. But efivars isn't the interface that should be used these days - efivarfs is. The efivars library will always use efivarfs
(mounted on /sys/firmware/efi/efivars) in preference to efivars (available through /sys/firmware/efi/vars).

Since it's safe, we may leave it in for someone running bleeding edge grub on an ancient system, or just using a misconfigured kernel. But the comment is misleading. I would suggest changing it to something like:

Quoted 9 lines

/*
Linux uses efivarfs (mounted on /sys/firmware/efi/efivars) to access the EFI variable store.
Some legacy systems may still use the deprecated efivars interface (accessed through /sys/firmware/efi/vars). Where both are present, libefivar will use the former in preference, so attempting to load efivars will not interfere with later operations.
*/

ACK. Using your text. :-)

Patch v2 on its way in a mo.

Signature · 3 lines
Steve McIntyre, Cambridge, UK.                                [email protected]
We don't need no education.
We don't need no thought control.
#8 lore raw

PATCH 1/1 grub-install: check for arm-efi as a default target

In reply to Leif Lindholm

Much like on x86, we can work out if the system is running on top of EFI firmware. If so, return "arm-efi". If not, fall back to "arm-uboot" as previously.

Split out the code to (maybe) load the efivar module and check for /sys/firmware/efi into a common helper routine is_efi_system()

---
 grub-core/osdep/basic/platform.c |  6 ++++++
 grub-core/osdep/linux/platform.c | 46 +++++++++++++++++++++++++++++++---------
 include/grub/util/install.h      |  3 +++
 util/grub-install.c              |  2 +-
 4 files changed, 46 insertions(+), 11 deletions(-)
grub-core/osdep/basic/platform.c +6 -0
index 4b5502aeb..a7dafd85a 100644
@@ -19,6 +19,12 @@
 #include <grub/util/install.h>
 
 const char *
+grub_install_get_default_arm_platform (void)
+{
+  return "arm-uboot";
+}
+
+const char *
 grub_install_get_default_x86_platform (void)
 { 
   return "i386-pc";
grub-core/osdep/linux/platform.c +36 -10

65 lines not on this page · raw message

include/grub/util/install.h +3 -0
index af2bf65d7..80a51fcb1 100644
@@ -209,6 +209,9 @@ void
 grub_install_create_envblk_file (const char *name);
 
 const char *
+grub_install_get_default_arm_platform (void);
+
+const char *
 grub_install_get_default_x86_platform (void);
 
 int
util/grub-install.c +1 -1
index 4a0a66168..1d68cc5bb 100644
@@ -319,7 +319,7 @@ get_default_platform (void)
 #elif defined (__ia64__)
    return "ia64-efi";
 #elif defined (__arm__)
-   return "arm-uboot";
+   return grub_install_get_default_arm_platform ();
 #elif defined (__aarch64__)
    return "arm64-efi";
 #elif defined (__amd64__) || defined (__x86_64__) || defined (__i386__)
Signature · 1 line
2.11.0
Reviewed-by on v1 1/1
#9 lore raw
Quoted 8 lines · Steve McIntyre

Much like on x86, we can work out if the system is running on top of EFI firmware. If so, return "arm-efi". If not, fall back to "arm-uboot" as previously.

Split out the code to (maybe) load the efivar module and check for /sys/firmware/efi into a common helper routine is_efi_system()

LGTM:

Quoted 130 lines
---
 grub-core/osdep/basic/platform.c |  6 ++++++
 grub-core/osdep/linux/platform.c | 46 +++++++++++++++++++++++++++++++---------
 include/grub/util/install.h      |  3 +++
 util/grub-install.c              |  2 +-
 4 files changed, 46 insertions(+), 11 deletions(-)
grub-core/osdep/basic/platform.c +6 -0
index 4b5502aeb..a7dafd85a 100644
@@ -19,6 +19,12 @@
 #include <grub/util/install.h>
 
 const char *
+grub_install_get_default_arm_platform (void)
+{
+  return "arm-uboot";
+}
+
+const char *
 grub_install_get_default_x86_platform (void)
 { 
   return "i386-pc";
grub-core/osdep/linux/platform.c +36 -10
index 775b6c031..5cb7bf923 100644
@@ -97,16 +97,19 @@ read_platform_size (void)
   return ret;
 }
 
-const char *
-grub_install_get_default_x86_platform (void)
-{ 
+/* Are we running on an EFI-based system? */
+static int
+is_efi_system (void)
+{
   /*
-     On Linux, we need the efivars kernel modules.
-     If no EFI is available this module just does nothing
-     besides a small hello and if we detect efi we'll load it
-     anyway later. So it should be safe to
-     try to load it here.
-   */
+     Linux uses efivarfs (mounted on /sys/firmware/efi/efivars)
+     to access the EFI variable store.
+     Some legacy systems may still use the deprecated efivars
+     interface (accessed through /sys/firmware/efi/vars).
+     Where both are present, libefivar will use the former in
+     preference, so attempting to load efivars will not interfere
+     with later operations.
+  */
   grub_util_exec_redirect_all ((const char * []){ "modprobe", "efivars", NULL },
 			       NULL, NULL, "/dev/null");
 
@@ -114,13 +117,36 @@ grub_install_get_default_x86_platform (void)
   if (is_not_empty_directory ("/sys/firmware/efi"))
     {
       grub_util_info ("...found");
+      return 1;
+    }
+  else
+    {
+      grub_util_info ("... not found");
+      return 0;
+    }
+}
+
+const char *
+grub_install_get_default_arm_platform (void)
+{
+  if (is_efi_system())
+    return "arm-efi";
+  else
+    return "arm-uboot";
+}
+
+const char *
+grub_install_get_default_x86_platform (void)
+{ 
+  if (is_efi_system())
+    {
       if (read_platform_size() == 64)
 	return "x86_64-efi";
       else
 	return "i386-efi";
     }
 
-  grub_util_info ("... not found. Looking for /proc/device-tree ..");
+  grub_util_info ("Looking for /proc/device-tree ..");
   if (is_not_empty_directory ("/proc/device-tree"))
     {
       grub_util_info ("...found");
include/grub/util/install.h +3 -0
index af2bf65d7..80a51fcb1 100644
@@ -209,6 +209,9 @@ void
 grub_install_create_envblk_file (const char *name);
 
 const char *
+grub_install_get_default_arm_platform (void);
+
+const char *
 grub_install_get_default_x86_platform (void);
 
 int
util/grub-install.c +1 -1
index 4a0a66168..1d68cc5bb 100644
@@ -319,7 +319,7 @@ get_default_platform (void)
 #elif defined (__ia64__)
    return "ia64-efi";
 #elif defined (__arm__)
-   return "arm-uboot";
+   return grub_install_get_default_arm_platform ();
 #elif defined (__aarch64__)
    return "arm64-efi";
 #elif defined (__amd64__) || defined (__x86_64__) || defined (__i386__)
Signature · 7 lines
2.11.0


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Reviewed-by
#10 lore raw
Quoted 5 lines · Leif Lindholm
Quoted 4 lines · Steve McIntyre

Much like on x86, we can work out if the system is running on top of EFI firmware. If so, return "arm-efi". If not, fall back to "arm-uboot" as previously.

Quoted 7 lines
Quoted 4 lines

Split out the code to (maybe) load the efivar module and check for /sys/firmware/efi into a common helper routine is_efi_system()

LGTM:

If there are no objections I will push this patch next week.

Daniel

#11 lore raw
Quoted 9 lines · Daniel Kiper
Quoted 8 lines · Leif Lindholm
Quoted 7 lines · Steve McIntyre

Much like on x86, we can work out if the system is running on top of EFI firmware. If so, return "arm-efi". If not, fall back to "arm-uboot" as previously.

Split out the code to (maybe) load the efivar module and check for /sys/firmware/efi into a common helper routine is_efi_system()

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

LGTM:

If there are no objections I will push this patch next week.

Eep.

As pointed out by Colin on IRC - it appears you have pushed Steves original submission rather than the revised one which I gave my R-b for.

Could you address?

Regards,

Leif

#12 lore raw
Quoted 19 lines · Leif Lindholm
Quoted 9 lines · Daniel Kiper
Quoted 8 lines · Leif Lindholm
Quoted 7 lines · Steve McIntyre

Much like on x86, we can work out if the system is running on top of EFI firmware. If so, return "arm-efi". If not, fall back to "arm-uboot" as previously.

Split out the code to (maybe) load the efivar module and check for /sys/firmware/efi into a common helper routine is_efi_system()

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

LGTM:

If there are no objections I will push this patch next week.

Quoted 7 lines

Eep.

As pointed out by Colin on IRC - it appears you have pushed Steves original submission rather than the revised one which I gave my R-b for.

Could you address?

Argh... Addressed. Sorry for the confusion. I took first email from the thread by mistake. Folks, next time please send new patches as not a reply to. Just create new threads.

Daniel

#13 lore raw
Quoted 11 lines · Daniel Kiper
Quoted 6 lines · Leif Lindholm

As pointed out by Colin on IRC - it appears you have pushed Steves original submission rather than the revised one which I gave my R-b for.

Could you address?

Argh... Addressed. Sorry for the confusion. I took first email from the thread by mistake. Folks, next time please send new patches as not a reply to. Just create new threads.

ACK, will do!

Signature · 2 lines
Steve McIntyre, Cambridge, UK.                                [email protected]
"You can't barbecue lettuce!" -- Ellie Crane