pvmfw: Add support for appended configuration data

Implement a standardized way for pvmfw to receive data at load time,
which can be used by the platform to pass device-specific secrets or
influence the boot process. Unlike data received from the VMM, it is
(and must be) trusted.

Previously, the payload appended to pvmfw was the BCC (now incorporated
into the config data). To avoid breaking devices that do not yet support
this config format, if the appended data doesn't contain a valid config
header, fall back to assuming that it is a raw BCC when the 'legacy'
feature is enabled (default).

Bug: 238050226
Bug: 256827715
Test: atest MicrodroidTestApp
Change-Id: I2614e5df34df19052d7e12d24280d581dfaf06f7
diff --git a/pvmfw/src/mmu.rs b/pvmfw/src/mmu.rs
index d68e389..fa94e85 100644
--- a/pvmfw/src/mmu.rs
+++ b/pvmfw/src/mmu.rs
@@ -14,6 +14,7 @@
 
 //! Memory management.
 
+use crate::helpers;
 use aarch64_paging::idmap::IdMap;
 use aarch64_paging::paging::Attributes;
 use aarch64_paging::paging::MemoryRegion;
@@ -35,6 +36,14 @@
     idmap: IdMap,
 }
 
+fn appended_payload_range() -> Range<usize> {
+    let start = helpers::align_up(layout::binary_end(), helpers::SIZE_4KB).unwrap();
+    // pvmfw is contained in a 2MiB region so the payload can't be larger than the 2MiB alignment.
+    let end = helpers::align_up(start, helpers::SIZE_2MB).unwrap();
+
+    start..end
+}
+
 impl PageTable {
     const ASID: usize = 1;
     const ROOT_LEVEL: usize = 1;
@@ -46,6 +55,7 @@
         page_table.map_code(&layout::text_range())?;
         page_table.map_data(&layout::writable_region())?;
         page_table.map_rodata(&layout::rodata_range())?;
+        page_table.map_data(&appended_payload_range())?;
 
         Ok(page_table)
     }