hypervisor, vmm: pass SNP guest policy to sev_snp_init

The SNP guest policy (AMD SEV-SNP ABI bits controlling SMT, migration,
debug, etc.) was previously hardcoded inside the MSHV implementation.
Widen Vm::sev_snp_init() to accept an SnpPolicy parameter so each
hypervisor backend receives the policy at init time.

Add get_default_sev_snp_guest_policy() in the VMM to construct the
default policy.

Co-authored-by: Keith Adler <kadler@cloudflare.com>
Signed-off-by: Keith Adler <kadler@cloudflare.com>
Co-authored-by: Alex Orozco <aorozco@google.com>
Signed-off-by: Alex Orozco <aorozco@google.com>
Signed-off-by: Ruben Hakobyan <hruben@meta.com>
This commit is contained in:
Ruben Hakobyan
2026-04-07 08:09:58 -07:00
committed by Rob Bradford
parent 8ee0a07ab1
commit b545b2fc4e
4 changed files with 28 additions and 5 deletions

View File

@@ -58,7 +58,7 @@ pub use aarch64::VcpuMshvState;
#[cfg(target_arch = "aarch64")]
use aarch64::gic::{BASE_SPI_IRQ, MshvGicV2M};
#[cfg(feature = "sev_snp")]
use igvm_defs::IGVM_VHS_SNP_ID_BLOCK;
use igvm_defs::{IGVM_VHS_SNP_ID_BLOCK, SnpPolicy};
#[cfg(feature = "sev_snp")]
use snp_constants::*;
use vmm_sys_util::eventfd::EventFd;
@@ -2254,7 +2254,7 @@ impl vm::Vm for MshvVm {
/// Initialize the SEV-SNP VM
#[cfg(feature = "sev_snp")]
fn sev_snp_init(&self) -> vm::Result<()> {
fn sev_snp_init(&self, _guest_policy: SnpPolicy) -> vm::Result<()> {
self.fd
.set_partition_property(
hv_partition_property_code_HV_PARTITION_PROPERTY_ISOLATION_STATE,

View File

@@ -17,6 +17,8 @@ use std::sync::Mutex;
#[cfg(feature = "sev_snp")]
use igvm_defs::IGVM_VHS_SNP_ID_BLOCK;
#[cfg(feature = "sev_snp")]
use igvm_defs::SnpPolicy;
use thiserror::Error;
use vmm_sys_util::eventfd::EventFd;
@@ -392,7 +394,7 @@ pub trait Vm: Send + Sync + Any {
fn get_dirty_log(&self, slot: u32, base_gpa: u64, memory_size: u64) -> Result<Vec<u64>>;
#[cfg(feature = "sev_snp")]
/// Initialize SEV-SNP on this VM
fn sev_snp_init(&self) -> Result<()> {
fn sev_snp_init(&self, _guest_policy: SnpPolicy) -> Result<()> {
unimplemented!()
}
#[cfg(feature = "tdx")]