pvmfw: config: Tolerate invalid zero-sized entries
Instead of rejecting entries that have a non-zero offset with zero size,
which the config data spec considers to be invalid (as missing entries
should have both offset and size set to zero), consider them as (valid)
missing entries. This allows pVMs to boot with our currentt bootloader.
Bug: 262181812
Test: boot pVM on a device that doesn't have a debug policy
Change-Id: I7cd7e6196329333409e4043c8bd79174767e82b9
diff --git a/pvmfw/src/config.rs b/pvmfw/src/config.rs
index 4b6f9d2..b633745 100644
--- a/pvmfw/src/config.rs
+++ b/pvmfw/src/config.rs
@@ -114,7 +114,16 @@
let offset = e.offset as usize;
let size = e.size as usize;
- self._get_body_range(offset, size).map_err(|e| Error::InvalidEntry(entry, e))
+ match self._get_body_range(offset, size) {
+ Ok(r) => Ok(r),
+ Err(EntryError::InvalidSize(0)) => {
+ // As our bootloader currently uses this (non-compliant) case, permit it for now.
+ log::warn!("Config entry {entry:?} uses non-zero offset with zero size");
+ // TODO(b/262181812): Either make this case valid or fix the bootloader.
+ Ok(None)
+ }
+ Err(e) => Err(Error::InvalidEntry(entry, e)),
+ }
}
fn _get_body_range(