pvmfw: Issue MMIO_GUARD_ENROLL before UART setup

Issue the HVC for when pvmfw is loaded by the VMM (in crosvm, when the
--protected-vm-with-firmware flag is passed) as, in that case, pKVM
supports MMIO_GUARD but doesn't auto-enroll the VM into it. When the pVM
has been auto-enrolled, the HVC returns SUCCESS and this change has no
effect.

Test: crosvm run --protected-vm-with-firmware <pvmfw> --bios <payload>
Change-Id: Id552d6dccea7d865d593dc87c4195d146105c67f
diff --git a/pvmfw/src/mmio_guard.rs b/pvmfw/src/mmio_guard.rs
index 3b300ab..421f2c4 100644
--- a/pvmfw/src/mmio_guard.rs
+++ b/pvmfw/src/mmio_guard.rs
@@ -20,6 +20,8 @@
 
 #[derive(Debug, Clone)]
 pub enum Error {
+    /// Failed the necessary MMIO_GUARD_ENROLL call.
+    EnrollFailed(smccc::Error),
     /// Failed to obtain the MMIO_GUARD granule size.
     InfoFailed(smccc::Error),
     /// Failed to MMIO_GUARD_MAP a page.
@@ -33,6 +35,7 @@
 impl fmt::Display for Error {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match self {
+            Self::EnrollFailed(e) => write!(f, "Failed to enroll into MMIO_GUARD: {e}"),
             Self::InfoFailed(e) => write!(f, "Failed to get the MMIO_GUARD granule: {e}"),
             Self::MapFailed(e) => write!(f, "Failed to MMIO_GUARD map: {e}"),
             Self::UnsupportedGranule(g) => write!(f, "Unsupported MMIO_GUARD granule: {g}"),
@@ -41,6 +44,7 @@
 }
 
 pub fn init() -> Result<()> {
+    mmio_guard_enroll().map_err(Error::EnrollFailed)?;
     let mmio_granule = mmio_guard_info().map_err(Error::InfoFailed)? as usize;
     if mmio_granule != helpers::SIZE_4KB {
         return Err(Error::UnsupportedGranule(mmio_granule));
@@ -59,6 +63,13 @@
     smccc::checked_hvc64(VENDOR_HYP_KVM_MMIO_GUARD_INFO_FUNC_ID, args)
 }
 
+fn mmio_guard_enroll() -> smccc::Result<()> {
+    const VENDOR_HYP_KVM_MMIO_GUARD_ENROLL_FUNC_ID: u32 = 0xc6000006;
+    let args = [0u64; 17];
+
+    smccc::checked_hvc64_expect_zero(VENDOR_HYP_KVM_MMIO_GUARD_ENROLL_FUNC_ID, args)
+}
+
 fn mmio_guard_map(ipa: u64) -> smccc::Result<()> {
     const VENDOR_HYP_KVM_MMIO_GUARD_MAP_FUNC_ID: u32 = 0xc6000007;
     let mut args = [0u64; 17];