mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm, arch: Move CPU identification handling to shared CPUID code
Move the code for populating the CPUID with details of the CPU identification from the per-vCPU CPUID handling code to the shared CPUID handling code. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
@@ -393,22 +393,6 @@ pub fn configure_vcpu(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy CPU identification string
|
|
||||||
for i in 0x8000_0002..=0x8000_0004 {
|
|
||||||
cpuid.retain(|c| c.function != i);
|
|
||||||
let leaf = unsafe { x86_64::__cpuid(i) };
|
|
||||||
cpuid
|
|
||||||
.push(CpuIdEntry {
|
|
||||||
function: i,
|
|
||||||
eax: leaf.eax,
|
|
||||||
ebx: leaf.ebx,
|
|
||||||
ecx: leaf.ecx,
|
|
||||||
edx: leaf.edx,
|
|
||||||
..Default::default()
|
|
||||||
})
|
|
||||||
.map_err(|_| Error::PopulatingCpuid)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
fd.set_cpuid2(&cpuid)
|
fd.set_cpuid2(&cpuid)
|
||||||
.map_err(|e| Error::SetSupportedCpusFailed(e.into()))?;
|
.map_err(|e| Error::SetSupportedCpusFailed(e.into()))?;
|
||||||
|
|
||||||
|
|||||||
+18
-2
@@ -31,9 +31,9 @@ use arch::EntryPoint;
|
|||||||
use devices::interrupt_controller::InterruptController;
|
use devices::interrupt_controller::InterruptController;
|
||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
use hypervisor::kvm::kvm_bindings;
|
use hypervisor::kvm::kvm_bindings;
|
||||||
#[cfg(target_arch = "x86_64")]
|
|
||||||
use hypervisor::CpuId;
|
|
||||||
use hypervisor::{vm::VmmOps, CpuState, HypervisorCpuError, VmExit};
|
use hypervisor::{vm::VmmOps, CpuState, HypervisorCpuError, VmExit};
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
use hypervisor::{CpuId, CpuIdEntry};
|
||||||
use libc::{c_void, siginfo_t};
|
use libc::{c_void, siginfo_t};
|
||||||
use seccomp::{SeccompAction, SeccompFilter};
|
use seccomp::{SeccompAction, SeccompFilter};
|
||||||
use std::os::unix::thread::JoinHandleExt;
|
use std::os::unix::thread::JoinHandleExt;
|
||||||
@@ -667,6 +667,22 @@ impl CpuManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy CPU identification string
|
||||||
|
for i in 0x8000_0002..=0x8000_0004 {
|
||||||
|
cpuid.retain(|c| c.function != i);
|
||||||
|
let leaf = unsafe { std::arch::x86_64::__cpuid(i) };
|
||||||
|
cpuid
|
||||||
|
.push(CpuIdEntry {
|
||||||
|
function: i,
|
||||||
|
eax: leaf.eax,
|
||||||
|
ebx: leaf.ebx,
|
||||||
|
ecx: leaf.ecx,
|
||||||
|
edx: leaf.edx,
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
Ok(cpuid)
|
Ok(cpuid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user