openhcl_boot/arch/x86_64/
vsm.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! Arch-specific VSM details.
5
6use crate::host_params::shim_params::IsolationType;
7use loader_defs::shim::SupportedIsolationType;
8
9pub fn get_isolation_type(supported_isolation_type: SupportedIsolationType) -> IsolationType {
10    match supported_isolation_type {
11        SupportedIsolationType::VBS => {
12            let cpuid_result = safe_intrinsics::cpuid(hvdef::HV_CPUID_FUNCTION_MS_HV_FEATURES, 0);
13            let privs = cpuid_result.eax as u64 | ((cpuid_result.ebx as u64) << 32);
14            if hvdef::HvPartitionPrivilege::from(privs).isolation() {
15                IsolationType::Vbs
16            } else {
17                IsolationType::None
18            }
19        }
20        SupportedIsolationType::SNP => IsolationType::Snp,
21        SupportedIsolationType::TDX => IsolationType::Tdx,
22        _ => panic!("unexpected isolation type"),
23    }
24}