- Timestamp:
- Mar 8, 2007 1:02:08 PM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 19296
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/TRPM.cpp
r1325 r1328 96 96 TRPM_HANDLER_MAX 97 97 } TRPMHANDLER, *PTRPMHANDLER; 98 99 /** First interrupt handler. Used for validating input. */100 #define TRPM_HANDLER_INT_BASE 0x20101 98 102 99 … … 423 420 static DECLCALLBACK(int) trpmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version); 424 421 static DECLCALLBACK(int) trpmGuestIDTWriteHandler(PVM pVM, RTGCPTR GCPtr, void *pvPtr, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, void *pvUser); 425 static int trpmR3ClearGuestTrapHandler(PVM pVM, unsigned iTrap);426 422 427 423 … … 471 467 * Statistics. 472 468 */ 473 STAM_REG(pVM, &pVM->trpm.s.StatGCWriteGuestIDT, STAMTYPE_COUNTER, "/TRPM/GC/Write/Guest/IDT", STAMUNIT_OCCURENCES, "The number of writes to the Guest IDT."); 469 STAM_REG(pVM, &pVM->trpm.s.StatGCWriteGuestIDTFault, STAMTYPE_COUNTER, "/TRPM/GC/Write/IDT/Fault", STAMUNIT_OCCURENCES, "The number of writes to the Guest IDT."); 470 STAM_REG(pVM, &pVM->trpm.s.StatGCWriteGuestIDTHandled, STAMTYPE_COUNTER, "/TRPM/GC/Write/IDT/Handled", STAMUNIT_OCCURENCES, "The number of writes to the Guest IDT."); 474 471 475 472 STAM_REG(pVM, &pVM->trpm.s.StatSyncIDT, STAMTYPE_PROFILE, "/PROF/TRPM/SyncIDT", STAMUNIT_TICKS_PER_CALL, "Profiling of TRPMR3SyncIDT()."); … … 872 869 /** @todo inefficient, but simple */ 873 870 for (unsigned iGate=0;iGate<256;iGate++) 874 trpm R3ClearGuestTrapHandler(pVM, iGate);871 trpmClearGuestTrapHandler(pVM, iGate); 875 872 876 873 /* Scan them all (only the first time) */ … … 1105 1102 1106 1103 /** 1107 * Clear guest trap/interrupt gate handler1108 *1109 * @returns VBox status code.1110 * @param pVM The VM to operate on.1111 * @param iTrap Interrupt/trap number.1112 */1113 static int trpmR3ClearGuestTrapHandler(PVM pVM, unsigned iTrap)1114 {1115 /*1116 * Validate.1117 */1118 if (iTrap >= ELEMENTS(pVM->trpm.s.aIdt))1119 {1120 AssertMsg(iTrap < TRPM_HANDLER_INT_BASE, ("Illegal gate number %d!\n", iTrap));1121 return VERR_INVALID_PARAMETER;1122 }1123 1124 if (ASMBitTest(&pVM->trpm.s.au32IdtPatched[0], iTrap))1125 trpmR3ClearPassThroughHandler(pVM, iTrap);1126 1127 pVM->trpm.s.aGuestTrapHandler[iTrap] = TRPM_INVALID_HANDLER;1128 return VINF_SUCCESS;1129 }1130 1131 /**1132 1104 * Set guest trap/interrupt gate handler 1133 1105 * Used for setting up trap gates used for kernel calls. … … 1160 1132 /* clear trap handler */ 1161 1133 Log(("TRPMR3SetGuestTrapHandler: clear handler %x\n", iTrap)); 1162 return trpm R3ClearGuestTrapHandler(pVM, iTrap);1134 return trpmClearGuestTrapHandler(pVM, iTrap); 1163 1135 } 1164 1136 -
trunk/src/VBox/VMM/TRPMInternal.h
r1283 r1328 35 35 /* Enable to allow trap forwarding in GC. */ 36 36 #define TRPM_FORWARD_TRAPS_IN_GC 37 38 /** First interrupt handler. Used for validating input. */ 39 #define TRPM_HANDLER_INT_BASE 0x20 37 40 38 41 __BEGIN_DECLS … … 146 149 147 150 /** GC: The number of times writes to the Guest IDT were detected. */ 148 STAMCOUNTER StatGCWriteGuestIDT; 151 STAMCOUNTER StatGCWriteGuestIDTFault; 152 STAMCOUNTER StatGCWriteGuestIDTHandled; 153 149 154 /** HC: Profiling of the TRPMR3SyncIDT() method. */ 150 155 STAMPROFILE StatSyncIDT; … … 176 181 TRPMGCDECL(int) trpmgcShadowIDTWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, void *pvFault, void *pvRange, uintptr_t offRange); 177 182 183 /** 184 * Clear guest trap/interrupt gate handler 185 * 186 * @returns VBox status code. 187 * @param pVM The VM to operate on. 188 * @param iTrap Interrupt/trap number. 189 */ 190 TRPMDECL(int) trpmClearGuestTrapHandler(PVM pVM, unsigned iTrap); 191 178 192 179 193 #ifdef IN_RING3 194 195 /** 196 * Clear passthrough interrupt gate handler (reset to default handler) 197 * 198 * @returns VBox status code. 199 * @param pVM The VM to operate on. 200 * @param iTrap Trap/interrupt gate number. 201 */ 202 TRPMR3DECL(int) trpmR3ClearPassThroughHandler(PVM pVM, unsigned iTrap); 180 203 181 204 #endif -
trunk/src/VBox/VMM/TRPMInternal.mac
r716 r1328 55 55 .aGuestTrapHandler resd 256 56 56 57 .StatGCWriteGuestIDT resb STAMCOUNTER_size 57 .StatGCWriteGuestIDTFault resb STAMCOUNTER_size 58 .StatGCWriteGuestIDTHandled resb STAMCOUNTER_size 58 59 .StatSyncIDT resb STAMPROFILE_size 59 60 .aStatGCTraps resb STAMPROFILEADV_size * 0x14 -
trunk/src/VBox/VMM/VMMAll/TRPMAll.cpp
r1326 r1328 821 821 } 822 822 823 824 /** 825 * Clear guest trap/interrupt gate handler 826 * 827 * @returns VBox status code. 828 * @param pVM The VM to operate on. 829 * @param iTrap Interrupt/trap number. 830 */ 831 TRPMDECL(int) trpmClearGuestTrapHandler(PVM pVM, unsigned iTrap) 832 { 833 /* 834 * Validate. 835 */ 836 if (iTrap >= ELEMENTS(pVM->trpm.s.aIdt)) 837 { 838 AssertMsg(iTrap < TRPM_HANDLER_INT_BASE, ("Illegal gate number %d!\n", iTrap)); 839 return VERR_INVALID_PARAMETER; 840 } 841 842 if (ASMBitTest(&pVM->trpm.s.au32IdtPatched[0], iTrap)) 843 #ifdef IN_RING3 844 trpmR3ClearPassThroughHandler(pVM, iTrap); 845 #else 846 AssertFailed(); 847 #endif 848 849 pVM->trpm.s.aGuestTrapHandler[iTrap] = TRPM_INVALID_HANDLER; 850 return VINF_SUCCESS; 851 } 852 853 -
trunk/src/VBox/VMM/VMMGC/TRPMGC.cpp
r1327 r1328 33 33 #include <VBox/err.h> 34 34 #include <VBox/x86.h> 35 #include <VBox/em.h> 35 36 #include <iprt/assert.h> 36 37 #include <iprt/asm.h> … … 109 110 #ifdef VBOX_STRICT 110 111 RTGCPTR GCPtrIDTEnd = (RTGCPTR)((RTGCUINTPTR)GCPtrIDT + cbIDT + 1); 112 #endif 111 113 uint32_t iTrap = ((RTGCUINTPTR)pvFault - (RTGCUINTPTR)GCPtrIDT)/sizeof(VBOXIDTE); 112 #endif113 114 114 115 Assert(pvFault >= GCPtrIDT && pvFault < GCPtrIDTEnd); 115 116 Log(("trpmgcGuestIDTWriteHandler: write to gate %x\n", iTrap)); 116 117 117 ////LogCom(("trpmgcGuestIDTWriteHandler: eip=%08X pvFault=%08X pvRange=%08X\r\n", pRegFrame->eip, pvFault, pvRange)); 118 #if 0 119 /* Check if we can handle the write here. */ 120 if ( iTrap != 3 /* Gate 3 is handled differently; could do it here as well, but let ring 3 handle this case for now. */ 121 && !ASMBitTest(&pVM->trpm.s.au32IdtPatched[0], iTrap)) /* Passthru gates need special attention too. */ 122 { 123 uint32_t cb; 124 int rc = EMInterpretInstruction(pVM, pRegFrame, pvFault, &cb); 125 if (VBOX_SUCCESS(rc) && cb) 126 { 127 trpmClearGuestTrapHandler(pVM, iTrap); 128 STAM_COUNTER_INC(&pVM->trpm.s.StatGCWriteGuestIDTHandled); 129 return VINF_SUCCESS; 130 } 131 } 132 #endif 133 134 /** @todo Check which IDT entry and keep the update cost low in TRPMR3SyncIDT() and CSAMCheckGates(). */ 118 135 VM_FF_SET(pVM, VM_FF_TRPM_SYNC_IDT); 119 /** @todo Check which IDT entry and keep the update cost low in TRPMR3SyncIDT() and CSAMCheckGates(). */120 136 121 STAM_COUNTER_INC(&pVM->trpm.s.StatGCWriteGuestIDT );137 STAM_COUNTER_INC(&pVM->trpm.s.StatGCWriteGuestIDTFault); 122 138 return VINF_EM_RAW_EMULATE_INSTR_IDT_FAULT; 123 139 }
Note:
See TracChangeset
for help on using the changeset viewer.