- Timestamp:
- Feb 28, 2007 8:36:20 AM (18 years ago)
- Location:
- trunk/src/VBox/VMM/PATM
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/PATM/CSAM.cpp
r882 r1086 2032 2032 * @returns VBox status code. 2033 2033 * @param pVM The VM to operate on. 2034 * @param pCtx CPU context 2034 * @param Sel selector 2035 * @param pHiddenSel The hidden selector register. 2035 2036 * @param pInstrGC Instruction pointer 2036 2037 */ 2037 CSAMR3DECL(int) CSAMR3CheckCode(PVM pVM, PCPUMCTX pCtx, RTGCPTR pInstrGC) 2038 CSAMR3DECL(int) CSAMR3CheckCodeEx(PVM pVM, RTSEL Sel, CPUMSELREGHID *pHiddenSel, RTGCPTR pInstrGC) 2039 { 2040 PCSAMPAGE pPage = NULL; 2041 2042 if (EMIsRawRing0Enabled(pVM) == false || PATMIsPatchGCAddr(pVM, pInstrGC) == true) 2043 { 2044 // No use 2045 return VINF_SUCCESS; 2046 } 2047 2048 if (CSAMIsEnabled(pVM)) 2049 { 2050 bool fCode32 = SELMIsSelector32Bit(pVM, Sel, pHiddenSel); 2051 2052 //assuming 32 bits code for now 2053 Assert(fCode32); 2054 2055 pInstrGC = SELMToFlat(pVM, Sel, pHiddenSel, pInstrGC); 2056 2057 return CSAMR3CheckCode(pVM, pInstrGC); 2058 } 2059 return VINF_SUCCESS; 2060 } 2061 2062 /** 2063 * Scan and analyse code 2064 * 2065 * @returns VBox status code. 2066 * @param pVM The VM to operate on. 2067 * @param pInstrGC Instruction pointer (0:32 virtual address) 2068 */ 2069 CSAMR3DECL(int) CSAMR3CheckCode(PVM pVM, RTGCPTR pInstrGC) 2038 2070 { 2039 2071 int rc; … … 2050 2082 // Cache record for PATMGCVirtToHCVirt 2051 2083 CSAMP2GLOOKUPREC cacheRec = {0}; 2052 bool fCode32 = SELMIsSelector32Bit(pVM, pCtx->cs, &pCtx->csHid);2053 2054 //assuming 32 bits code for now2055 Assert(fCode32);2056 2057 pInstrGC = SELMToFlat(pVM, pCtx->cs, &pCtx->csHid, pInstrGC);2058 2084 2059 2085 STAM_PROFILE_START(&pVM->csam.s.StatTime, a); 2060 rc = csamAnalyseCallCodeStream(pVM, pInstrGC, pInstrGC, fCode32, CSAMR3AnalyseCallback, pPage, &cacheRec);2086 rc = csamAnalyseCallCodeStream(pVM, pInstrGC, pInstrGC, true /* 32 bits code */, CSAMR3AnalyseCallback, pPage, &cacheRec); 2061 2087 STAM_PROFILE_STOP(&pVM->csam.s.StatTime, a); 2062 2088 if (rc != VINF_SUCCESS) -
trunk/src/VBox/VMM/PATM/PATM.cpp
r885 r1086 3336 3336 3337 3337 pBranchTarget = pCtx->edx; 3338 pBranchTarget = SELMToFlat(pVM, pCtx->cs, &pCtx->csHid, pBranchTarget); 3338 3339 3339 3340 /* First we check if the duplicate function target lies in some existing function patch already. Will save some space. */ … … 3901 3902 * @returns VBox status code. 3902 3903 * @param pVM The VM to operate on. 3903 * @param pInstr Guest context point to privileged instruction 3904 * @param pInstr Guest context point to privileged instruction (0:32 flat address) 3904 3905 * @param flags Patch flags 3905 3906 * … … 3909 3910 { 3910 3911 DISCPUSTATE cpu; 3911 PCPUMCTX pCtx;3912 3912 HCPTRTYPE(uint8_t *) pInstrHC; 3913 3913 uint32_t opsize; … … 3925 3925 return VERR_PATCHING_REFUSED; 3926 3926 3927 CPUMQueryGuestCtxPtr(pVM, &pCtx);3928 3929 3927 /* Test for patch conflict only with patches that actually change guest code. */ 3930 3928 if (!(flags & (PATMFL_GUEST_SPECIFIC|PATMFL_IDTHANDLER|PATMFL_INTHANDLER|PATMFL_TRAMPOLINE))) … … 3947 3945 return VERR_PATCHING_REFUSED; 3948 3946 3947 #ifdef VBOX_STRICT 3948 PCPUMCTX pCtx = 0; 3949 3950 CPUMQueryGuestCtxPtr(pVM, &pCtx); 3951 3952 if ( !pCtx->eflags.Bits.u1VM 3953 && (pCtx->ss & X86_SEL_RPL) == 0) 3954 { 3955 RTGCPTR pInstrGCFlat = SELMToFlat(pVM, pCtx->cs, &pCtx->csHid, pInstrGC); 3956 Assert(pInstrGCFlat == pInstrGC); 3957 } 3958 #endif 3959 3949 3960 /** @note the OpenBSD specific check will break if we allow additional patches to be installed (int 3)) */ 3950 3961 if (!(flags & PATMFL_GUEST_SPECIFIC)) 3951 3962 { 3952 3963 /* New code. Make sure CSAM has a go at it first. */ 3953 CSAMR3CheckCode(pVM, p Ctx, pInstrGC);3964 CSAMR3CheckCode(pVM, pInstrGC); 3954 3965 } 3955 3966 -
trunk/src/VBox/VMM/PATM/PATMA.asm
r744 r1086 41 41 ; Noisy, but useful for debugging certain problems 42 42 ;;;%define PATM_LOG_PATCHINSTR 43 %define PATM_LOG_PATCHIRET 43 44 %endif 44 45 … … 378 379 ; Trampoline code for trap entry (without error code on the stack) 379 380 ; 381 ; esp + 32 - GS (V86 only) 382 ; esp + 28 - FS (V86 only) 383 ; esp + 24 - DS (V86 only) 384 ; esp + 20 - ES (V86 only) 380 385 ; esp + 16 - SS (if transfer to inner ring) 381 386 ; esp + 12 - ESP (if transfer to inner ring) … … 388 393 mov dword [ss:PATM_INTERRUPTFLAG], 0 389 394 pushf 395 396 test dword [esp+12], X86_EFL_VM 397 jnz PATMTrapNoRing1 390 398 391 399 ; make sure the saved CS selector for ring 1 is made 0 … … 433 441 ; Trampoline code for trap entry (with error code on the stack) 434 442 ; 443 ; esp + 36 - GS (V86 only) 444 ; esp + 32 - FS (V86 only) 445 ; esp + 28 - DS (V86 only) 446 ; esp + 24 - ES (V86 only) 435 447 ; esp + 20 - SS (if transfer to inner ring) 436 448 ; esp + 16 - ESP (if transfer to inner ring) … … 444 456 mov dword [ss:PATM_INTERRUPTFLAG], 0 445 457 pushf 458 459 test dword [esp+16], X86_EFL_VM 460 jnz PATMTrapErrorCodeNoRing1 446 461 447 462 ; make sure the saved CS selector for ring 1 is made 0 … … 490 505 ; Trampoline code for interrupt gate entry (without error code on the stack) 491 506 ; 507 ; esp + 32 - GS (V86 only) 508 ; esp + 28 - FS (V86 only) 509 ; esp + 24 - DS (V86 only) 510 ; esp + 20 - ES (V86 only) 492 511 ; esp + 16 - SS (if transfer to inner ring) 493 512 ; esp + 12 - ESP (if transfer to inner ring) … … 500 519 mov dword [ss:PATM_INTERRUPTFLAG], 0 501 520 pushf 521 522 test dword [esp+12], X86_EFL_VM 523 jnz PATMIntNoRing1 502 524 503 525 ; make sure the saved CS selector for ring 1 is made 0 … … 542 564 ; Trampoline code for interrupt gate entry (*with* error code on the stack) 543 565 ; 566 ; esp + 36 - GS (V86 only) 567 ; esp + 32 - FS (V86 only) 568 ; esp + 28 - DS (V86 only) 569 ; esp + 24 - ES (V86 only) 544 570 ; esp + 20 - SS (if transfer to inner ring) 545 571 ; esp + 16 - ESP (if transfer to inner ring) … … 553 579 mov dword [ss:PATM_INTERRUPTFLAG], 0 554 580 pushf 581 582 test dword [esp+16], X86_EFL_VM 583 jnz PATMIntNoRing1_ErrorCode 555 584 556 585 ; make sure the saved CS selector for ring 1 is made 0 … … 1070 1099 pushfd 1071 1100 1072 %ifdef PATM_LOG_PATCHI NSTR1101 %ifdef PATM_LOG_PATCHIRET 1073 1102 push eax 1074 1103 push ecx … … 1085 1114 1086 1115 test dword [esp], X86_EFL_NT 1087 jnz neariret_fault11116 jnz iret_fault1 1088 1117 1089 1118 test dword [esp+12], X86_EFL_VM 1090 jnz near iret_fault1119 jnz iret_notring0 1091 1120 1092 1121 ;;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! … … 1098 1127 1099 1128 test dword [esp+12], X86_EFL_IF 1100 jz neariret_clearIF1129 jz iret_clearIF 1101 1130 1102 1131 ; if interrupts are pending, then we must go back to the host context to handle them! … … 1217 1246 DD 0 1218 1247 DD PATMIretEnd- PATMIretStart 1219 %ifdef PATM_LOG_PATCHI NSTR1248 %ifdef PATM_LOG_PATCHIRET 1220 1249 DD 22 1221 1250 %else … … 1224 1253 DD PATM_INTERRUPTFLAG 1225 1254 DD 0 1226 %ifdef PATM_LOG_PATCHI NSTR1255 %ifdef PATM_LOG_PATCHIRET 1227 1256 DD PATM_PENDINGACTION 1228 1257 DD 0
Note:
See TracChangeset
for help on using the changeset viewer.