Skip to content

Commit e5faa5b

Browse files
committed
added kvm enlightment merge logic with hyper-v
1 parent 90e2e3a commit e5faa5b

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/vmaware.hpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4648,6 +4648,11 @@ struct VM {
46484648
merge(brand_enum::QEMU, brand_enum::KVM_HYPERV, brand_enum::QEMU_KVM_HYPERV);
46494649
merge(brand_enum::QEMU_KVM, brand_enum::KVM_HYPERV, brand_enum::QEMU_KVM_HYPERV);
46504650

4651+
merge(brand_enum::HYPERV_VPC, brand_enum::KVM_HYPERV, brand_enum::KVM_HYPERV);
4652+
merge(brand_enum::HYPERV, brand_enum::KVM_HYPERV, brand_enum::KVM_HYPERV);
4653+
merge(brand_enum::HYPERV_VPC, brand_enum::QEMU_KVM_HYPERV, brand_enum::QEMU_KVM_HYPERV);
4654+
merge(brand_enum::HYPERV, brand_enum::QEMU_KVM_HYPERV, brand_enum::QEMU_KVM_HYPERV);
4655+
46514656
triple_merge(brand_enum::QEMU, brand_enum::KVM, brand_enum::KVM_HYPERV, brand_enum::QEMU_KVM_HYPERV);
46524657

46534658
merge(brand_enum::VMWARE, brand_enum::VMWARE_FUSION, brand_enum::VMWARE_FUSION);
@@ -5758,9 +5763,16 @@ struct VM {
57585763
return result;
57595764
};
57605765

5761-
bool is_intel = true;
5762-
if (!cpu::is_intel()) {
5763-
is_intel = false;
5766+
bool is_intel = cpu::is_intel();
5767+
5768+
if (is_intel) {
5769+
// SERIALIZE (CPUID leaf 7, subleaf 0, EDX bit 14) requires Ice Lake or newer.
5770+
// Older Intel CPUs in Azure/Hyper-V environments crash with STATUS_ILLEGAL_INSTRUCTION.
5771+
u32 l7_eax = 0, l7_ebx = 0, l7_ecx = 0, l7_edx = 0;
5772+
cpu::cpuid(l7_eax, l7_ebx, l7_ecx, l7_edx, 7, 0);
5773+
if (!(l7_edx & (1u << 14))) {
5774+
is_intel = false;
5775+
}
57645776
}
57655777

57665778
const HANDLE current_thread = reinterpret_cast<HANDLE>(-2LL);

0 commit comments

Comments
 (0)