Skip to contentSkip to conversation

Update 00_header to load efi video on EFI platforms

PATCH In review Andrew Hamilton 3 participants 4 messages Nov 7, 2025 – Feb 7

lore
Share & tools
lore
#1 lore raw

PATCH v2 1/1 util/grub.d/00_header.in: Disable loading all_video for EFI

In reply to Andrew Hamilton

Loading all_video for EFI can cause video issues in some cases since GRUB Bochs/Cirrus drivers may conflict with native EFI drivers. Change default behavior for EFI to only load EFI specific video modules. Also include a new environment variable to restore the old behavior if needed.

---
 docs/grub.texi           |  7 +++++++
 util/grub-mkconfig.in    |  3 ++-
 util/grub.d/00_header.in | 16 +++++++++++++++-
 3 files changed, 24 insertions(+), 2 deletions(-)
docs/grub.texi +7 -0
index 5b23ae47b..1ec5d3566 100644
@@ -1642,6 +1642,13 @@ This option is unset by default, and is deprecated in favour of the less
 confusing @samp{GRUB_TIMEOUT_STYLE=countdown} or
 @samp{GRUB_TIMEOUT_STYLE=hidden}.
 
+@item GRUB_FORCE_EFI_ALL_VIDEO
+When set to true, this will allow grub-mkconfig to generate a GRUB config
+that supports loading the all_video module on the EFI platform instead of
+just the efi_gop and efi_uga modules.
+
+This option is unset by default.
+
 @end table
 
 For more detailed customisation of @command{grub-mkconfig}'s output, you may
util/grub-mkconfig.in +2 -1
index 32c480dae..45787a1d1 100644
@@ -255,7 +255,8 @@ export GRUB_DEFAULT \
   GRUB_ENABLE_CRYPTODISK \
   GRUB_BADRAM \
   GRUB_OS_PROBER_SKIP_LIST \
-  GRUB_DISABLE_SUBMENU
+  GRUB_DISABLE_SUBMENU \
+  GRUB_FORCE_EFI_ALL_VIDEO
 
 if test "x${grub_cfg}" != "x"; then
   rm -f "${grub_cfg}.new"
util/grub.d/00_header.in +15 -1
index 9d36feda3..77834cfaf 100644
@@ -124,10 +124,24 @@ if [ -n "${GRUB_VIDEO_BACKEND}" ]; then
   insmod ${GRUB_VIDEO_BACKEND}
 EOF
 else
+# For EFI, use EFI video drivers only by default to avoid conflict between
+# GRUB Bochs/Cirrus and native EFI drivers. If GRUB_FORCE_EFI_ALL_VIDEO is
+# set/true then defer back to all_video even for EFI.
+if [ "${GRUB_FORCE_EFI_ALL_VIDEO}" = "1" ]; then
+    cat <<EOF
+  if [ x\$feature_all_video_module = xy ]; then
+EOF
+else # GRUB_FORCE_EFI_ALL_VIDEO is not set true
+    cat <<EOF
+  if [ x\$grub_platform = xefi ]; then
+    insmod efi_gop
+    insmod efi_uga
+  elif [ x\$feature_all_video_module = xy ]; then
+EOF
+fi # end GRUB_FORCE_EFI_ALL_VIDEO
 # If all_video.mod isn't available load all modules available
 # with versions prior to introduction of all_video.mod
 cat <<EOF
-  if [ x\$feature_all_video_module = xy ]; then
     insmod all_video
   else
     insmod efi_gop
Signature · 7 lines
2.43.0


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

v2 cover Update 00_header to load efi video on EFI platforms

This is a new attempt to fix the issue with video corruption that can occur in some cases on EFI when all_video is loaded. Previously, the proposed change was to disable building video_bochs and video_cirrus for EFI completely, however there was concern around this approach.

Previous thread:
https://lists.gnu.org/archive/html/grub-devel/2025-09/msg00265.html

This new approach modifies the 00_header script to default to only load efi_gop and efi_uga for EFI platforms. A new env variable is added to force the old behavior of loading all_video for EFI if desired.

There is likely an additional change required on distros that bundle all_video into the signed EFI GRUB image, such as Debian:
https://sources.debian.org/src/grub2/2.14~git20250718.0e36779-2/debian/build-efi-images

There is some additional analysis from the Qemu team in this thread:
https://gitlab.com/qemu-project/qemu/-/issues/2562

This is an issue on some major distros such as Debian on EFI when running under Qemu and potentially other scenarios.

There is some discussion on the Debian side in this thread:
https://salsa.debian.org/kernel-team/linux/-/merge_requests/1453

This relates to this discussion from grub-devel also:
https://lists.gnu.org/archive/html/grub-devel/2025-09/msg00244.html

Changes since v1:
- Fix some comments
- Change name of env variable
- Combine patches into one

Andrew Hamilton (1):
util/grub.d/00_header.in: Disable loading all_video for EFI

 docs/grub.texi           |  7 +++++++
 util/grub-mkconfig.in    |  3 ++-
 util/grub.d/00_header.in | 16 +++++++++++++++-
 3 files changed, 24 insertions(+), 2 deletions(-)
Signature · 7 lines
2.43.0


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Reviewed-by Daniel Kiper on v2 1/1
#2 lore raw

Re: [PATCH v2 1/1] util/grub.d/00_header.in: Disable loading all_video for EFI

In reply to Andrew Hamilton
Quoted 9 lines · Andrew Hamilton

Loading all_video for EFI can cause video issues in some cases since GRUB Bochs/Cirrus drivers may conflict with native EFI drivers. Change default behavior for EFI to only load EFI specific video modules. Also include a new environment variable to restore the old behavior if needed.

Daniel

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

#3 lore raw
In reply to Andrew Hamilton

Andrew Hamilton <[email protected]>:

Quoted 2 lines

This is a new attempt to fix the issue with video corruption that can occur in some cases on EFI when all_video is loaded. Previously, the

Thank you for the patch!

It indeed solved my immidiate problem.

But I still believe that ideally we should do some more fundamental fix.

Ideally whatever Gerd Hoffmann proposed here:
https://lore.kernel.org/grub-devel/3boqeafidphhrxmbzc7ojp6a4ezwdcoxphjcwpaa2jlhgdpwkz@he4xf627vqik/

Quoted 10 lines

Alternatively you can check for conflicts. Check which physical device backs efi_gop, block that from being used by grub drivers. Same for all other device types.

The latter would handle the corner case that there is hardware which is
(a) supported by grub, and (b) not supported by the firmware, and (c) essential to boot the system. Not sure how relevant that is in practice, most EFI firmware I've seen recently is pretty complete when it comes to hardware support. NIC drivers are missing sometimes, iPXE to the rescue ;)

So I will keep https://savannah.gnu.org/bugs/index.php?66200 opened.

Please, CC me when answering, I'm not subscribed.

Signature · 6 lines
Askar Safin

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