Changeset 30338 in vbox for trunk/src/VBox/VMM/VMMGC
- Timestamp:
- Jun 21, 2010 2:48:17 PM (15 years ago)
- Location:
- trunk/src/VBox/VMM/VMMGC
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMGC/EMGCA.asm
r28800 r30338 25 25 BEGINCODE 26 26 27 ;;28 ; Emulate LOCK CMPXCHG instruction, CDECL calling conv.29 ; VMMRCDECL(uint32_t) EMGCEmulateLockCmpXchg(RTGCPTR pu32Param1, uint32_t *pu32Param2, uint32_t u32Param3, size_t cbSize, uint32_t *pEflags);30 ;31 ; @returns eax=0 if data written, other code - invalid access, #PF was generated.32 ; @param [esp + 04h] Param 1 - First parameter - pointer to first parameter33 ; @param [esp + 08h] Param 2 - Second parameter - pointer to second parameter (eax)34 ; @param [esp + 0ch] Param 3 - Third parameter - third parameter35 ; @param [esp + 10h] Param 4 - Size of parameters, only 1/2/4 is valid.36 ; @param [esp + 14h] Param 4 - Pointer to eflags (out)37 ; @uses eax, ecx, edx38 ;39 align 1640 BEGINPROC EMGCEmulateLockCmpXchg41 push ebx42 mov ecx, [esp + 04h + 4] ; ecx = first parameter43 mov ebx, [esp + 08h + 4] ; ebx = 2nd parameter (eax)44 mov edx, [esp + 0ch + 4] ; edx = third parameter45 mov eax, [esp + 10h + 4] ; eax = size of parameters46 47 cmp al, 448 je short .do_dword ; 4 bytes variant49 cmp al, 250 je short .do_word ; 2 byte variant51 cmp al, 152 je short .do_byte ; 1 bytes variant53 int354 55 .do_dword:56 ; load 2nd parameter's value57 mov eax, dword [ebx]58 59 lock cmpxchg dword [ecx], edx ; do 4 bytes CMPXCHG60 mov dword [ebx], eax61 jmp short .done62 63 .do_word:64 ; load 2nd parameter's value65 mov eax, dword [ebx]66 67 lock cmpxchg word [ecx], dx ; do 2 bytes CMPXCHG68 mov word [ebx], ax69 jmp short .done70 71 .do_byte:72 ; load 2nd parameter's value73 mov eax, dword [ebx]74 75 lock cmpxchg byte [ecx], dl ; do 1 bytes CMPXCHG76 mov byte [ebx], al77 78 .done:79 ; collect flags and return.80 pushf81 pop eax82 83 mov edx, [esp + 14h + 4] ; eflags pointer84 mov dword [edx], eax85 86 pop ebx87 mov eax, VINF_SUCCESS88 retn89 90 ; Read error - we will be here after our page fault handler.91 GLOBALNAME EMGCEmulateLockCmpXchg_Error92 pop ebx93 mov eax, VERR_ACCESS_DENIED94 ret95 96 ENDPROC EMGCEmulateLockCmpXchg97 98 ;;99 ; Emulate CMPXCHG instruction, CDECL calling conv.100 ; VMMRCDECL(uint32_t) EMGCEmulateCmpXchg(RTGCPTR pu32Param1, uint32_t *pu32Param2, uint32_t u32Param3, size_t cbSize, uint32_t *pEflags);101 ;102 ; @returns eax=0 if data written, other code - invalid access, #PF was generated.103 ; @param [esp + 04h] Param 1 - First parameter - pointer to first parameter104 ; @param [esp + 08h] Param 2 - Second parameter - pointer to second parameter (eax)105 ; @param [esp + 0ch] Param 3 - Third parameter - third parameter106 ; @param [esp + 10h] Param 4 - Size of parameters, only 1/2/4 is valid.107 ; @param [esp + 14h] Param 4 - Pointer to eflags (out)108 ; @uses eax, ecx, edx109 ;110 align 16111 BEGINPROC EMGCEmulateCmpXchg112 push ebx113 mov ecx, [esp + 04h + 4] ; ecx = first parameter114 mov ebx, [esp + 08h + 4] ; ebx = 2nd parameter (eax)115 mov edx, [esp + 0ch + 4] ; edx = third parameter116 mov eax, [esp + 10h + 4] ; eax = size of parameters117 118 cmp al, 4119 je short .do_dword ; 4 bytes variant120 cmp al, 2121 je short .do_word ; 2 byte variant122 cmp al, 1123 je short .do_byte ; 1 bytes variant124 int3125 126 .do_dword:127 ; load 2nd parameter's value128 mov eax, dword [ebx]129 130 cmpxchg dword [ecx], edx ; do 4 bytes CMPXCHG131 mov dword [ebx], eax132 jmp short .done133 134 .do_word:135 ; load 2nd parameter's value136 mov eax, dword [ebx]137 138 cmpxchg word [ecx], dx ; do 2 bytes CMPXCHG139 mov word [ebx], ax140 jmp short .done141 142 .do_byte:143 ; load 2nd parameter's value144 mov eax, dword [ebx]145 146 cmpxchg byte [ecx], dl ; do 1 bytes CMPXCHG147 mov byte [ebx], al148 149 .done:150 ; collect flags and return.151 pushf152 pop eax153 154 mov edx, [esp + 14h + 4] ; eflags pointer155 mov dword [edx], eax156 157 pop ebx158 mov eax, VINF_SUCCESS159 retn160 161 ; Read error - we will be here after our page fault handler.162 GLOBALNAME EMGCEmulateCmpXchg_Error163 pop ebx164 mov eax, VERR_ACCESS_DENIED165 ret166 ENDPROC EMGCEmulateCmpXchg167 168 ;;169 ; Emulate LOCK CMPXCHG8B instruction, CDECL calling conv.170 ; VMMRCDECL(uint32_t) EMGCEmulateLockCmpXchg8b(RTGCPTR pu32Param1, uint32_t *pEAX, uint32_t *pEDX, uint32_t uEBX, uint32_t uECX, uint32_t *pEflags);171 ;172 ; @returns eax=0 if data written, other code - invalid access, #PF was generated.173 ; @param [esp + 04h] Param 1 - First parameter - pointer to first parameter174 ; @param [esp + 08h] Param 2 - Address of the eax register175 ; @param [esp + 0ch] Param 3 - Address of the edx register176 ; @param [esp + 10h] Param 4 - EBX177 ; @param [esp + 14h] Param 5 - ECX178 ; @param [esp + 18h] Param 6 - Pointer to eflags (out)179 ; @uses eax, ecx, edx180 ;181 align 16182 BEGINPROC EMGCEmulateLockCmpXchg8b183 push ebp184 push ebx185 mov ebp, [esp + 04h + 8] ; ebp = first parameter186 mov eax, [esp + 08h + 8] ; &EAX187 mov eax, dword [eax]188 mov edx, [esp + 0ch + 8] ; &EDX189 mov edx, dword [edx]190 mov ebx, [esp + 10h + 8] ; EBX191 mov ecx, [esp + 14h + 8] ; ECX192 193 %ifdef RT_OS_OS2194 lock cmpxchg8b [ebp] ; do CMPXCHG8B195 %else196 lock cmpxchg8b qword [ebp] ; do CMPXCHG8B197 %endif198 mov ebx, dword [esp + 08h + 8]199 mov dword [ebx], eax200 mov ebx, dword [esp + 0ch + 8]201 mov dword [ebx], edx202 203 ; collect flags and return.204 pushf205 pop eax206 207 mov edx, [esp + 18h + 8] ; eflags pointer208 mov dword [edx], eax209 210 pop ebx211 pop ebp212 mov eax, VINF_SUCCESS213 retn214 215 ; Read error - we will be here after our page fault handler.216 GLOBALNAME EMGCEmulateLockCmpXchg8b_Error217 pop ebx218 pop ebp219 mov eax, VERR_ACCESS_DENIED220 ret221 222 ENDPROC EMGCEmulateLockCmpXchg8b223 224 ;;225 ; Emulate CMPXCHG8B instruction, CDECL calling conv.226 ; VMMRCDECL(uint32_t) EMGCEmulateCmpXchg8b(RTGCPTR pu32Param1, uint32_t *pEAX, uint32_t *pEDX, uint32_t uEBX, uint32_t uECX, uint32_t *pEflags);227 ;228 ; @returns eax=0 if data written, other code - invalid access, #PF was generated.229 ; @param [esp + 04h] Param 1 - First parameter - pointer to first parameter230 ; @param [esp + 08h] Param 2 - Address of the eax register231 ; @param [esp + 0ch] Param 3 - Address of the edx register232 ; @param [esp + 10h] Param 4 - EBX233 ; @param [esp + 14h] Param 5 - ECX234 ; @param [esp + 18h] Param 6 - Pointer to eflags (out)235 ; @uses eax, ecx, edx236 ;237 align 16238 BEGINPROC EMGCEmulateCmpXchg8b239 push ebp240 push ebx241 mov ebp, [esp + 04h + 8] ; ebp = first parameter242 mov eax, [esp + 08h + 8] ; &EAX243 mov eax, dword [eax]244 mov edx, [esp + 0ch + 8] ; &EDX245 mov edx, dword [edx]246 mov ebx, [esp + 10h + 8] ; EBX247 mov ecx, [esp + 14h + 8] ; ECX248 249 %ifdef RT_OS_OS2250 cmpxchg8b [ebp] ; do CMPXCHG8B251 %else252 cmpxchg8b qword [ebp] ; do CMPXCHG8B253 %endif254 mov ebx, dword [esp + 08h + 8]255 mov dword [ebx], eax256 mov ebx, dword [esp + 0ch + 8]257 mov dword [ebx], edx258 259 ; collect flags and return.260 pushf261 pop eax262 263 mov edx, [esp + 18h + 8] ; eflags pointer264 mov dword [edx], eax265 266 pop ebx267 pop ebp268 mov eax, VINF_SUCCESS269 retn270 271 ; Read error - we will be here after our page fault handler.272 GLOBALNAME EMGCEmulateCmpXchg8b_Error273 pop ebx274 pop ebp275 mov eax, VERR_ACCESS_DENIED276 ret277 ENDPROC EMGCEmulateCmpXchg8b278 279 ;;280 ; Emulate LOCK XADD instruction, CDECL calling conv.281 ; VMMRCDECL(uint32_t) EMGCEmulateLockXAdd(RTGCPTR pu32Param1, uint32_t *pu32Param2, uint32_t u32Param3, size_t cbSize, uint32_t *pEflags);282 ;283 ; @returns eax=0 if data exchanged, other code - invalid access, #PF was generated.284 ; @param [esp + 04h] Param 1 - First parameter - pointer to first parameter285 ; @param [esp + 08h] Param 2 - Second parameter - pointer to second parameter (general register)286 ; @param [esp + 0ch] Param 3 - Size of parameters, only 1/2/4 is valid.287 ; @param [esp + 10h] Param 4 - Pointer to eflags (out)288 ; @uses eax, ecx, edx289 ;290 align 16291 BEGINPROC EMGCEmulateLockXAdd292 mov ecx, [esp + 04h + 0] ; ecx = first parameter293 mov edx, [esp + 08h + 0] ; edx = 2nd parameter294 mov eax, [esp + 0ch + 0] ; eax = size of parameters295 296 cmp al, 4297 je short .do_dword ; 4 bytes variant298 cmp al, 2299 je short .do_word ; 2 byte variant300 cmp al, 1301 je short .do_byte ; 1 bytes variant302 int3303 304 .do_dword:305 ; load 2nd parameter's value306 mov eax, dword [edx]307 lock xadd dword [ecx], eax ; do 4 bytes XADD308 mov dword [edx], eax309 jmp short .done310 311 .do_word:312 ; load 2nd parameter's value313 mov eax, dword [edx]314 lock xadd word [ecx], ax ; do 2 bytes XADD315 mov word [edx], ax316 jmp short .done317 318 .do_byte:319 ; load 2nd parameter's value320 mov eax, dword [edx]321 lock xadd byte [ecx], al ; do 1 bytes XADD322 mov byte [edx], al323 324 .done:325 ; collect flags and return.326 mov edx, [esp + 10h + 0] ; eflags pointer327 pushf328 pop dword [edx]329 330 mov eax, VINF_SUCCESS331 retn332 333 ; Read error - we will be here after our page fault handler.334 GLOBALNAME EMGCEmulateLockXAdd_Error335 mov eax, VERR_ACCESS_DENIED336 ret337 338 ENDPROC EMGCEmulateLockXAdd339 340 ;;341 ; Emulate XADD instruction, CDECL calling conv.342 ; VMMRCDECL(uint32_t) EMGCEmulateXAdd(RTGCPTR pu32Param1, uint32_t *pu32Param2, uint32_t u32Param3, size_t cbSize, uint32_t *pEflags);343 ;344 ; @returns eax=0 if data written, other code - invalid access, #PF was generated.345 ; @param [esp + 04h] Param 1 - First parameter - pointer to first parameter346 ; @param [esp + 08h] Param 2 - Second parameter - pointer to second parameter (general register)347 ; @param [esp + 0ch] Param 3 - Size of parameters, only 1/2/4 is valid.348 ; @param [esp + 10h] Param 4 - Pointer to eflags (out)349 ; @uses eax, ecx, edx350 ;351 align 16352 BEGINPROC EMGCEmulateXAdd353 mov ecx, [esp + 04h + 0] ; ecx = first parameter354 mov edx, [esp + 08h + 0] ; edx = 2nd parameter (eax)355 mov eax, [esp + 0ch + 0] ; eax = size of parameters356 357 cmp al, 4358 je short .do_dword ; 4 bytes variant359 cmp al, 2360 je short .do_word ; 2 byte variant361 cmp al, 1362 je short .do_byte ; 1 bytes variant363 int3364 365 .do_dword:366 ; load 2nd parameter's value367 mov eax, dword [edx]368 xadd dword [ecx], eax ; do 4 bytes XADD369 mov dword [edx], eax370 jmp short .done371 372 .do_word:373 ; load 2nd parameter's value374 mov eax, dword [edx]375 xadd word [ecx], ax ; do 2 bytes XADD376 mov word [edx], ax377 jmp short .done378 379 .do_byte:380 ; load 2nd parameter's value381 mov eax, dword [edx]382 xadd byte [ecx], al ; do 1 bytes XADD383 mov byte [edx], al384 385 .done:386 ; collect flags and return.387 mov edx, [esp + 10h + 0] ; eflags pointer388 pushf389 pop dword [edx]390 391 mov eax, VINF_SUCCESS392 retn393 394 ; Read error - we will be here after our page fault handler.395 GLOBALNAME EMGCEmulateXAdd_Error396 mov eax, VERR_ACCESS_DENIED397 ret398 ENDPROC EMGCEmulateXAdd -
trunk/src/VBox/VMM/VMMGC/MMRamGC.cpp
r28800 r30338 42 42 DECLASM(void) MMGCRamReadNoTrapHandler_EndProc(void); 43 43 DECLASM(void) MMGCRamWriteNoTrapHandler_EndProc(void); 44 DECLASM(void) EMGCEmulateLockCmpXchg_EndProc(void);45 DECLASM(void) EMGCEmulateLockCmpXchg_Error(void);46 DECLASM(void) EMGCEmulateCmpXchg_EndProc(void);47 DECLASM(void) EMGCEmulateCmpXchg_Error(void);48 DECLASM(void) EMGCEmulateLockCmpXchg8b_EndProc(void);49 DECLASM(void) EMGCEmulateLockCmpXchg8b_Error(void);50 DECLASM(void) EMGCEmulateCmpXchg8b_EndProc(void);51 DECLASM(void) EMGCEmulateCmpXchg8b_Error(void);52 DECLASM(void) EMGCEmulateLockXAdd_EndProc(void);53 DECLASM(void) EMGCEmulateLockXAdd_Error(void);54 DECLASM(void) EMGCEmulateXAdd_EndProc(void);55 DECLASM(void) EMGCEmulateXAdd_Error(void);56 DECLASM(void) EMEmulateLockOr_EndProc(void);57 DECLASM(void) EMEmulateLockOr_Error(void);58 DECLASM(void) EMEmulateLockBtr_EndProc(void);59 DECLASM(void) EMEmulateLockBtr_Error(void);60 44 DECLASM(void) MMGCRamRead_Error(void); 61 45 DECLASM(void) MMGCRamWrite_Error(void); … … 122 106 * @param pSrc Pointer to the data to write. 123 107 * @param cb Size of data to write, only 1/2/4 is valid. 108 * 109 * @deprecated Don't use this as it doesn't check the page state. 124 110 */ 125 111 VMMRCDECL(int) MMGCRamWrite(PVM pVM, void *pDst, void *pSrc, size_t cb) … … 175 161 176 162 /* 177 * Page fault inside EMGCEmulateLockCmpXchg()? Resume at _Error.178 */179 if ( (uintptr_t)&EMGCEmulateLockCmpXchg < (uintptr_t)pRegFrame->eip180 && (uintptr_t)pRegFrame->eip < (uintptr_t)&EMGCEmulateLockCmpXchg_EndProc)181 {182 pRegFrame->eip = (uintptr_t)&EMGCEmulateLockCmpXchg_Error;183 return VINF_SUCCESS;184 }185 186 /*187 * Page fault inside EMGCEmulateCmpXchg()? Resume at _Error.188 */189 if ( (uintptr_t)&EMGCEmulateCmpXchg < (uintptr_t)pRegFrame->eip190 && (uintptr_t)pRegFrame->eip < (uintptr_t)&EMGCEmulateCmpXchg_EndProc)191 {192 pRegFrame->eip = (uintptr_t)&EMGCEmulateCmpXchg_Error;193 return VINF_SUCCESS;194 }195 196 /*197 * Page fault inside EMGCEmulateLockCmpXchg8b()? Resume at _Error.198 */199 if ( (uintptr_t)&EMGCEmulateLockCmpXchg8b < (uintptr_t)pRegFrame->eip200 && (uintptr_t)pRegFrame->eip < (uintptr_t)&EMGCEmulateLockCmpXchg8b_EndProc)201 {202 pRegFrame->eip = (uintptr_t)&EMGCEmulateLockCmpXchg8b_Error;203 return VINF_SUCCESS;204 }205 206 /*207 * Page fault inside EMGCEmulateCmpXchg8b()? Resume at _Error.208 */209 if ( (uintptr_t)&EMGCEmulateCmpXchg8b < (uintptr_t)pRegFrame->eip210 && (uintptr_t)pRegFrame->eip < (uintptr_t)&EMGCEmulateCmpXchg8b_EndProc)211 {212 pRegFrame->eip = (uintptr_t)&EMGCEmulateCmpXchg8b_Error;213 return VINF_SUCCESS;214 }215 216 /*217 * Page fault inside EMGCEmulateLockXAdd()? Resume at _Error.218 */219 if ( (uintptr_t)&EMGCEmulateLockXAdd < (uintptr_t)pRegFrame->eip220 && (uintptr_t)pRegFrame->eip < (uintptr_t)&EMGCEmulateLockXAdd_EndProc)221 {222 pRegFrame->eip = (uintptr_t)&EMGCEmulateLockXAdd_Error;223 return VINF_SUCCESS;224 }225 226 /*227 * Page fault inside EMGCEmulateXAdd()? Resume at _Error.228 */229 if ( (uintptr_t)&EMGCEmulateXAdd < (uintptr_t)pRegFrame->eip230 && (uintptr_t)pRegFrame->eip < (uintptr_t)&EMGCEmulateXAdd_EndProc)231 {232 pRegFrame->eip = (uintptr_t)&EMGCEmulateXAdd_Error;233 return VINF_SUCCESS;234 }235 236 /*237 * Page fault inside EMEmulateLockOr()? Resume at *_Error.238 */239 if ( (uintptr_t)&EMEmulateLockOr < (uintptr_t)pRegFrame->eip240 && (uintptr_t)pRegFrame->eip < (uintptr_t)&EMEmulateLockOr_EndProc)241 {242 pRegFrame->eip = (uintptr_t)&EMEmulateLockOr_Error;243 return VINF_SUCCESS;244 }245 246 /*247 * Page fault inside EMEmulateLockBtr()? Resume at *_Error.248 */249 if ( (uintptr_t)&EMEmulateLockBtr < (uintptr_t)pRegFrame->eip250 && (uintptr_t)pRegFrame->eip < (uintptr_t)&EMEmulateLockBtr_EndProc)251 {252 pRegFrame->eip = (uintptr_t)&EMEmulateLockBtr_Error;253 return VINF_SUCCESS;254 }255 256 /*257 163 * #PF is not handled - cause guru meditation. 258 164 */
Note:
See TracChangeset
for help on using the changeset viewer.