Configures a vcpu and should be called once per vcpu when created. # Arguments `kernel_entry_point` - Kernel entry point address in guest memory and boot protocol used. `guest_memory` - Guest memory. `cpuid` - (x86_64) CpuId, wrapper over the `kvm_cpuid2` structure.
(
&mut self,
#[cfg(target_arch = "aarch64")] vm: &dyn hypervisor::Vm,
boot_setup: Option<(EntryPoint, &GuestMemoryAtomic<GuestMemoryMmap>)>,
#[cfg(target_arch = "x86_64
| 542 | /// * `guest_memory` - Guest memory. |
| 543 | /// * `cpuid` - (x86_64) CpuId, wrapper over the `kvm_cpuid2` structure. |
| 544 | pub fn configure( |
| 545 | &mut self, |
| 546 | #[cfg(target_arch = "aarch64")] vm: &dyn hypervisor::Vm, |
| 547 | boot_setup: Option<(EntryPoint, &GuestMemoryAtomic<GuestMemoryMmap>)>, |
| 548 | #[cfg(target_arch = "x86_64")] cpuid: Vec<CpuIdEntry>, |
| 549 | #[cfg(target_arch = "x86_64")] kvm_hyperv: bool, |
| 550 | #[cfg(target_arch = "x86_64")] topology: (u16, u16, u16, u16), |
| 551 | #[cfg(target_arch = "x86_64")] nested: bool, |
| 552 | #[cfg(feature = "igvm")] igvm_enabled: bool, |
| 553 | ) -> Result<()> { |
| 554 | #[cfg(target_arch = "aarch64")] |
| 555 | { |
| 556 | self.init(vm)?; |
| 557 | self.mpidr = arch::configure_vcpu(self.vcpu.as_ref(), self.id, boot_setup) |
| 558 | .map_err(Error::VcpuConfiguration)?; |
| 559 | } |
| 560 | #[cfg(target_arch = "riscv64")] |
| 561 | arch::configure_vcpu(self.vcpu.as_ref(), self.id, boot_setup) |
| 562 | .map_err(Error::VcpuConfiguration)?; |
| 563 | info!("Configuring vCPU: cpu_id = {}", self.id); |
| 564 | #[cfg(target_arch = "x86_64")] |
| 565 | { |
| 566 | // When IGVM is enabled, skip standard register setup here — the IGVM |
| 567 | // loader populates vCPU registers from the VMSA via set_sev_control_register |
| 568 | // (currently KVM-specific; MSHV handles this through its own import path). |
| 569 | // igvm_enabled is kept as an explicit flag rather than derived from sev_snp |
| 570 | // state because IGVM could theoretically be used independently of SEV-SNP. |
| 571 | cfg_if::cfg_if! { |
| 572 | if #[cfg(feature = "igvm")] { |
| 573 | let setup_registers = !igvm_enabled; |
| 574 | } else { |
| 575 | let setup_registers = true; |
| 576 | } |
| 577 | } |
| 578 | arch::configure_vcpu( |
| 579 | self.vcpu.as_ref(), |
| 580 | self.id, |
| 581 | boot_setup, |
| 582 | cpuid, |
| 583 | kvm_hyperv, |
| 584 | self.vendor, |
| 585 | topology, |
| 586 | nested, |
| 587 | setup_registers, |
| 588 | ) |
| 589 | .map_err(Error::VcpuConfiguration)?; |
| 590 | } |
| 591 | |
| 592 | Ok(()) |
| 593 | } |
| 594 | |
| 595 | /// Gets the MPIDR register value. |
| 596 | #[cfg(target_arch = "aarch64")] |
no test coverage detected