From 34385e99f20058e5a537ea36d795844c12fc2258 Mon Sep 17 00:00:00 2001 From: Peter Oskolkov Date: Wed, 13 Aug 2025 19:26:24 +0000 Subject: [PATCH] misc: simplify configure_vcpu() signature on x86_64 It is always called with topology provided, so there is no need to pass topology as an Option. Simplifying the signature makes further topology-related changes to arc/src/x86_64 module simpler. Signed-off-by: Peter Oskolkov --- arch/src/x86_64/mod.rs | 10 +++++----- vmm/src/cpu.rs | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/src/x86_64/mod.rs b/arch/src/x86_64/mod.rs index 6dcac04f1..e4c626835 100644 --- a/arch/src/x86_64/mod.rs +++ b/arch/src/x86_64/mod.rs @@ -832,9 +832,9 @@ pub fn configure_vcpu( cpuid: Vec, kvm_hyperv: bool, cpu_vendor: CpuVendor, - topology: Option<(u16, u16, u16, u16)>, + topology: (u16, u16, u16, u16), ) -> super::Result<()> { - let x2apic_id = get_x2apic_id(id, topology); + let x2apic_id = get_x2apic_id(id, Some(topology)); // Per vCPU CPUID changes; common are handled via generate_common_cpuid() let mut cpuid = cpuid; @@ -856,9 +856,9 @@ pub fn configure_vcpu( } assert!(apic_id_patched); - if let Some(t) = topology { - update_cpuid_topology(&mut cpuid, t.0, t.1, t.2, t.3, cpu_vendor, id); - } + update_cpuid_topology( + &mut cpuid, topology.0, topology.1, topology.2, topology.3, cpu_vendor, id, + ); // The TSC frequency CPUID leaf should not be included when running with HyperV emulation if !kvm_hyperv { diff --git a/vmm/src/cpu.rs b/vmm/src/cpu.rs index 7b16b3988..629b0152b 100644 --- a/vmm/src/cpu.rs +++ b/vmm/src/cpu.rs @@ -390,7 +390,7 @@ impl Vcpu { boot_setup: Option<(EntryPoint, &GuestMemoryAtomic)>, #[cfg(target_arch = "x86_64")] cpuid: Vec, #[cfg(target_arch = "x86_64")] kvm_hyperv: bool, - #[cfg(target_arch = "x86_64")] topology: Option<(u16, u16, u16, u16)>, + #[cfg(target_arch = "x86_64")] topology: (u16, u16, u16, u16), ) -> Result<()> { #[cfg(target_arch = "aarch64")] { @@ -885,20 +885,20 @@ impl CpuManager { #[cfg(target_arch = "x86_64")] let topology = self.config.topology.clone().map_or_else( || { - Some(( + ( 1_u16, u16::try_from(self.boot_vcpus()).unwrap(), 1_u16, 1_u16, - )) + ) }, |t| { - Some(( + ( t.threads_per_core.into(), t.cores_per_die.into(), t.dies_per_package.into(), t.packages.into(), - )) + ) }, ); #[cfg(target_arch = "x86_64")]