mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-25 05:03:05 +00:00
aarch64: Merge adjacent regions in FDT memory node.
BUG=b:244553205 TEST=Patched into AOSP and ran some VMs. Change-Id: I95710fdb264a3bd1e8e69ed6dfad77bbc05b3043 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4440589 Reviewed-by: Jiyong Park <jiyong@google.com> Reviewed-by: Alexandre Courbot <acourbot@chromium.org> Reviewed-by: Pierre-Clément Tosi <ptosi@google.com> Commit-Queue: Andrew Walbran <qwandor@google.com>
This commit is contained in:
parent
03c4671233
commit
fc8bb6efbf
1 changed files with 16 additions and 1 deletions
|
@ -63,12 +63,27 @@ const IRQ_TYPE_LEVEL_LOW: u32 = 0x00000008;
|
|||
|
||||
fn create_memory_node(fdt: &mut FdtWriter, guest_mem: &GuestMemory) -> Result<()> {
|
||||
let mut mem_reg_prop = Vec::new();
|
||||
for region in guest_mem.guest_memory_regions() {
|
||||
let mut previous_memory_region_end = None;
|
||||
let mut regions = guest_mem.guest_memory_regions();
|
||||
regions.sort();
|
||||
for region in regions {
|
||||
if region.0.offset() == AARCH64_PROTECTED_VM_FW_START {
|
||||
continue;
|
||||
}
|
||||
// Merge with the previous region if possible.
|
||||
if let Some(previous_end) = previous_memory_region_end {
|
||||
if region.0 == previous_end {
|
||||
*mem_reg_prop.last_mut().unwrap() += region.1 as u64;
|
||||
previous_memory_region_end =
|
||||
Some(previous_end.checked_add(region.1 as u64).unwrap());
|
||||
continue;
|
||||
}
|
||||
assert!(region.0 > previous_end, "Memory regions overlap");
|
||||
}
|
||||
|
||||
mem_reg_prop.push(region.0.offset());
|
||||
mem_reg_prop.push(region.1 as u64);
|
||||
previous_memory_region_end = Some(region.0.checked_add(region.1 as u64).unwrap());
|
||||
}
|
||||
|
||||
let memory_node = fdt.begin_node("memory")?;
|
||||
|
|
Loading…
Reference in a new issue