vmbase: Support missing SwiotlbInfo DT node
Stop failing with an Err() when SwiotlbInfo::new_from_fdt() is called on
DTs missing the "restricted-dma-pool" (e.g. in non-protected VMs) and
instead return Ok(None), which the caller can handle appropriately.
While here, use the proper error code (BadValue) when a <reg> property
is present but empty or is missing a size.
Bug: 377276983
Test: m {pvmfw,rialto,vmbase_example_{bios,kernel}}_bin
Test: atest rialto_test vmbase_example.integration_test
Change-Id: I58179318d34c33c20e6333f02b066574d0fb47a5
diff --git a/guest/rialto/src/main.rs b/guest/rialto/src/main.rs
index 0b79e1e..ec26e0f 100644
--- a/guest/rialto/src/main.rs
+++ b/guest/rialto/src/main.rs
@@ -117,7 +117,7 @@
MEMORY.lock().as_mut().unwrap().init_dynamic_shared_pool(granule).inspect_err(|_| {
error!("Failed to initialize dynamically shared pool.");
})?;
- } else if let Ok(swiotlb_info) = SwiotlbInfo::new_from_fdt(fdt) {
+ } else if let Ok(Some(swiotlb_info)) = SwiotlbInfo::new_from_fdt(fdt) {
let range = swiotlb_info.fixed_range().ok_or_else(|| {
error!("Pre-shared pool range not specified in swiotlb node");
Error::from(FdtError::BadValue)