[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/pvmfw/src/entry.rs b/pvmfw/src/entry.rs
index e0af856..1309d73 100644
--- a/pvmfw/src/entry.rs
+++ b/pvmfw/src/entry.rs
@@ -25,7 +25,7 @@
use core::arch::asm;
use core::num::NonZeroUsize;
use core::slice;
-use hyp::mmio_guard;
+use hyp::get_hypervisor;
use log::debug;
use log::error;
use log::info;
@@ -172,12 +172,12 @@
// Use debug!() to avoid printing to the UART if we failed to configure it as only local
// builds that have tweaked the logger::init() call will actually attempt to log the message.
- mmio_guard::init().map_err(|e| {
+ get_hypervisor().mmio_guard_init().map_err(|e| {
debug!("{e}");
RebootReason::InternalError
})?;
- mmio_guard::map(console::BASE_ADDRESS).map_err(|e| {
+ get_hypervisor().mmio_guard_map(console::BASE_ADDRESS).map_err(|e| {
debug!("Failed to configure the UART: {e}");
RebootReason::InternalError
})?;
@@ -236,7 +236,7 @@
error!("Failed to unshare MMIO ranges: {e}");
RebootReason::InternalError
})?;
- mmio_guard::unmap(console::BASE_ADDRESS).map_err(|e| {
+ get_hypervisor().mmio_guard_unmap(console::BASE_ADDRESS).map_err(|e| {
error!("Failed to unshare the UART: {e}");
RebootReason::InternalError
})?;