Skip to contentSkip to conversation

x86: use old screen_info if needed

PATCH Applied Dave Young 2 participants 5 messages Jan 28, 2018 – Jan 29, 2018

Subsystems (2)
lore
Share & tools
lore

Dave Young

author
#0 lore raw

PATCH 1/1 x86: use old screen_info if needed

With modern drm/kms graphic driver kexec-tools does not setup screen_info correctly so one will only see screen output after those drm drivers reinitializing after rebooting. Copying the old screen info from original boot_params will help during my test, although it could not work for some potential cases, but it is not worse than before. This has been used in the kernel kexec_file_load.

---
 kexec/arch/i386/x86-linux-setup.c |   21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
kexec/arch/i386/x86-linux-setup.c +19 -2
@@ -27,6 +27,7 @@
 #include <fcntl.h>
 #include <sys/ioctl.h>
 #include <linux/fb.h>
+#include <linux/screen_info.h>
 #include <unistd.h>
 #include <dirent.h>
 #include <mntent.h>
@@ -122,7 +123,7 @@ void setup_linux_bootloader_parameters_h
 	cmdline_ptr[cmdline_len - 1] = '\0';
 }
 
-int setup_linux_vesafb(struct x86_linux_param_header *real_mode)
+static int setup_linux_vesafb(struct x86_linux_param_header *real_mode)
 {
 	struct fb_fix_screeninfo fix;
 	struct fb_var_screeninfo var;
@@ -826,6 +827,8 @@ out:
 void setup_linux_system_parameters(struct kexec_info *info,
 				   struct x86_linux_param_header *real_mode)
 {
+	int err;
+
 	/* get subarch from running kernel */
 	setup_subarch(real_mode);
 	if (bzImage_support_efi_boot && !arch_options.noefi)
@@ -841,8 +844,22 @@ void setup_linux_system_parameters(struc
 	real_mode->orig_video_ega_bx = 0;
 	real_mode->orig_video_isVGA = 1;
 	real_mode->orig_video_points = 16;
-	setup_linux_vesafb(real_mode);
 
+	/* setup vesa fb if possible, or just use original screen_info */
+	err = setup_linux_vesafb(real_mode);
+	if (err) {
+		uint16_t cl_magic, cl_offset;
+
+		/* save and restore the old cmdline param if needed */
+		cl_magic = real_mode->cl_magic;
+		cl_offset = real_mode->cl_offset;
+
+		err = get_bootparam(real_mode, 0, sizeof(struct screen_info));
+		if (!err) {
+			real_mode->cl_magic = cl_magic;
+			real_mode->cl_offset = cl_offset;
+		}
+	}
 	/* Fill in the memsize later */
 	real_mode->ext_mem_k = 0;
 	real_mode->alt_mem_k = 0;

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

Applied
#1 lore raw
Quoted 8 lines · Dave Young

With modern drm/kms graphic driver kexec-tools does not setup screen_info correctly so one will only see screen output after those drm drivers reinitializing after rebooting. Copying the old screen info from original boot_params will help during my test, although it could not work for some potential cases, but it is not worse than before. This has been used in the kernel kexec_file_load.

Thanks, applied.

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

author
#2 lore raw
Quoted 11 lines · Simon Horman
Quoted 8 lines · Dave Young

With modern drm/kms graphic driver kexec-tools does not setup screen_info correctly so one will only see screen output after those drm drivers reinitializing after rebooting. Copying the old screen info from original boot_params will help during my test, although it could not work for some potential cases, but it is not worse than before. This has been used in the kernel kexec_file_load.

Thanks, applied.

Hi Simon,

Thanks for taking it. I tested the original version on my laptop with efi boot. either of below two changes work for me:

a) use the setup_linux_vesafb() detected values and change the orig_video_isVGA to 0x70 (copy from boot params)

b) copy all screen_info from boot params.

I actually was hesitating which one is better and finally I sent the b). But maybe a) + b) will be better, since my case is a framebuffer, I'm not sure non-framebuffer case though it will be not worse with the patch. Could you consider an appending patch below?

---
In current kexec-tools we have already vesafb detecting code, but in case unsupported vesa fb types it just return and do nothing During my test copying the old boot time screen info works for me with efi booted machine. And the vesa fb detected values also work even if the fb fix.id is "inteldrmfb", thus change the code to use those values detected with fb ioctl first for framebuffer systems.

---
 kexec/arch/i386/x86-linux-setup.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
kexec/arch/i386/x86-linux-setup.c +8 -2
@@ -123,6 +123,7 @@ void setup_linux_bootloader_parameters_h
 	cmdline_ptr[cmdline_len - 1] = '\0';
 }
 
+static int get_bootparam(void *buf, off_t offset, size_t size);
 static int setup_linux_vesafb(struct x86_linux_param_header *real_mode)
 {
 	struct fb_fix_screeninfo fix;
@@ -144,8 +145,13 @@ static int setup_linux_vesafb(struct x86
 		/* VIDEO_TYPE_EFI */
 		real_mode->orig_video_isVGA = 0x70;
 	} else {
-		/* cannot handle and other types */
-		goto out;
+		int err;
+		off_t offset = offsetof(typeof(*real_mode), orig_video_isVGA);
+
+		/* blindly try old boot time video type */
+		err = get_bootparam(&real_mode->orig_video_isVGA, offset, 1);
+		if (err)
+			goto out;
 	}
 	close(fd);
 

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

#3 lore raw
Quoted 21 lines · Dave Young
Quoted 11 lines · Simon Horman
Quoted 8 lines · Dave Young

With modern drm/kms graphic driver kexec-tools does not setup screen_info correctly so one will only see screen output after those drm drivers reinitializing after rebooting. Copying the old screen info from original boot_params will help during my test, although it could not work for some potential cases, but it is not worse than before. This has been used in the kernel kexec_file_load.

Thanks, applied.

Hi Simon,

Thanks for taking it. I tested the original version on my laptop with efi boot. either of below two changes work for me:

a) use the setup_linux_vesafb() detected values and change the orig_video_isVGA to 0x70 (copy from boot params)

Quoted 6 lines

b) copy all screen_info from boot params.

I actually was hesitating which one is better and finally I sent the b). But maybe a) + b) will be better, since my case is a framebuffer, I'm not sure non-framebuffer case though it will be not worse with the patch. Could you consider an appending patch below?

Sure, sorry for being a bit hasty.

I've appended the change below.

Quoted 31 lines

---
In current kexec-tools we have already vesafb detecting code, but in case unsupported vesa fb types it just return and do nothing During my test copying the old boot time screen info works for me with efi booted machine. And the vesa fb detected values also work even if the fb fix.id is "inteldrmfb", thus change the code to use those values detected with fb ioctl first for framebuffer systems.

---
 kexec/arch/i386/x86-linux-setup.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
kexec/arch/i386/x86-linux-setup.c +1 -2
@@ -123,6 +123,7 @@ void setup_linux_bootloader_parameters_h
 	cmdline_ptr[cmdline_len - 1] = '\0';
 }
 
+static int get_bootparam(void *buf, off_t offset, size_t size);
 static int setup_linux_vesafb(struct x86_linux_param_header *real_mode)
 {
 	struct fb_fix_screeninfo fix;
@@ -144,8 +145,13 @@ static int setup_linux_vesafb(struct x86
 		/* VIDEO_TYPE_EFI */
 		real_mode->orig_video_isVGA = 0x70;
 	} else {
-		/* cannot handle and other types */
-		goto out;

kexec/arch/i386/x86-linux-setup.c static int setup_linux_vesafb(struct x86 · line 157

Quoted 10 lines
kexec/arch/i386/x86-linux-setup.c +7 -0
+		int err;
+		off_t offset = offsetof(typeof(*real_mode), orig_video_isVGA);
+
+		/* blindly try old boot time video type */
+		err = get_bootparam(&real_mode->orig_video_isVGA, offset, 1);
+		if (err)
+			goto out;
 	}
 	close(fd);
 

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

author
#4 lore raw
Quoted 22 lines · Simon Horman
Quoted 21 lines · Dave Young
Quoted 11 lines · Simon Horman
Quoted 8 lines · Dave Young

With modern drm/kms graphic driver kexec-tools does not setup screen_info correctly so one will only see screen output after those drm drivers reinitializing after rebooting. Copying the old screen info from original boot_params will help during my test, although it could not work for some potential cases, but it is not worse than before. This has been used in the kernel kexec_file_load.

Thanks, applied.

Hi Simon,

Thanks for taking it. I tested the original version on my laptop with efi boot. either of below two changes work for me:

a) use the setup_linux_vesafb() detected values and change the orig_video_isVGA to 0x70 (copy from boot params)

Quoted 8 lines
Quoted 6 lines

b) copy all screen_info from boot params.

I actually was hesitating which one is better and finally I sent the b). But maybe a) + b) will be better, since my case is a framebuffer, I'm not sure non-framebuffer case though it will be not worse with the patch. Could you consider an appending patch below?

Sure, sorry for being a bit hasty.

Instead, I should say that..

Quoted 2 lines

I've appended the change below.

Simon, great, thank you!

Quoted 33 lines
Quoted 33 lines

---
In current kexec-tools we have already vesafb detecting code, but in case unsupported vesa fb types it just return and do nothing During my test copying the old boot time screen info works for me with efi booted machine. And the vesa fb detected values also work even if the fb fix.id is "inteldrmfb", thus change the code to use those values detected with fb ioctl first for framebuffer systems.

---
 kexec/arch/i386/x86-linux-setup.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
kexec/arch/i386/x86-linux-setup.c +4 -2
@@ -123,6 +123,7 @@ void setup_linux_bootloader_parameters_h
 	cmdline_ptr[cmdline_len - 1] = '\0';
 }
 
+static int get_bootparam(void *buf, off_t offset, size_t size);
 static int setup_linux_vesafb(struct x86_linux_param_header *real_mode)
 {
 	struct fb_fix_screeninfo fix;
@@ -144,8 +145,13 @@ static int setup_linux_vesafb(struct x86
 		/* VIDEO_TYPE_EFI */
 		real_mode->orig_video_isVGA = 0x70;
 	} else {
-		/* cannot handle and other types */
-		goto out;
+		int err;
+		off_t offset = offsetof(typeof(*real_mode), orig_video_isVGA);
+
Quoted 8 lines

kexec/arch/i386/x86-linux-setup.c static int setup_linux_vesafb(struct x86 · line 157

Quoted 8 lines
kexec/arch/i386/x86-linux-setup.c +4 -0
+		/* blindly try old boot time video type */
+		err = get_bootparam(&real_mode->orig_video_isVGA, offset, 1);
+		if (err)
+			goto out;
 	}
 	close(fd);
 

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