pvmfw: Warn for misaligned assigned MMIO regions
Prepare for an upcoming change by checking that the regions are properly
aligned to the hypervisor granule (re-used from MEM_SHARE). However,
don't fail validation yet, as our tests use data that is not aligned.
Update the tests to supply an MMIO_GRANULE.
Test: m libpvmfw.device_assignment.test pvmfw_bin
Change-Id: I8bb9aa134f8f5f74586fcc36b6de3e552c2491ba
diff --git a/guest/pvmfw/src/fdt.rs b/guest/pvmfw/src/fdt.rs
index 0d934a6..f667d60 100644
--- a/guest/pvmfw/src/fdt.rs
+++ b/guest/pvmfw/src/fdt.rs
@@ -1148,7 +1148,18 @@
let device_assignment = match vm_dtbo {
Some(vm_dtbo) => {
if let Some(hypervisor) = hyp::get_device_assigner() {
- DeviceAssignmentInfo::parse(fdt, vm_dtbo, hypervisor).map_err(|e| {
+ // TODO(ptosi): Cache the (single?) granule once, in vmbase.
+ let granule = hyp::get_mem_sharer()
+ .ok_or_else(|| {
+ error!("No MEM_SHARE found during device assignment validation");
+ RebootReason::InternalError
+ })?
+ .granule()
+ .map_err(|e| {
+ error!("Failed to get granule for device assignment validation: {e}");
+ RebootReason::InternalError
+ })?;
+ DeviceAssignmentInfo::parse(fdt, vm_dtbo, hypervisor, granule).map_err(|e| {
error!("Failed to parse device assignment from DT and VM DTBO: {e}");
RebootReason::InvalidFdt
})?