pvmfw: config: Treat v1.x as latest version known

Currently, pvmfw rejects config data of versions it doesn't support,
which leads to the pVM boot being aborted. Instead, as the config header
format was designed to be forward compatible[*], if a version v1.x
higher than the latest known version is encountered, treat it as the
highest supported version i.e. read the entries that were supported in
that latest version and ignore any new (unknown) entries.

For the same reason, stop rejecting unknown config data flags being set.

Rename body_offset() to body_lowest_bound() to make it clear that it is
a best-effort value.

[*]: its first fields (magic, version, size, flags) are fixed and its
     array of entries (of version-dependent size) contains offsets from
     the base (not end) of the header.

Bug: 296207806
Test: atest DebugPolicyHostTests
Change-Id: I7969d0189be48a6d54c85965d0092495b43e1982
diff --git a/pvmfw/src/config.rs b/pvmfw/src/config.rs
index db27001..d0a6b7f 100644
--- a/pvmfw/src/config.rs
+++ b/pvmfw/src/config.rs
@@ -18,7 +18,7 @@
 use core::mem;
 use core::ops::Range;
 use core::result;
-use log::info;
+use log::{info, warn};
 use static_assertions::const_assert_eq;
 use vmbase::util::RangeExt;
 use zerocopy::{FromBytes, LayoutVerified};
@@ -47,8 +47,6 @@
     InvalidMagic,
     /// Version of the header isn't supported.
     UnsupportedVersion(Version),
-    /// Header sets flags incorrectly or uses reserved flags.
-    InvalidFlags(u32),
     /// Header describes configuration data that doesn't fit in the expected buffer.
     InvalidSize(usize),
     /// Header entry is missing.
@@ -64,7 +62,6 @@
             Self::HeaderMisaligned => write!(f, "Reserved region is misaligned"),
             Self::InvalidMagic => write!(f, "Wrong magic number"),
             Self::UnsupportedVersion(v) => write!(f, "Version {v} not supported"),
-            Self::InvalidFlags(v) => write!(f, "Flags value {v:#x} is incorrect or reserved"),
             Self::InvalidSize(sz) => write!(f, "Total size ({sz:#x}) overflows reserved region"),
             Self::MissingEntry(entry) => write!(f, "Mandatory {entry:?} entry is missing"),
             Self::EntryOutOfBounds(entry, range, limits) => {
@@ -88,7 +85,7 @@
         self.total_size as usize
     }
 
-    pub fn body_offset(&self) -> Result<usize> {
+    pub fn body_lowest_bound(&self) -> Result<usize> {
         let entries_offset = mem::size_of::<Self>();
 
         // Ensure that the entries are properly aligned and do not require padding.
@@ -104,6 +101,11 @@
         let last_entry = match self.version {
             Self::VERSION_1_0 => Entry::DebugPolicy,
             Self::VERSION_1_1 => Entry::VmDtbo,
+            v @ Version { major: 1, .. } => {
+                const LATEST: Version = Header::VERSION_1_1;
+                warn!("Parsing unknown config data version {v} as version {LATEST}");
+                return Ok(Entry::COUNT);
+            }
             v => return Err(Error::UnsupportedVersion(v)),
         };
 
@@ -181,8 +183,9 @@
             return Err(Error::InvalidMagic);
         }
 
-        if header.flags != 0 {
-            return Err(Error::InvalidFlags(header.flags));
+        let header_flags = header.flags;
+        if header_flags != 0 {
+            warn!("Ignoring unknown config flags: {header_flags:#x}");
         }
 
         info!("pvmfw config version: {}", header.version);
@@ -206,7 +209,7 @@
         // Validate that we won't get an invalid alignment in the following due to padding to u64.
         const_assert_eq!(mem::size_of::<HeaderEntry>() % mem::size_of::<u64>(), 0);
 
-        let limits = header.body_offset()?..total_size;
+        let limits = header.body_lowest_bound()?..total_size;
         let ranges = [
             // TODO: Find a way to do this programmatically even if the trait
             // `core::marker::Copy` is not implemented for `core::ops::Range<usize>`.