mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Parse guest policy from IGVM initialization headers
Extract the SNP guest policy from IGVM initialization headers when available, falling back to the default policy. This matches QEMU's behaviour where only a non-zero IGVM policy overrides the default. Signed-off-by: Ruben Hakobyan <hruben@meta.com>
This commit is contained in:
committed by
Rob Bradford
parent
4a91b4a608
commit
bfab43e252
@@ -8,6 +8,8 @@ use std::mem::size_of;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use hypervisor::HypervisorType;
|
||||
#[cfg(feature = "sev_snp")]
|
||||
use igvm::IgvmInitializationHeader;
|
||||
use igvm::snp_defs::SevVmsa;
|
||||
use igvm::{IgvmDirectiveHeader, IgvmFile, IgvmPlatformHeader};
|
||||
#[cfg(feature = "sev_snp")]
|
||||
@@ -229,6 +231,20 @@ fn import_parameter(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
///
|
||||
/// Extract guest policy from the IGVM initialization headers.
|
||||
#[cfg(feature = "sev_snp")]
|
||||
pub fn extract_guest_policy(igvm_file: &IgvmFile) -> Option<igvm_defs::SnpPolicy> {
|
||||
for header in igvm_file.initializations() {
|
||||
if let IgvmInitializationHeader::GuestPolicy { policy, .. } = header
|
||||
&& *policy != 0
|
||||
{
|
||||
return Some(igvm_defs::SnpPolicy::from_bits(*policy));
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
///
|
||||
/// Extract sev_features from the boot CPU (vp_index 0) VMSA.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user