From 2d6287d159261b485fe587901449f3bd152747ce Mon Sep 17 00:00:00 2001 From: Muminul Islam Date: Tue, 12 Mar 2024 14:16:58 -0700 Subject: [PATCH] hypervisor: Fix boot failure on SNP guest Current version can't boot a SNP guest while using more than one VCPU. It turns out that there is an issue in the Snp AP creation process. We should be writing to Software exitinfo1 instead of exitinfo2. This patch fixes the issue and we can boot multi vcpu SNP guest. Signed-off-by: Muminul Islam --- hypervisor/src/mshv/mod.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hypervisor/src/mshv/mod.rs b/hypervisor/src/mshv/mod.rs index 3a63df500..847a02786 100644 --- a/hypervisor/src/mshv/mod.rs +++ b/hypervisor/src/mshv/mod.rs @@ -1104,13 +1104,14 @@ impl cpu::Vcpu for MshvVcpu { .sev_snp_ap_create(&mshv_ap_create_req) .map_err(|e| cpu::HypervisorCpuError::RunVcpu(e.into()))?; - let mut swei2_rw_gpa_arg = mshv_bindings::mshv_read_write_gpa { - base_gpa: ghcb_gpa + GHCB_SW_EXITINFO2_OFFSET, + let mut swei1_rw_gpa_arg = mshv_bindings::mshv_read_write_gpa { + base_gpa: ghcb_gpa + GHCB_SW_EXITINFO1_OFFSET, byte_count: std::mem::size_of::() as u32, ..Default::default() }; + self.fd - .gpa_write(&mut swei2_rw_gpa_arg) + .gpa_write(&mut swei1_rw_gpa_arg) .map_err(|e| cpu::HypervisorCpuError::GpaWrite(e.into()))?; } _ => panic!(