From 8c796e6d5d4d2db9e6800f7daa5aea785a05c041 Mon Sep 17 00:00:00 2001 From: Jinank Jain Date: Mon, 10 Feb 2025 07:54:03 +0000 Subject: [PATCH] hypervisor: Add MSHV implementation of VcpuInit Extend the VcpuInit interface to accomodate changes for MSHV on aarch64. Signed-off-by: Jinank Jain --- hypervisor/src/lib.rs | 2 ++ hypervisor/src/mshv/mod.rs | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/hypervisor/src/lib.rs b/hypervisor/src/lib.rs index d22e7b2b3..a644d5cd9 100644 --- a/hypervisor/src/lib.rs +++ b/hypervisor/src/lib.rs @@ -200,6 +200,8 @@ pub enum IrqRoutingEntry { pub enum VcpuInit { #[cfg(all(feature = "kvm", target_arch = "aarch64"))] Kvm(kvm_bindings::kvm_vcpu_init), + #[cfg(all(feature = "mshv", target_arch = "aarch64"))] + Mshv(mshv_bindings::MshvVcpuInit), } #[derive(Debug, Clone, PartialEq)] diff --git a/hypervisor/src/mshv/mod.rs b/hypervisor/src/mshv/mod.rs index a31461ef3..15cfe8fbd 100644 --- a/hypervisor/src/mshv/mod.rs +++ b/hypervisor/src/mshv/mod.rs @@ -210,6 +210,25 @@ impl From for mshv_bindings::MshvRegList { } } +#[cfg(target_arch = "aarch64")] +impl From for crate::VcpuInit { + fn from(s: mshv_bindings::MshvVcpuInit) -> Self { + crate::VcpuInit::Mshv(s) + } +} + +#[cfg(target_arch = "aarch64")] +impl From for mshv_bindings::MshvVcpuInit { + fn from(e: crate::VcpuInit) -> Self { + match e { + crate::VcpuInit::Mshv(e) => e, + /* Needed in case other hypervisors are enabled */ + #[allow(unreachable_patterns)] + _ => panic!("VcpuInit is not valid"), + } + } +} + struct MshvDirtyLogSlot { guest_pfn: u64, memory_size: u64,