VirtualBox

Ignore:
Timestamp:
Apr 3, 2016 3:26:34 PM (9 years ago)
Author:
vboxsync
Message:

bs3-cpu-basic-2: Added more checks for CS.ACCESSED and SS.ACCESSED.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-template.c

    r60295 r60296  
    489489    BS3_DATA_NM(Bs3GdteTestPage00) = BS3_DATA_NM(Bs3Gdt)[uSysR0Cs >> X86_SEL_SHIFT];
    490490    BS3_DATA_NM(Bs3GdteTestPage00).Gen.u1Present = 0;
     491    BS3_DATA_NM(Bs3GdteTestPage00).Gen.u4Type &= ~X86_SEL_TYPE_ACCESSED;
    491492    paIdt[0x80 << cIdteShift].Gate.u16Sel = BS3_SEL_TEST_PAGE_00;
    492493
     
    494495    Bs3TrapSetJmpAndRestore(&Ctx80, &TrapCtx);
    495496    bs3CpuBasic2_CompareNpCtx(&TrapCtx, &Ctx80, BS3_SEL_TEST_PAGE_00);
     497    if (BS3_DATA_NM(Bs3GdteTestPage00).Gen.u4Type & X86_SEL_TYPE_ACCESSED)
     498        bs3CpuBasic2_FailedF("selector was accessed");
    496499    g_uLine++;
    497500
     
    503506        Bs3TrapSetJmpAndRestore(&CtxTmp, &TrapCtx);
    504507        bs3CpuBasic2_CompareGpCtx(&TrapCtx, &CtxTmp, (0x80 << X86_TRAP_ERR_SEL_SHIFT) | X86_TRAP_ERR_IDT);
     508        if (BS3_DATA_NM(Bs3GdteTestPage00).Gen.u4Type & X86_SEL_TYPE_ACCESSED)
     509            bs3CpuBasic2_FailedF("selector was accessed");
    505510        g_uLine++;
    506511    }
    507512
    508513    /* CS.DPL mismatch takes precedence over CS.PRESENT = 0. */
     514    BS3_DATA_NM(Bs3GdteTestPage00).Gen.u4Type &= ~X86_SEL_TYPE_ACCESSED;
    509515    Bs3TrapSetJmpAndRestore(&Ctx80, &TrapCtx);
    510516    bs3CpuBasic2_CompareNpCtx(&TrapCtx, &Ctx80, BS3_SEL_TEST_PAGE_00);
     517    if (BS3_DATA_NM(Bs3GdteTestPage00).Gen.u4Type & X86_SEL_TYPE_ACCESSED)
     518        bs3CpuBasic2_FailedF("CS selector was accessed");
    511519    g_uLine++;
    512520    for (iDpl = 1; iDpl < 4; iDpl++)
     
    515523        Bs3TrapSetJmpAndRestore(&Ctx80, &TrapCtx);
    516524        bs3CpuBasic2_CompareGpCtx(&TrapCtx, &Ctx80, BS3_SEL_TEST_PAGE_00);
     525        if (BS3_DATA_NM(Bs3GdteTestPage00).Gen.u4Type & X86_SEL_TYPE_ACCESSED)
     526            bs3CpuBasic2_FailedF("CS selector was accessed");
    517527        g_uLine++;
    518528    }
     
    540550    }
    541551
     552    /* Fix CS again. */
     553    BS3_DATA_NM(Bs3GdteTestPage00) = BS3_DATA_NM(Bs3Gdt)[uSysR0Cs >> X86_SEL_SHIFT];
     554
    542555    /* Test SS. */
    543556    if (!BS3_MODE_IS_64BIT_SYS(g_bTestMode))
     
    547560        X86DESC const     SavedGate83 = paIdt[0x83 << cIdteShift];
    548561
    549         /* Fix CS again. */
    550         BS3_DATA_NM(Bs3GdteTestPage00) = BS3_DATA_NM(Bs3Gdt)[uSysR0Cs >> X86_SEL_SHIFT];
    551 
    552562        /* Make the handler execute in ring-2. */
    553563        BS3_DATA_NM(Bs3GdteTestPage02) = BS3_DATA_NM(Bs3Gdt)[(uSysR0Cs + (2 << BS3_SEL_RING_SHIFT)) >> X86_SEL_SHIFT];
     564        BS3_DATA_NM(Bs3GdteTestPage02).Gen.u4Type &= ~X86_SEL_TYPE_ACCESSED;
    554565        paIdt[0x83 << cIdteShift].Gate.u16Sel = BS3_SEL_TEST_PAGE_02 | 2;
    555566
     
    558569        Bs3TrapSetJmpAndRestore(&CtxTmp, &TrapCtx);
    559570        bs3CpuBasic2_CompareIntCtx1(&TrapCtx, &CtxTmp, 0x83);
     571        if (!(BS3_DATA_NM(Bs3GdteTestPage02).Gen.u4Type & X86_SEL_TYPE_ACCESSED))
     572            bs3CpuBasic2_FailedF("CS selector was not access");
    560573        g_uLine++;
    561574
     
    601614                {
    602615                    *puTssSs2 = BS3_SEL_TEST_PAGE_03 | iRpl;
     616                    BS3_DATA_NM(Bs3GdteTestPage02).Gen.u4Type &= ~X86_SEL_TYPE_ACCESSED;
     617                    BS3_DATA_NM(Bs3GdteTestPage03).Gen.u4Type &= ~X86_SEL_TYPE_ACCESSED;
    603618                    Bs3TrapSetJmpAndRestore(&CtxTmp, &TrapCtx);
    604619                    if (iRpl != 2 || iRpl != iDpl || k >= 4)
     
    612627                            bs3CpuBasic2_FailedF("uHandlerSs=%#x expected %#x\n", TrapCtx.uHandlerSs, BS3_SEL_TEST_PAGE_03 | 2);
    613628                    }
     629                    if (!(BS3_DATA_NM(Bs3GdteTestPage02).Gen.u4Type & X86_SEL_TYPE_ACCESSED))
     630                        bs3CpuBasic2_FailedF("CS selector was not access");
     631                    if (   TrapCtx.bXcpt == 0x83
     632                        || (TrapCtx.bXcpt == X86_XCPT_SS && k == 2) )
     633                    {
     634                        if (!(BS3_DATA_NM(Bs3GdteTestPage03).Gen.u4Type & X86_SEL_TYPE_ACCESSED))
     635                            bs3CpuBasic2_FailedF("SS selector was not accessed");
     636                    }
     637                    else if (BS3_DATA_NM(Bs3GdteTestPage03).Gen.u4Type & X86_SEL_TYPE_ACCESSED)
     638                        bs3CpuBasic2_FailedF("SS selector was accessed");
    614639                    g_uLine++;
    615640
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