258
258
PVMMSWITCHERDEF pSwitcher = s_apSwitchers[pVM->vmm.s.enmSwitcher];
259
259
RTRCPTR RCPtr = pVM->vmm.s.pvCoreCodeRC + pVM->vmm.s.aoffSwitchers[pVM->vmm.s.enmSwitcher];
260
pVM->vmm.s.pfnGuestToHostRC = RCPtr + pSwitcher->offGCGuestToHost;
261
pVM->vmm.s.pfnCallTrampolineRC = RCPtr + pSwitcher->offGCCallTrampoline;
262
pVM->pfnVMMGCGuestToHostAsm = RCPtr + pSwitcher->offGCGuestToHostAsm;
263
pVM->pfnVMMGCGuestToHostAsmHyperCtx = RCPtr + pSwitcher->offGCGuestToHostAsmHyperCtx;
264
pVM->pfnVMMGCGuestToHostAsmGuestCtx = RCPtr + pSwitcher->offGCGuestToHostAsmGuestCtx;
260
pVM->vmm.s.pfnRCToHost = RCPtr + pSwitcher->offRCToHost;
261
pVM->vmm.s.pfnCallTrampolineRC = RCPtr + pSwitcher->offRCCallTrampoline;
262
pVM->pfnVMMRCToHostAsm = RCPtr + pSwitcher->offRCToHostAsm;
263
pVM->pfnVMMRCToHostAsmNoReturn = RCPtr + pSwitcher->offRCToHostAsmNoReturn;
266
265
// AssertFailed();
273
#ifdef VBOX_WITH_RAW_MODE
272
276
* Generic switcher code relocator.
274
* @param pVM The VM handle.
278
* @param pVM Pointer to the VM.
275
279
* @param pSwitcher The switcher definition.
276
280
* @param pu8CodeR3 Pointer to the core code block for the switcher, ring-3 mapping.
277
281
* @param R0PtrCode Pointer to the core code block for the switcher, ring-0 mapping.
533
537
case FIX_EFER_OR_MASK:
535
539
uint32_t u32OrMask = MSR_K6_EFER_LME | MSR_K6_EFER_SCE;
536
/** note: we don't care if cpuid 0x8000001 isn't supported as that implies long mode isn't either, so this switcher would never be used. */
537
if (!!(ASMCpuId_EDX(0x80000001) & X86_CPUID_AMD_FEATURE_EDX_NX))
541
* We don't care if cpuid 0x8000001 isn't supported as that implies
542
* long mode isn't supported either, so this switched would never be used.
544
if (!!(ASMCpuId_EDX(0x80000001) & X86_CPUID_EXT_FEATURE_EDX_NX))
538
545
u32OrMask |= MSR_K6_EFER_NXE;
540
547
*uSrc.pu32 = u32OrMask;
810
817
* Disassemble it.
812
819
RTLogPrintf(" %s: offCode=%#x cbCode=%#x\n", pszDesc, offCode, cbCode);
815
memset(&Cpu, 0, sizeof(Cpu));
816
Cpu.mode = CPUMODE_32BIT;
817
821
while (cbCode > 0)
819
823
/* try label it */
820
if (pSwitcher->offR0HostToGuest == offCode)
821
RTLogPrintf(" *R0HostToGuest:\n");
822
if (pSwitcher->offGCGuestToHost == offCode)
823
RTLogPrintf(" *GCGuestToHost:\n");
824
if (pSwitcher->offGCCallTrampoline == offCode)
825
RTLogPrintf(" *GCCallTrampoline:\n");
826
if (pSwitcher->offGCGuestToHostAsm == offCode)
827
RTLogPrintf(" *GCGuestToHostAsm:\n");
828
if (pSwitcher->offGCGuestToHostAsmHyperCtx == offCode)
829
RTLogPrintf(" *GCGuestToHostAsmHyperCtx:\n");
830
if (pSwitcher->offGCGuestToHostAsmGuestCtx == offCode)
831
RTLogPrintf(" *GCGuestToHostAsmGuestCtx:\n");
824
if (pSwitcher->offR0ToRawMode == offCode)
825
RTLogPrintf(" *R0ToRawMode:\n");
826
if (pSwitcher->offRCToHost == offCode)
827
RTLogPrintf(" *RCToHost:\n");
828
if (pSwitcher->offRCCallTrampoline == offCode)
829
RTLogPrintf(" *RCCallTrampoline:\n");
830
if (pSwitcher->offRCToHostAsm == offCode)
831
RTLogPrintf(" *RCToHostAsm:\n");
832
if (pSwitcher->offRCToHostAsmNoReturn == offCode)
833
RTLogPrintf(" *RCToHostAsmNoReturn:\n");
834
uint32_t cbInstr = 0;
836
if (RT_SUCCESS(DISInstr(&Cpu, (uintptr_t)pu8CodeR3 + offCode, uBase - (uintptr_t)pu8CodeR3, &cbInstr, szDisas)))
837
RTLogPrintf(" %04x: %s", offCode, szDisas); //for whatever reason szDisas includes '\n'.
836
uint32_t cbInstr = 0;
839
int rc = DISInstr(pu8CodeR3 + offCode, DISCPUMODE_32BIT, &Cpu, &cbInstr);
842
Cpu.uInstrAddr += uBase - (uintptr_t)pu8CodeR3;
843
DISFormatYasmEx(&Cpu, szDisas, sizeof(szDisas),
844
DIS_FMT_FLAGS_ADDR_LEFT | DIS_FMT_FLAGS_BYTES_LEFT | DIS_FMT_FLAGS_BYTES_SPACED
845
| DIS_FMT_FLAGS_RELATIVE_BRANCH,
849
RTLogPrintf(" %04x: %s\n", offCode, szDisas);
840
RTLogPrintf(" %04x: %02x '%c'\n",
841
offCode, pu8CodeR3[offCode], RT_C_IS_PRINT(pu8CodeR3[offCode]) ? pu8CodeR3[offCode] : ' ');
852
RTLogPrintf(" %04x: %02x '%c' (rc=%Rrc\n",
853
offCode, pu8CodeR3[offCode], RT_C_IS_PRINT(pu8CodeR3[offCode]) ? pu8CodeR3[offCode] : ' ', rc);
844
856
offCode += cbInstr;
963
974
pVM->vmm.s.enmSwitcher = enmSwitcher;
965
976
RTR0PTR pbCodeR0 = (RTR0PTR)pVM->vmm.s.pvCoreCodeR0 + pVM->vmm.s.aoffSwitchers[enmSwitcher]; /** @todo fix the pvCoreCodeR0 type */
966
pVM->vmm.s.pfnHostToGuestR0 = pbCodeR0 + pSwitcher->offR0HostToGuest;
977
pVM->vmm.s.pfnR0ToRawMode = pbCodeR0 + pSwitcher->offR0ToRawMode;
968
RTGCPTR GCPtr = pVM->vmm.s.pvCoreCodeRC + pVM->vmm.s.aoffSwitchers[enmSwitcher];
969
pVM->vmm.s.pfnGuestToHostRC = GCPtr + pSwitcher->offGCGuestToHost;
970
pVM->vmm.s.pfnCallTrampolineRC = GCPtr + pSwitcher->offGCCallTrampoline;
971
pVM->pfnVMMGCGuestToHostAsm = GCPtr + pSwitcher->offGCGuestToHostAsm;
972
pVM->pfnVMMGCGuestToHostAsmHyperCtx = GCPtr + pSwitcher->offGCGuestToHostAsmHyperCtx;
973
pVM->pfnVMMGCGuestToHostAsmGuestCtx = GCPtr + pSwitcher->offGCGuestToHostAsmGuestCtx;
979
RTRCPTR RCPtr = pVM->vmm.s.pvCoreCodeRC + pVM->vmm.s.aoffSwitchers[enmSwitcher];
980
pVM->vmm.s.pfnRCToHost = RCPtr + pSwitcher->offRCToHost;
981
pVM->vmm.s.pfnCallTrampolineRC = RCPtr + pSwitcher->offRCCallTrampoline;
982
pVM->pfnVMMRCToHostAsm = RCPtr + pSwitcher->offRCToHostAsm;
983
pVM->pfnVMMRCToHostAsmNoReturn = RCPtr + pSwitcher->offRCToHostAsmNoReturn;
974
984
return VINF_SUCCESS;
977
987
return VERR_NOT_IMPLEMENTED;
990
#endif /* VBOX_WITH_RAW_MODE */
982
994
* Disable the switcher logic permanently.
984
996
* @returns VBox status code.
985
* @param pVM VM handle.
997
* @param pVM Pointer to the VM.
987
999
VMMR3_INT_DECL(int) VMMR3DisableSwitcher(PVM pVM)