Skip to contentSkip to conversation

x86: Clear isVGA flag if current fb driver is mimicking VGA

PATCH In review Kairui Song 3 participants 6 messages Nov 23, 2018 – Jun 4, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: Clear isVGA flag if current fb driver is mimicking VGA

Some device (eg. hyperv_fb) will mimic EFI (or VESA) VGA on first boot up, but after the real driver is loaded, it will switch to new mode and no longer compatible with EFI/VESA VGA. Keep setting orig_video_isVGA to EFI/VESA VGA flag will get wrong driver loaded and try to manipulate the framebuffer in a wrong way.

As we have already take care of "VESA VGA" and "EFI VGA", just set the orig_video_isVGA to 0 for any other driver reports as EFI/VESA VGA but is not EFI/VESA VGA.

---
 kexec/arch/i386/x86-linux-setup.c | 5 +++++
 1 file changed, 5 insertions(+)
kexec/arch/i386/x86-linux-setup.c +5 -0
index dc785a2..a129812 100644
@@ -152,6 +152,11 @@ static int setup_linux_vesafb(struct x86_linux_param_header *real_mode)
 		err = get_bootparam(&real_mode->orig_video_isVGA, offset, 1);
 		if (err)
 			goto out;
+
+		if (real_mode->orig_video_isVGA == 0x70 || real_mode->orig_video_isVGA == 0x23) {
+			/* Clear isVGA flag for fb drivers that mimic EFI/VESA VGA */
+			real_mode->orig_video_isVGA = 0;
+		}
 	}
 	close(fd);
 
Signature · 7 lines
2.19.1


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#1 lore raw
Quoted 20 lines · Kairui Song

Some device (eg. hyperv_fb) will mimic EFI (or VESA) VGA on first boot up, but after the real driver is loaded, it will switch to new mode and no longer compatible with EFI/VESA VGA. Keep setting orig_video_isVGA to EFI/VESA VGA flag will get wrong driver loaded and try to manipulate the framebuffer in a wrong way.

As we have already take care of "VESA VGA" and "EFI VGA", just set the orig_video_isVGA to 0 for any other driver reports as EFI/VESA VGA but is not EFI/VESA VGA.

---
 kexec/arch/i386/x86-linux-setup.c | 5 +++++
 1 file changed, 5 insertions(+)
kexec/arch/i386/x86-linux-setup.c +0 -0
index dc785a2..a129812 100644

kexec/arch/i386/x86-linux-setup.c static int setup_linux_vesafb(struct x86_linux_param_header *real_mode) · line 159

Quoted 8 lines
kexec/arch/i386/x86-linux-setup.c +5 -0
@@ -152,6 +152,11 @@ static int setup_linux_vesafb(struct x86_linux_param_header *real_mode)
 		err = get_bootparam(&real_mode->orig_video_isVGA, offset, 1);
 		if (err)
 			goto out;
+
+		if (real_mode->orig_video_isVGA == 0x70 || real_mode->orig_video_isVGA == 0x23) {
+			/* Clear isVGA flag for fb drivers that mimic EFI/VESA VGA */
+			real_mode->orig_video_isVGA = 0;
+		}

The blindly reuse original isVGA might be a problem like you said, but it does work for me for i915 laptop even if later drm driver loaded. With your patch it does not work anymore.

kexec reboot with earlyprintk=efi without initramfs looks just hang, but previously I can see all the kernel console logs.

Probably you can make real_mode->orig_video_isVGA = 0 as default in the else {} section, and introduce an extra x86 only argument for people to reuse isVGA blindly. eg.

kexec --reuse-vga-type

Quoted 11 lines
kexec/arch/i386/x86-linux-setup.c +0 -0
 	}
 	close(fd);
 
Signature · 7 lines
2.19.1


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

Thanks
Dave

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#2 lore raw

Thanks for the feedback!
This didn't happen with my laptop with i915, blindly using previous vga type is not working for it, so didn't expect it would break some i915 devices. I tried with my home laptop (also use i915) again and this patch did break the previous working vga.
Will adopt your suggestion and update the patch.

Quoted 51 lines · Dave Young
Quoted 20 lines · Kairui Song

Some device (eg. hyperv_fb) will mimic EFI (or VESA) VGA on first boot up, but after the real driver is loaded, it will switch to new mode and no longer compatible with EFI/VESA VGA. Keep setting orig_video_isVGA to EFI/VESA VGA flag will get wrong driver loaded and try to manipulate the framebuffer in a wrong way.

As we have already take care of "VESA VGA" and "EFI VGA", just set the orig_video_isVGA to 0 for any other driver reports as EFI/VESA VGA but is not EFI/VESA VGA.

---
 kexec/arch/i386/x86-linux-setup.c | 5 +++++
 1 file changed, 5 insertions(+)
kexec/arch/i386/x86-linux-setup.c +0 -0
index dc785a2..a129812 100644

kexec/arch/i386/x86-linux-setup.c static int setup_linux_vesafb(struct x86_linux_param_header *real_mode) · line 159

Quoted 8 lines
kexec/arch/i386/x86-linux-setup.c +5 -0
@@ -152,6 +152,11 @@ static int setup_linux_vesafb(struct x86_linux_param_header *real_mode)
              err = get_bootparam(&real_mode->orig_video_isVGA, offset, 1);
              if (err)
                      goto out;
+
+             if (real_mode->orig_video_isVGA == 0x70 || real_mode->orig_video_isVGA == 0x23) {
+                     /* Clear isVGA flag for fb drivers that mimic EFI/VESA VGA */
+                     real_mode->orig_video_isVGA = 0;
+             }

The blindly reuse original isVGA might be a problem like you said, but it does work for me for i915 laptop even if later drm driver loaded. With your patch it does not work anymore.

kexec reboot with earlyprintk=efi without initramfs looks just hang, but previously I can see all the kernel console logs.

Probably you can make real_mode->orig_video_isVGA = 0 as default in the else {} section, and introduce an extra x86 only argument for people to reuse isVGA blindly. eg.

kexec --reuse-vga-type

Quoted 7 lines
kexec/arch/i386/x86-linux-setup.c +0 -1
      }
      close(fd);
 
--

2.19.1

Quoted 7 lines
Quoted 4 lines

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

Thanks
Dave

--
Best Regards,
Kairui Song

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#3 lore raw
In reply to Kairui Song
Quoted 11 lines · Kairui Song

Some device (eg. hyperv_fb) will mimic EFI (or VESA) VGA on first boot up, but after the real driver is loaded, it will switch to new mode and no longer compatible with EFI/VESA VGA. Keep setting orig_video_isVGA to EFI/VESA VGA flag will get wrong driver loaded and try to manipulate the framebuffer in a wrong way.

As we have already take care of "VESA VGA" and "EFI VGA", just set the orig_video_isVGA to 0 for any other driver reports as EFI/VESA VGA but is not EFI/VESA VGA.

Sorry for letting this slip through the cracks.
Please let me know if this is still relevant.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#4 lore raw
Quoted 8 lines · Simon Horman
Quoted 6 lines · Kairui Song

Some device (eg. hyperv_fb) will mimic EFI (or VESA) VGA on first boot up, but after the real driver is loaded, it will switch to new mode and no longer compatible with EFI/VESA VGA. Keep setting orig_video_isVGA to EFI/VESA VGA flag will get wrong driver loaded and try to manipulate the framebuffer in a wrong way.

Quoted 8 lines
Quoted 5 lines

As we have already take care of "VESA VGA" and "EFI VGA", just set the orig_video_isVGA to 0 for any other driver reports as EFI/VESA VGA but is not EFI/VESA VGA.

Sorry for letting this slip through the cracks.
Please let me know if this is still relevant.

Hi Simon, after fb5a879 ("x86: Introduce a new option --reuse-video-type") in kexec-tools, this patch is no longer needed.

--
Best Regards,
Kairui Song

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#5 lore raw
Quoted 13 lines · Kairui Song
Quoted 12 lines · Simon Horman
Quoted 10 lines · Kairui Song

Some device (eg. hyperv_fb) will mimic EFI (or VESA) VGA on first boot up, but after the real driver is loaded, it will switch to new mode and no longer compatible with EFI/VESA VGA. Keep setting orig_video_isVGA to EFI/VESA VGA flag will get wrong driver loaded and try to manipulate the framebuffer in a wrong way.

As we have already take care of "VESA VGA" and "EFI VGA", just set the orig_video_isVGA to 0 for any other driver reports as EFI/VESA VGA but is not EFI/VESA VGA.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Sorry for letting this slip through the cracks.
Please let me know if this is still relevant.

Hi Simon, after fb5a879 ("x86: Introduce a new option --reuse-video-type") in kexec-tools, this patch is no longer needed.

Hi Kairui,

thanks for the clarification.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec