diff --git a/arch/src/aarch64/fdt.rs b/arch/src/aarch64/fdt.rs index 999c0e517..0401b6e25 100644 --- a/arch/src/aarch64/fdt.rs +++ b/arch/src/aarch64/fdt.rs @@ -18,14 +18,13 @@ use std::str; use super::super::DeviceType; use super::super::GuestMemoryMmap; use super::super::InitramfsConfig; -use super::get_fdt_addr; use super::gic::GicDevice; use super::layout::{ IRQ_BASE, MEM_32BIT_DEVICES_SIZE, MEM_32BIT_DEVICES_START, MEM_PCI_IO_SIZE, MEM_PCI_IO_START, PCI_HIGH_BASE, PCI_MMIO_CONFIG_SIZE_PER_SEGMENT, }; use vm_fdt::{FdtWriter, FdtWriterResult}; -use vm_memory::{Address, Bytes, GuestAddress, GuestMemory, GuestMemoryError, GuestMemoryRegion}; +use vm_memory::{Address, Bytes, GuestMemory, GuestMemoryError, GuestMemoryRegion}; // This is a value for uniquely identifying the FDT node declaring the interrupt controller. const GIC_PHANDLE: u32 = 1; @@ -141,9 +140,8 @@ pub fn create_fdt, guest_mem: &GuestMemoryMmap) -> Result<()> { // Write FDT to memory. - let fdt_address = GuestAddress(get_fdt_addr()); guest_mem - .write_slice(fdt_final.as_slice(), fdt_address) + .write_slice(fdt_final.as_slice(), super::layout::FDT_START) .map_err(Error::WriteFdtToMemory)?; Ok(()) } diff --git a/arch/src/aarch64/mod.rs b/arch/src/aarch64/mod.rs index 05522f720..efeef3697 100644 --- a/arch/src/aarch64/mod.rs +++ b/arch/src/aarch64/mod.rs @@ -200,21 +200,6 @@ pub fn initramfs_load_addr( } } -/// Returns the memory address where the kernel could be loaded. -pub fn get_kernel_start() -> u64 { - layout::KERNEL_START.raw_value() -} - -///Return guest memory address where the uefi should be loaded. -pub fn get_uefi_start() -> u64 { - layout::UEFI_START.raw_value() -} - -// Auxiliary function to get the address where the device tree blob is loaded. -fn get_fdt_addr() -> u64 { - layout::FDT_START.raw_value() -} - pub fn get_host_cpu_phys_bits() -> u8 { // A dummy hypervisor created only for querying the host IPA size and will // be freed after the query. diff --git a/arch/src/aarch64/regs.rs b/arch/src/aarch64/regs.rs index bc9e449fa..ad80ff7fe 100644 --- a/arch/src/aarch64/regs.rs +++ b/arch/src/aarch64/regs.rs @@ -5,13 +5,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the THIRD-PARTY file. -use super::get_fdt_addr; use hypervisor::kvm::kvm_bindings::{ kvm_regs, user_pt_regs, KVM_REG_ARM64, KVM_REG_ARM_CORE, KVM_REG_SIZE_U64, }; use hypervisor::{arm64_core_reg_id, offset__of}; use std::sync::Arc; use std::{mem, result}; +use vm_memory::Address; /// Errors thrown while setting aarch64 registers. #[derive(Debug)] @@ -67,7 +67,7 @@ pub fn setup_regs(vcpu: &Arc, cpu_id: u8, boot_ip: u64) -> let regs0 = offset__of!(user_pt_regs, regs) + kreg_off; vcpu.set_reg( arm64_core_reg_id!(KVM_REG_SIZE_U64, regs0), - get_fdt_addr() as u64, + super::layout::FDT_START.raw_value(), ) .map_err(Error::SetCoreRegister)?; } diff --git a/arch/src/lib.rs b/arch/src/lib.rs index b4cc80dcc..b404b790a 100644 --- a/arch/src/lib.rs +++ b/arch/src/lib.rs @@ -85,8 +85,8 @@ pub mod aarch64; #[cfg(target_arch = "aarch64")] pub use aarch64::{ arch_memory_regions, configure_system, configure_vcpu, fdt::DeviceInfoForFdt, - get_host_cpu_phys_bits, get_kernel_start, get_uefi_start, initramfs_load_addr, layout, - layout::CMDLINE_MAX_SIZE, layout::IRQ_BASE, uefi, EntryPoint, + get_host_cpu_phys_bits, initramfs_load_addr, layout, layout::CMDLINE_MAX_SIZE, + layout::IRQ_BASE, uefi, EntryPoint, }; #[cfg(target_arch = "x86_64")] diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index bf89b96f9..ae3879220 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -992,7 +992,7 @@ impl Vm { let mut kernel = self.kernel.as_ref().unwrap(); let entry_addr = match linux_loader::loader::pe::PE::load( mem.deref(), - Some(GuestAddress(arch::get_kernel_start())), + Some(arch::layout::KERNEL_START), &mut kernel, None, ) { @@ -1001,15 +1001,11 @@ impl Vm { // If failed, retry to load it as UEFI binary. // As the UEFI binary is formatless, it must be the last option to try. Err(linux_loader::loader::Error::Pe(InvalidImageMagicNumber)) => { - arch::aarch64::uefi::load_uefi( - mem.deref(), - GuestAddress(arch::get_uefi_start()), - &mut kernel, - ) - .map_err(Error::UefiLoad)?; + arch::aarch64::uefi::load_uefi(mem.deref(), arch::layout::UEFI_START, &mut kernel) + .map_err(Error::UefiLoad)?; // The entry point offset in UEFI image is always 0. return Ok(EntryPoint { - entry_addr: GuestAddress(arch::get_uefi_start()), + entry_addr: arch::layout::UEFI_START, }); } Err(e) => {