From ff4c8f7480ae6646e99515acae33493c220d8d71 Mon Sep 17 00:00:00 2001 From: Muminul Islam Date: Fri, 13 Feb 2026 12:18:10 -0800 Subject: [PATCH] hypervisor: mshv: handle Special Debug Print VMG exit Add handling for GHCB_INFO_SPECIAL_DBGPRINT VMG exit in the SEV-SNP guest exit handler. This exit occurs when the guest sends debug print requests through the GHCB interface. Without this handler, SEV-SNP guests fail to boot when debug output is triggered, such as when a debugger is attached to the guest image. The handler acknowledges the exit without printing to avoid performance degradation from frequent debug print requests. Signed-off-by: Muminul Islam --- hypervisor/src/mshv/mod.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hypervisor/src/mshv/mod.rs b/hypervisor/src/mshv/mod.rs index b36b306a9..b7bdbf6a5 100644 --- a/hypervisor/src/mshv/mod.rs +++ b/hypervisor/src/mshv/mod.rs @@ -873,6 +873,19 @@ impl cpu::Vcpu for MshvVcpu { assert!(info.header.intercept_access_type == HV_INTERCEPT_ACCESS_EXECUTE as u8); match ghcb_op { + GHCB_INFO_SPECIAL_DBGPRINT => { + // Handle debug print from guest + // The guest sends a character to print via GHCB data + // Sample debug print implementation that only prints ASCII characters and ignores the rest + // let char_to_print = (ghcb_data & 0xFF) as u8; + // if char_to_print.is_ascii() { + // debug!("'{}'", char_to_print as char); + // } + // Not printing the character to slow down the guest a bit, + // as these debug prints can be very frequent. + // In real implementation, we might want to buffer these characters and + // print them out together or implement some rate limiting.] + } GHCB_INFO_HYP_FEATURE_REQUEST => { // Pre-condition: GHCB data must be zero assert!(ghcb_data == 0);