Olaf Hering 51a484
From: Kairui Song <kasong@redhat.com>
Olaf Hering 51a484
Date: Wed, 14 Oct 2020 17:24:28 +0800
Olaf Hering 51a484
Patch-mainline: v5.10-rc2
Olaf Hering 51a484
References: bsc#1175306
Olaf Hering 51a484
Subject: x86/kexec: Use up-to-dated screen_info copy to fill boot params
Olaf Hering 51a484
Git-commit: afc18069a2cb7ead5f86623a5f3d4ad6e21f940d
Olaf Hering 51a484
Olaf Hering 51a484
kexec_file_load() currently reuses the old boot_params.screen_info,
Olaf Hering 51a484
but if drivers have change the hardware state, boot_param.screen_info
Olaf Hering 51a484
could contain invalid info.
Olaf Hering 51a484
Olaf Hering 51a484
For example, the video type might be no longer VGA, or the frame buffer
Olaf Hering 51a484
address might be changed. If the kexec kernel keeps using the old screen_info,
Olaf Hering 51a484
kexec'ed kernel may attempt to write to an invalid framebuffer
Olaf Hering 51a484
memory region.
Olaf Hering 51a484
Olaf Hering 51a484
There are two screen_info instances globally available, boot_params.screen_info
Olaf Hering 51a484
and screen_info. Later one is a copy, and is updated by drivers.
Olaf Hering 51a484
Olaf Hering 51a484
So let kexec_file_load use the updated copy.
Olaf Hering 51a484
Olaf Hering 51a484
[ mingo: Tidied up the changelog. ]
Olaf Hering 51a484
Olaf Hering 51a484
Signed-off-by: Kairui Song <kasong@redhat.com>
Olaf Hering 51a484
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Olaf Hering 51a484
Link: https://lore.kernel.org/r/20201014092429.1415040-2-kasong@redhat.com
Olaf Hering 51a484
Acked-by: Olaf Hering <ohering@suse.de>
Olaf Hering 51a484
---
Olaf Hering 51a484
 arch/x86/kernel/kexec-bzimage64.c | 3 +--
Olaf Hering 51a484
 1 file changed, 1 insertion(+), 2 deletions(-)
Olaf Hering 51a484
Olaf Hering 51a484
diff --git a/arch/x86/kernel/kexec-bzimage64.c b/arch/x86/kernel/kexec-bzimage64.c
Olaf Hering 51a484
--- a/arch/x86/kernel/kexec-bzimage64.c
Olaf Hering 51a484
+++ b/arch/x86/kernel/kexec-bzimage64.c
Olaf Hering 51a484
@@ -200,8 +200,7 @@ setup_boot_parameters(struct kimage *image, struct boot_params *params,
Olaf Hering 51a484
 	params->hdr.hardware_subarch = boot_params.hdr.hardware_subarch;
Olaf Hering 51a484
 
Olaf Hering 51a484
 	/* Copying screen_info will do? */
Olaf Hering 51a484
-	memcpy(&params->screen_info, &boot_params.screen_info,
Olaf Hering 51a484
-				sizeof(struct screen_info));
Olaf Hering 51a484
+	memcpy(&params->screen_info, &screen_info, sizeof(struct screen_info));
Olaf Hering 51a484
 
Olaf Hering 51a484
 	/* Fill in memsize later */
Olaf Hering 51a484
 	params->screen_info.ext_mem_k = 0;