pvmfw: Add support for variable config entry count
Refactor Header::entries out of the struct so that it keeps a constant
size and parse the variable-sized (version-dependent) entry array from
Config, which will store a validated list of ranges describing the
blobs. This should make adding support for new blobs considerably
easier.
Derive Entry variant count (Entry::COUNT) programatically, using the
implementation suggested by jaewan@.
Bug: 291191157
Test: atest DebugPolicyHostTests
Change-Id: I7e7ad7d249a4463b3979c22b3ce10b00b97ad492
diff --git a/pvmfw/src/entry.rs b/pvmfw/src/entry.rs
index 9c929a9..3efa61e 100644
--- a/pvmfw/src/entry.rs
+++ b/pvmfw/src/entry.rs
@@ -207,7 +207,10 @@
RebootReason::InvalidConfig
})?;
- let (bcc_slice, debug_policy) = appended.get_entries();
+ let (bcc_slice, debug_policy) = appended.get_entries().map_err(|e| {
+ error!("Failed to obtained the config entries: {e}");
+ RebootReason::InvalidConfig
+ })?;
// Up to this point, we were using the built-in static (from .rodata) page tables.
MEMORY.lock().replace(MemoryTracker::new(
@@ -427,10 +430,10 @@
}
}
- fn get_entries(&mut self) -> (&mut [u8], Option<&mut [u8]>) {
+ fn get_entries(&mut self) -> config::Result<(&mut [u8], Option<&mut [u8]>)> {
match self {
Self::Config(ref mut cfg) => cfg.get_entries(),
- Self::LegacyBcc(ref mut bcc) => (bcc, None),
+ Self::LegacyBcc(ref mut bcc) => Ok((bcc, None)),
}
}
}