From 0d9749282a8638a0891e45db0947660d4ddaebf3 Mon Sep 17 00:00:00 2001 From: Julian Stecklina Date: Fri, 8 Sep 2023 12:02:28 +0200 Subject: [PATCH] vmm: simplify EntryPoint EntryPoint had an optional entry_addr, but there is no usage of this struct that makes it necessary that the address is optional. Remove the Option to avoid being able to express things that are not useful. Signed-off-by: Julian Stecklina --- arch/src/x86_64/mod.rs | 12 +++++------- vmm/src/vm.rs | 4 +--- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/arch/src/x86_64/mod.rs b/arch/src/x86_64/mod.rs index 3c645c12c..884d0b504 100644 --- a/arch/src/x86_64/mod.rs +++ b/arch/src/x86_64/mod.rs @@ -60,7 +60,7 @@ pub const _NSIG: i32 = 65; /// is to be used to configure the guest initial state. pub struct EntryPoint { /// Address in guest memory where the guest must start execution - pub entry_addr: Option, + pub entry_addr: GuestAddress, } const E820_RAM: u32 = 1; @@ -811,12 +811,10 @@ pub fn configure_vcpu( regs::setup_msrs(vcpu).map_err(Error::MsrsConfiguration)?; if let Some((kernel_entry_point, guest_memory)) = boot_setup { - if let Some(entry_addr) = kernel_entry_point.entry_addr { - // Safe to unwrap because this method is called after the VM is configured - regs::setup_regs(vcpu, entry_addr.raw_value()).map_err(Error::RegsConfiguration)?; - regs::setup_fpu(vcpu).map_err(Error::FpuConfiguration)?; - regs::setup_sregs(&guest_memory.memory(), vcpu).map_err(Error::SregsConfiguration)?; - } + regs::setup_regs(vcpu, kernel_entry_point.entry_addr.raw_value()) + .map_err(Error::RegsConfiguration)?; + regs::setup_fpu(vcpu).map_err(Error::FpuConfiguration)?; + regs::setup_sregs(&guest_memory.memory(), vcpu).map_err(Error::SregsConfiguration)?; } interrupts::set_lint(vcpu).map_err(|e| Error::LocalIntConfiguration(e.into()))?; Ok(()) diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index 15cf9896b..2b829df52 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -980,9 +980,7 @@ impl Vm { if let PvhEntryPresent(entry_addr) = entry_addr.pvh_boot_cap { // Use the PVH kernel entry point to boot the guest info!("Kernel loaded: entry_addr = 0x{:x}", entry_addr.0); - Ok(EntryPoint { - entry_addr: Some(entry_addr), - }) + Ok(EntryPoint { entry_addr }) } else { Err(Error::KernelMissingPvhHeader) }