mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-09-12 10:04:51 +00:00
arch: x86_64: Copy CPU identification string into guest cpuid
This is stored in leaves 0x80000002 to 0x80000004 inclusive. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
6d30fe05e4
commit
df26b428b1
@ -25,6 +25,7 @@ use vm_memory::{
|
|||||||
GuestMemoryMmap, GuestMemoryRegion, GuestUsize,
|
GuestMemoryMmap, GuestMemoryRegion, GuestUsize,
|
||||||
};
|
};
|
||||||
mod smbios;
|
mod smbios;
|
||||||
|
use std::arch::x86_64;
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub enum BootProtocol {
|
pub enum BootProtocol {
|
||||||
@ -393,6 +394,22 @@ 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()))?;
|
||||||
|
|
||||||
@ -808,7 +825,6 @@ pub fn initramfs_load_addr(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_host_cpu_phys_bits() -> u8 {
|
pub fn get_host_cpu_phys_bits() -> u8 {
|
||||||
use std::arch::x86_64;
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let leaf = x86_64::__cpuid(0x8000_0000);
|
let leaf = x86_64::__cpuid(0x8000_0000);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user