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/helpers.rs b/pvmfw/src/helpers.rs
index 9062957..ead8bb4 100644
--- a/pvmfw/src/helpers.rs
+++ b/pvmfw/src/helpers.rs
@@ -26,6 +26,13 @@
addr & !(alignment - 1)
}
+/// Computes the smallest multiple of the provided alignment larger or equal to the address.
+///
+/// Note: the result is undefined if alignment isn't a power of two and may wrap to 0.
+pub const fn unchecked_align_up(addr: usize, alignment: usize) -> usize {
+ unchecked_align_down(addr + alignment - 1, alignment)
+}
+
/// Safe wrapper around unchecked_align_up() that validates its assumptions and doesn't wrap.
pub const fn align_up(addr: usize, alignment: usize) -> Option<usize> {
if !alignment.is_power_of_two() {