VirtualBox

Changeset 60215 in vbox for trunk


Ignore:
Timestamp:
Mar 27, 2016 11:39:19 PM (9 years ago)
Author:
vboxsync
Message:

bs3-cpu-basic-2: cleanups

File:
1 edited

Legend:

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

    r60214 r60215  
    626626BS3_DECL(uint8_t) TMPL_NM(bs3CpuBasic2_TssGateEsp)(uint8_t bMode)
    627627{
    628     uint8_t         bRet = 0;
    629 #if 0
    630     BS3TRAPFRAME    TrapCtx;
    631     BS3REGCTX       Ctx, Ctx2;
    632     uint8_t        *pbTmp;
    633     unsigned        uLine;
    634     const char     *pszMode = BS3_DATA_NM(TMPL_NM(g_szBs3ModeName));
    635     bool const      f16BitSys = BS3_MODE_IS_16BIT_SYS(TMPL_MODE);
    636 
    637     pbTmp = NULL; NOREF(pbTmp); uLine = 0; NOREF(uLine); NOREF(pszMode); NOREF(f16BitSys);
    638 
    639     /* make sure they're allocated  */
    640     Bs3MemZero(&Ctx, sizeof(Ctx));
    641     Bs3MemZero(&Ctx2, sizeof(Ctx2));
    642     Bs3MemZero(&TrapCtx, sizeof(TrapCtx));
    643 #endif
     628    uint8_t bRet = 0;
    644629
    645630#if TMPL_MODE == BS3_MODE_PE16 \
     
    650635 || TMPL_MODE == BS3_MODE_PAE16_32 \
    651636 || TMPL_MODE == BS3_MODE_PE32
    652 
    653 #if 1
    654637    bs3CpuBasic2_TssGateEspCommon(bMode,
    655638                                  BS3_DATA_NM(TMPL_NM(g_szBs3ModeName)),
     
    657640                                  (PX86DESC)MyBs3Idt,
    658641                                  BS3_MODE_IS_64BIT_SYS(TMPL_MODE) ? 1 : 0);
    659 #else
    660 
    661     Bs3RegCtxSave(&Ctx);
    662     Ctx.rsp.u -= 0x80;
    663     Ctx.rip.u  = (uintptr_t)BS3_FP_OFF(&TMPL_NM(bs3CpuBasic2_Int80));
    664 # if TMPL_BITS == 32
    665     BS3_DATA_NM(g_uBs3TrapEipHint) = Ctx.rip.u32;
    666 # endif
    667 
    668     /*
    669      * We'll be using IDT entry 80 and 81 here. The first one will be
    670      * accessible from all DPLs, the latter not. So, start with setting
    671      * the DPLs.
    672      */
    673     MyBs3Idt[0x80].Gate.u2Dpl = 3;
    674     MyBs3Idt[0x81].Gate.u2Dpl = 0;
    675 
    676     /*
    677      * Check that the basic stuff works first.
    678      */
    679     Bs3TrapSetJmpAndRestore(&Ctx, &TrapCtx);
    680     bs3CpuBasic2_CompareTrapCtx1(&TrapCtx, &Ctx, 2 /*int 80h*/, 0x80 /*bXcpt*/, pszMode, __LINE__);
    681 
    682     bs3CpuBasic2_TssGateEsp_AltStackOuterRing(&Ctx, 1, NULL, 0, f16BitSys, f16BitSys, f16BitSys, pszMode, __LINE__);
    683     bs3CpuBasic2_TssGateEsp_AltStackOuterRing(&Ctx, 2, NULL, 0, f16BitSys, f16BitSys, f16BitSys, pszMode, __LINE__);
    684     bs3CpuBasic2_TssGateEsp_AltStackOuterRing(&Ctx, 3, NULL, 0, f16BitSys, f16BitSys, f16BitSys, pszMode, __LINE__);
    685 
    686     /*
    687      * Check that the upper part of ESP is preserved when doing .
    688      */
    689     if ((BS3_DATA_NM(g_uBs3CpuDetected) & BS3CPU_TYPE_MASK) >= BS3CPU_80386)
    690     {
    691         size_t const cbAltStack = _8K;
    692         uint8_t *pbAltStack = Bs3MemAllocZ(BS3MEMKIND_TILED, cbAltStack);
    693         if (pbAltStack)
    694         {
    695             /* same ring */
    696             uLine = __LINE__;
    697             Bs3MemCpy(&Ctx2, &Ctx, sizeof(Ctx2));
    698             Ctx2.rsp.u = Bs3SelPtrToFlat(pbAltStack + 0x1980);
    699             if (Bs3TrapSetJmp(&TrapCtx))
    700                 Bs3RegCtxRestore(&Ctx2, 0); /* (does not return) */
    701             bs3CpuBasic2_CompareTrapCtx1(&TrapCtx, &Ctx2, 2 /*int 80h*/, 0x80 /*bXcpt*/, pszMode, uLine);
    702 # if TMPL_BITS == 16
    703             if ((pbTmp = (uint8_t *)ASMMemFirstNonZero(pbAltStack, cbAltStack)) != NULL)
    704                 Bs3TestFailedF("%u - %s: someone touched the alt stack (%p) with SS:ESP=%04x:%#RX32: %p=%02x\n",
    705                                uLine, pszMode, pbAltStack, Ctx2.ss, Ctx2.rsp.u32, pbTmp, *pbTmp);
    706 # else
    707             if (ASMMemIsZero(pbAltStack, cbAltStack))
    708                 Bs3TestFailedF("%u - %s: alt stack wasn't used despite SS:ESP=%04x:%#RX32\n",
    709                                uLine, pszMode, Ctx2.ss, Ctx2.rsp.u32);
    710 # endif
    711 
    712             /* Different rings (load SS0:SP0 from TSS). */
    713             bs3CpuBasic2_TssGateEsp_AltStackOuterRing(&Ctx, 1, pbAltStack, cbAltStack,
    714                                                       f16BitSys, f16BitSys, f16BitSys, pszMode, __LINE__);
    715             bs3CpuBasic2_TssGateEsp_AltStackOuterRing(&Ctx, 2, pbAltStack, cbAltStack,
    716                                                       f16BitSys, f16BitSys, f16BitSys, pszMode, __LINE__);
    717             bs3CpuBasic2_TssGateEsp_AltStackOuterRing(&Ctx, 3, pbAltStack, cbAltStack,
    718                                                       f16BitSys, f16BitSys, f16BitSys, pszMode, __LINE__);
    719 
    720             /* Different rings but switch the SS bitness in the TSS. */
    721 # if BS3_MODE_IS_16BIT_SYS(TMPL_MODE)
    722             Bs3Tss16.ss0 = BS3_SEL_R0_SS32;
    723             bs3CpuBasic2_TssGateEsp_AltStackOuterRing(&Ctx, 1, pbAltStack, cbAltStack,
    724                                                       false, f16BitSys, f16BitSys, pszMode, __LINE__);
    725             Bs3Tss16.ss0 = BS3_SEL_R0_SS16;
    726 # else
    727             Bs3Tss32.ss0 = BS3_SEL_R0_SS16;
    728             bs3CpuBasic2_TssGateEsp_AltStackOuterRing(&Ctx, 1, pbAltStack, cbAltStack,
    729                                                       true,  f16BitSys, f16BitSys, pszMode, __LINE__);
    730             Bs3Tss32.ss0 = BS3_SEL_R0_SS32;
    731 # endif
    732 
    733             Bs3MemFree(pbAltStack, cbAltStack);
    734         }
    735         else
    736             Bs3TestPrintf("%s: Skipping ESP check, alloc failed\n", pszMode);
    737     }
    738     else
    739         Bs3TestPrintf("%s: Skipping ESP check, CPU too old\n", pszMode);
    740 #endif
    741642#else
    742643    bRet = BS3TESTDOMODE_SKIPPED;
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