VirtualBox

Ignore:
Timestamp:
Jun 29, 2021 8:37:15 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
145400
Message:

bs3-cpu-basic-2: Must make sure to cross cachelines in the #AC test. bugref:10052

File:
1 edited

Legend:

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

    r89932 r89942  
    15181518
    15191519
    1520 static void bs3CpuBasic2_RaiseXcpt11Worker(uint8_t bMode, uint8_t *pbBuf, bool fAm,
     1520static void bs3CpuBasic2_RaiseXcpt11Worker(uint8_t bMode, uint8_t *pbBuf, unsigned cbCacheLine, bool fAm,
    15211521                                           BS3CPUBASIC2PFTTSTCMNMODE const BS3_FAR *pCmn)
    15221522{
     
    15731573            for (iTest = 0; iTest < pCmn->cEntries; iTest++)
    15741574            {
     1575                uint8_t const    fOp    = pCmn->paEntries[iTest].fOp;
    15751576                uint8_t const    cbMem  = pCmn->paEntries[iTest].cbMem;
    1576                 uint8_t const    fOp    = pCmn->paEntries[iTest].fOp;
    1577                 uint8_t          offMem;
     1577                uint16_t const   cbMax  = cbCacheLine + cbMem;
     1578                uint16_t         offMem;
    15781579                uint8_t BS3_FAR *poffUd = (uint8_t BS3_FAR *)Bs3SelLnkPtrToCurPtr(pCmn->paEntries[iTest].pfn);
    15791580                Bs3RegCtxSetRipCsFromLnkPtr(&Ctx, pCmn->paEntries[iTest].pfn);
     
    16031604                /*
    16041605                 * Buffer misalignment loop.
     1606                 * Note! We must make sure to cross a cache line here to make sure
     1607                 *       to cover the split-lock scenario. (The buffer is cache
     1608                 *       line aligned.)
    16051609                 */
    1606                 for (offMem = 0; offMem < cbMem; offMem++)
     1610                for (offMem = 0; offMem < cbMax; offMem++)
    16071611                {
    1608                     unsigned offBuf = cbMem * 2 + cbMem;
     1612                    unsigned offBuf = cbMax + cbMem * 2;
    16091613                    while (offBuf-- > 0)
    16101614                        pbBuf[offBuf] = 1; /* byte-by-byte to make sure it doesn't trigger AC. */
     
    16571661BS3_DECL_FAR(uint8_t) BS3_CMN_FAR_NM(bs3CpuBasic2_RaiseXcpt11)(uint8_t bMode)
    16581662{
    1659     uint8_t             abBuf[4096 /** @todo 128 - but that went crazy in real mode; now it's long mode going wrong.  */];
     1663    unsigned            cbCacheLine = 128; /** @todo detect */
     1664    uint8_t             abBuf[4096 /** @todo 512 - but that went crazy in real mode; now it's long mode going wrong.  */];
    16601665    uint8_t BS3_FAR    *pbBuf;
    16611666    unsigned            idxCmnModes;
     
    16761681    /* Get us a 64-byte aligned buffer. */
    16771682    pbBuf = abBuf;
    1678     if (BS3_FP_OFF(pbBuf) & 63)
    1679         pbBuf = &abBuf[64 - BS3_FP_OFF(pbBuf) & 63];
     1683    if (BS3_FP_OFF(pbBuf) & (cbCacheLine - 1))
     1684        pbBuf = &abBuf[cbCacheLine - BS3_FP_OFF(pbBuf) & (cbCacheLine - 1)];
    16801685    //Bs3TestPrintf("pbBuf=%p\n", pbBuf);
    16811686
     
    16901695    BS3_ASSERT(!(fCr0 & X86_CR0_AM));
    16911696    Bs3RegSetCr0(fCr0 & ~X86_CR0_AM);
    1692     bs3CpuBasic2_RaiseXcpt11Worker(bMode, pbBuf, false /*fAm*/, &g_aCmnModes[idxCmnModes]);
     1697    bs3CpuBasic2_RaiseXcpt11Worker(bMode, pbBuf, cbCacheLine, false /*fAm*/, &g_aCmnModes[idxCmnModes]);
    16931698
    16941699#if 1
    16951700    /* The second round is with aligment checks enabled. */
    16961701    Bs3RegSetCr0(Bs3RegGetCr0() | X86_CR0_AM);
    1697     bs3CpuBasic2_RaiseXcpt11Worker(bMode, pbBuf, true /*fAm*/, &g_aCmnModes[idxCmnModes]);
     1702    bs3CpuBasic2_RaiseXcpt11Worker(bMode, pbBuf, cbCacheLine, true /*fAm*/, &g_aCmnModes[idxCmnModes]);
    16981703#endif
    16991704
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