From c0549c75e789747b714ee04052b408e1f2cecede Mon Sep 17 00:00:00 2001 From: Sam Leffler Date: Fri, 8 Apr 2022 15:56:51 +0000 Subject: [PATCH] kata-os-model: correct slot calculation for untyped memory handoff When calculating the landing spot for handing off the UntypedMemory objects we need to take into account empty slots. Calculate the max occupied slot # and add one. This works so long as empty slots have not been allocated (by CAmkES) at the end of the CNode--which should be safe since we control the MemoryManager CAmkES specification. Change-Id: I5bfb75bd7134254c4475a91653d54e2aeb126721 GitOrigin-RevId: cf14850894ad21be97ea094f977c3420edf322ab --- .../components/kata-os-common/src/kata-os-model/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/system/components/kata-os-common/src/kata-os-model/mod.rs b/apps/system/components/kata-os-common/src/kata-os-model/mod.rs index a1b6d85..e81eab4 100644 --- a/apps/system/components/kata-os-common/src/kata-os-model/mod.rs +++ b/apps/system/components/kata-os-common/src/kata-os-model/mod.rs @@ -934,7 +934,11 @@ impl<'a> KataOsModel<'a> { let num_untypeds = self.bootinfo.untyped.end - self.bootinfo.untyped.start; // NB: UntypedMemory caps are appended to the CAmkES-generated slots - let dest_start = self.spec.obj_slice()[cnode_obj_id].num_slots() + 1; + let dest_start = self.spec.obj_slice()[cnode_obj_id] + .slots_slice() + .iter() + .max_by_key(|slot| slot.slot) + .map_or(0, |slot| slot.slot + 1); info!("Hand-off {} untypeds from {} to {}", num_untypeds,