Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ pe = ["elf"]
elf = []

[dependencies]
vm-memory = ">=0.16.0, <=0.17.1"
vm-memory = "0.18"

[dev-dependencies]
criterion = { version = "0.7.0", features = ["html_reports"] }
vm-memory = { version = ">=0.16.0, <=0.17.1", features = ["backend-mmap"] }
vm-memory = { version = "0.18", features = ["backend-mmap"] }

[[bench]]
name = "main"
Expand Down
6 changes: 3 additions & 3 deletions src/configurator/fdt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

//! Traits and structs for loading the device tree.

use vm_memory::{Bytes, GuestMemory};
use vm_memory::{Bytes, GuestMemoryBackend};

use std::fmt;

Expand Down Expand Up @@ -56,7 +56,7 @@ impl BootConfigurator for FdtBootConfigurator {
/// # extern crate vm_memory;
/// # use linux_loader::configurator::{BootConfigurator, BootParams};
/// # use linux_loader::configurator::fdt::FdtBootConfigurator;
/// # use vm_memory::{Address, ByteValued, GuestMemory, GuestMemoryMmap, GuestAddress};
/// # use vm_memory::{Address, ByteValued, GuestMemoryBackend, GuestMemoryMmap, GuestAddress};
/// # #[derive(Clone, Copy, Default)]
/// # struct FdtPlaceholder([u8; 0x20]);
/// # unsafe impl ByteValued for FdtPlaceholder {}
Expand All @@ -79,7 +79,7 @@ impl BootConfigurator for FdtBootConfigurator {
/// ```
fn write_bootparams<M>(params: &BootParams, guest_memory: &M) -> Result<()>
where
M: GuestMemory,
M: GuestMemoryBackend,
{
guest_memory
.checked_offset(params.header_start, params.header.len())
Expand Down
4 changes: 2 additions & 2 deletions src/configurator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#![cfg(any(feature = "elf", feature = "pe", feature = "bzimage"))]

use vm_memory::{Address, ByteValued, GuestAddress, GuestMemory};
use vm_memory::{Address, ByteValued, GuestAddress, GuestMemoryBackend};

use std::fmt;

Expand Down Expand Up @@ -123,7 +123,7 @@ pub trait BootConfigurator {
/// * `guest_memory` - guest's physical memory.
fn write_bootparams<M>(params: &BootParams, guest_memory: &M) -> Result<()>
where
M: GuestMemory;
M: GuestMemoryBackend;
}

/// Boot parameters to be written in guest memory.
Expand Down
6 changes: 3 additions & 3 deletions src/configurator/x86_64/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//! Traits and structs for configuring and loading boot parameters on `x86_64` using the Linux
//! boot protocol.

use vm_memory::{Bytes, GuestMemory};
use vm_memory::{Bytes, GuestMemoryBackend};

use crate::configurator::{BootConfigurator, BootParams, Error as BootConfiguratorError, Result};

Expand Down Expand Up @@ -66,7 +66,7 @@ impl BootConfigurator for LinuxBootConfigurator {
/// # use linux_loader::configurator::{BootConfigurator, BootParams};
/// # use linux_loader::configurator::linux::LinuxBootConfigurator;
/// # use linux_loader::loader::bootparam::boot_params;
/// # use vm_memory::{Address, ByteValued, GuestMemory, GuestMemoryMmap, GuestAddress};
/// # use vm_memory::{Address, ByteValued, GuestMemoryBackend, GuestMemoryMmap, GuestAddress};
/// # const KERNEL_BOOT_FLAG_MAGIC: u16 = 0xaa55;
/// # const KERNEL_HDR_MAGIC: u32 = 0x53726448;
/// # const KERNEL_LOADER_OTHER: u8 = 0xff;
Expand Down Expand Up @@ -97,7 +97,7 @@ impl BootConfigurator for LinuxBootConfigurator {
/// [`boot_params`]: ../loader/bootparam/struct.boot_params.html
fn write_bootparams<M>(params: &BootParams, guest_memory: &M) -> Result<()>
where
M: GuestMemory,
M: GuestMemoryBackend,
{
// The VMM has filled a `boot_params` struct and its e820 map.
// This will be written in guest memory at the zero page.
Expand Down
6 changes: 3 additions & 3 deletions src/configurator/x86_64/pvh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#![cfg(any(feature = "elf", feature = "bzimage"))]

use vm_memory::{ByteValued, Bytes, GuestMemory};
use vm_memory::{ByteValued, Bytes, GuestMemoryBackend};

use crate::configurator::{BootConfigurator, BootParams, Error as BootConfiguratorError, Result};
use crate::loader_gen::start_info::{hvm_memmap_table_entry, hvm_modlist_entry, hvm_start_info};
Expand Down Expand Up @@ -108,7 +108,7 @@ impl BootConfigurator for PvhBootConfigurator {
/// # use linux_loader::configurator::{BootConfigurator, BootParams};
/// # use linux_loader::configurator::pvh::PvhBootConfigurator;
/// # use linux_loader::loader::elf::start_info::{hvm_start_info, hvm_memmap_table_entry};
/// # use vm_memory::{Address, ByteValued, GuestMemory, GuestMemoryMmap, GuestAddress};
/// # use vm_memory::{Address, ByteValued, GuestMemoryBackend, GuestMemoryMmap, GuestAddress};
/// # const XEN_HVM_START_MAGIC_VALUE: u32 = 0x336ec578;
/// # const MEM_SIZE: u64 = 0x100_0000;
/// # const E820_RAM: u32 = 1;
Expand Down Expand Up @@ -145,7 +145,7 @@ impl BootConfigurator for PvhBootConfigurator {
/// ```
fn write_bootparams<M>(params: &BootParams, guest_memory: &M) -> Result<()>
where
M: GuestMemory,
M: GuestMemoryBackend,
{
// The VMM has filled an `hvm_start_info` struct and a `Vec<hvm_memmap_table_entry>`
// and has passed them on to this function.
Expand Down
10 changes: 6 additions & 4 deletions src/loader/bzimage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
use std::fmt;
use std::io::{Seek, SeekFrom};

use vm_memory::{Address, ByteValued, Bytes, GuestAddress, GuestMemory, GuestUsize, ReadVolatile};
use vm_memory::{
Address, ByteValued, Bytes, GuestAddress, GuestMemoryBackend, GuestUsize, ReadVolatile,
};

use crate::loader::{
bootparam, Error as KernelLoaderError, KernelLoader, KernelLoaderResult, Result,
Expand Down Expand Up @@ -71,7 +73,7 @@ impl KernelLoader for BzImage {
///
/// # Arguments
///
/// * `guest_mem`: [`GuestMemory`] to load the kernel in.
/// * `guest_mem`: [`GuestMemoryBackend`] to load the kernel in.
/// * `kernel_offset`: Address in guest memory where the kernel is loaded.
/// * `kernel_image` - Input bzImage image.
/// * `highmem_start_address`: Address where high memory starts.
Expand Down Expand Up @@ -99,8 +101,8 @@ impl KernelLoader for BzImage {
/// .unwrap();
/// ```
///
/// [`GuestMemory`]: https://docs.rs/vm-memory/latest/vm_memory/guest_memory/trait.GuestMemory.html
fn load<F, M: GuestMemory>(
/// [`GuestMemoryBackend`]: https://docs.rs/vm-memory/latest/vm_memory/guest_memory/trait.GuestMemoryBackend.html
fn load<F, M: GuestMemoryBackend>(
guest_mem: &M,
kernel_offset: Option<GuestAddress>,
kernel_image: &mut F,
Expand Down
10 changes: 6 additions & 4 deletions src/loader/elf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ use std::io::{Read, Seek, SeekFrom};
use std::mem;
use std::result;

use vm_memory::{Address, ByteValued, Bytes, GuestAddress, GuestMemory, GuestUsize, ReadVolatile};
use vm_memory::{
Address, ByteValued, Bytes, GuestAddress, GuestMemoryBackend, GuestUsize, ReadVolatile,
};

use crate::loader::{Error as KernelLoaderError, KernelLoader, KernelLoaderResult, Result};
use crate::loader_gen::elf;
Expand Down Expand Up @@ -169,7 +171,7 @@ impl KernelLoader for Elf {
///
/// # Arguments
///
/// * `guest_mem`: [`GuestMemory`] to load the kernel in.
/// * `guest_mem`: [`GuestMemoryBackend`] to load the kernel in.
/// * `kernel_offset`: Offset to be added to default kernel load address in guest memory.
/// * `kernel_image` - Input vmlinux image.
/// * `highmem_start_address`: Address where high memory starts.
Expand Down Expand Up @@ -197,8 +199,8 @@ impl KernelLoader for Elf {
/// .unwrap();
/// ```
///
/// [`GuestMemory`]: https://docs.rs/vm-memory/latest/vm_memory/guest_memory/trait.GuestMemory.html
fn load<F, M: GuestMemory>(
/// [`GuestMemoryBackend`]: https://docs.rs/vm-memory/latest/vm_memory/guest_memory/trait.GuestMemoryBackend.html
fn load<F, M: GuestMemoryBackend>(
guest_mem: &M,
kernel_offset: Option<GuestAddress>,
kernel_image: &mut F,
Expand Down
14 changes: 7 additions & 7 deletions src/loader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use std::io::{Read, Seek};

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
use vm_memory::ByteValued;
use vm_memory::{Address, Bytes, GuestAddress, GuestMemory, GuestUsize, ReadVolatile};
use vm_memory::{Address, Bytes, GuestAddress, GuestMemoryBackend, GuestUsize, ReadVolatile};

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
pub use crate::loader_gen::bootparam;
Expand Down Expand Up @@ -167,13 +167,13 @@ pub trait KernelLoader {
///
/// # Arguments
///
/// * `guest_mem`: [`GuestMemory`] to load the kernel in.
/// * `guest_mem`: [`GuestMemoryBackend`] to load the kernel in.
/// * `kernel_offset`: Usage varies between implementations.
/// * `kernel_image`: Kernel image to be loaded.
/// * `highmem_start_address`: Address where high memory starts.
///
/// [`GuestMemory`]: https://docs.rs/vm-memory/latest/vm_memory/guest_memory/trait.GuestMemory.html
fn load<F, M: GuestMemory>(
/// [`GuestMemoryBackend`]: https://docs.rs/vm-memory/latest/vm_memory/guest_memory/trait.GuestMemoryBackend.html
fn load<F, M: GuestMemoryBackend>(
guest_mem: &M,
kernel_offset: Option<GuestAddress>,
kernel_image: &mut F,
Expand All @@ -197,11 +197,11 @@ unsafe impl ByteValued for bootparam::boot_params {}
///
/// # Arguments
///
/// * `guest_mem` - [`GuestMemory`] that will be partially overwritten by the command line.
/// * `guest_mem` - [`GuestMemoryBackend`] that will be partially overwritten by the command line.
/// * `guest_addr` - The address in `guest_mem` at which to load the command line.
/// * `cmdline` - The kernel command line.
///
/// [`GuestMemory`]: https://docs.rs/vm-memory/latest/vm_memory/guest_memory/trait.GuestMemory.html
/// [`GuestMemoryBackend`]: https://docs.rs/vm-memory/latest/vm_memory/guest_memory/trait.GuestMemoryBackend.html
///
/// # Examples
///
Expand All @@ -219,7 +219,7 @@ unsafe impl ByteValued for bootparam::boot_params {}
/// let result = load_cmdline(&gm, GuestAddress(0x1000), &cl).unwrap();
/// gm.read_slice(buf.as_mut_slice(), GuestAddress(0x1000)).unwrap();
/// assert_eq!(buf.as_slice(), "foo=bar\0".as_bytes());
pub fn load_cmdline<M: GuestMemory>(
pub fn load_cmdline<M: GuestMemoryBackend>(
guest_mem: &M,
guest_addr: GuestAddress,
cmdline: &Cmdline,
Expand Down
8 changes: 5 additions & 3 deletions src/loader/pe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
use std::fmt;
use std::io::{Read, Seek, SeekFrom};

use vm_memory::{Address, ByteValued, Bytes, GuestAddress, GuestMemory, GuestUsize, ReadVolatile};
use vm_memory::{
Address, ByteValued, Bytes, GuestAddress, GuestMemoryBackend, GuestUsize, ReadVolatile,
};

use crate::loader::{Error as KernelLoaderError, KernelLoader, KernelLoaderResult, Result};

Expand Down Expand Up @@ -131,7 +133,7 @@ impl KernelLoader for PE {
///
/// # Returns
/// * KernelLoaderResult
fn load<F, M: GuestMemory>(
fn load<F, M: GuestMemoryBackend>(
guest_mem: &M,
kernel_offset: Option<GuestAddress>,
kernel_image: &mut F,
Expand Down Expand Up @@ -213,7 +215,7 @@ impl KernelLoader for PE {
/// * `guest_addr` - The address in `guest_mem` at which to load the device tree blob.
/// * `dtb_image` - The device tree blob.
#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))]
pub fn load_dtb<F, M: GuestMemory>(
pub fn load_dtb<F, M: GuestMemoryBackend>(
guest_mem: &M,
guest_addr: GuestAddress,
dtb_image: &mut F,
Expand Down