mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
hypervisor, vmm: Add KVM SEV_{INIT2, SNP_LAUNCH_START} support
Introduce the SevFd abstraction that wraps /dev/sev and implements the KVM_SEV_INIT2 and KVM_SEV_SNP_LAUNCH_START ioctls for SEV-SNP VM initialization on KVM. Key changes: - Add sev.rs with KvmSevInit and KvmSevSnpLaunchStart ioctl structs matching the kernel layout (linux/arch/x86/include/uapi/asm/kvm.h) - Implement KVM_SEV_INIT2 and KVM_SEV_SNP_LAUNCH_START ioctls - Set KVM_MEMORY_ATTRIBUTE_PRIVATE on newly created memory regions when guest_memfd is supported - Widen SevSnpPageAccessProxy cfg gates from mshv-only to all sev_snp-enabled builds - Make sev_snp_init a required trait method (remove default impl) - Include KVM_SEV_SNP_LAUNCH_START in the seccomp allowlist - Parse VMSA SEV features from IGVM and include them in the KVM_SEV_INIT2 ioctl 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> Co-authored-by: Rob Bradford <rbradford@meta.com> Signed-off-by: Rob Bradford <rbradford@meta.com> Signed-off-by: Ruben Hakobyan <hruben@meta.com>
This commit is contained in:
committed by
Rob Bradford
parent
425609a8b5
commit
2e004521e0
@@ -129,6 +129,21 @@ fn import_parameter(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
///
|
||||
/// Extract sev_features from the boot CPU (vp_index 0) VMSA.
|
||||
///
|
||||
#[cfg(feature = "sev_snp")]
|
||||
pub fn extract_sev_features(igvm_file: &IgvmFile) -> u64 {
|
||||
for header in igvm_file.directives() {
|
||||
if let IgvmDirectiveHeader::SnpVpContext { vp_index, vmsa, .. } = header
|
||||
&& *vp_index == 0
|
||||
{
|
||||
return vmsa.sev_features.into();
|
||||
}
|
||||
}
|
||||
0
|
||||
}
|
||||
|
||||
///
|
||||
/// Load the given IGVM file to guest memory.
|
||||
/// Right now it only supports SNP based isolation.
|
||||
|
||||
Reference in New Issue
Block a user