diff --git a/hypervisor/Cargo.toml b/hypervisor/Cargo.toml index 05d4c9947..1729dd90a 100644 --- a/hypervisor/Cargo.toml +++ b/hypervisor/Cargo.toml @@ -7,7 +7,8 @@ version = "0.1.0" [features] kvm = ["kvm-bindings", "kvm-ioctls", "vfio-ioctls/kvm"] -mshv = ["iced-x86", "mshv-bindings", "mshv-ioctls", "vfio-ioctls/mshv"] +mshv = ["mshv-bindings", "mshv-ioctls", "mshv_emulator", "vfio-ioctls/mshv"] +mshv_emulator = ["iced-x86", "mshv-bindings"] sev_snp = ["igvm", "igvm_defs"] tdx = [] diff --git a/hypervisor/src/arch/x86/mod.rs b/hypervisor/src/arch/x86/mod.rs index eb3db34a2..6dc195b49 100644 --- a/hypervisor/src/arch/x86/mod.rs +++ b/hypervisor/src/arch/x86/mod.rs @@ -11,7 +11,7 @@ // Copyright © 2020, Microsoft Corporation // -#[cfg(all(feature = "mshv", target_arch = "x86_64"))] +#[cfg(all(feature = "mshv_emulator", target_arch = "x86_64"))] pub mod emulator; pub mod gdt; #[allow(non_camel_case_types)] diff --git a/hypervisor/src/lib.rs b/hypervisor/src/lib.rs index ea3bb77df..7fd16ee0c 100644 --- a/hypervisor/src/lib.rs +++ b/hypervisor/src/lib.rs @@ -202,7 +202,10 @@ pub enum StandardRegisters { Kvm(kvm_bindings::kvm_regs), #[cfg(all(feature = "kvm", target_arch = "riscv64"))] Kvm(kvm_bindings::kvm_riscv_core), - #[cfg(all(feature = "mshv", target_arch = "x86_64"))] + #[cfg(all( + any(feature = "mshv", feature = "mshv_emulator"), + target_arch = "x86_64" + ))] Mshv(mshv_bindings::StandardRegisters), } @@ -215,7 +218,7 @@ macro_rules! set_x86_64_reg { match self { #[cfg(feature = "kvm")] StandardRegisters::Kvm(s) => s.$reg_name = val, - #[cfg(feature = "mshv")] + #[cfg(any(feature = "mshv", feature = "mshv_emulator"))] StandardRegisters::Mshv(s) => s.$reg_name = val, } } @@ -233,7 +236,7 @@ macro_rules! get_x86_64_reg { match self { #[cfg(feature = "kvm")] StandardRegisters::Kvm(s) => s.$reg_name, - #[cfg(feature = "mshv")] + #[cfg(any(feature = "mshv", feature = "mshv_emulator"))] StandardRegisters::Mshv(s) => s.$reg_name, } }