VirtualBox

Changeset 97108 in vbox


Ignore:
Timestamp:
Oct 12, 2022 12:19:22 PM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
154068
Message:

ValKit: Test if 32-bit CVTxx2SI sign extends result (it does not).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/bootsectors/bootsector2-cpu-instr-1-template.mac

    r96407 r97108  
    158158
    159159;;
     160; Floating-point to integer conversion (SSE/SSE2).
     161; Neither Intel nor AMD explicitly document what happens for the 32-bit forms
     162; of CVTxx2SI in 64-bit mode with regard to the high dword of a 64-bit
     163; destination register.
     164;
     165; @uses XMM0, and BS2_SEL_SPARE0 is trashed.
     166;
     167BEGINPROC TMPL_NM(TestCvtSize)
     168        push    xBP
     169        mov     xBP, xSP
     170        push    sAX
     171        push    xBX
     172        push    xCX
     173        push    xDX
     174        push    xDI
     175        push    xSI
     176        sub     xSP, 80h                ; iret stack frame space.
     177        mov     xSI, xSP                ; Save the stack register.
     178
     179        mov     xAX, .s_szSubTestName
     180        call    TMPL_NM_CMN(TestSub)
     181
     182        ;
     183        ; SSE2 supported?
     184        ;
     185        mov     eax, 1
     186        xor     ecx, ecx
     187        cpuid
     188        test    edx, X86_CPUID_FEATURE_EDX_SSE2
     189        jz      .skip
     190
     191%ifdef TMPL_64BIT
     192
     193        ;
     194        ; Have to enable OSFXSR for SSE instructions to work.
     195        ;
     196        mov     rcx,cr4
     197        mov     rsi,rcx
     198        or      rcx,200h
     199        mov     cr4,rcx
     200
     201        ;
     202        ; Load 32-bit float -2.75 into XMM0
     203        ;
     204        mov     eax, 0C0300000h
     205        movd    xmm0, eax
     206        mov     rbx, -1            ; make sure high dword is not zero
     207        cvtss2si ebx, xmm0         ; result is -3
     208        mov     eax, -3            ; high dword of rax zeroed
     209        TEST_ASSERT_SIMPLE rbx, rax, jz, "CVTSS2SI EBX"
     210
     211        mov     eax, 0C0300000h
     212        movd    xmm0, eax
     213        mov     rbx, -1
     214        cvttss2si ebx, xmm0        ; result is -2
     215        mov     eax, -2
     216        TEST_ASSERT_SIMPLE rbx, rax, jz, "CVTTSS2SI EBX"
     217
     218        ;
     219        ; Load 64-bit double -2.75 into XMM0
     220        ;
     221        mov     rax, 0C006000000000000h
     222        movd    xmm0, rax
     223        mov     rbx, -1
     224        cvtsd2si ebx, xmm0
     225        mov     eax, -3
     226        TEST_ASSERT_SIMPLE rbx, rax, jz, "CVTSD2SI EBX"
     227
     228        mov     rax, 0C006000000000000h
     229        mov     rbx, -1
     230        movd    xmm0, rax
     231        cvttsd2si ebx, xmm0
     232        mov     eax,-2
     233        TEST_ASSERT_SIMPLE rbx, rax, jz, "CVTTSD2SI EBX"
     234
     235        ;
     236        ; Restore prior CR4 value
     237        ;
     238        mov     cr4,rsi
     239%endif
     240
     241        ;
     242        ; Done.
     243        ;
     244        call    TMPL_NM_CMN(TestSubDone)
     245.done:
     246        mov     xSP, xSI
     247        add     xSP, 80h
     248        pop     xSI
     249        pop     xDI
     250        pop     xDX
     251        pop     xCX
     252        pop     xBX
     253        pop     sAX
     254        leave
     255        ret
     256
     257.skip:
     258        mov     xAX, .s_szSse2Missing
     259        call    TMPL_NM_CMN(TestSubDone)
     260        jmp     .done
     261
     262.s_szSubTestName:
     263        db      TMPL_MODE_STR, ', cvtss2si et al.', 0
     264.s_szSse2Missing:
     265        db      'SSE2 is missing', 0
     266ENDPROC   TMPL_NM(TestCvtSize)
     267
     268
     269;;
    160270; Proving intel manual wrong about using REX.X for BSWAP R8-R15 on 64-bit.
    161271; Checking the 'undefined' 16-bit bswap behavior.
     
    305415        call    TMPL_NM(TestMemFences)
    306416        call    TMPL_NM(TestBSwap)
     417%ifdef TMPL_64BIT
     418        ; Specifically tests 64-bit behavior.
     419        call    TMPL_NM(TestCvtSize)
     420%endif
    307421
    308422        ;
Note: See TracChangeset for help on using the changeset viewer.

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