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>
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 @@
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 @@
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 @@
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 @@
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()