diff options
author | Daniel Verkamp <dverkamp@chromium.org> | 2019-05-22 10:24:24 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-05-23 02:14:28 -0700 |
commit | ced74e6f2f4653049fc9a23959214bd9b3a3ab4a (patch) | |
tree | 97c780836f97d40292242419bb24e5167bc9cf16 /x86_64 | |
parent | 2b570f698a8dc018a61a192a377a281546585f02 (diff) | |
download | crosvm-ced74e6f2f4653049fc9a23959214bd9b3a3ab4a.tar crosvm-ced74e6f2f4653049fc9a23959214bd9b3a3ab4a.tar.gz crosvm-ced74e6f2f4653049fc9a23959214bd9b3a3ab4a.tar.bz2 crosvm-ced74e6f2f4653049fc9a23959214bd9b3a3ab4a.tar.lz crosvm-ced74e6f2f4653049fc9a23959214bd9b3a3ab4a.tar.xz crosvm-ced74e6f2f4653049fc9a23959214bd9b3a3ab4a.tar.zst crosvm-ced74e6f2f4653049fc9a23959214bd9b3a3ab4a.zip |
devices: cmos: report memory size in CMOS
This matches the QEMU CMOS implementation and is used by BIOSes to determine the valid memory regions to add to the e820 map. BUG=b:133358982 TEST=Boot u-boot qemu build; observe memory size Change-Id: I27956bc05738b5dd5b84240d5137cb06846aaab9 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1625330 Tested-by: kokoro <noreply+kokoro@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
Diffstat (limited to 'x86_64')
-rw-r--r-- | x86_64/src/lib.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/x86_64/src/lib.rs b/x86_64/src/lib.rs index 0a2185c..5e54e69 100644 --- a/x86_64/src/lib.rs +++ b/x86_64/src/lib.rs @@ -352,6 +352,7 @@ impl arch::LinuxArch for X8664arch { split_irqchip, exit_evt.try_clone().map_err(Error::CloneEventFd)?, Some(pci_bus.clone()), + components.memory_size, )?; let (stdio_serial_num, stdio_serial) = @@ -582,11 +583,13 @@ impl X8664arch { /// * - `vm` the vm object /// * - `split_irqchip`: whether to use a split IRQ chip (i.e. userspace PIT/PIC/IOAPIC) /// * - `exit_evt` - the event fd object which should receive exit events + /// * - `mem_size` - the size in bytes of physical ram for the guest fn setup_io_bus( vm: &mut Vm, split_irqchip: bool, exit_evt: EventFd, pci: Option<Arc<Mutex<devices::PciConfigIo>>>, + mem_size: u64, ) -> Result<(devices::Bus)> { struct NoDevice; impl devices::BusDevice for NoDevice { @@ -597,8 +600,17 @@ impl X8664arch { let mut io_bus = devices::Bus::new(); + let mem_gap_start = FIRST_ADDR_PAST_32BITS - MEM_32BIT_GAP_SIZE; + let mem_below_4g = std::cmp::min(mem_gap_start, mem_size); + let mem_above_4g = mem_size.saturating_sub(FIRST_ADDR_PAST_32BITS); + io_bus - .insert(Arc::new(Mutex::new(devices::Cmos::new())), 0x70, 0x2, false) + .insert( + Arc::new(Mutex::new(devices::Cmos::new(mem_below_4g, mem_above_4g))), + 0x70, + 0x2, + false, + ) .unwrap(); io_bus .insert( |