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/pvmfw/src/fdt.rs b/guest/pvmfw/src/fdt.rs
index 6bbb05e..027f163 100644
--- a/guest/pvmfw/src/fdt.rs
+++ b/guest/pvmfw/src/fdt.rs
@@ -1140,10 +1140,15 @@
RebootReason::InvalidFdt
})?;
- let swiotlb_info = SwiotlbInfo::new_from_fdt(fdt).map_err(|e| {
- error!("Failed to read swiotlb info from DT: {e}");
- RebootReason::InvalidFdt
- })?;
+ let swiotlb_info = SwiotlbInfo::new_from_fdt(fdt)
+ .map_err(|e| {
+ error!("Failed to read swiotlb info from DT: {e}");
+ RebootReason::InvalidFdt
+ })?
+ .ok_or_else(|| {
+ error!("Swiotlb info missing from DT");
+ RebootReason::InvalidFdt
+ })?;
validate_swiotlb_info(&swiotlb_info, &memory_range)?;
let device_assignment = match vm_dtbo {