From b8503b5f45bc264f64c47c0a90eef618f3209c3a Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Tue, 27 Sep 2022 12:28:30 +0100 Subject: [PATCH] hypervisor: Support compiling "tdx" and "mshv" feature together TDX functionality is not currently available on MSHV but we should not preclude building a binary that can run on both. Fixes: #4677 Signed-off-by: Rob Bradford --- hypervisor/src/cpu.rs | 12 +++++++++--- hypervisor/src/hypervisor.rs | 4 +++- hypervisor/src/vm.rs | 20 +++++++++++++------- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/hypervisor/src/cpu.rs b/hypervisor/src/cpu.rs index 4d5caae3a..29142892e 100644 --- a/hypervisor/src/cpu.rs +++ b/hypervisor/src/cpu.rs @@ -406,7 +406,9 @@ pub trait Vcpu: Send + Sync { /// Initialize TDX support on the vCPU /// #[cfg(feature = "tdx")] - fn tdx_init(&self, hob_address: u64) -> Result<()>; + fn tdx_init(&self, _hob_address: u64) -> Result<()> { + unimplemented!() + } /// /// Set the "immediate_exit" state /// @@ -415,12 +417,16 @@ pub trait Vcpu: Send + Sync { /// /// Returns the details about TDX exit reason /// - fn get_tdx_exit_details(&mut self) -> Result; + fn get_tdx_exit_details(&mut self) -> Result { + unimplemented!() + } #[cfg(feature = "tdx")] /// /// Set the status code for TDX exit /// - fn set_tdx_status(&mut self, status: TdxExitStatus); + fn set_tdx_status(&mut self, _status: TdxExitStatus) { + unimplemented!() + } #[cfg(target_arch = "x86_64")] /// /// Return the list of initial MSR entries for a VCPU diff --git a/hypervisor/src/hypervisor.rs b/hypervisor/src/hypervisor.rs index 3252d125b..08daee461 100644 --- a/hypervisor/src/hypervisor.rs +++ b/hypervisor/src/hypervisor.rs @@ -124,7 +124,9 @@ pub trait Hypervisor: Send + Sync { /// Retrieve TDX capabilities /// #[cfg(feature = "tdx")] - fn tdx_capabilities(&self) -> Result; + fn tdx_capabilities(&self) -> Result { + unimplemented!() + } /// /// Get the number of supported hardware breakpoints /// diff --git a/hypervisor/src/vm.rs b/hypervisor/src/vm.rs index 6361844d6..cb52d54bf 100644 --- a/hypervisor/src/vm.rs +++ b/hypervisor/src/vm.rs @@ -326,19 +326,25 @@ pub trait Vm: Send + Sync + Any { fn get_dirty_log(&self, slot: u32, base_gpa: u64, memory_size: u64) -> Result>; #[cfg(feature = "tdx")] /// Initalize TDX on this VM - fn tdx_init(&self, cpuid: &[CpuIdEntry], max_vcpus: u32) -> Result<()>; + fn tdx_init(&self, _cpuid: &[CpuIdEntry], _max_vcpus: u32) -> Result<()> { + unimplemented!() + } #[cfg(feature = "tdx")] /// Finalize the configuration of TDX on this VM - fn tdx_finalize(&self) -> Result<()>; + fn tdx_finalize(&self) -> Result<()> { + unimplemented!() + } #[cfg(feature = "tdx")] /// Initalize a TDX memory region for this VM fn tdx_init_memory_region( &self, - host_address: u64, - guest_address: u64, - size: u64, - measure: bool, - ) -> Result<()>; + _host_address: u64, + _guest_address: u64, + _size: u64, + _measure: bool, + ) -> Result<()> { + unimplemented!() + } /// Downcast to the underlying hypervisor VM type fn as_any(&self) -> &dyn Any; }