VirtualBox

Changeset 102855 in vbox for trunk


Ignore:
Timestamp:
Jan 12, 2024 10:51:18 AM (13 months ago)
Author:
vboxsync
Message:

Debugger: Don't allow plain PAGE_SIZE etc.

Location:
trunk/src/VBox/Debugger
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Debugger/.scm-settings

    r98103 r102855  
    2828/*.h: --guard-relative-to-dir . --guard-prefix DEBUGGER_INCLUDED_SRC_
    2929
     30# Forbid PAGE_SIZE, PAGE_SIZE and PAGE_OFFSET_MASK w/o GUEST_ or HOST_ prefix.
     31/*.cpp: --only-guest-host-page
     32/*.h:   --only-guest-host-page
     33
     34# Forbid ASMMemIsZeroPage and ASMMemZeroPage.
     35/*.cpp: --no-ASMMemPage-use
     36/*.h:   --no-ASMMemPage-use
  • trunk/src/VBox/Debugger/DBGCCmdHlp.cpp

    r100120 r102855  
    414414         * Calc read size.
    415415         */
    416         size_t cb = RT_MIN(PAGE_SIZE, cbLeft);
     416        size_t cb = RT_MIN(GUEST_PAGE_SIZE, cbLeft);
    417417        switch (pVarPointer->enmType)
    418418        {
    419             case DBGCVAR_TYPE_GC_FLAT: cb = RT_MIN(cb, PAGE_SIZE - (Var.u.GCFlat & PAGE_OFFSET_MASK)); break;
    420             case DBGCVAR_TYPE_GC_PHYS: cb = RT_MIN(cb, PAGE_SIZE - (Var.u.GCPhys & PAGE_OFFSET_MASK)); break;
    421             case DBGCVAR_TYPE_HC_FLAT: cb = RT_MIN(cb, PAGE_SIZE - ((uintptr_t)Var.u.pvHCFlat & PAGE_OFFSET_MASK)); break;
    422             case DBGCVAR_TYPE_HC_PHYS: cb = RT_MIN(cb, PAGE_SIZE - ((size_t)Var.u.HCPhys & PAGE_OFFSET_MASK)); break; /* size_t: MSC has braindead loss of data warnings! */
     419            case DBGCVAR_TYPE_GC_FLAT: cb = RT_MIN(cb, GUEST_PAGE_SIZE - (Var.u.GCFlat & GUEST_PAGE_OFFSET_MASK)); break;
     420            case DBGCVAR_TYPE_GC_PHYS: cb = RT_MIN(cb, GUEST_PAGE_SIZE - (Var.u.GCPhys & GUEST_PAGE_OFFSET_MASK)); break;
     421            case DBGCVAR_TYPE_HC_FLAT: cb = RT_MIN(cb, GUEST_PAGE_SIZE - ((uintptr_t)Var.u.pvHCFlat & GUEST_PAGE_OFFSET_MASK)); break;
     422            case DBGCVAR_TYPE_HC_PHYS: cb = RT_MIN(cb, GUEST_PAGE_SIZE - ((size_t)Var.u.HCPhys & GUEST_PAGE_OFFSET_MASK)); break; /* size_t: MSC has braindead loss of data warnings! */
    423423            default: break;
    424424        }
     
    604604
    605605                /* calc size. */
    606                 size_t cbChunk = PAGE_SIZE;
    607                 cbChunk -= (uintptr_t)Var.u.pvHCFlat & PAGE_OFFSET_MASK;
     606                size_t cbChunk = GUEST_PAGE_SIZE;
     607                cbChunk -= (uintptr_t)Var.u.pvHCFlat & GUEST_PAGE_OFFSET_MASK;
    608608                if (cbChunk > cbWrite)
    609609                    cbChunk = cbWrite;
  • trunk/src/VBox/Debugger/DBGCEmulateCodeView.cpp

    r102093 r102855  
    32123212        uint32_t cbLimit = pDesc->Gen.u16LimitLow | (pDesc->Gen.u4LimitHigh << 16);
    32133213        if (pDesc->Gen.u1Granularity)
    3214             cbLimit <<= PAGE_SHIFT;
     3214            cbLimit <<= GUEST_PAGE_SHIFT;
    32153215
    32163216        rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %s Bas=%08x Lim=%08x DPL=%d %s %s %s %s AVL=%d L=%d%s\n",
     
    32663266                uint32_t cbLimit = pDesc->Gen.u16LimitLow | (pDesc->Gen.u4LimitHigh << 16);
    32673267                if (pDesc->Gen.u1Granularity)
    3268                     cbLimit <<= PAGE_SHIFT;
     3268                    cbLimit <<= GUEST_PAGE_SHIFT;
    32693269
    32703270                rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %s Bas=%08x Lim=%08x DPL=%d %s %s %s %s AVL=%d R=%d%s\n",
     
    39763976        if (fPAE)
    39773977            return DBGCCmdHlpPrintf(pCmdHlp, "PDE indexing is only implemented for 32-bit paging.\n");
    3978         if (VarDefault.u.u64Number >= PAGE_SIZE / cbEntry)
    3979             return DBGCCmdHlpPrintf(pCmdHlp, "PDE index is out of range [0..%d].\n", PAGE_SIZE / cbEntry - 1);
     3978        if (VarDefault.u.u64Number >= GUEST_PAGE_SIZE / cbEntry)
     3979            return DBGCCmdHlpPrintf(pCmdHlp, "PDE index is out of range [0..%d].\n", GUEST_PAGE_SIZE / cbEntry - 1);
    39803980        VarDefault.u.u64Number <<= X86_PD_SHIFT;
    39813981        VarDefault.enmType = DBGCVAR_TYPE_GC_FLAT;
     
    40064006            default:                        cEntries = 10; break;
    40074007        }
    4008         cEntriesMax = PAGE_SIZE / cbEntry;
     4008        cEntriesMax = GUEST_PAGE_SIZE / cbEntry;
    40094009    }
    40104010    else
     
    40154015        switch (paArgs[0].enmRangeType)
    40164016        {
    4017             case DBGCVAR_RANGE_BYTES:       cEntries = paArgs[0].u64Range / PAGE_SIZE; break;
     4017            case DBGCVAR_RANGE_BYTES:       cEntries = paArgs[0].u64Range / GUEST_PAGE_SIZE; break;
    40184018            case DBGCVAR_RANGE_ELEMENTS:    cEntries = paArgs[0].u64Range; break;
    40194019            default:                        cEntries = 10; break;
     
    40834083            VarPDEAddr.u.u64Number += iEntry * sizeof(X86PDE);
    40844084        }
    4085         cEntriesMax = (PAGE_SIZE - iEntry) / cbEntry;
     4085        cEntriesMax = (GUEST_PAGE_SIZE - iEntry) / cbEntry;
    40864086    }
    40874087
     
    42204220
    42214221    uint64_t cbRange;
    4222     rc = DBGCCmdHlpVarGetRange(pCmdHlp, pRange, PAGE_SIZE, PAGE_SIZE * 8, &cbRange);
     4222    rc = DBGCCmdHlpVarGetRange(pCmdHlp, pRange, GUEST_PAGE_SIZE, GUEST_PAGE_SIZE * 8, &cbRange);
    42234223    if (RT_FAILURE(rc))
    42244224        return DBGCCmdHlpFail(pCmdHlp, pCmd, "Failed to obtain the range of %DV: %Rrc", pRange, rc);
     
    43534353            default:                        cEntries = 10; break;
    43544354        }
    4355         cEntriesMax = PAGE_SIZE / cbEntry;
     4355        cEntriesMax = GUEST_PAGE_SIZE / cbEntry;
    43564356    }
    43574357    else
     
    43624362        switch (paArgs[0].enmRangeType)
    43634363        {
    4364             case DBGCVAR_RANGE_BYTES:       cEntries = paArgs[0].u64Range / PAGE_SIZE; break;
     4364            case DBGCVAR_RANGE_BYTES:       cEntries = paArgs[0].u64Range / GUEST_PAGE_SIZE; break;
    43654365            case DBGCVAR_RANGE_ELEMENTS:    cEntries = paArgs[0].u64Range; break;
    43664366            default:                        cEntries = 10; break;
     
    43784378            VarGCPtr.enmType = DBGCVAR_TYPE_GC_FLAT;
    43794379        }
    4380         VarGCPtr.u.GCFlat &= ~(RTGCPTR)PAGE_OFFSET_MASK;
     4380        VarGCPtr.u.GCFlat &= ~(RTGCPTR)GUEST_PAGE_OFFSET_MASK;
    43814381
    43824382        /*
     
    44514451            VarPTEAddr.u.u64Number += iEntry * sizeof(X86PTE);
    44524452        }
    4453         cEntriesMax = (PAGE_SIZE - iEntry) / cbEntry;
     4453        cEntriesMax = (GUEST_PAGE_SIZE - iEntry) / cbEntry;
    44544454    }
    44554455
     
    45114511        VarPTEAddr.u.u64Number += cbEntry;
    45124512        if (iEntry != ~0U)
    4513             VarGCPtr.u.GCFlat += PAGE_SIZE;
     4513            VarGCPtr.u.GCFlat += GUEST_PAGE_SIZE;
    45144514    } while (cEntries-- > 0);
    45154515
  • trunk/src/VBox/Debugger/DBGPlugInDarwin.cpp

    r98103 r102855  
    458458     * Check that all the pages are present.
    459459     */
    460     cbSeg    += uSegAddr & X86_PAGE_OFFSET_MASK;
    461     uSegAddr &= ~(uint64_t)X86_PAGE_OFFSET_MASK;
     460    cbSeg    += uSegAddr & GUEST_PAGE_OFFSET_MASK;
     461    uSegAddr &= ~(uint64_t)GUEST_PAGE_OFFSET_MASK;
    462462    for (;;)
    463463    {
     
    473473
    474474        /* Advance */
    475         if (cbSeg <= X86_PAGE_SIZE)
     475        if (cbSeg <= GUEST_PAGE_SIZE)
    476476            return true;
    477         cbSeg    -= X86_PAGE_SIZE;
    478         uSegAddr += X86_PAGE_SIZE;
     477        cbSeg    -= GUEST_PAGE_SIZE;
     478        uSegAddr += GUEST_PAGE_SIZE;
    479479    }
    480480}
     
    522522    union
    523523    {
    524         uint8_t             ab[2 * X86_PAGE_4K_SIZE];
     524        uint8_t             ab[2 * GUEST_PAGE_SIZE];
    525525        mach_header_64_t    Hdr64;
    526526        mach_header_32_t    Hdr32;
     
    530530    DBGFADDRESS ModAddr;
    531531    int rc = pVMM->pfnDBGFR3MemRead(pUVM, 0 /*idCpu*/,
    532                                     pVMM->pfnDBGFR3AddrFromFlat(pUVM, &ModAddr, uModAddr), uBuf.ab, X86_PAGE_4K_SIZE);
     532                                    pVMM->pfnDBGFR3AddrFromFlat(pUVM, &ModAddr, uModAddr), uBuf.ab, GUEST_PAGE_SIZE);
    533533    if (RT_FAILURE(rc))
    534534        return rc;
     
    551551        return VERR_BAD_EXE_FORMAT;
    552552    AssertCompileMembersSameSizeAndOffset(mach_header_64_t, sizeofcmds, mach_header_32_t, sizeofcmds);
    553     if (uBuf.Hdr32.sizeofcmds > X86_PAGE_4K_SIZE * 2 - sizeof(mach_header_64_t))
     553    if (uBuf.Hdr32.sizeofcmds > GUEST_PAGE_SIZE * 2 - sizeof(mach_header_64_t))
    554554        return VERR_BAD_EXE_FORMAT;
    555555
    556556    /* Do we need to read a 2nd page to get all the load commands? If so, do it. */
    557     if (uBuf.Hdr32.sizeofcmds + (f64Bit ? sizeof(mach_header_64_t) : sizeof(mach_header_32_t)) > X86_PAGE_4K_SIZE)
    558     {
    559         rc = pVMM->pfnDBGFR3MemRead(pUVM, 0 /*idCpu*/, pVMM->pfnDBGFR3AddrFromFlat(pUVM, &ModAddr, uModAddr + X86_PAGE_4K_SIZE),
    560                                     &uBuf.ab[X86_PAGE_4K_SIZE], X86_PAGE_4K_SIZE);
     557    if (uBuf.Hdr32.sizeofcmds + (f64Bit ? sizeof(mach_header_64_t) : sizeof(mach_header_32_t)) > GUEST_PAGE_SIZE)
     558    {
     559        rc = pVMM->pfnDBGFR3MemRead(pUVM, 0 /*idCpu*/, pVMM->pfnDBGFR3AddrFromFlat(pUVM, &ModAddr, uModAddr + GUEST_PAGE_SIZE),
     560                                    &uBuf.ab[GUEST_PAGE_SIZE], GUEST_PAGE_SIZE);
    561561        if (RT_FAILURE(rc))
    562562            return rc;
     
    10111011        for (pVMM->pfnDBGFR3AddrFromFlat(pUVM, &KernelAddr, s_aRanges[iRange].uStart);
    10121012             KernelAddr.FlatPtr < s_aRanges[iRange].uEnd;
    1013              KernelAddr.FlatPtr += X86_PAGE_4K_SIZE)
     1013             KernelAddr.FlatPtr += GUEST_PAGE_SIZE)
    10141014        {
    10151015            static const uint8_t s_abNeedle[16 + 16] =
     
    10231023            if (RT_FAILURE(rc))
    10241024                break;
    1025             pVMM->pfnDBGFR3AddrSub(&KernelAddr, KernelAddr.FlatPtr & X86_PAGE_4K_OFFSET_MASK);
     1025            pVMM->pfnDBGFR3AddrSub(&KernelAddr, KernelAddr.FlatPtr & GUEST_PAGE_OFFSET_MASK);
    10261026
    10271027            /*
     
    10301030            union
    10311031            {
    1032                 uint8_t             ab[X86_PAGE_4K_SIZE];
     1032                uint8_t             ab[GUEST_PAGE_SIZE];
    10331033                mach_header_64_t    Hdr64;
    10341034                mach_header_32_t    Hdr32;
    10351035            } uBuf;
    1036             rc = pVMM->pfnDBGFR3MemRead(pUVM, 0 /*idCpu*/, &KernelAddr, uBuf.ab, X86_PAGE_4K_SIZE);
     1036            rc = pVMM->pfnDBGFR3MemRead(pUVM, 0 /*idCpu*/, &KernelAddr, uBuf.ab, GUEST_PAGE_SIZE);
    10371037            if (RT_FAILURE(rc))
    10381038                continue;
     
    10521052                continue;
    10531053            AssertCompileMembersSameSizeAndOffset(mach_header_64_t, sizeofcmds, mach_header_32_t, sizeofcmds);
    1054             if (uBuf.Hdr32.sizeofcmds > X86_PAGE_4K_SIZE * 2 - sizeof(mach_header_64_t))
     1054            if (uBuf.Hdr32.sizeofcmds > GUEST_PAGE_SIZE * 2 - sizeof(mach_header_64_t))
    10551055                continue;
    10561056
  • trunk/src/VBox/Debugger/DBGPlugInWinNt.cpp

    r99739 r102855  
    12931293    union
    12941294    {
    1295         uint8_t             au8[0x2000];
    1296         RTUTF16             wsz[0x2000/2];
     1295        uint8_t             au8[GUEST_PAGE_SIZE * 2];
     1296        RTUTF16             wsz[GUEST_PAGE_SIZE];
    12971297        NTKUSERSHAREDDATA   UserSharedData;
    12981298    }               u;
     
    13041304     */
    13051305    pVMM->pfnDBGFR3AddrFromFlat(pUVM, &Addr, pThis->f32Bit ? NTKUSERSHAREDDATA_WINNT32 : NTKUSERSHAREDDATA_WINNT64);
    1306     rc = pVMM->pfnDBGFR3MemRead(pUVM, 0 /*idCpu*/, &Addr, &u, PAGE_SIZE);
     1306    rc = pVMM->pfnDBGFR3MemRead(pUVM, 0 /*idCpu*/, &Addr, &u, GUEST_PAGE_SIZE);
    13071307    if (RT_SUCCESS(rc))
    13081308    {
     
    15151515    for (pVMM->pfnDBGFR3AddrFromFlat(pUVM, &KernelAddr, uKrnlStart);
    15161516         KernelAddr.FlatPtr < uKrnlEnd;
    1517          KernelAddr.FlatPtr += PAGE_SIZE)
     1517         KernelAddr.FlatPtr += GUEST_PAGE_SIZE)
    15181518    {
    15191519        bool fNt31 = false;
     
    15321532        if (RT_FAILURE(rc))
    15331533            break;
    1534         pVMM->pfnDBGFR3AddrSub(&KernelAddr, KernelAddr.FlatPtr & PAGE_OFFSET_MASK);
     1534        pVMM->pfnDBGFR3AddrSub(&KernelAddr, KernelAddr.FlatPtr & GUEST_PAGE_OFFSET_MASK);
    15351535
    15361536        /* MZ + PE header. */
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