mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-03 11:25:20 +00:00
arch: x86_64: enable nested virtualization on amd if supported
When using amd topology, the svm feature flag on cpuid leaf 0x8000_0001.ecx is overwritten. We update the amd cpu topology logic to use the flag values that originated in KVM_GET_SUPPORTED_CPUID ioctl and override as necessary. Signed-off-by: Thomas Barrett <tbarrett@crusoeenergy.com>
This commit is contained in:
parent
34e965d775
commit
7bc764d4e0
@ -263,6 +263,26 @@ pub struct CpuidPatch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CpuidPatch {
|
impl CpuidPatch {
|
||||||
|
pub fn get_cpuid_reg(
|
||||||
|
cpuid: &[CpuIdEntry],
|
||||||
|
function: u32,
|
||||||
|
index: Option<u32>,
|
||||||
|
reg: CpuidReg,
|
||||||
|
) -> Option<u32> {
|
||||||
|
for entry in cpuid.iter() {
|
||||||
|
if entry.function == function && (index.is_none() || index.unwrap() == entry.index) {
|
||||||
|
return match reg {
|
||||||
|
CpuidReg::EAX => Some(entry.eax),
|
||||||
|
CpuidReg::EBX => Some(entry.ebx),
|
||||||
|
CpuidReg::ECX => Some(entry.ecx),
|
||||||
|
CpuidReg::EDX => Some(entry.edx),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_cpuid_reg(
|
pub fn set_cpuid_reg(
|
||||||
cpuid: &mut Vec<CpuIdEntry>,
|
cpuid: &mut Vec<CpuIdEntry>,
|
||||||
function: u32,
|
function: u32,
|
||||||
@ -1326,12 +1346,14 @@ fn update_cpuid_topology(
|
|||||||
);
|
);
|
||||||
CpuidPatch::set_cpuid_reg(cpuid, 0x8000_001e, Some(0), CpuidReg::EDX, 0);
|
CpuidPatch::set_cpuid_reg(cpuid, 0x8000_001e, Some(0), CpuidReg::EDX, 0);
|
||||||
if cores_per_die * threads_per_core > 1 {
|
if cores_per_die * threads_per_core > 1 {
|
||||||
|
let ecx =
|
||||||
|
CpuidPatch::get_cpuid_reg(cpuid, 0x8000_0001, Some(0), CpuidReg::ECX).unwrap_or(0);
|
||||||
CpuidPatch::set_cpuid_reg(
|
CpuidPatch::set_cpuid_reg(
|
||||||
cpuid,
|
cpuid,
|
||||||
0x8000_0001,
|
0x8000_0001,
|
||||||
Some(0),
|
Some(0),
|
||||||
CpuidReg::ECX,
|
CpuidReg::ECX,
|
||||||
(1u32 << 1) | (1u32 << 22),
|
ecx | (1u32 << 1) | (1u32 << 22),
|
||||||
);
|
);
|
||||||
CpuidPatch::set_cpuid_reg(
|
CpuidPatch::set_cpuid_reg(
|
||||||
cpuid,
|
cpuid,
|
||||||
|
Loading…
Reference in New Issue
Block a user