summary refs log tree commit diff
path: root/x86_64
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2020-03-13 22:21:00 +0000
committerAlyssa Ross <hi@alyssa.is>2020-06-15 09:36:35 +0000
commita5dc93df5b96728226bd3fcbc4298e6fb54f146d (patch)
tree795929a504f61dc6c38646e3076b818420343f8f /x86_64
parentc8ea9a839e28254474000729fa522b51fa860925 (diff)
downloadcrosvm-a5dc93df5b96728226bd3fcbc4298e6fb54f146d.tar
crosvm-a5dc93df5b96728226bd3fcbc4298e6fb54f146d.tar.gz
crosvm-a5dc93df5b96728226bd3fcbc4298e6fb54f146d.tar.bz2
crosvm-a5dc93df5b96728226bd3fcbc4298e6fb54f146d.tar.lz
crosvm-a5dc93df5b96728226bd3fcbc4298e6fb54f146d.tar.xz
crosvm-a5dc93df5b96728226bd3fcbc4298e6fb54f146d.tar.zst
crosvm-a5dc93df5b96728226bd3fcbc4298e6fb54f146d.zip
move MemoryParams to devices
Diffstat (limited to 'x86_64')
-rw-r--r--x86_64/Cargo.toml1
-rw-r--r--x86_64/src/lib.rs31
2 files changed, 5 insertions, 27 deletions
diff --git a/x86_64/Cargo.toml b/x86_64/Cargo.toml
index cc247c3..49ef53f 100644
--- a/x86_64/Cargo.toml
+++ b/x86_64/Cargo.toml
@@ -15,7 +15,6 @@ kernel_loader = { path = "../kernel_loader" }
 kvm = { path = "../kvm" }
 kvm_sys = { path = "../kvm_sys" }
 libc = "*"
-msg_socket = { path = "../msg_socket" }
 remain = "*"
 resources = { path = "../resources" }
 sync = { path = "../sync" }
diff --git a/x86_64/src/lib.rs b/x86_64/src/lib.rs
index 09940cf..3aff53d 100644
--- a/x86_64/src/lib.rs
+++ b/x86_64/src/lib.rs
@@ -62,12 +62,11 @@ use arch::{
 };
 use devices::split_irqchip_common::GsiRelay;
 use devices::{
-    Ioapic, PciAddress, PciConfigIo, PciDevice, PciInterruptPin, Pic, IOAPIC_BASE_ADDRESS,
-    IOAPIC_MEM_LENGTH_BYTES,
+    Ioapic, MemoryParams, PciAddress, PciConfigIo, PciDevice, PciInterruptPin, Pic,
+    IOAPIC_BASE_ADDRESS, IOAPIC_MEM_LENGTH_BYTES,
 };
 use io_jail::Minijail;
 use kvm::*;
-use msg_socket::MsgOnSocket;
 use remain::sorted;
 use resources::SystemAllocator;
 use sync::Mutex;
@@ -309,27 +308,6 @@ fn add_e820_entry(params: &mut boot_params, addr: u64, size: u64, mem_type: u32)
     Ok(())
 }
 
-#[derive(Clone, Copy, Debug, MsgOnSocket)]
-pub struct MemoryParams {
-    /// Physical memory size in bytes for the VM.
-    pub size: u64,
-    pub has_bios: bool,
-}
-
-impl MemoryParams {
-    fn new(components: &VmComponents) -> Self {
-        let has_bios = match components.vm_image {
-            VmImage::Bios(_) => true,
-            _ => false,
-        };
-
-        MemoryParams {
-            size: components.memory_size,
-            has_bios,
-        }
-    }
-}
-
 /// Returns a Vec of the valid memory addresses.
 /// These should be used to configure the GuestMemory structure for the platform.
 /// For x86_64 all addresses are valid from the start of the kernel except a
@@ -374,13 +352,14 @@ impl arch::LinuxArch for X8664arch {
     where
         F: FnOnce(
             &GuestMemory,
+            MemoryParams,
             &mut Vm,
             &mut SystemAllocator,
             &EventFd,
         ) -> std::result::Result<Vec<(Box<dyn PciDevice>, Option<Minijail>)>, E>,
         E: StdError + 'static,
     {
-        let mem_params = MemoryParams::new(&components);
+        let mem_params = components.memory_params();
         let mem = Self::setup_memory(mem_params)?;
         let mut resources = Self::get_resource_allocator(&mem, components.wayland_dmabuf);
 
@@ -429,7 +408,7 @@ impl arch::LinuxArch for X8664arch {
         } else {
             (None, None)
         };
-        let pci_devices = create_devices(&mem, &mut vm, &mut resources, &exit_evt)
+        let pci_devices = create_devices(&mem, mem_params, &mut vm, &mut resources, &exit_evt)
             .map_err(|e| Error::CreateDevices(Box::new(e)))?;
         let (pci, pci_irqs, pid_debug_label_map) = arch::generate_pci_root(
             pci_devices,