diff options
author | Cody Schuffelen <schuffelen@google.com> | 2019-05-21 12:12:38 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-05-31 17:21:46 -0700 |
commit | 6d1ab5094375afb653d9955fe7ccb818eca48665 (patch) | |
tree | 863d07e2334dec3f66961afbdcb8a618b08384e1 /src/linux.rs | |
parent | 580d4186562c9c1e5b399885c6c5647cdde15243 (diff) | |
download | crosvm-6d1ab5094375afb653d9955fe7ccb818eca48665.tar crosvm-6d1ab5094375afb653d9955fe7ccb818eca48665.tar.gz crosvm-6d1ab5094375afb653d9955fe7ccb818eca48665.tar.bz2 crosvm-6d1ab5094375afb653d9955fe7ccb818eca48665.tar.lz crosvm-6d1ab5094375afb653d9955fe7ccb818eca48665.tar.xz crosvm-6d1ab5094375afb653d9955fe7ccb818eca48665.tar.zst crosvm-6d1ab5094375afb653d9955fe7ccb818eca48665.zip |
Initial BIOS support.
The --bios argument is added as an alternative to the kernel positional argument. The BIOS runs in unreal mode (16-bit cs selector set to the end of 32-bit address space), which matches the default state KVM puts the segment and data registers into. Example usage: Build u-boot with "make qemu-x86_defconfig && make" Run crosvm with "crosvm_wrapper.sh run --bios=u-boot.rom" This produces the following message: """ U-Boot 2019.01-00017-gdc76aabe6a-dirty (May 21 2019 - 12:17:02 -0700) CPU: DRAM: 16 MiB unable to get online cpu number: -19 Warning: MP init failure Model: QEMU x86 (I440FX) Net: No ethernet found. error: can't find etc/table-loader Hit any key to stop autoboot: 0 => """ At this point the u-boot shell works with stdin/stdout, but virtual disks passed with --rwdisk weren't immediately visible from running "virtio scan" and "virtio info". This change puts the bios loading together with the linux kernel loading code since there is a lot of overlap in functionality. Bug: b/133358982 Test: ./crosvm_wrapper.sh run --mem=4097 --bios=u-boot.rom Change-Id: I65b0e1044233af662a642c592d35b106217f3c13 Reviewed-on: https://chromium-review.googlesource.com/1622648 Commit-Ready: Daniel Verkamp <dverkamp@chromium.org> Tested-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Diffstat (limited to 'src/linux.rs')
-rw-r--r-- | src/linux.rs | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/linux.rs b/src/linux.rs index c29b5d1..9f158ed 100644 --- a/src/linux.rs +++ b/src/linux.rs @@ -52,9 +52,9 @@ use vm_control::{ VmMemoryControlResponseSocket, VmMemoryRequest, VmMemoryResponse, VmRunMode, }; -use crate::{Config, DiskOption, TouchDeviceOption}; +use crate::{Config, DiskOption, Executable, TouchDeviceOption}; -use arch::{self, LinuxArch, RunnableLinuxVm, VirtioDeviceStub, VmComponents}; +use arch::{self, LinuxArch, RunnableLinuxVm, VirtioDeviceStub, VmComponents, VmImage}; #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] use aarch64::AArch64 as Arch; @@ -100,6 +100,7 @@ pub enum Error { LoadKernel(Box<dyn StdError>), NetDeviceNew(virtio::NetError), OpenAndroidFstab(PathBuf, io::Error), + OpenBios(PathBuf, io::Error), OpenInitrd(PathBuf, io::Error), OpenKernel(PathBuf, io::Error), OpenVinput(PathBuf, io::Error), @@ -179,6 +180,7 @@ impl Display for Error { p.display(), e ), + OpenBios(p, e) => write!(f, "failed to open bios {}: {}", p.display(), e), OpenInitrd(p, e) => write!(f, "failed to open initrd {}: {}", p.display(), e), OpenKernel(p, e) => write!(f, "failed to open kernel image {}: {}", p.display(), e), OpenVinput(p, e) => write!(f, "failed to open vinput device {}: {}", p.display(), e), @@ -1147,12 +1149,21 @@ pub fn run_config(cfg: Config) -> Result<()> { None }; + let vm_image = match cfg.executable_path { + Some(Executable::Kernel(ref kernel_path)) => VmImage::Kernel( + File::open(kernel_path).map_err(|e| Error::OpenKernel(kernel_path.to_path_buf(), e))?, + ), + Some(Executable::Bios(ref bios_path)) => VmImage::Bios( + File::open(bios_path).map_err(|e| Error::OpenBios(bios_path.to_path_buf(), e))?, + ), + _ => panic!("Did not receive a bios or kernel, should be impossible."), + }; + let components = VmComponents { memory_size: (cfg.memory.unwrap_or(256) << 20) as u64, vcpu_count: cfg.vcpu_count.unwrap_or(1), vcpu_affinity: cfg.vcpu_affinity.clone(), - kernel_image: File::open(&cfg.kernel_path) - .map_err(|e| Error::OpenKernel(cfg.kernel_path.clone(), e))?, + vm_image, android_fstab: cfg .android_fstab .as_ref() |