From: Ashish Kalra <ashish.ka...@amd.com>

Accessing guest video memory/RAM during kernel decompressor
causes guest termination as boot stage2 #VC handler for
SEV-ES/SNP systems does not support MMIO handling.

This issue is observed with SEV-ES/SNP guest kexec as
kexec -c adds screen_info to the boot parameters
passed to the kexec kernel, which causes console output to
be dumped to both video and serial.

As the decompressor output gets cleared really fast, it is
preferable to get the console output only on serial, hence,
skip accessing video RAM during decompressor stage to
prevent guest termination.

Add early_sev_detect() to detect SEV-ES/SNP guest and skip
accessing video RAM during decompressor stage.

Serial console output during decompressor stage works as
boot stage2 #VC handler already supports handling port I/O.

Suggested-by: Borislav Petkov <borislav.pet...@amd.com>
Suggested-by: Thomas Lendacy <thomas.lenda...@amd.com>
Signed-off-by: Ashish Kalra <ashish.ka...@amd.com>
Reviewed-by: Kuppuswamy Sathyanarayanan 
<sathyanarayanan.kuppusw...@linux.intel.com>
---
 arch/x86/boot/compressed/misc.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index b70e4a21c15f..bad924f20a3a 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -385,6 +385,27 @@ static void parse_mem_encrypt(struct setup_header *hdr)
                hdr->xloadflags |= XLF_MEM_ENCRYPTION;
 }
 
+static void early_sev_detect(void)
+{
+       /*
+        * Accessing guest video memory/RAM during kernel decompressor
+        * causes guest termination as boot stage2 #VC handler for
+        * SEV-ES/SNP systems does not support MMIO handling.
+        *
+        * This issue is observed with SEV-ES/SNP guest kexec as
+        * kexec -c adds screen_info to the boot parameters
+        * passed to the kexec kernel, which causes console output to
+        * be dumped to both video and serial.
+        *
+        * As the decompressor output gets cleared really fast, it is
+        * preferable to get the console output only on serial, hence,
+        * skip accessing video RAM during decompressor stage to
+        * prevent guest termination.
+        */
+       if (sev_status & MSR_AMD64_SEV_ES_ENABLED)
+               lines = cols = 0;
+}
+
 /*
  * The compressed kernel image (ZO), has been moved so that its position
  * is against the end of the buffer used to hold the uncompressed kernel
@@ -440,6 +461,8 @@ asmlinkage __visible void *extract_kernel(void *rmode, 
unsigned char *output)
         */
        early_tdx_detect();
 
+       early_sev_detect();
+
        console_init();
 
        /*
-- 
2.34.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

Reply via email to