[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/Android.bp b/rialto/Android.bp
index 5034bf4..cf81563 100644
--- a/rialto/Android.bp
+++ b/rialto/Android.bp
@@ -13,7 +13,6 @@
         "libbuddy_system_allocator",
         "libhyp",
         "liblog_rust_nostd",
-        "libsmccc",
         "libvmbase",
     ],
     apex_available: ["com.android.virt"],
diff --git a/rialto/src/error.rs b/rialto/src/error.rs
index 8f34676..754e554 100644
--- a/rialto/src/error.rs
+++ b/rialto/src/error.rs
@@ -16,14 +16,14 @@
 
 use aarch64_paging::MapError;
 use core::{fmt, result};
-use hyp::mmio_guard::Error as MmioError;
+use hyp::Error as HypervisorError;
 
 pub type Result<T> = result::Result<T, Error>;
 
 #[derive(Clone, Debug)]
 pub enum Error {
-    /// MMIO guard failed.
-    MmioGuard(MmioError),
+    /// Hypervisor error.
+    Hypervisor(HypervisorError),
     /// Failed when attempting to map some range in the page table.
     PageTableMapping(MapError),
     /// Failed to initialize the logger.
@@ -33,7 +33,7 @@
 impl fmt::Display for Error {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match self {
-            Self::MmioGuard(e) => write!(f, "MMIO guard failed: {e}."),
+            Self::Hypervisor(e) => write!(f, "MMIO guard failed: {e}."),
             Self::PageTableMapping(e) => {
                 write!(f, "Failed when attempting to map some range in the page table: {e}.")
             }
@@ -42,9 +42,9 @@
     }
 }
 
-impl From<MmioError> for Error {
-    fn from(e: MmioError) -> Self {
-        Self::MmioGuard(e)
+impl From<HypervisorError> for Error {
+    fn from(e: HypervisorError) -> Self {
+        Self::Hypervisor(e)
     }
 }
 
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)