VirtualBox

Changeset 106692 in vbox for trunk/src/VBox/ValidationKit


Ignore:
Timestamp:
Oct 25, 2024 12:27:42 PM (6 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
165562
Message:

ValidationKit/bootsectors: Implement SIMD FP testcases for cvtpi2ps, and fix it in IEM; bugref:10658; jiraref:VBP-1206

IEM:

  • fix IEM cvtpi2ps [mem] trashing the target register
  • fix IEM cvtpi2ps [mem] sometimes leaving x87/MMX FTW in the wrong state

Valkit:

  • fix Bs3ExtCtxSetReg() ability to load MMX registers
  • add BS3_REGISTER_IS_MMX macro
  • fix test worker's interaction with x87/MMX FTW
  • add 'RAND_x6' FP32 value bars for use in tests of these instructions
  • add wacky set of macros for injecting integers into FP data arrays
  • implement cvtpi2ps tests
Location:
trunk/src/VBox/ValidationKit/bootsectors
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-instr-4.c32

    r106677 r106692  
    252252 * intended to be used for for unused arguments in scalar instructions.
    253253 */
    254 #define FP32_0_x7(a_Sign)                   FP32_0(a_Sign), FP32_0(a_Sign), FP32_0(a_Sign),      \
    255                                             FP32_0(a_Sign), FP32_0(a_Sign), FP32_0(a_Sign),      \
    256                                             FP32_0(a_Sign)
    257 #define FP32_RAND_x7_V0                     FP32_RAND_V0(0), FP32_RAND_V1(1), FP32_RAND_V2(0),   \
    258                                             FP32_RAND_V3(0), FP32_NORM_V1(1), FP32_RAND_V5(1),   \
    259                                             FP32_RAND_V6(0)
    260 #define FP32_RAND_x7_V1                     FP32_RAND_V7(0), FP32_RAND_V6(0), FP32_RAND_V5(1),   \
    261                                             FP32_RAND_V4(1), FP32_QNAN(0),    FP32_RAND_V2(1),   \
    262                                             FP32_NORM_V0(1)
    263 #define FP32_RAND_x7_V2                     FP32_RAND_V1(0), FP32_RAND_V7(1), FP32_RAND_V6(1),   \
    264                                             FP32_RAND_V2(1), FP32_RAND_V3(1), FP32_RAND_V4(0),   \
    265                                             FP32_INF(0)
    266 #define FP32_RAND_x7_V3                     FP32_RAND_V6(1), FP32_QNAN(0),    FP32_RAND_V2(1),   \
    267                                             FP32_1(1),       FP32_RAND_V1(0), FP32_INF(1),       \
    268                                             FP32_RAND_V5(0)
    269 #define FP32_RAND_x7_V4                     FP32_RAND_V4(1), FP32_RAND_V6(0), FP32_RAND_V0(0),   \
    270                                             FP32_RAND_V2(1), FP32_RAND_V1(0), FP32_1(1),         \
    271                                             FP32_SNAN_MAX(1)
    272 #define FP32_RAND_x7_V5                     FP32_RAND_V5(1),  FP32_RAND_V4(1), FP32_QNAN_MAX(1), \
    273                                             FP32_QNAN_MAX(1), FP32_RAND_V1(0), FP32_RAND_V2(0),  \
    274                                             FP32_RAND_V6(0)
    275 #define FP32_RAND_x7_V6                     FP32_RAND_V1(1), FP32_RAND_V4(0), FP32_RAND_V6(1),   \
    276                                             FP32_RAND_V2(0), FP32_QNAN(1),    FP32_QNAN_V(1, 0), \
    277                                             FP32_SNAN(1)
    278 #define FP32_RAND_x7_V7                     FP32_RAND_V7(0), FP32_RAND_V1(1),   FP32_RAND_V2(0), \
    279                                             FP32_RAND_V6(1), FP32_QNAN_V(0, 1), FP32_RAND_V2(1), \
    280                                             FP32_NORM_SAFE_INT_MAX(1)
     254#define FP32_0_x6(a_Sign)                   FP32_0(a_Sign), FP32_0(a_Sign), FP32_0(a_Sign),      \
     255                                            FP32_0(a_Sign), FP32_0(a_Sign), FP32_0(a_Sign)
     256#define FP32_0_x7(a_Sign)                   FP32_0_x6(a_Sign), FP32_0(a_Sign)
     257#define FP32_RAND_x6_V0                     FP32_RAND_V0(0), FP32_RAND_V1(1), FP32_RAND_V2(0),   \
     258                                            FP32_RAND_V3(0), FP32_NORM_V1(1), FP32_RAND_V5(1)
     259#define FP32_RAND_x7_V0                     FP32_RAND_x6_V0, FP32_RAND_V6(0)
     260#define FP32_RAND_x6_V1                     FP32_RAND_V7(0), FP32_RAND_V6(0), FP32_RAND_V5(1),   \
     261                                            FP32_RAND_V4(1), FP32_QNAN(0),    FP32_RAND_V2(1)
     262#define FP32_RAND_x7_V1                     FP32_RAND_x6_V1, FP32_NORM_V0(1)
     263#define FP32_RAND_x6_V2                     FP32_RAND_V1(0), FP32_RAND_V7(1), FP32_RAND_V6(1),   \
     264                                            FP32_RAND_V2(1), FP32_RAND_V3(1), FP32_RAND_V4(0)
     265#define FP32_RAND_x7_V2                     FP32_RAND_x6_V2, FP32_INF(0)
     266#define FP32_RAND_x6_V3                     FP32_RAND_V6(1), FP32_QNAN(0),    FP32_RAND_V2(1),   \
     267                                            FP32_1(1),       FP32_RAND_V1(0), FP32_INF(1)
     268#define FP32_RAND_x7_V3                     FP32_RAND_x6_V3, FP32_RAND_V5(0)
     269#define FP32_RAND_x6_V4                     FP32_RAND_V4(1), FP32_RAND_V6(0), FP32_RAND_V0(0),   \
     270                                            FP32_RAND_V2(1), FP32_RAND_V1(0), FP32_1(1)
     271#define FP32_RAND_x7_V4                     FP32_RAND_x6_V4, FP32_SNAN_MAX(1)
     272#define FP32_RAND_x6_V5                     FP32_RAND_V5(1),  FP32_RAND_V4(1), FP32_QNAN_MAX(1), \
     273                                            FP32_QNAN_MAX(1), FP32_RAND_V1(0), FP32_RAND_V2(0)
     274#define FP32_RAND_x7_V5                     FP32_RAND_x6_V5, FP32_RAND_V6(0)
     275#define FP32_RAND_x6_V6                     FP32_RAND_V1(1), FP32_RAND_V4(0), FP32_RAND_V6(1),   \
     276                                            FP32_RAND_V2(0), FP32_QNAN(1),    FP32_QNAN_V(1, 0)
     277#define FP32_RAND_x7_V6                     FP32_RAND_x6_V6, FP32_SNAN(1)
     278#define FP32_RAND_x6_V7                     FP32_RAND_V7(0), FP32_RAND_V1(1),   FP32_RAND_V2(0), \
     279                                            FP32_RAND_V6(1), FP32_QNAN_V(0, 1), FP32_RAND_V2(1)
     280#define FP32_RAND_x7_V7                     FP32_RAND_x6_V7, FP32_NORM_SAFE_INT_MAX(1)
    281281#define FP32_ROW_UNUSED                     FP32_1(0),       FP32_RAND_x7_V0
    282282
     
    28932893        if (fNonFpOK)
    28942894        {
     2895            /* MMX instructions set FTW to 0xff 'all valid' (even if they MXCSR-fault) */
     2896            if (BS3_REGISTER_IS_MMX(pTest->iRegSrc1) || BS3_REGISTER_IS_MMX(pTest->iRegSrc2) || BS3_REGISTER_IS_MMX(pTest->iRegDst))
     2897                Bs3ExtCtxSetAbridgedFtw(pExtCtx, 0xff);
     2898
    28952899            if (fFuzzyPE)
    28962900            {
     
    1630816312
    1630916313
     16314#define FP32_INT_SIGN_PART(a_uInt32) ((((uint32_t)a_uInt32) >> 31) & 1)
     16315#define FP32_INT_EXPN_PART(a_uInt32) ((((uint32_t)a_uInt32) >> 23) & 0xFF)
     16316#define FP32_INT_FRAC_PART(a_uInt32) (((uint32_t)a_uInt32) & 0x7FFFFF)
     16317#define FP32_INT(a_uInt32) RTFLOAT32U_INIT(FP32_INT_SIGN_PART(a_uInt32), FP32_INT_FRAC_PART(a_uInt32), FP32_INT_EXPN_PART(a_uInt32))
     16318
     16319#define FP64_INT_SIGN_PART(a_uInt64) ((((uint64_t)a_uInt64) >> 63) & 1)
     16320#define FP64_INT_EXPN_PART(a_uInt64) ((((uint64_t)a_uInt64) >> 52) & 0x7FF)
     16321#define FP64_INT_FRAC_PART(a_uInt64) (((uint64_t)a_uInt64) & 0xFFFFFFFFFFFFF)
     16322#define FP64_INT(a_uInt64) RTFLOAT64U_INIT(FP64_INT_SIGN_PART(a_uInt64), FP64_INT_FRAC_PART(a_uInt64), FP64_INT_EXPN_PART(a_uInt64))
     16323
     16324/*
     16325 * CVTPI2PS.
     16326 */
     16327BS3_DECL_FAR(uint8_t) bs3CpuInstr4_cvtpi2ps(uint8_t bMode)
     16328{
     16329    static BS3CPUINSTR4_TEST1_VALUES_SS_T const s_aValues[] =
     16330    {
     16331    /*
     16332     * Zero.
     16333     */
     16334    /* 0*/{ { /*init dst */ { FP32_RAND_V1(0), FP32_RAND_V3(1), FP32_RAND_x6_V0 } },
     16335            { /*  mm src */ { FP32_INT(0),     FP32_INT(0),     FP32_RAND_x6_V2 } },
     16336            { /* =>      */ { FP32_0(0),       FP32_0(0),       FP32_RAND_x6_V0 } },
     16337              /*mxcsr:in */ 0,
     16338              /*128:out  */ 0,
     16339              /*256:out  */ -1 },
     16340
     16341    /*
     16342     * Normals & Precision.
     16343     */
     16344    /* 1*/{ { /*init dst */ { FP32_NORM_V0(0),         FP32_NORM_V4(0),         FP32_RAND_x6_V3 } },
     16345            { /*  mm src */ { FP32_INT(123456789),     FP32_INT(-123456789),    FP32_RAND_x6_V4 } },
     16346            { /* =>      */ { FP32_V(0,0x6b79a3,0x99), FP32_V(1,0x6b79a3,0x99), FP32_RAND_x6_V3 } },
     16347                              /*123456792.0*/          /*-123456792.0*/
     16348              /*mxcsr:in */ 0,
     16349              /*128:out  */ X86_MXCSR_PE,
     16350              /*256:out  */ -1 },
     16351          { { /*init dst */ { FP32_NORM_V1(0),         FP32_NORM_V7(0),         FP32_RAND_x6_V5 } },
     16352            { /*  mm src */ { FP32_INT(-47),           FP32_INT(42),            FP32_RAND_x6_V1 } },
     16353            { /* =>      */ { FP32_V(1,0x3c0000,0x84), FP32_V(0,0x280000,0x84), FP32_RAND_x6_V5 } },
     16354                              /*-47.0*/                /*42.0*/
     16355              /*mxcsr:in */ 0,
     16356              /*128:out  */ 0,
     16357              /*256:out  */ -1 },
     16358          { { /*init dst */ { FP32_NORM_V0(0),     FP32_NORM_V4(0),      FP32_RAND_x6_V0 } },
     16359            { /*  mm src */ { FP32_INT(INT32_MAX), FP32_INT(-INT32_MAX), FP32_RAND_x6_V5 } },
     16360            { /* =>      */ { FP32_V(0,0,0x9e),    FP32_V(1,0,0x9e),     FP32_RAND_x6_V0 } },
     16361                              /*2147483648.0*/     /*-2147483648.0*/
     16362              /*mxcsr:in */ 0,
     16363              /*128:out  */ X86_MXCSR_PE,
     16364              /*256:out  */ -1 },
     16365          { { /*init dst */ { FP32_NORM_V0(0),         FP32_NORM_V4(0),         FP32_RAND_x6_V7 } },
     16366            { /*  mm src */ { FP32_INT(123456789),     FP32_INT(-123456789),    FP32_RAND_x6_V7 } },
     16367            { /* =>      */ { FP32_V(0,0x6b79a3,0x99), FP32_V(1,0x6b79a3,0x99), FP32_RAND_x6_V7 } },
     16368                              /*123456792.0*/          /*-123456792.0*/
     16369              /*mxcsr:in */ X86_MXCSR_FZ | X86_MXCSR_DAZ,
     16370              /*128:out  */ X86_MXCSR_FZ | X86_MXCSR_DAZ | X86_MXCSR_PE,
     16371              /*256:out  */ -1 },
     16372          { { /*init dst */ { FP32_NORM_V0(0),         FP32_NORM_V4(0),         FP32_RAND_x6_V6 } },
     16373            { /*  mm src */ { FP32_INT(123456789),     FP32_INT(-123456789),    FP32_RAND_x6_V4 } },
     16374            { /* =>      */ { FP32_V(0,0x6b79a2,0x99), FP32_V(1,0x6b79a3,0x99), FP32_RAND_x6_V6 } },
     16375                              /*123456784.0*/          /*-123456792.0*/
     16376              /*mxcsr:in */ X86_MXCSR_RC_DOWN,
     16377              /*128:out  */ X86_MXCSR_RC_DOWN | X86_MXCSR_PE,
     16378              /*256:out  */ -1 },
     16379          { { /*init dst */ { FP32_NORM_V0(0),         FP32_NORM_V4(0),         FP32_RAND_x6_V2 } },
     16380            { /*  mm src */ { FP32_INT(123456789),     FP32_INT(-123456789),    FP32_RAND_x6_V1 } },
     16381            { /* =>      */ { FP32_V(0,0x6b79a3,0x99), FP32_V(1,0x6b79a2,0x99), FP32_RAND_x6_V2 } },
     16382                              /*123456792.0*/          /*-123456784.0*/
     16383              /*mxcsr:in */ X86_MXCSR_RC_UP,
     16384              /*128:out  */ X86_MXCSR_RC_UP | X86_MXCSR_PE,
     16385              /*256:out  */ -1 },
     16386          { { /*init dst */ { FP32_NORM_V0(0),         FP32_NORM_V4(0),         FP32_RAND_x6_V0 } },
     16387            { /*  mm src */ { FP32_INT(123456789),     FP32_INT(-123456789),    FP32_RAND_x6_V5 } },
     16388            { /* =>      */ { FP32_V(0,0x6b79a2,0x99), FP32_V(1,0x6b79a2,0x99), FP32_RAND_x6_V0 } },
     16389                              /*123456784.0*/          /*-123456784.0*/
     16390              /*mxcsr:in */ X86_MXCSR_RC_ZERO,
     16391              /*128:out  */ X86_MXCSR_RC_ZERO | X86_MXCSR_PE,
     16392              /*256:out  */ -1 },
     16393    };
     16394    /*
     16395     * Infinity, Overflow, Underflow, Invalids not possible.
     16396     */
     16397
     16398    static BS3CPUINSTR4_TEST1_T const s_aTests16[] =
     16399    {
     16400        { bs3CpuInstr4_cvtpi2ps_XMM1_MM1_icebp_c16,   255, RM_REG, T_SSE, XMM1, MM1,   XMM1, PASS_s_aValues },
     16401        { bs3CpuInstr4_cvtpi2ps_XMM1_FSxBX_icebp_c16, 255, RM_MEM, T_SSE, XMM1, FSxBX, XMM1, PASS_s_aValues },
     16402    };
     16403    static BS3CPUINSTR4_TEST1_T const s_aTests32[] =
     16404    {
     16405        { bs3CpuInstr4_cvtpi2ps_XMM1_MM1_icebp_c32,   255, RM_REG, T_SSE, XMM1, MM1,   XMM1, PASS_s_aValues },
     16406        { bs3CpuInstr4_cvtpi2ps_XMM1_FSxBX_icebp_c32, 255, RM_MEM, T_SSE, XMM1, FSxBX, XMM1, PASS_s_aValues },
     16407    };
     16408    static BS3CPUINSTR4_TEST1_T const s_aTests64[] =
     16409    {
     16410        { bs3CpuInstr4_cvtpi2ps_XMM1_MM1_icebp_c64,   255, RM_REG, T_SSE, XMM1, MM1,   XMM1, PASS_s_aValues },
     16411        { bs3CpuInstr4_cvtpi2ps_XMM1_FSxBX_icebp_c64, 255, RM_MEM, T_SSE, XMM1, FSxBX, XMM1, PASS_s_aValues },
     16412        { bs3CpuInstr4_cvtpi2ps_XMM8_MM1_icebp_c64,   255, RM_REG, T_SSE, XMM8, MM1,   XMM8, PASS_s_aValues },
     16413        { bs3CpuInstr4_cvtpi2ps_XMM8_FSxBX_icebp_c64, 255, RM_MEM, T_SSE, XMM8, FSxBX, XMM8, PASS_s_aValues },
     16414    };
     16415
     16416    static BS3CPUINSTR4_TEST1_MODE_T const s_aTests[3] = BS3CPUINSTR4_TEST1_MODES_INIT(s_aTests16, s_aTests32, s_aTests64);
     16417    unsigned const                         iTest       = BS3CPUINSTR4_TEST_MODES_INDEX(bMode);
     16418    return bs3CpuInstr4_WorkerTestType1(bMode, s_aTests[iTest].paTests, s_aTests[iTest].cTests,
     16419                                        g_aXcptConfig5, RT_ELEMENTS(g_aXcptConfig5));
     16420}
     16421
     16422
    1631016423/**
    1631116424 * The 32-bit protected mode main function.
     
    1636516478        { "[v]rsqrtps",     bs3CpuInstr4_v_rsqrtps,  0 },
    1636616479        { "[v]rsqrtss",     bs3CpuInstr4_v_rsqrtss,  0 },
     16480        { "cvtpi2ps",       bs3CpuInstr4_cvtpi2ps,   0 },
    1636716481#endif
    1636816482    };
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-instr-x-regs.c32

    r106620 r106692  
    334334#define MM6     (BS3_REGISTER_FAMILY_MMX        | 6)
    335335#define MM7     (BS3_REGISTER_FAMILY_MMX        | 7)
     336#define          BS3_REGISTER_IS_MMX(uReg)      ((uReg) >= MM0 && (uReg) <= MM7)
    336337
    337338#define          BS3_REGISTER_FAMILY_OPMASK     (0xE8 | BS3_REGISTER_FAMILY_AVX512_TODO)
     
    490491                return true;
    491492            case BS3_REGISTER_FAMILY_OTHER:
    492                 if (uReg >= MM0 && uReg <= MM7)
    493                     return Bs3ExtCtxSetMm(pExtCtx, uRegNum, (uint64_t)pValue, BS3EXTCTXTOPMM_SET);
     493                if (BS3_REGISTER_IS_MMX(uReg))
     494                    return Bs3ExtCtxSetMm(pExtCtx, uRegNum, *((uint64_t *)pValue), BS3EXTCTXTOPMM_AS_IS);
     495                break;
    494496            case BS3_REGISTER_FAMILY_8BIT_L:
    495497            case BS3_REGISTER_FAMILY_ZMM:
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