VirtualBox

Ignore:
Timestamp:
Apr 17, 2008 2:08:15 PM (17 years ago)
Author:
vboxsync
Message:

Emulate cmpxchg8b in GC.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMGC/EMGCA.asm

    r7294 r8098  
    167167
    168168;;
     169; Emulate LOCK CMPXCHG8B instruction, CDECL calling conv.
     170; EMGCDECL(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 parameter
     174; @param    [esp + 08h]    Param 2 - Address of the eax register
     175; @param    [esp + 0ch]    Param 3 - Address of the edx register
     176; @param    [esp + 10h]    Param 4 - EBX
     177; @param    [esp + 14h]    Param 5 - ECX
     178; @param    [esp + 18h]    Param 6 - Pointer to eflags (out)
     179; @uses     eax, ecx, edx
     180;
     181align 16
     182BEGINPROC   EMGCEmulateLockCmpXchg8b
     183    push    ebp
     184    push    ebx
     185    mov     ebp, [esp + 04h + 8]        ; ebp = first parameter
     186    mov     eax, [esp + 08h + 8]        ; &EAX
     187    mov     eax, dword [eax]
     188    mov     edx, [esp + 0ch + 8]        ; &EDX
     189    mov     edx, dword [edx]
     190    mov     ebx, [esp + 10h + 8]        ; EBX
     191    mov     ecx, [esp + 14h + 8]        ; ECX
     192
     193    lock cmpxchg8b qword [ebp]          ; do CMPXCHG8B
     194    mov     dword [esp + 08h + 8], eax
     195    mov     dword [esp + 0ch + 8], edx
     196
     197    ; collect flags and return.
     198    pushf
     199    pop     eax
     200
     201    mov     edx, [esp + 18h + 8]            ; eflags pointer
     202    mov     dword [edx], eax
     203
     204    pop     ebx
     205    pop     ebp
     206    mov     eax, VINF_SUCCESS
     207    retn
     208
     209; Read error - we will be here after our page fault handler.
     210GLOBALNAME EMGCEmulateLockCmpXchg8b_Error
     211    pop     ebx
     212    pop     ebp
     213    mov     eax, VERR_ACCESS_DENIED
     214    ret
     215
     216ENDPROC     EMGCEmulateLockCmpXchg8b
     217
     218;;
     219; Emulate CMPXCHG8B instruction, CDECL calling conv.
     220; EMGCDECL(uint32_t) EMGCEmulateCmpXchg8b(RTGCPTR pu32Param1, uint32_t *pEAX, uint32_t *pEDX, uint32_t uEBX, uint32_t uECX, uint32_t *pEflags);
     221;
     222; @returns eax=0 if data written, other code - invalid access, #PF was generated.
     223; @param    [esp + 04h]    Param 1 - First parameter - pointer to first parameter
     224; @param    [esp + 08h]    Param 2 - Address of the eax register
     225; @param    [esp + 0ch]    Param 3 - Address of the edx register
     226; @param    [esp + 10h]    Param 4 - EBX
     227; @param    [esp + 14h]    Param 5 - ECX
     228; @param    [esp + 18h]    Param 6 - Pointer to eflags (out)
     229; @uses     eax, ecx, edx
     230;
     231align 16
     232BEGINPROC   EMGCEmulateCmpXchg8b
     233    push    ebp
     234    push    ebx
     235    mov     ebp, [esp + 04h + 8]        ; ebp = first parameter
     236    mov     eax, [esp + 08h + 8]        ; &EAX
     237    mov     eax, dword [eax]
     238    mov     edx, [esp + 0ch + 8]        ; &EDX
     239    mov     edx, dword [edx]
     240    mov     ebx, [esp + 10h + 8]        ; EBX
     241    mov     ecx, [esp + 14h + 8]        ; ECX
     242
     243    cmpxchg8b qword [ebp]               ; do CMPXCHG8B
     244    mov     dword [esp + 08h + 8], eax
     245    mov     dword [esp + 0ch + 8], edx
     246
     247    ; collect flags and return.
     248    pushf
     249    pop     eax
     250
     251    mov     edx, [esp + 18h + 8]            ; eflags pointer
     252    mov     dword [edx], eax
     253
     254    pop     ebx
     255    pop     ebp
     256    mov     eax, VINF_SUCCESS
     257    retn
     258
     259; Read error - we will be here after our page fault handler.
     260GLOBALNAME EMGCEmulateCmpXchg8b_Error
     261    pop     ebx
     262    pop     ebp
     263    mov     eax, VERR_ACCESS_DENIED
     264    ret
     265ENDPROC     EMGCEmulateCmpXchg8b
     266
     267;;
    169268; Emulate LOCK XADD instruction, CDECL calling conv.
    170269; EMGCDECL(uint32_t) EMGCEmulateLockXAdd(RTGCPTR pu32Param1, uint32_t *pu32Param2, uint32_t u32Param3, size_t cbSize, uint32_t *pEflags);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette