[hypervisor] Gunyah support
Extend support for Gunyah hypervisor.
Test: Booted protected VM on Gunyah hypervisor.
Bug: 271493784
Change-Id: I32d59ac35f884327b5ddab5ab9a8b71f17530007
Merged-In: I32d59ac35f884327b5ddab5ab9a8b71f17530007
diff --git a/libs/hyp/src/hypervisor/gunyah.rs b/libs/hyp/src/hypervisor/gunyah.rs
new file mode 100644
index 0000000..b335c87
--- /dev/null
+++ b/libs/hyp/src/hypervisor/gunyah.rs
@@ -0,0 +1,40 @@
+use super::common::{Hypervisor, HypervisorCap};
+use crate::error::Result;
+use crate::util::SIZE_4KB;
+use uuid::{uuid, Uuid};
+
+pub(super) struct GunyahHypervisor;
+
+impl GunyahHypervisor {
+ pub const UUID: Uuid = uuid!("c1d58fcd-a453-5fdb-9265-ce36673d5f14");
+}
+
+impl Hypervisor for GunyahHypervisor {
+ fn mmio_guard_init(&self) -> Result<()> {
+ Ok(())
+ }
+
+ fn mmio_guard_map(&self, _addr: usize) -> Result<()> {
+ Ok(())
+ }
+
+ fn mmio_guard_unmap(&self, _addr: usize) -> Result<()> {
+ Ok(())
+ }
+
+ fn mem_share(&self, _base_ipa: u64) -> Result<()> {
+ unimplemented!();
+ }
+
+ fn mem_unshare(&self, _base_ipa: u64) -> Result<()> {
+ unimplemented!();
+ }
+
+ fn memory_protection_granule(&self) -> Result<usize> {
+ Ok(SIZE_4KB)
+ }
+
+ fn has_cap(&self, _cap: HypervisorCap) -> bool {
+ false
+ }
+}
diff --git a/libs/hyp/src/hypervisor/mod.rs b/libs/hyp/src/hypervisor/mod.rs
index a419726..05c82dc 100644
--- a/libs/hyp/src/hypervisor/mod.rs
+++ b/libs/hyp/src/hypervisor/mod.rs
@@ -17,12 +17,14 @@
extern crate alloc;
mod common;
+mod gunyah;
mod kvm;
use crate::error::{Error, Result};
use alloc::boxed::Box;
pub use common::Hypervisor;
pub use common::HypervisorCap;
+use gunyah::GunyahHypervisor;
pub use kvm::KvmError;
use kvm::KvmHypervisor;
use once_cell::race::OnceBox;
@@ -31,12 +33,14 @@
enum HypervisorBackend {
Kvm,
+ Gunyah,
}
impl HypervisorBackend {
fn get_hypervisor(&self) -> &'static dyn Hypervisor {
match self {
Self::Kvm => &KvmHypervisor,
+ Self::Gunyah => &GunyahHypervisor,
}
}
}
@@ -46,6 +50,7 @@
fn try_from(uuid: Uuid) -> Result<HypervisorBackend> {
match uuid {
+ GunyahHypervisor::UUID => Ok(HypervisorBackend::Gunyah),
KvmHypervisor::UUID => Ok(HypervisorBackend::Kvm),
u => Err(Error::UnsupportedHypervisorUuid(u)),
}