[rialto][fdt] Map and validate FDT range in memory before parsing
Bug: 284462758
Test: atest rialto_test
Change-Id: I50c081ad806a59da9a3965dd6787b9a1f0c9795e
diff --git a/rialto/src/error.rs b/rialto/src/error.rs
index bf26639..8e2991c 100644
--- a/rialto/src/error.rs
+++ b/rialto/src/error.rs
@@ -19,6 +19,7 @@
use fdtpci::PciError;
use hyp::Error as HypervisorError;
use libfdt::FdtError;
+use vmbase::memory::MemoryTrackerError;
pub type Result<T> = result::Result<T, Error>;
@@ -34,6 +35,8 @@
InvalidFdt(FdtError),
/// Invalid PCI.
InvalidPci(PciError),
+ /// Failed memory operation.
+ MemoryOperationFailed(MemoryTrackerError),
}
impl fmt::Display for Error {
@@ -46,6 +49,7 @@
Self::LoggerInit => write!(f, "Failed to initialize the logger."),
Self::InvalidFdt(e) => write!(f, "Invalid FDT: {e}"),
Self::InvalidPci(e) => write!(f, "Invalid PCI: {e}"),
+ Self::MemoryOperationFailed(e) => write!(f, "Failed memory operation: {e}"),
}
}
}
@@ -73,3 +77,9 @@
Self::InvalidPci(e)
}
}
+
+impl From<MemoryTrackerError> for Error {
+ fn from(e: MemoryTrackerError) -> Self {
+ Self::MemoryOperationFailed(e)
+ }
+}