Re: [RFC] Feature proposal: EFI variable check to enter grub menu

2026-01-13 Thread Mitchell Augustin via Grub-devel
Hi Vladimir,

Thanks for the quick feedback! We'll take a look at the grub script option here.

-Mitchell Augustin

-Mitchell Augustin

On Tue, Jan 13, 2026 at 6:47 AM Vladimir 'phcoder' Serbinenko
 wrote:
>
> I don't see any need for the change in menu module. You can do the same by 
> grub scripting. You just need a way to access EFI variables from grub shell 
> and there is already a patch for it
>
> Regards
>
> Le mar. 13 janv. 2026, 00:02, Mitchell Augustin via Grub-devel 
>  a écrit :
>>
>> Hi all!
>>
>> We're interested in implementing a small feature that would drop into
>> the grub menu (same as when we press shift or f4) if some new EFI
>> variable is set by the firmware. The motivation here is to enable
>> firmware vendors to add menu entries that will set this new EFI
>> variable before booting into the device with GRUB, enabling another
>> method through which we can access the grub menu on systems where it
>> is hidden / skipped by default.
>>
>> I have not previously done any upstream grub development, so I'm
>> interested in hearing whether this is something the grub team would
>> consider, or if there are any technical concerns.
>>
>> My thought is that this could be implemented within normal/menu.c if
>> you'd be willing to add EFI-specific code there, perhaps along these
>> lines (just an example, haven't been able to test yet since no
>> firmware implements this feature):
>>
>> diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c
>> index b946c834d..7f46d7514 100644
>> --- a/grub-core/normal/menu.c
>> +++ b/grub-core/normal/menu.c
>> @@ -33,6 +33,9 @@
>>  #include 
>>  #include 
>>  #include 
>> +#ifdef GRUB_MACHINE_EFI
>> +#include 
>> +#endif
>>
>>  /* Time to delay after displaying an error message about a default/fallback
>> entry failing to boot.  */
>> @@ -615,6 +618,14 @@ run_menu (grub_menu_t menu, int nested, int
>> *auto_boot, int *notify_boot)
>>/* Enter interruptible sleep until Escape or a menu hotkey is pressed,
>>   or the timeout expires.  */
>>saved_time = grub_get_time_ms ();
>> +#ifdef GRUB_MACHINE_EFI
>> +  static grub_guid_t efi_variable_guid = GRUB_EFI_GLOBAL_VARIABLE_GUID;
>> +  grub_size_t size = 0;
>> +  grub_efi_status_t status;
>> +  grub_uint8_t *enter_grub_menu = NULL;
>> +  status = grub_efi_get_variable ("EnterGrubMenu", &efi_variable_guid,
>> +  &size, (void **) &enter_grub_menu);
>> +#endif
>>while (1)
>>   {
>> int key;
>> @@ -632,6 +643,14 @@ run_menu (grub_menu_t menu, int nested, int
>> *auto_boot, int *notify_boot)
>> break;
>>   }
>>
>> +#ifdef GRUB_MACHINE_EFI
>> +   if (enter_grub_menu)
>> + {
>> +   timeout = -1;
>> +   break;
>> + }
>> +#endif
>> +
>> if (timeout > 0 && has_second_elapsed (&saved_time))
>>   {
>> timeout--;
>> --
>> 2.43.0
>>
>> Thanks in advance for your comments,
>> --
>> Mitchell Augustin
>> Software Engineer - Ubuntu Partner Engineering
>>
>> ___
>> Grub-devel mailing list
>> [email protected]
>> https://lists.gnu.org/mailman/listinfo/grub-devel



--
Mitchell Augustin
Software Engineer - Ubuntu Partner Engineering
Email:[email protected]
Location:United States of America (Central Time)


canonical.com
ubuntu.com

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


Re: [RFC] Feature proposal: EFI variable check to enter grub menu

2026-01-13 Thread Vladimir 'phcoder' Serbinenko
I don't see any need for the change in menu module. You can do the same by
grub scripting. You just need a way to access EFI variables from grub shell
and there is already a patch for it

Regards

Le mar. 13 janv. 2026, 00:02, Mitchell Augustin via Grub-devel <
[email protected]> a écrit :

> Hi all!
>
> We're interested in implementing a small feature that would drop into
> the grub menu (same as when we press shift or f4) if some new EFI
> variable is set by the firmware. The motivation here is to enable
> firmware vendors to add menu entries that will set this new EFI
> variable before booting into the device with GRUB, enabling another
> method through which we can access the grub menu on systems where it
> is hidden / skipped by default.
>
> I have not previously done any upstream grub development, so I'm
> interested in hearing whether this is something the grub team would
> consider, or if there are any technical concerns.
>
> My thought is that this could be implemented within normal/menu.c if
> you'd be willing to add EFI-specific code there, perhaps along these
> lines (just an example, haven't been able to test yet since no
> firmware implements this feature):
>
> diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c
> index b946c834d..7f46d7514 100644
> --- a/grub-core/normal/menu.c
> +++ b/grub-core/normal/menu.c
> @@ -33,6 +33,9 @@
>  #include 
>  #include 
>  #include 
> +#ifdef GRUB_MACHINE_EFI
> +#include 
> +#endif
>
>  /* Time to delay after displaying an error message about a
> default/fallback
> entry failing to boot.  */
> @@ -615,6 +618,14 @@ run_menu (grub_menu_t menu, int nested, int
> *auto_boot, int *notify_boot)
>/* Enter interruptible sleep until Escape or a menu hotkey is
> pressed,
>   or the timeout expires.  */
>saved_time = grub_get_time_ms ();
> +#ifdef GRUB_MACHINE_EFI
> +  static grub_guid_t efi_variable_guid =
> GRUB_EFI_GLOBAL_VARIABLE_GUID;
> +  grub_size_t size = 0;
> +  grub_efi_status_t status;
> +  grub_uint8_t *enter_grub_menu = NULL;
> +  status = grub_efi_get_variable ("EnterGrubMenu", &efi_variable_guid,
> +  &size, (void **) &enter_grub_menu);
> +#endif
>while (1)
>   {
> int key;
> @@ -632,6 +643,14 @@ run_menu (grub_menu_t menu, int nested, int
> *auto_boot, int *notify_boot)
> break;
>   }
>
> +#ifdef GRUB_MACHINE_EFI
> +   if (enter_grub_menu)
> + {
> +   timeout = -1;
> +   break;
> + }
> +#endif
> +
> if (timeout > 0 && has_second_elapsed (&saved_time))
>   {
> timeout--;
> --
> 2.43.0
>
> Thanks in advance for your comments,
> --
> Mitchell Augustin
> Software Engineer - Ubuntu Partner Engineering
>
> ___
> 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


Re: [RFC] Feature proposal: EFI variable check to enter grub menu

2026-01-12 Thread Mitchell Augustin via Grub-devel
Adding Scott Fudally  to this thread, who is also
interested in this


On Mon, Jan 12, 2026 at 2:37 PM Mitchell Augustin
 wrote:
>
> Hi all!
>
> We're interested in implementing a small feature that would drop into
> the grub menu (same as when we press shift or f4) if some new EFI
> variable is set by the firmware. The motivation here is to enable
> firmware vendors to add menu entries that will set this new EFI
> variable before booting into the device with GRUB, enabling another
> method through which we can access the grub menu on systems where it
> is hidden / skipped by default.
>
> I have not previously done any upstream grub development, so I'm
> interested in hearing whether this is something the grub team would
> consider, or if there are any technical concerns.
>
> My thought is that this could be implemented within normal/menu.c if
> you'd be willing to add EFI-specific code there, perhaps along these
> lines (just an example, haven't been able to test yet since no
> firmware implements this feature):
>
> diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c
> index b946c834d..7f46d7514 100644
> --- a/grub-core/normal/menu.c
> +++ b/grub-core/normal/menu.c
> @@ -33,6 +33,9 @@
>  #include 
>  #include 
>  #include 
> +#ifdef GRUB_MACHINE_EFI
> +#include 
> +#endif
>
>  /* Time to delay after displaying an error message about a default/fallback
> entry failing to boot.  */
> @@ -615,6 +618,14 @@ run_menu (grub_menu_t menu, int nested, int
> *auto_boot, int *notify_boot)
>/* Enter interruptible sleep until Escape or a menu hotkey is pressed,
>   or the timeout expires.  */
>saved_time = grub_get_time_ms ();
> +#ifdef GRUB_MACHINE_EFI
> +  static grub_guid_t efi_variable_guid = GRUB_EFI_GLOBAL_VARIABLE_GUID;
> +  grub_size_t size = 0;
> +  grub_efi_status_t status;
> +  grub_uint8_t *enter_grub_menu = NULL;
> +  status = grub_efi_get_variable ("EnterGrubMenu", &efi_variable_guid,
> +  &size, (void **) &enter_grub_menu);
> +#endif
>while (1)
>   {
> int key;
> @@ -632,6 +643,14 @@ run_menu (grub_menu_t menu, int nested, int
> *auto_boot, int *notify_boot)
> break;
>   }
>
> +#ifdef GRUB_MACHINE_EFI
> +   if (enter_grub_menu)
> + {
> +   timeout = -1;
> +   break;
> + }
> +#endif
> +
> if (timeout > 0 && has_second_elapsed (&saved_time))
>   {
> timeout--;
> --
> 2.43.0
>
> Thanks in advance for your comments,
> --
> Mitchell Augustin
> Software Engineer - Ubuntu Partner Engineering



-- 
Mitchell Augustin
Software Engineer - Ubuntu Partner Engineering
Email:[email protected]
Location:United States of America (Central Time)


canonical.com
ubuntu.com

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