[hypervisor] Add mmio_guard_init() to Hypervisor trait
Since MMIO guard is currently KVM specific, we can move the details
to hypervisor/kvm.rs. This makes it easier to extend the Hypervisor
trait for the hypervisors that do not support MMIO guard.
Bug: 272226230
Test: atest rialto_test && m pvmfw_img
Change-Id: Ib313130946f7f27968fca79c7954a27bc283d0b5
diff --git a/rialto/src/main.rs b/rialto/src/main.rs
index 76f5495..99e07b6 100644
--- a/rialto/src/main.rs
+++ b/rialto/src/main.rs
@@ -28,7 +28,7 @@
paging::{Attributes, MemoryRegion},
};
use buddy_system_allocator::LockedHeap;
-use hyp::mmio_guard;
+use hyp::get_hypervisor;
use log::{debug, error, info};
use vmbase::{main, power::reboot};
@@ -109,11 +109,11 @@
}
fn try_init_logger() -> Result<()> {
- match mmio_guard::init() {
+ match get_hypervisor().mmio_guard_init() {
// pKVM blocks MMIO by default, we need to enable MMIO guard to support logging.
- Ok(()) => mmio_guard::map(vmbase::console::BASE_ADDRESS)?,
+ Ok(()) => get_hypervisor().mmio_guard_map(vmbase::console::BASE_ADDRESS)?,
// MMIO guard enroll is not supported in unprotected VM.
- Err(mmio_guard::Error::EnrollFailed(smccc::Error::NotSupported)) => {}
+ Err(hyp::Error::MmioGuardNotsupported) => {}
Err(e) => return Err(e.into()),
};
vmbase::logger::init(log::LevelFilter::Debug).map_err(|_| Error::LoggerInit)