Skip to content

Commit

Permalink
fix: VMs getting stuck when starting from snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
CompuIves committed Aug 31, 2022
1 parent a432354 commit 4164371
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/cpuid/src/transformer/amd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ impl CpuidTransformer for AmdCpuidTransformer {
leaf_0x8000001d::LEAF_NUM => Some(amd::update_extended_cache_topology_entry),
leaf_0x8000001e::LEAF_NUM => Some(amd::update_extended_apic_id_entry),
0x8000_0002..=0x8000_0004 => Some(common::update_brand_string_entry),

// hypervisor stuff
0x4000_0001 => Some(common::disable_kvm_feature_async_pf),
_ => None,
}
}
Expand Down
13 changes: 13 additions & 0 deletions src/cpuid/src/transformer/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ pub fn update_brand_string_entry(
Ok(())
}

// KVM feature bits
#[cfg(target_arch = "x86_64")]
const KVM_FEATURE_ASYNC_PF_INT_BIT: u32 = 14;

pub fn disable_kvm_feature_async_pf(
entry: &mut kvm_cpuid_entry2,
vm_spec: &VmSpec,
) -> Result<(), Error> {
entry.eax.write_bit(KVM_FEATURE_ASYNC_PF_INT_BIT, false);

Ok(())
}

pub fn update_cache_parameters_entry(
entry: &mut kvm_cpuid_entry2,
vm_spec: &VmSpec,
Expand Down
2 changes: 2 additions & 0 deletions src/cpuid/src/transformer/intel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ impl CpuidTransformer for IntelCpuidTransformer {
leaf_0xa::LEAF_NUM => Some(intel::update_perf_mon_entry),
leaf_0xb::LEAF_NUM => Some(intel::update_extended_topology_entry),
0x8000_0002..=0x8000_0004 => Some(common::update_brand_string_entry),
// hypervisor stuff
0x4000_0001 => Some(common::disable_kvm_feature_async_pf),
_ => None,
}
}
Expand Down

0 comments on commit 4164371

Please sign in to comment.