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)
| 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, |
no outgoing calls