From 985bd6f25fdfa3efd7ce08938e852ae443752a03 Mon Sep 17 00:00:00 2001 From: Dr-Noob Date: Sat, 6 May 2023 11:02:03 +0200 Subject: [PATCH] [v1.03][X86] Do not consider an empty HV as a bug --- src/x86/cpuid.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/x86/cpuid.c b/src/x86/cpuid.c index 751c000..8d507cc 100644 --- a/src/x86/cpuid.c +++ b/src/x86/cpuid.c @@ -261,23 +261,29 @@ struct hypervisor* get_hp_info(bool hv_present) { cpuid(&eax, &ebx, &ecx, &edx); - char name[13]; - memset(name, 0, 13); - get_name_cpuid(name, ebx, ecx, edx); - - bool found = false; - uint8_t len = sizeof(hv_vendors_string) / sizeof(hv_vendors_string[0]); - - for(uint8_t v=0; v < len && !found; v++) { - if(hv_vendors_string[v] != NULL && strcmp(hv_vendors_string[v], name) == 0) { - hv->hv_vendor = v; - found = true; - } - } - - if(!found) { + if(ebx == 0x0 && ecx == 0x0 && edx == 0x0) { hv->hv_vendor = HV_VENDOR_INVALID; - printBug("Unknown hypervisor vendor: %s", name); + printWarn("Hypervisor vendor is empty"); + } + else { + char name[13]; + memset(name, 0, 13); + get_name_cpuid(name, ebx, ecx, edx); + + bool found = false; + uint8_t len = sizeof(hv_vendors_string) / sizeof(hv_vendors_string[0]); + + for(uint8_t v=0; v < len && !found; v++) { + if(hv_vendors_string[v] != NULL && strcmp(hv_vendors_string[v], name) == 0) { + hv->hv_vendor = v; + found = true; + } + } + + if(!found) { + hv->hv_vendor = HV_VENDOR_INVALID; + printBug("Unknown hypervisor vendor: %s", name); + } } hv->hv_name = hv_vendors_name[hv->hv_vendor];