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:
Rob Bradford 2020-09-29 18:12:34 +01:00
parent 6d30fe05e4
commit df26b428b1

View File

@ -25,6 +25,7 @@ use vm_memory::{
GuestMemoryMmap, GuestMemoryRegion, GuestUsize,
};
mod smbios;
use std::arch::x86_64;
#[derive(Debug, Copy, Clone)]
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)
.map_err(|e| Error::SetSupportedCpusFailed(e.into()))?;
@ -808,7 +825,6 @@ pub fn initramfs_load_addr(
}
pub fn get_host_cpu_phys_bits() -> u8 {
use std::arch::x86_64;
unsafe {
let leaf = x86_64::__cpuid(0x8000_0000);