Add vmware hypervisor to cpuid (for vmware port)

This commit is contained in:
copy 2017-06-20 11:01:33 -05:00
parent f8ddf4dc9c
commit f8ebdea1ac
2 changed files with 15 additions and 0 deletions

View file

@ -58,3 +58,7 @@ var TSC_RATE = 8 * 1024;
/** @const */
var APIC_TIMER_FREQ = TSC_RATE;
/** @const */
var VMWARE_HYPERVISOR_PORT = true;

View file

@ -3632,6 +3632,7 @@ CPU.prototype.cpuid = function()
ebx = 1 << 16 | 8 << 8; // cpu count, clflush size
ecx = 1 << 23 | 1 << 30; // popcnt, rdrand
var vme = 0 << 1;
if(VMWARE_HYPERVISOR_PORT) ecx |= 1 << 31; // hypervisor
edx = (this.fpu ? 1 : 0) | // fpu
vme | 1 << 3 | 1 << 4 | 1 << 5 | // vme, pse, tsc, msr
1 << 8 | 1 << 11 | 1 << 13 | 1 << 15 | // cx8, sep, pge, cmov
@ -3690,6 +3691,16 @@ CPU.prototype.cpuid = function()
// other registers are reserved
break;
case 0x40000000|0: // hypervisor
if(VMWARE_HYPERVISOR_PORT)
{
// h("Ware".split("").reduce((a, c, i) => a | c.charCodeAt(0) << i * 8, 0))
ebx = 0x61774D56|0; // VMwa
ecx = 0x4D566572|0; // reVM
edx = 0x65726177|0; // ware
}
break;
default:
dbg_log("cpuid: unimplemented eax: " + h(this.reg32[reg_eax]), LOG_CPU);
}