/** * Remove MMGCRam Hypervisor page fault handler. * See description of MMGCRamRegisterTrapHandler call. * * @param pVM Pointer to the VM. */ VMMRCDECL(void) MMGCRamDeregisterTrapHandler(PVM pVM) { TRPMGCSetTempHandler(pVM, 0xe, NULL); }
/** * Execute the trap testcase. * * There is some common code here, that's why we're collecting them * like this. Odd numbered variation (uArg) are executed with write * protection (WP) enabled. * * @returns VINF_SUCCESS if it was a testcase setup up to continue and did so successfully. * @returns VERR_NOT_IMPLEMENTED if the testcase wasn't implemented. * @returns VERR_GENERAL_FAILURE if the testcase continued when it shouldn't. * * @param pVM The VM handle. * @param uOperation The testcase. * @param uArg The variation. See function description for odd / even details. * * @remark Careful with the trap 08 testcase and WP, it will triple * fault the box if the TSS, the Trap8 TSS and the fault TSS * GDTE are in pages which are read-only. * See bottom of SELMR3Init(). */ static int vmmGCTest(PVM pVM, unsigned uOperation, unsigned uArg) { /* * Set up the testcase. */ #if 0 switch (uOperation) { default: break; } #endif /* * Enable WP if odd variation. */ if (uArg & 1) vmmGCEnableWP(); /* * Execute the testcase. */ int rc = VERR_NOT_IMPLEMENTED; switch (uOperation) { //case VMMGC_DO_TESTCASE_TRAP_0: //case VMMGC_DO_TESTCASE_TRAP_1: //case VMMGC_DO_TESTCASE_TRAP_2: case VMMGC_DO_TESTCASE_TRAP_3: { if (uArg <= 1) rc = vmmGCTestTrap3(); break; } //case VMMGC_DO_TESTCASE_TRAP_4: //case VMMGC_DO_TESTCASE_TRAP_5: //case VMMGC_DO_TESTCASE_TRAP_6: //case VMMGC_DO_TESTCASE_TRAP_7: case VMMGC_DO_TESTCASE_TRAP_8: { #ifndef DEBUG_bird /** @todo dynamic check that this won't triple fault... */ if (uArg & 1) break; #endif if (uArg <= 1) rc = vmmGCTestTrap8(); break; } //VMMGC_DO_TESTCASE_TRAP_9, //VMMGC_DO_TESTCASE_TRAP_0A, //VMMGC_DO_TESTCASE_TRAP_0B, //VMMGC_DO_TESTCASE_TRAP_0C, case VMMGC_DO_TESTCASE_TRAP_0D: { if (uArg <= 1) rc = vmmGCTestTrap0d(); break; } case VMMGC_DO_TESTCASE_TRAP_0E: { if (uArg <= 1) rc = vmmGCTestTrap0e(); else if (uArg == 2 || uArg == 4) { /* * Test the use of a temporary #PF handler. */ rc = TRPMGCSetTempHandler(pVM, X86_XCPT_PF, uArg != 4 ? vmmGCTestTmpPFHandler : vmmGCTestTmpPFHandlerCorruptFS); if (RT_SUCCESS(rc)) { rc = vmmGCTestTrap0e(); /* in case it didn't fire. */ int rc2 = TRPMGCSetTempHandler(pVM, X86_XCPT_PF, NULL); if (RT_FAILURE(rc2) && RT_SUCCESS(rc)) rc = rc2; } } break; } } /* * Re-enable WP. */ if (uArg & 1) vmmGCDisableWP(); return rc; }
/** * Install MMGCRam Hypervisor page fault handler for normal working * of MMGCRamRead and MMGCRamWrite calls. * This handler will be automatically removed at page fault. * In other case it must be removed by MMGCRamDeregisterTrapHandler call. * * @param pVM Pointer to the VM. */ VMMRCDECL(void) MMGCRamRegisterTrapHandler(PVM pVM) { TRPMGCSetTempHandler(pVM, 0xe, mmGCRamTrap0eHandler); }