Skip to content

Commit

Permalink
loader: simplify handling of multiple VTLs (#217)
Browse files Browse the repository at this point in the history
The individual firmware loaders generally do not need to be VTL aware.
Remove VTL awareness from most of the code. This will soon allow OpenHCL
to be loaded into VTL0.

The remaining exception is the VTL0 VP context. Simplify the handling of
this, so that the CVM-specific code doesn't have to know about this.

A future change should consider whether we really need this at all: it
seems that it's just so that OpenVMM in OpenHCL doesn't have to replay
the UEFI register state. But OpenVMM already knows so much about how to
load UEFI, so it seems kind of silly to pretend that it doesn't know how
to set the register state appropriately.
  • Loading branch information
jstarks authored Oct 31, 2024
1 parent f61ce37 commit 7ef241c
Show file tree
Hide file tree
Showing 15 changed files with 395 additions and 732 deletions.
8 changes: 7 additions & 1 deletion openvmm/hvlite_core/src/worker/vm_loaders/igvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ pub enum Error {
UnsupportedGuestArch,
#[error("igvm file does not support vbs")]
NoVbsSupport,
#[error("vp context for lower VTL not supported")]
LowerVtlContext,
}

fn from_memory_range(range: &MemoryRange) -> IGVM_VHS_MEMORY_RANGE {
Expand Down Expand Up @@ -995,6 +997,10 @@ fn load_igvm_x86(
ref registers,
compatibility_mask: _,
} => {
if from_igvm_vtl(vtl) != max_vtl {
return Err(Error::LowerVtlContext);
}

let mut cr3: Option<u64> = None;
let mut cr4: Option<u64> = None;

Expand Down Expand Up @@ -1097,7 +1103,7 @@ fn load_igvm_x86(
};

loader
.import_vp_register(from_igvm_vtl(vtl), reloc_reg)
.import_vp_register(reloc_reg)
.map_err(Error::Loader)?;
}

Expand Down
2 changes: 1 addition & 1 deletion openvmm/hvlite_core/src/worker/vm_loaders/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ pub fn load_linux_arm64(

// Set the registers separately so they won't conflict with the UEFI boot when
// `load_kernel_and_initrd_arm64` is used for VTL2 direct kernel boot.
loader::linux::set_direct_boot_registers_arm64(&mut loader, &load_info, hvdef::Vtl::Vtl0)
loader::linux::set_direct_boot_registers_arm64(&mut loader, &load_info)
.map_err(Error::Loader)?;

Ok(loader.initial_regs())
Expand Down
Loading

0 comments on commit 7ef241c

Please sign in to comment.