MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / start_addr

Method start_addr

vmm/src/memory_manager.rs:2139–2156  ·  view source on GitHub ↗

Calculate the start address of an area next to RAM. If memory hotplug is allowed, the start address needs to be aligned (rounded-up) to 128MiB boundary. If memory hotplug is not allowed, there is no alignment required. And it must also start at the 64bit start.

(mem_end: GuestAddress, allow_mem_hotplug: bool)

Source from the content-addressed store, hash-verified

2137 // If memory hotplug is not allowed, there is no alignment required.
2138 // And it must also start at the 64bit start.
2139 fn start_addr(mem_end: GuestAddress, allow_mem_hotplug: bool) -> Result<GuestAddress, Error> {
2140 let mut start_addr = if allow_mem_hotplug {
2141 GuestAddress(mem_end.0 | ((128 << 20) - 1))
2142 } else {
2143 mem_end
2144 };
2145
2146 start_addr = start_addr
2147 .checked_add(1)
2148 .ok_or(Error::GuestAddressOverFlow)?;
2149
2150 #[cfg(not(target_arch = "riscv64"))]
2151 if mem_end < arch::layout::MEM_32BIT_RESERVED_START {
2152 return Ok(arch::layout::RAM_64BIT_START);
2153 }
2154
2155 Ok(start_addr)
2156 }
2157
2158 pub fn add_ram_region(
2159 &mut self,

Callers 15

create_memory_nodeFunction · 0.80
create_memory_nodeFunction · 0.80
generate_ram_rangesFunction · 0.80
dma_mapMethod · 0.80
dma_unmapMethod · 0.80
mapMethod · 0.80
from_regionMethod · 0.80
add_vfio_deviceMethod · 0.80
add_virtio_pci_deviceMethod · 0.80
update_memoryMethod · 0.80
eject_deviceMethod · 0.80
plugged_rangesMethod · 0.80

Calls

no outgoing calls

Tested by 1

test_vmFunction · 0.64