VirtualBox

Ignore:
Timestamp:
Mar 18, 2020 4:59:45 PM (5 years ago)
Author:
vboxsync
Message:

ValKit/bs3-fpustate-1: Check the value we read and also test MOVUPS. skylake fmul FOP value adjustments.

Location:
trunk/src/VBox/ValidationKit/bootsectors
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-fpustate-1-template.c

    r82968 r83318  
    102102
    103103BS3_DECL_NEAR(void) TMPL_NM(bs3FpuState1_FNStEnv)(void BS3_FAR *pvMmioReg);
    104 BS3_DECL_NEAR(void) TMPL_NM(bs3FpuState1_MovDQU_Read)(void BS3_FAR *pvMmioReg);
     104BS3_DECL_NEAR(void) TMPL_NM(bs3FpuState1_MovDQU_Read)(void BS3_FAR *pvMmioReg, void BS3_FAR *pvResult);
    105105BS3_DECL_NEAR(void) TMPL_NM(bs3FpuState1_MovDQU_Write)(void BS3_FAR *pvMmioReg);
    106 BS3_DECL_NEAR(void) TMPL_NM(bs3FpuState1_FMul)(void BS3_FAR *pvMmioReg);
     106BS3_DECL_NEAR(void) TMPL_NM(bs3FpuState1_MovUPS_Read)(void BS3_FAR *pvMmioReg, void BS3_FAR *pvResult);
     107BS3_DECL_NEAR(void) TMPL_NM(bs3FpuState1_MovUPS_Write)(void BS3_FAR *pvMmioReg);
     108BS3_DECL_NEAR(void) TMPL_NM(bs3FpuState1_FMul)(void BS3_FAR *pvMmioReg, void BS3_FAR *pvNoResult);
    107109
    108110
     
    129131    bool                fMmioReadback;
    130132    bool                fReadBackError = false;
     133    bool                fReadError = false;
    131134    BS3PTRUNION         MmioReg;
    132135
     
    255258
    256259# undef  CHECK_READBACK_READ_RUN
    257 # define CHECK_READBACK_READ_RUN(a_Instr, a_Worker, a_Type) \
     260#define CHECK_READBACK_READ_RUN(a_Instr, a_Worker, a_Type) \
    258261            do { \
    259262                off = (unsigned)(iLoop & (VMMDEV_TESTING_READBACK_SIZE / 2 - 1)); \
    260263                if (off + sizeof(a_Type) > VMMDEV_TESTING_READBACK_SIZE) \
    261264                    off = VMMDEV_TESTING_READBACK_SIZE - sizeof(a_Type); \
    262                 a_Worker((a_Type *)&MmioReg.pb[off]); \
     265                a_Worker((a_Type *)&MmioReg.pb[off], (a_Type *)&abReadback[0]); \
    263266                TMPL_NM(bs3FpuState1_Save)(pChecking); \
    264267            } while (0)
    265268# undef  CHECK_READBACK_READ
    266269# define CHECK_READBACK_READ(a_Instr, a_Worker, a_Type) \
    267             CHECK_READBACK_READ_RUN(a_Instr, a_Worker, a_Type); \
    268             CHECK_STATE(a_Instr)
    269 
     270            do { \
     271                Bs3MemSet(&abReadback[0], 0xcc, sizeof(abReadback)); \
     272                CHECK_READBACK_READ_RUN(a_Instr, a_Worker, a_Type); \
     273                CHECK_STATE(a_Instr); \
     274                if (!fReadError || iLoop == 0) \
     275                { \
     276                    Bs3MemZero(&abCompare[0], sizeof(abCompare)); \
     277                    Bs3MemCpy(&abCompare[0], &MmioReg.pb[off], sizeof(a_Type)); \
     278                    if (Bs3MemCmp(abReadback, abCompare, sizeof(a_Type)) != 0) \
     279                    { \
     280                        Bs3TestFailedF("Read result check for " #a_Instr " in loop #%RU32:\n%.*Rhxs expected:\n%.*Rhxs\n", \
     281                                       iLoop, sizeof(a_Type), abReadback, sizeof(a_Type), abCompare); \
     282                        fReadError = true; \
     283                    } \
     284                } \
     285            } while (0)
    270286
    271287        /* The tests. */
     
    274290        CHECK_READBACK_WRITE(  MOVDQU,   TMPL_NM(bs3FpuState1_MovDQU_Write), X86XMMREG);
    275291        CHECK_READBACK_READ(   MOVDQU,   TMPL_NM(bs3FpuState1_MovDQU_Read),  X86XMMREG);
     292        CHECK_READBACK_WRITE(  MOVUPS,   TMPL_NM(bs3FpuState1_MovUPS_Write), X86XMMREG);
     293        CHECK_READBACK_READ(   MOVUPS,   TMPL_NM(bs3FpuState1_MovUPS_Read),  X86XMMREG);
    276294
    277295        /* Using the FPU is a little complicated, but we really need to check these things. */
    278296        CHECK_READBACK_READ_RUN(FMUL,    TMPL_NM(bs3FpuState1_FMul),         uint64_t);
    279         pExpected->FOP    = 0x7dc;
     297        if (1)
     298# if BS3_MODE_IS_16BIT_CODE(TMPL_MODE)
     299            pExpected->FOP    =  0x40f; // skylake 6700k
     300# else
     301            pExpected->FOP    =  0x40b; // skylake 6700k
     302# endif
     303        else
     304            pExpected->FOP    = 0x7dc; // dunno where we got this.
    280305# if ARCH_BITS == 64
    281306        pExpected->FPUDP  = (uint32_t) (uintptr_t)&MmioReg.pb[off];
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-fpustate-1-template.mac

    r82968 r83318  
    8484        movdqu  xmm1, [TMPL_DATA16_WRT(g_r32_Two)]
    8585        movdqu  xmm2, [TMPL_DATA16_WRT(g_r32_ThirtyTwo)]
    86         movdqu  xmm3, [TMPL_DATA16_WRT(g_r32_ThirtyTwo)]
    87         movdqu  xmm4, [TMPL_DATA16_WRT(g_r32_SNaN)]
     86        movdqu  xmm3, [TMPL_DATA16_WRT(g_r32_SNaN)]
     87        movdqu  xmm4, [TMPL_DATA16_WRT(g_r80_ThirtyTwo)]
    8888        movdqu  xmm5, [TMPL_DATA16_WRT(g_r32_NegQNaN)]
    8989        movdqu  xmm6, [TMPL_DATA16_WRT(g_r64_Zero)]
     
    211211
    212212        ; Do read.
    213         movdqu  [xBX], xmm3
     213        movdqu  [xBX], xmm0
    214214
    215215TONLY16 pop     ds
     
    227227;
    228228BS3_PROC_BEGIN_MODE bs3FpuState1_MovDQU_Read, BS3_PBC_NEAR
    229         BS3_CALL_CONV_PROLOG 1
     229        BS3_CALL_CONV_PROLOG 2
    230230        push    xBP
    231231        mov     xBP, xSP
     
    247247        movdqu  xmm2, [xBX]
    248248
     249        ; Save the result.
     250        mov     xBX, [xBP + xCB + cbCurRetAddr + sCB]
     251TONLY16 mov     ds,  [xBP + xCB + cbCurRetAddr + sCB + 2]
     252        movups  [xBX], xmm2
     253
    249254%if TMPL_BITS == 16
    250255        movdqu  xmm2, [xBP - xCB - xCB - 2 - 18h]
     
    257262        mov     xSP, xBP
    258263        pop     xBP
     264        BS3_CALL_CONV_EPILOG 2
     265        BS3_HYBRID_RET
     266BS3_PROC_END_MODE   bs3FpuState1_MovDQU_Read
     267
     268
     269;;
     270; Performs a MOVUPS write on the specified memory.
     271;
     272; BS3_DECL_NEAR(void) TMPL_NM(bs3FpuState1_MovUPS_Write)(void *pvMmioReg);
     273;
     274BS3_PROC_BEGIN_MODE bs3FpuState1_MovUPS_Write, BS3_PBC_NEAR
     275        BS3_CALL_CONV_PROLOG 1
     276        push    xBP
     277        mov     xBP, xSP
     278        push    xBX
     279TONLY16 push    ds
     280
     281        ; Load the register pointer.
     282        mov     xBX, [xBP + xCB + cbCurRetAddr]
     283TONLY16 mov     ds,  [xBP + xCB + cbCurRetAddr + 2]
     284
     285        ; Do read.
     286        movups  [xBX], xmm3
     287
     288TONLY16 pop     ds
     289        pop     xBX
     290        leave
    259291        BS3_CALL_CONV_EPILOG 1
    260292        BS3_HYBRID_RET
    261 BS3_PROC_END_MODE   bs3FpuState1_MovDQU_Read
     293BS3_PROC_END_MODE   bs3FpuState1_MovUPS_Write
     294
     295
     296;;
     297; Performs a MOVUPS write to the specified memory.
     298;
     299; BS3_DECL_NEAR(void) TMPL_NM(bs3FpuState1_MovUPS_Read)(void *pvMmioReg, void *pvResult);
     300;
     301BS3_PROC_BEGIN_MODE bs3FpuState1_MovUPS_Read, BS3_PBC_NEAR
     302        BS3_CALL_CONV_PROLOG 2
     303        push    xBP
     304        mov     xBP, xSP
     305        push    xBX
     306TONLY16 push    ds
     307        sub     xSP, 20h
     308%if TMPL_BITS == 16
     309        movups  [xBP - xCB - xCB - 2 - 18h], xmm1
     310%else
     311        movups  [xSP], xmm1
     312%endif
     313
     314        ; Load the register pointer.
     315        mov     xBX, [xBP + xCB + cbCurRetAddr]
     316TONLY16 mov     ds,  [xBP + xCB + cbCurRetAddr + 2]
     317
     318
     319        ; Do read.
     320        movups  xmm1, [xBX]
     321
     322        ; Save the result.
     323        mov     xBX, [xBP + xCB + cbCurRetAddr + sCB]
     324TONLY16 mov     ds,  [xBP + xCB + cbCurRetAddr + sCB + 2]
     325        movups  [xBX], xmm1
     326
     327%if TMPL_BITS == 16
     328        movups  xmm1, [xBP - xCB - xCB - 2 - 18h]
     329%else
     330        movups  xmm1, [xSP]
     331%endif
     332        add     xSP, 20h
     333TONLY16 pop     ds
     334        pop     xBX
     335        mov     xSP, xBP
     336        pop     xBP
     337        BS3_CALL_CONV_EPILOG 2
     338        BS3_HYBRID_RET
     339BS3_PROC_END_MODE   bs3FpuState1_MovUPS_Read
    262340
    263341
     
    293371; Performs a FMUL on the specified memory, after writing a 64-bit value to it first.
    294372;
    295 ; BS3_DECL_NEAR(void) TMPL_NM(bs3FpuState1_FMul)(void *pvMmioReg);
     373; BS3_DECL_NEAR(void) TMPL_NM(bs3FpuState1_FMul)(void *pvMmioReg, void *pvResultIgnored);
    296374;
    297375BS3_PROC_BEGIN_MODE bs3FpuState1_FMul, BS3_PBC_NEAR
    298         BS3_CALL_CONV_PROLOG 1
     376        BS3_CALL_CONV_PROLOG 2
    299377        push    xBP
    300378        mov     xBP, xSP
     
    319397        mov     xSP, xBP
    320398        pop     xBP
    321         BS3_CALL_CONV_EPILOG 1
     399        BS3_CALL_CONV_EPILOG 2
    322400        BS3_HYBRID_RET
    323401.do_it:
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