HM.cpp revision a86176df1bcfd6d689ea3cfeab1630e1b2f93d70
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay * HM - Intel/AMD VM Hardware Support Manager.
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay * Copyright (C) 2006-2013 Oracle Corporation
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay * This file is part of VirtualBox Open Source Edition (OSE), as
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay * available from http://www.virtualbox.org. This file is free software;
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay * you can redistribute it and/or modify it under the terms of the GNU
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay * General Public License (GPL) as published by the Free Software
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay * Foundation, in version 2 as it comes in the "COPYING" file of the
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay/*******************************************************************************
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay* Header Files *
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay*******************************************************************************/
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay/*******************************************************************************
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay* Global Variables *
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay*******************************************************************************/
c778db2859a5f59aa80244e248847d38b8d5df84Lana Frost# define EXIT_REASON(def, val, str) #def " - " #val " - " str
c778db2859a5f59aa80244e248847d38b8d5df84Lana Frost/** Exit reason descriptions for VT-x, used to describe statistics. */
c778db2859a5f59aa80244e248847d38b8d5df84Lana Froststatic const char * const g_apszVTxExitReasons[MAX_EXITREASON_STAT] =
c778db2859a5f59aa80244e248847d38b8d5df84Lana Frost EXIT_REASON(VMX_EXIT_XCPT_NMI , 0, "Exception or non-maskable interrupt (NMI)."),
c778db2859a5f59aa80244e248847d38b8d5df84Lana Frost EXIT_REASON(VMX_EXIT_EXT_INT , 1, "External interrupt."),
c778db2859a5f59aa80244e248847d38b8d5df84Lana Frost EXIT_REASON(VMX_EXIT_TRIPLE_FAULT , 2, "Triple fault."),
c778db2859a5f59aa80244e248847d38b8d5df84Lana Frost EXIT_REASON(VMX_EXIT_INIT_SIGNAL , 3, "INIT signal."),
c778db2859a5f59aa80244e248847d38b8d5df84Lana Frost EXIT_REASON(VMX_EXIT_SIPI , 4, "Start-up IPI (SIPI)."),
c778db2859a5f59aa80244e248847d38b8d5df84Lana Frost EXIT_REASON(VMX_EXIT_IO_SMI_IRQ , 5, "I/O system-management interrupt (SMI)."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_INT_WINDOW , 7, "Interrupt window."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_TASK_SWITCH , 9, "Task switch."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_CPUID , 10, "Guest attempted to execute CPUID."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_HLT , 12, "Guest attempted to execute HLT."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_INVD , 13, "Guest attempted to execute INVD."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_INVLPG , 14, "Guest attempted to execute INVLPG."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_RDPMC , 15, "Guest attempted to execute RDPMC."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_RDTSC , 16, "Guest attempted to execute RDTSC."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_RSM , 17, "Guest attempted to execute RSM in SMM."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_VMCALL , 18, "Guest attempted to execute VMCALL."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_VMCLEAR , 19, "Guest attempted to execute VMCLEAR."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_VMLAUNCH , 20, "Guest attempted to execute VMLAUNCH."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_VMPTRLD , 21, "Guest attempted to execute VMPTRLD."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_VMPTRST , 22, "Guest attempted to execute VMPTRST."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_VMREAD , 23, "Guest attempted to execute VMREAD."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_VMRESUME , 24, "Guest attempted to execute VMRESUME."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_VMWRITE , 25, "Guest attempted to execute VMWRITE."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_VMXOFF , 26, "Guest attempted to execute VMXOFF."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_VMXON , 27, "Guest attempted to execute VMXON."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_MOV_CRX , 28, "Control-register accesses."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_MOV_DRX , 29, "Debug-register accesses."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_PORT_IO , 30, "I/O instruction."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_RDMSR , 31, "Guest attempted to execute RDMSR."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_WRMSR , 32, "Guest attempted to execute WRMSR."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_ERR_INVALID_GUEST_STATE, 33, "VM-entry failure due to invalid guest state."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_ERR_MSR_LOAD , 34, "VM-entry failure due to MSR loading."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_MWAIT , 36, "Guest executed MWAIT."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_MTF , 37, "Monitor Trap Flag."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_MONITOR , 39, "Guest attempted to execute MONITOR."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_PAUSE , 40, "Guest attempted to execute PAUSE."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_ERR_MACHINE_CHECK , 41, "VM-entry failure due to machine-check."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_TPR_BELOW_THRESHOLD, 43, "TPR below threshold. Guest attempted to execute MOV to CR8."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_APIC_ACCESS , 44, "APIC access. Guest attempted to access memory at a physical address on the APIC-access page."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_XDTR_ACCESS , 46, "Access to GDTR or IDTR. Guest attempted to execute LGDT, LIDT, SGDT, or SIDT."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_TR_ACCESS , 47, "Access to LDTR or TR. Guest attempted to execute LLDT, LTR, SLDT, or STR."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_EPT_VIOLATION , 48, "EPT violation. An attempt to access memory with a guest-physical address was disallowed by the configuration of the EPT paging structures."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_EPT_MISCONFIG , 49, "EPT misconfiguration. An attempt to access memory with a guest-physical address encountered a misconfigured EPT paging-structure entry."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_INVEPT , 50, "Guest attempted to execute INVEPT."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_RDTSCP , 51, "Guest attempted to execute RDTSCP."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_PREEMPT_TIMER , 52, "VMX-preemption timer expired."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_INVVPID , 53, "Guest attempted to execute INVVPID."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_WBINVD , 54, "Guest attempted to execute WBINVD."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_XSETBV , 55, "Guest attempted to execute XSETBV."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_RDRAND , 57, "Guest attempted to execute RDRAND."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_INVPCID , 58, "Guest attempted to execute INVPCID."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(VMX_EXIT_VMFUNC , 59, "Guest attempted to execute VMFUNC.")
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay/** Exit reason descriptions for AMD-V, used to describe statistics. */
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemaystatic const char * const g_apszAmdVExitReasons[MAX_EXITREASON_STAT] =
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(SVM_EXIT_READ_CR0 , 0, "Read CR0."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(SVM_EXIT_READ_CR1 , 1, "Read CR1."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(SVM_EXIT_READ_CR2 , 2, "Read CR2."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(SVM_EXIT_READ_CR3 , 3, "Read CR3."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(SVM_EXIT_READ_CR4 , 4, "Read CR4."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(SVM_EXIT_READ_CR5 , 5, "Read CR5."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(SVM_EXIT_READ_CR6 , 6, "Read CR6."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(SVM_EXIT_READ_CR7 , 7, "Read CR7."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(SVM_EXIT_READ_CR8 , 8, "Read CR8."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(SVM_EXIT_READ_CR9 , 9, "Read CR9."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(SVM_EXIT_READ_CR10 , 10, "Read CR10."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(SVM_EXIT_READ_CR11 , 11, "Read CR11."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(SVM_EXIT_READ_CR12 , 12, "Read CR12."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(SVM_EXIT_READ_CR13 , 13, "Read CR13."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(SVM_EXIT_READ_CR14 , 14, "Read CR14."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(SVM_EXIT_READ_CR15 , 15, "Read CR15."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(SVM_EXIT_WRITE_CR0 , 16, "Write CR0."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(SVM_EXIT_WRITE_CR1 , 17, "Write CR1."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(SVM_EXIT_WRITE_CR2 , 18, "Write CR2."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(SVM_EXIT_WRITE_CR3 , 19, "Write CR3."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(SVM_EXIT_WRITE_CR4 , 20, "Write CR4."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(SVM_EXIT_WRITE_CR5 , 21, "Write CR5."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(SVM_EXIT_WRITE_CR6 , 22, "Write CR6."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(SVM_EXIT_WRITE_CR7 , 23, "Write CR7."),
a20efbd22b33014647993674c901e85b7aca2c42Jason Lemay EXIT_REASON(SVM_EXIT_WRITE_CR8 , 24, "Write CR8."),
EXIT_REASON(SVM_EXIT_CR0_SEL_WRITE ,101, "Write to CR0 that changed any bits other than CR0.TS or CR0.MP."),
EXIT_REASON(SVM_EXIT_IOIO ,123, "IN/OUT accessing protected port (EXITINFO1 field provides more information)."),
EXIT_REASON(SVM_EXIT_FERR_FREEZE ,126, "FP legacy handling enabled, and processor is frozen in an x87/mmx instruction waiting for an interrupt"),
EXIT_REASON(SVM_EXIT_NPF ,1024, "Nested paging: host-level page fault occurred (EXITINFO1 contains fault errorcode; EXITINFO2 contains the guest physical address causing the fault)."),
return rc;
//pVM->hm.s.vmx.fSupported = false;
//pVM->hm.s.svm.fSupported = false;
//pVM->hm.s.vmx.fEnabled = false;
//pVM->hm.s.svm.fEnabled = false;
//pVM->hm.s.fNestedPaging = false;
bool fHMForced;
#ifdef VBOX_WITH_RAW_MODE
AssertLogRelMsgReturn(!fHMForced || pVM->fHMEnabled, ("Configuration error: HM forced but not enabled!\n"),
# if defined(RT_OS_DARWIN)
fHMForced = true;
AssertLogRelMsgReturn(pVM->cCpus == 1 || pVM->fHMEnabled, ("Configuration error: SMP requires HM to be enabled!\n"),
fHMForced = true;
fHMForced = true;
/** @cfgm{/HM/EnableNestedPaging, bool, false}
/** @cfgm{/HM/EnableLargePages, bool, false}
/** @cfgm{/HM/EnableVPID, bool, false}
/** @cfgm{/HM/TPRPatchingEnabled, bool, false}
#ifdef VBOX_ENABLE_64_BITS_GUESTS
/** @cfgm{/HM/MaxResumeLoops, uint32_t}
rc = CFGMR3QueryU32Def(pCfgHM, "MaxResumeLoops", &pVM->hm.s.cMaxResumeLoops, 0 /* set by R0 later */);
#ifdef RT_OS_LINUX
if (fHMForced)
LogRel(("HMR3Init: Falling back to raw-mode: The host kernel does not support VT-x.%s\n", pszMinReq));
AssertLogRelMsgFailedReturn(("SUPR3QueryVTCaps didn't return either AMD-V or VT-x flag set (%#x)!\n", fCaps),
const char *pszMsg;
switch (rc)
case VERR_UNSUPPORTED_CPU:
case VERR_VMX_NO_VMX:
case VERR_SVM_NO_SVM:
case VERR_SVM_DISABLED:
if (!pszMsg)
return VINF_SUCCESS;
return VINF_SUCCESS;
#ifdef VBOX_WITH_STATISTICS
STAM_REG(pVM, &pVM->hm.s.StatTprPatchSuccess, STAMTYPE_COUNTER, "/HM/TPR/Patch/Success", STAMUNIT_OCCURENCES, "Number of times an instruction was successfully patched.");
STAM_REG(pVM, &pVM->hm.s.StatTprPatchFailure, STAMTYPE_COUNTER, "/HM/TPR/Patch/Failed", STAMUNIT_OCCURENCES, "Number of unsuccessful patch attempts.");
STAM_REG(pVM, &pVM->hm.s.StatTprReplaceSuccess, STAMTYPE_COUNTER, "/HM/TPR/Replace/Success",STAMUNIT_OCCURENCES, "Number of times an instruction was successfully patched.");
STAM_REG(pVM, &pVM->hm.s.StatTprReplaceFailure, STAMTYPE_COUNTER, "/HM/TPR/Replace/Failed", STAMUNIT_OCCURENCES, "Number of unsuccessful patch attempts.");
int rc;
rc = STAMR3RegisterF(pVM, &pVCpu->hm.s.StatPoke, STAMTYPE_PROFILE, STAMVISIBILITY_USED, STAMUNIT_TICKS_PER_CALL,
rc = STAMR3RegisterF(pVM, &pVCpu->hm.s.StatSpinPoke, STAMTYPE_PROFILE, STAMVISIBILITY_USED, STAMUNIT_TICKS_PER_CALL,
rc = STAMR3RegisterF(pVM, &pVCpu->hm.s.StatSpinPokeFailed, STAMTYPE_PROFILE, STAMVISIBILITY_USED, STAMUNIT_TICKS_PER_CALL,
"/PROF/CPU%d/HM/PokeWaitFailed", i);
rc = STAMR3RegisterF(pVM, &pVCpu->hm.s.StatEntry, STAMTYPE_PROFILE, STAMVISIBILITY_USED, STAMUNIT_TICKS_PER_CALL,
rc = STAMR3RegisterF(pVM, &pVCpu->hm.s.StatExit1, STAMTYPE_PROFILE, STAMVISIBILITY_USED, STAMUNIT_TICKS_PER_CALL,
"/PROF/CPU%d/HM/SwitchFromGC_1", i);
rc = STAMR3RegisterF(pVM, &pVCpu->hm.s.StatExit2, STAMTYPE_PROFILE, STAMVISIBILITY_USED, STAMUNIT_TICKS_PER_CALL,
"/PROF/CPU%d/HM/SwitchFromGC_2", i);
rc = STAMR3RegisterF(pVM, &pVCpu->hm.s.StatExitIO, STAMTYPE_PROFILE, STAMVISIBILITY_USED, STAMUNIT_TICKS_PER_CALL,
rc = STAMR3RegisterF(pVM, &pVCpu->hm.s.StatExitMovCRx, STAMTYPE_PROFILE, STAMVISIBILITY_USED, STAMUNIT_TICKS_PER_CALL,
rc = STAMR3RegisterF(pVM, &pVCpu->hm.s.StatExitXcptNmi, STAMTYPE_PROFILE, STAMVISIBILITY_USED, STAMUNIT_TICKS_PER_CALL,
rc = STAMR3RegisterF(pVM, &pVCpu->hm.s.StatLoadGuestState, STAMTYPE_PROFILE, STAMVISIBILITY_USED, STAMUNIT_TICKS_PER_CALL,
"/PROF/CPU%d/HM/StatLoadGuestState", i);
rc = STAMR3RegisterF(pVM, &pVCpu->hm.s.StatInGC, STAMTYPE_PROFILE, STAMVISIBILITY_USED, STAMUNIT_TICKS_PER_CALL,
# if HC_ARCH_BITS == 32 && defined(VBOX_ENABLE_64_BITS_GUESTS) && !defined(VBOX_WITH_HYBRID_32BIT_KERNEL)
"/PROF/CPU%d/HM/Switcher3264", i);
# ifdef HM_PROFILE_EXIT_DISPATCH
"/PROF/CPU%d/HM/ExitDispatch", i);
rc = STAMR3RegisterF(pVM, a, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, desc, b, i); \
HM_REG_COUNTER(&pVCpu->hm.s.StatExitShadowNM, "/HM/CPU%d/Exit/Trap/Shw/#NM", "Shadow #NM (device not available, no math co-processor) exception.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitGuestNM, "/HM/CPU%d/Exit/Trap/Gst/#NM", "Guest #NM (device not available, no math co-processor) exception.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitShadowPF, "/HM/CPU%d/Exit/Trap/Shw/#PF", "Shadow #PF (page fault) exception.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitShadowPFEM, "/HM/CPU%d/Exit/Trap/Shw/#PF-EM", "#PF (page fault) exception going back to ring-3 for emulating the instruction.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitGuestPF, "/HM/CPU%d/Exit/Trap/Gst/#PF", "Guest #PF (page fault) exception.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitGuestUD, "/HM/CPU%d/Exit/Trap/Gst/#UD", "Guest #UD (undefined opcode) exception.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitGuestSS, "/HM/CPU%d/Exit/Trap/Gst/#SS", "Guest #SS (stack-segment fault) exception.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitGuestNP, "/HM/CPU%d/Exit/Trap/Gst/#NP", "Guest #NP (segment not present) exception.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitGuestGP, "/HM/CPU%d/Exit/Trap/Gst/#GP", "Guest #GP (general protection) execption.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitGuestMF, "/HM/CPU%d/Exit/Trap/Gst/#MF", "Guest #MF (x87 FPU error, math fault) exception.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitGuestDE, "/HM/CPU%d/Exit/Trap/Gst/#DE", "Guest #DE (divide error) exception.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitGuestDB, "/HM/CPU%d/Exit/Trap/Gst/#DB", "Guest #DB (debug) exception.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitGuestBP, "/HM/CPU%d/Exit/Trap/Gst/#BP", "Guest #BP (breakpoint) exception.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitGuestXF, "/HM/CPU%d/Exit/Trap/Gst/#XF", "Guest #XF (extended math fault, SIMD FPU) exception.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitGuestXcpUnk, "/HM/CPU%d/Exit/Trap/Gst/Other", "Other guest exceptions.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitInvlpg, "/HM/CPU%d/Exit/Instr/Invlpg", "Guest attempted to execute INVLPG.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitInvd, "/HM/CPU%d/Exit/Instr/Invd", "Guest attempted to execute INVD.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitWbinvd, "/HM/CPU%d/Exit/Instr/Wbinvd", "Guest attempted to execute WBINVD.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitPause, "/HM/CPU%d/Exit/Instr/Pause", "Guest attempted to execute PAUSE.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitCpuid, "/HM/CPU%d/Exit/Instr/Cpuid", "Guest attempted to execute CPUID.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitRdtsc, "/HM/CPU%d/Exit/Instr/Rdtsc", "Guest attempted to execute RDTSC.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitRdtscp, "/HM/CPU%d/Exit/Instr/Rdtscp", "Guest attempted to execute RDTSCP.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitRdpmc, "/HM/CPU%d/Exit/Instr/Rdpmc", "Guest attempted to execute RDPMC.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitRdrand, "/HM/CPU%d/Exit/Instr/Rdrand", "Guest attempted to execute RDRAND.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitRdmsr, "/HM/CPU%d/Exit/Instr/Rdmsr", "Guest attempted to execute RDMSR.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitWrmsr, "/HM/CPU%d/Exit/Instr/Wrmsr", "Guest attempted to execute WRMSR.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitMwait, "/HM/CPU%d/Exit/Instr/Mwait", "Guest attempted to execute MWAIT.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitMonitor, "/HM/CPU%d/Exit/Instr/Monitor", "Guest attempted to execute MONITOR.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitDRxWrite, "/HM/CPU%d/Exit/Instr/DR/Write", "Guest attempted to write a debug register.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitDRxRead, "/HM/CPU%d/Exit/Instr/DR/Read", "Guest attempted to read a debug register.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitClts, "/HM/CPU%d/Exit/Instr/CLTS", "Guest attempted to execute CLTS.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitLmsw, "/HM/CPU%d/Exit/Instr/LMSW", "Guest attempted to execute LMSW.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitCli, "/HM/CPU%d/Exit/Instr/Cli", "Guest attempted to execute CLI.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitSti, "/HM/CPU%d/Exit/Instr/Sti", "Guest attempted to execute STI.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitPushf, "/HM/CPU%d/Exit/Instr/Pushf", "Guest attempted to execute PUSHF.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitPopf, "/HM/CPU%d/Exit/Instr/Popf", "Guest attempted to execute POPF.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitIret, "/HM/CPU%d/Exit/Instr/Iret", "Guest attempted to execute IRET.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitInt, "/HM/CPU%d/Exit/Instr/Int", "Guest attempted to execute INT.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitHlt, "/HM/CPU%d/Exit/Instr/Hlt", "Guest attempted to execute HLT.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitXdtrAccess, "/HM/CPU%d/Exit/Instr/XdtrAccess", "Guest attempted to access descriptor table register (GDTR, IDTR, LDTR).");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitIOStringWrite, "/HM/CPU%d/Exit/IO/WriteString", "String I/O write.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitIOStringRead, "/HM/CPU%d/Exit/IO/ReadString", "String I/O read.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitIntWindow, "/HM/CPU%d/Exit/IntWindow", "Interrupt-window exit. Guest is ready to receive interrupts again.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitMaxResume, "/HM/CPU%d/Exit/MaxResume", "Maximum VMRESUME inner-loop counter reached.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitPreemptTimer, "/HM/CPU%d/Exit/PreemptTimer", "VMX-preemption timer expired.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitTprBelowThreshold, "/HM/CPU%d/Exit/TprBelowThreshold", "TPR lowered below threshold by the guest.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitTaskSwitch, "/HM/CPU%d/Exit/TaskSwitch", "Guest attempted a task switch.");
HM_REG_COUNTER(&pVCpu->hm.s.StatExitApicAccess, "/HM/CPU%d/Exit/ApicAccess", "APIC access. Guest attempted to access memory at a physical address on the APIC-access page.");
HM_REG_COUNTER(&pVCpu->hm.s.StatSwitchGuestIrq, "/HM/CPU%d/Switch/IrqPending", "PDMGetInterrupt() cleared behind our back!?!.");
HM_REG_COUNTER(&pVCpu->hm.s.StatSwitchHmToR3FF, "/HM/CPU%d/Switch/HmToR3FF", "Exit to ring-3 due to pending timers, EMT rendezvous, critical section etc.");
HM_REG_COUNTER(&pVCpu->hm.s.StatSwitchExitToR3, "/HM/CPU%d/Switch/ExitToR3", "Exit to ring-3 (total).");
HM_REG_COUNTER(&pVCpu->hm.s.StatSwitchLongJmpToR3, "/HM/CPU%d/Switch/LongJmpToR3", "Longjump to ring-3.");
HM_REG_COUNTER(&pVCpu->hm.s.StatIntInject, "/HM/CPU%d/Irq/Inject", "Injecting hardware interrupt into the guest.");
HM_REG_COUNTER(&pVCpu->hm.s.StatIntReinject, "/HM/CPU%d/Irq/Reinject", "Re-injecting an event into the guest.");
HM_REG_COUNTER(&pVCpu->hm.s.StatPendingHostIrq, "/HM/CPU%d/Irq/PendingOnHost", "Exiting to ring-3 due to preemption pending on the host.");
HM_REG_COUNTER(&pVCpu->hm.s.StatFlushPage, "/HM/CPU%d/Flush/Page", "Invalidating a guest page on all guest CPUs.");
HM_REG_COUNTER(&pVCpu->hm.s.StatFlushPageManual, "/HM/CPU%d/Flush/Page/Virt", "Invalidating a guest page using guest-virtual address.");
HM_REG_COUNTER(&pVCpu->hm.s.StatFlushPhysPageManual, "/HM/CPU%d/Flush/Page/Phys", "Invalidating a guest page using guest-physical address.");
HM_REG_COUNTER(&pVCpu->hm.s.StatFlushTlb, "/HM/CPU%d/Flush/TLB", "Forcing a full guest-TLB flush (ring-0).");
HM_REG_COUNTER(&pVCpu->hm.s.StatFlushTlbManual, "/HM/CPU%d/Flush/TLB/Manual", "Request a full guest-TLB flush.");
HM_REG_COUNTER(&pVCpu->hm.s.StatFlushTlbWorldSwitch, "/HM/CPU%d/Flush/TLB/CpuSwitch", "Forcing a full guest-TLB flush due to host-CPU reschedule or ASID-limit hit by another guest-VCPU.");
HM_REG_COUNTER(&pVCpu->hm.s.StatNoFlushTlbWorldSwitch, "/HM/CPU%d/Flush/TLB/Skipped", "No TLB flushing required.");
HM_REG_COUNTER(&pVCpu->hm.s.StatFlushAsid, "/HM/CPU%d/Flush/TLB/ASID", "Flushed guest-TLB entries for the current VPID.");
HM_REG_COUNTER(&pVCpu->hm.s.StatFlushNestedPaging, "/HM/CPU%d/Flush/TLB/NestedPaging", "Flushed guest-TLB entries for the current EPT.");
HM_REG_COUNTER(&pVCpu->hm.s.StatFlushTlbInvlpgVirt, "/HM/CPU%d/Flush/TLB/InvlpgVirt", "Invalidated a guest-TLB entry for a guest-virtual address.");
HM_REG_COUNTER(&pVCpu->hm.s.StatFlushTlbInvlpgPhys, "/HM/CPU%d/Flush/TLB/InvlpgPhys", "Currently not possible, flushes entire guest-TLB.");
HM_REG_COUNTER(&pVCpu->hm.s.StatTlbShootdown, "/HM/CPU%d/Flush/Shootdown/Page", "Inter-VCPU request to flush queued guest page.");
HM_REG_COUNTER(&pVCpu->hm.s.StatTlbShootdownFlush, "/HM/CPU%d/Flush/Shootdown/TLB", "Inter-VCPU request to flush entire guest-TLB.");
HM_REG_COUNTER(&pVCpu->hm.s.StatTscIntercept, "/HM/CPU%d/TSC/Intercept", "Guest is in catchup mode, intercept TSC accesses.");
HM_REG_COUNTER(&pVCpu->hm.s.StatTscInterceptOverFlow, "/HM/CPU%d/TSC/InterceptOverflow", "TSC offset overflow, fallback to intercept TSC accesses.");
HM_REG_COUNTER(&pVCpu->hm.s.StatDRxArmed, "/HM/CPU%d/Debug/Armed", "Loaded guest-debug state while loading guest-state.");
HM_REG_COUNTER(&pVCpu->hm.s.StatDRxContextSwitch, "/HM/CPU%d/Debug/ContextSwitch", "Loaded guest-debug state on MOV DRx.");
HM_REG_COUNTER(&pVCpu->hm.s.StatDRxIoCheck, "/HM/CPU%d/Debug/IOCheck", "Checking for I/O breakpoint.");
HM_REG_COUNTER(&pVCpu->hm.s.StatLoadMinimal, "/HM/CPU%d/Load/Minimal", "VM-entry loading just RIP (+RSP, RFLAGs for old VT-x code).");
HM_REG_COUNTER(&pVCpu->hm.s.StatLoadFull, "/HM/CPU%d/Load/Full", "VM-entry loading more of the state.");
HM_REG_COUNTER(&pVCpu->hm.s.StatVmxCheckBadRmSelBase, "/HM/CPU%d/VMXCheck/RMSelBase", "Could not use VMX due to unsuitable real-mode selector base.");
HM_REG_COUNTER(&pVCpu->hm.s.StatVmxCheckBadRmSelLimit, "/HM/CPU%d/VMXCheck/RMSelLimit", "Could not use VMX due to unsuitable real-mode selector limit.");
HM_REG_COUNTER(&pVCpu->hm.s.StatVmxCheckRmOk, "/HM/CPU%d/VMXCheck/VMX_RM", "VMX execution in real (V86) mode OK.");
HM_REG_COUNTER(&pVCpu->hm.s.StatVmxCheckBadSel, "/HM/CPU%d/VMXCheck/Selector", "Could not use VMX due to unsuitable selector.");
HM_REG_COUNTER(&pVCpu->hm.s.StatVmxCheckBadRpl, "/HM/CPU%d/VMXCheck/RPL", "Could not use VMX due to unsuitable RPL.");
HM_REG_COUNTER(&pVCpu->hm.s.StatVmxCheckBadLdt, "/HM/CPU%d/VMXCheck/LDT", "Could not use VMX due to unsuitable LDT.");
HM_REG_COUNTER(&pVCpu->hm.s.StatVmxCheckBadTr, "/HM/CPU%d/VMXCheck/TR", "Could not use VMX due to unsuitable TR.");
HM_REG_COUNTER(&pVCpu->hm.s.StatVmxCheckPmOk, "/HM/CPU%d/VMXCheck/VMX_PM", "VMX execution in protected mode OK.");
#if HC_ARCH_BITS == 32 && defined(VBOX_ENABLE_64_BITS_GUESTS) && !defined(VBOX_WITH_HYBRID_32BIT_KERNEL)
HM_REG_COUNTER(&pVCpu->hm.s.StatFpu64SwitchBack, "/HM/CPU%d/Switch64/Fpu", "Saving guest FPU/XMM state.");
HM_REG_COUNTER(&pVCpu->hm.s.StatDebug64SwitchBack, "/HM/CPU%d/Switch64/Debug", "Saving guest debug state.");
const char * const *papszDesc = ASMIsIntelCpu() ? &g_apszVTxExitReasons[0] : &g_apszAmdVExitReasons[0];
for (int j = 0; j < MAX_EXITREASON_STAT; j++)
if (papszDesc[j])
rc = STAMR3RegisterF(pVM, &pVCpu->hm.s.StatExitReasonNpf, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_OCCURENCES,
# ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
rc = MMHyperAlloc(pVM, sizeof(STAMCOUNTER) * 256, 8, MM_TAG_HM, (void **)&pVCpu->hm.s.paStatInjectedIrqs);
# ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
STAMR3RegisterF(pVM, &pVCpu->hm.s.paStatInjectedIrqs[j], STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_OCCURENCES,
#ifdef VBOX_WITH_CRASHDUMP_MAGIC
return VINF_SUCCESS;
switch (enmWhat)
case VMINITCOMPLETED_RING3:
case VMINITCOMPLETED_RING0:
return VINF_SUCCESS;
int rc;
return VINF_SUCCESS;
case VERR_VMX_NO_VMX:
case VERR_SVM_IN_USE:
case VERR_SVM_NO_SVM:
case VERR_SVM_DISABLED:
return VMSetError(pVM, pVM->hm.s.lLastError, RT_SRC_POS, "HM ring-0 init failed: %Rrc", pVM->hm.s.lLastError);
return rc;
return rc;
int rc;
#ifndef VBOX_WITH_OLD_VTX_CODE
LogRel(("HM: VMCS size = %x\n", MSR_IA32_VMX_BASIC_INFO_VMCS_SIZE(pVM->hm.s.vmx.msr.vmx_basic_info)));
LogRel(("HM: VMCS physical address limit = %s\n", MSR_IA32_VMX_BASIC_INFO_VMCS_PHYS_WIDTH(pVM->hm.s.vmx.msr.vmx_basic_info) ? "< 4 GB" : "None"));
LogRel(("HM: VMCS memory type = %x\n", MSR_IA32_VMX_BASIC_INFO_VMCS_MEM_TYPE(pVM->hm.s.vmx.msr.vmx_basic_info)));
LogRel(("HM: Dual-monitor treatment = %d\n", MSR_IA32_VMX_BASIC_INFO_VMCS_DUAL_MON(pVM->hm.s.vmx.msr.vmx_basic_info)));
if (MSR_IA32_VMX_MISC_PREEMPT_TSC_BIT(pVM->hm.s.vmx.msr.vmx_misc) == pVM->hm.s.vmx.cPreemptTimerShift)
LogRel(("HM: MSR_IA32_VMX_MISC_STORE_EFERLMA_VMEXIT = %x\n", MSR_IA32_VMX_MISC_STORE_EFERLMA_VMEXIT(pVM->hm.s.vmx.msr.vmx_misc)));
LogRel(("HM: MSR_IA32_VMX_MISC_ACTIVITY_STATES = %x\n", MSR_IA32_VMX_MISC_ACTIVITY_STATES(pVM->hm.s.vmx.msr.vmx_misc)));
LogRel(("HM: MSR_IA32_VMX_MISC_CR3_TARGET = %x\n", MSR_IA32_VMX_MISC_CR3_TARGET(pVM->hm.s.vmx.msr.vmx_misc)));
LogRel(("HM: MSR_IA32_VMX_MISC_MAX_MSR = %x\n", MSR_IA32_VMX_MISC_MAX_MSR(pVM->hm.s.vmx.msr.vmx_misc)));
LogRel(("HM: MSR_IA32_VMX_MISC_RDMSR_SMBASE_MSR_SMM = %x\n", MSR_IA32_VMX_MISC_RDMSR_SMBASE_MSR_SMM(pVM->hm.s.vmx.msr.vmx_misc)));
LogRel(("HM: MSR_IA32_VMX_MISC_SMM_MONITOR_CTL_B2 = %x\n", MSR_IA32_VMX_MISC_SMM_MONITOR_CTL_B2(pVM->hm.s.vmx.msr.vmx_misc)));
LogRel(("HM: MSR_IA32_VMX_MISC_VMWRITE_VMEXIT_INFO = %x\n", MSR_IA32_VMX_MISC_VMWRITE_VMEXIT_INFO(pVM->hm.s.vmx.msr.vmx_misc)));
LogRel(("HM: MSR_IA32_VMX_MISC_MSEG_ID = %x\n", MSR_IA32_VMX_MISC_MSEG_ID(pVM->hm.s.vmx.msr.vmx_misc)));
* Disallow RDTSCP in the guest if there is no secondary process-based VM execution controls as otherwise
* RDTSCP would cause a #UD. There might be no CPUs out there where this happens, as RDTSCP was introduced
* in Nehalems and secondary VM exec. controls should be supported in all of them, but nonetheless it's Intel...
if ( !(pVM->hm.s.vmx.msr.vmx_proc_ctls.n.allowed1 & VMX_VMCS_CTRL_PROC_EXEC_USE_SECONDARY_EXEC_CTRL)
memset(pVM->hm.s.vmx.pRealModeTSS->IntRedirBitmap, 0, sizeof(pVM->hm.s.vmx.pRealModeTSS->IntRedirBitmap));
pVM->hm.s.vmx.pNonPagingModeEPTPageTable = (PX86PD)((char *)pVM->hm.s.vmx.pRealModeTSS + PAGE_SIZE * 3);
| X86_PDE4M_G;
LogRel(("HM: CPU[%ld] Last instruction error %x\n", i, pVM->aCpus[i].hm.s.vmx.lasterror.u32InstrError));
#if RT_ARCH_X86
LogRel(("HM: VMX-preemption timer enabled (cPreemptTimerShift=%u).\n", pVM->hm.s.vmx.cPreemptTimerShift));
return VINF_SUCCESS;
LogRel(("HM: AMD Cpu with erratum 170 family %#x model %#x stepping %#x\n", u32Family, u32Model, u32Stepping));
if (fSvmFeatures)
return VINF_SUCCESS;
#ifdef VBOX_WITH_OLD_VTX_CODE
#if HC_ARCH_BITS == 32 && defined(VBOX_ENABLE_64_BITS_GUESTS) && !defined(VBOX_WITH_HYBRID_32BIT_KERNEL)
case PGMMODE_32_BIT:
case PGMMODE_PAE:
case PGMMODE_PAE_NX:
AssertFailed();
VMMR3_INT_DECL(void) HMR3PagingModeChanged(PVM pVM, PVMCPU pVCpu, PGMMODE enmShadowMode, PGMMODE enmGuestMode)
#ifdef VBOX_WITH_OLD_VTX_CODE
Log(("HMR3PagingModeChanged missed %s->%s transition (prev %s)\n", PGMGetModeName(pVCpu->hm.s.vmx.enmPrevGuestMode),
PGMGetModeName(pVCpu->hm.s.vmx.enmCurrGuestMode), PGMGetModeName(pVCpu->hm.s.vmx.enmLastSeenGuestMode)));
#ifdef VMX_USE_CACHED_VMCS_ACCESSES
#ifdef VBOX_WITH_STATISTICS
#ifdef VBOX_WITH_CRASHDUMP_MAGIC
#ifdef VBOX_WITH_OLD_VTX_CODE
#ifdef VBOX_WITH_CRASHDUMP_MAGIC
return VINF_SUCCESS;
int rc;
#ifdef LOG_ENABLED
rc = DBGFR3DisasInstrEx(pVM->pUVM, pVCpu->idCpu, CPUMGetGuestCS(pVCpu), pInstrGC, DBGF_DISAS_FLAGS_DEFAULT_MODE,
#ifdef LOG_ENABLED
rc = DBGFR3DisasInstrEx(pVM->pUVM, pVCpu->idCpu, CPUMGetGuestCS(pVCpu), pInstrGC, DBGF_DISAS_FLAGS_DEFAULT_MODE,
return VINF_SUCCESS;
int rc = VMMR3EmtRendezvous(pVM, VMMEMTRENDEZVOUS_FLAGS_TYPE_ONE_BY_ONE, hmR3RemovePatches, (void *)(uintptr_t)idCpu);
return VINF_SUCCESS;
/* We own the IOM lock here and could cause a deadlock by waiting for a VCPU that is blocking on the IOM lock. */
return rc;
return VINF_SUCCESS;
return VINF_SUCCESS;
if (pPatch)
return VINF_SUCCESS;
return VINF_SUCCESS;
return VINF_SUCCESS;
return VINF_SUCCESS;
return VINF_SUCCESS;
if (pPatch)
return VINF_SUCCESS;
return VINF_SUCCESS;
bool fUsesEax = (pDis->Param2.fUse == DISUSE_REG_GEN32 && pDis->Param2.Base.idxGenReg == DISGREG_EAX);
if (!fUsesEax)
if (!fUsesEax)
if (!fUsesEax)
*(RTRCUINTPTR *)&aPatch[off] = ((RTRCUINTPTR)pCtx->eip + cbOp) - ((RTRCUINTPTR)pVM->hm.s.pFreeGuestPatchMem + off + 4);
#ifdef LOG_ENABLED
rc = DBGFR3DisasInstrEx(pVM->pUVM, pVCpu->idCpu, pCtx->cs.Sel, GCPtrInstr, DBGF_DISAS_FLAGS_DEFAULT_MODE,
*(RTRCUINTPTR *)&pPatch->aNewOpcode[1] = ((RTRCUINTPTR)pVM->hm.s.pFreeGuestPatchMem) - ((RTRCUINTPTR)pCtx->eip + 5);
return VINF_SUCCESS;
return VINF_SUCCESS;
return rc;
bool rc = false;
rc = true;
return rc;
bool rc = false;
* This logic must be in sync with HMVMXR0.cpp!
rc = true;
return rc;
bool rc = false;
* This logic must be in sync with HMVMXR0.cpp!
rc = true;
return rc;
return VINF_EM_RESCHEDULE_REM;
return VINF_SUCCESS;
/* Note! The context supplied by REM is partial. If we add more checks here, be sure to verify that REM provides this info! */
* The VMM device heap is a requirement for emulating real mode or protected mode without paging with the unrestricted
if (fSupportsRealMode)
* Update: Implemented in EM.cpp, see #ifdef EM_NOTIFY_HM. */
if ( !pVM->hm.s.fNestedPaging /* requires a fake PD for real *and* protected mode without paging - stored in the VMM device heap */
|| CPUMIsGuestInRealModeEx(pCtx)) /* requires a fake TSS for real mode - stored in the VMM device heap */
/* Note: We ignore the NE bit here on purpose; see vmmr0\hmr0.cpp for details. */
if (fSupportsRealMode)
/* Note: We ignore the PE & PG bits here on purpose; we emulate real and protected mode without paging. */
#ifdef VBOX_WITH_OLD_VTX_CODE
return VERR_NOT_FOUND;
switch (enmType)
case HMPENDINGIO_PORT_READ:
&u32Val,
case HMPENDINGIO_PORT_WRITE:
return rcStrict;
switch (iStatusCode)
LogRel(("HM: CPU%d Current pointer %RGp vs %RGp\n", i, pVM->aCpus[i].hm.s.vmx.lasterror.u64VMCSPhys, pVM->aCpus[i].hm.s.vmx.HCPhysVmcs));
LogRel(("HM: CPU%d Current VMCS version %x\n", i, pVM->aCpus[i].hm.s.vmx.lasterror.u32VMCSRevision));
LogRel(("VERR_VMX_UNABLE_TO_START_VM: VM-entry allowed %x\n", pVM->hm.s.vmx.msr.vmx_entry.n.allowed1));
LogRel(("VERR_VMX_UNABLE_TO_START_VM: VM-entry disallowed %x\n", pVM->hm.s.vmx.msr.vmx_entry.n.disallowed0));
int rc;
#ifdef VBOX_WITH_OLD_VTX_CODE
//@todo: We only need to save pVM->aCpus[i].hm.s.vmx.fWasInRealMode and
#ifdef VBOX_HM_WITH_GUEST_PATCHING
return VINF_SUCCESS;
int rc;
#ifdef VBOX_WITH_OLD_VTX_CODE
#ifdef VBOX_HM_WITH_GUEST_PATCHING
return VINF_SUCCESS;