VirtualBox

Changeset 98065 in vbox for trunk


Ignore:
Timestamp:
Jan 12, 2023 3:57:23 PM (2 years ago)
Author:
vboxsync
Message:

DevVGA: Simplified the tracking of remapped VGA pages, we don't need two variables for that. Corrected comments about the range, since it's technically the 128KB range A0000 thru BFFFF, not just 64KB thru AFFFF. bugref:10251

Location:
trunk/src/VBox/Devices
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/DevVGA.cpp

    r97779 r98065  
    311311
    312312/**
    313  * Mark a page in VGA A0000-AFFFF range as remapped.
     313 * Mark a page in VGA A0000-BFFFF range as remapped.
    314314 *
    315315 * @param   pThis       VGA instance data.
     
    318318DECLINLINE(void) vgaMarkRemapped(PVGASTATE pThis, RTGCPHYS offVGAMem)
    319319{
    320     AssertMsg(offVGAMem < _64K, ("offVGAMem = %p > 64K\n", offVGAMem));
    321     ASMBitSet(&pThis->bmPageMapBitmap, offVGAMem >> GUEST_PAGE_SHIFT);
    322     pThis->fRemappedVGA = true;
    323 }
    324 
    325 /**
    326  * Checks if a page in VGA A0000-AFFFF range is remapped.
     320    AssertMsg(offVGAMem < _128K, ("offVGAMem = %RGp\n", offVGAMem));
     321    pThis->bmPageRemappedVGA |= RT_BIT_32((uint32_t)offVGAMem >> GUEST_PAGE_SHIFT);
     322}
     323
     324
     325/**
     326 * Checks if a page in VGA A0000-BFFFF range is remapped.
    327327 *
    328328 * @returns true if remapped.
     
    333333DECLINLINE(bool) vgaIsRemapped(PVGASTATE pThis, RTGCPHYS offVGAMem)
    334334{
    335     AssertMsg(offVGAMem < _64K, ("offVGAMem = %p > 64K\n", offVGAMem));
    336     return ASMBitTest(&pThis->bmPageMapBitmap, offVGAMem >> GUEST_PAGE_SHIFT);
    337 }
     335    AssertMsg(offVGAMem < _128K, ("offVGAMem = %RGp\n", offVGAMem));
     336    return pThis->bmPageRemappedVGA & RT_BIT_32((uint32_t)offVGAMem >> GUEST_PAGE_SHIFT);
     337}
     338
    338339
    339340/**
     
    344345DECLINLINE(void) vgaResetRemapped(PVGASTATE pThis)
    345346{
    346     pThis->fRemappedVGA = false;
    347     ASMBitClearRange(&pThis->bmPageMapBitmap, 0, _64K >> GUEST_PAGE_SHIFT);
    348 }
     347    pThis->bmPageRemappedVGA = 0;
     348}
     349
    349350
    350351/**
     
    745746            ||  pThis->sr_index == 2 /* plane mask */)
    746747        {
    747             if (pThis->fRemappedVGA)
     748            if (pThis->bmPageRemappedVGA != 0)
    748749            {
    749750                PDMDevHlpMmioResetRegion(pDevIns, pThis->hMmioLegacy);
     
    785786        if (pThis->gr_index == 6 /* memory map mode */)
    786787        {
    787             if (pThis->fRemappedVGA)
     788            if (pThis->bmPageRemappedVGA != 0)
    788789            {
    789790                PDMDevHlpMmioResetRegion(pDevIns, pThis->hMmioLegacy);
     
    10441045# ifndef IN_RC
    10451046            /* The VGA region is (could be) affected by this change; reset all aliases we've created. */
    1046             if (pThis->fRemappedVGA)
     1047            if (pThis->bmPageRemappedVGA != 0)
    10471048            {
    10481049                PDMDevHlpMmioResetRegion(pDevIns, pThis->hMmioLegacy);
     
    11541155
    11551156            /* The VGA region is (could be) affected by this change; reset all aliases we've created. */
    1156             if (pThis->fRemappedVGA)
     1157            if (pThis->bmPageRemappedVGA != 0)
    11571158            {
    11581159                PDMDevHlpMmioResetRegion(pDevIns, pThis->hMmioLegacy);
     
    12211222
    12221223    /* convert to VGA memory offset */
     1224    addr &= 0x1ffff;
    12231225#ifndef IN_RC
    1224     RTGCPHYS GCPhys = addr; /* save original address */
     1226    RTGCPHYS const offMmio = addr; /* save original MMIO range offset */
    12251227#endif
    1226     addr &= 0x1ffff;
    12271228
    12281229    int const memory_map_mode = (pThis->gr[6] >> 2) & 3;
     
    12531254        /* If all planes are accessible, then map the page to the frame buffer and make it writable. */
    12541255        if (   (pThis->sr[2] & 3) == 3
    1255             && !vgaIsRemapped(pThis, GCPhys - 0xa0000)
     1256            && !vgaIsRemapped(pThis, offMmio)
    12561257            && pThis->GCPhysVRAM)
    12571258        {
    12581259            /** @todo only allow read access (doesn't work now) */
    12591260            STAM_COUNTER_INC(&pThis->StatMapPage);
    1260             PDMDevHlpMmioMapMmio2Page(pDevIns, pThis->hMmioLegacy, GCPhys - 0xa0000,
    1261                                       pThis->hMmio2VRam, addr, X86_PTE_RW | X86_PTE_P);
     1261            PDMDevHlpMmioMapMmio2Page(pDevIns, pThis->hMmioLegacy, offMmio, pThis->hMmio2VRam, addr, X86_PTE_RW | X86_PTE_P);
    12621262            /* Set as dirty as write accesses won't be noticed now. */
    12631263            vgaR3MarkDirty(pThis, addr);
    1264             vgaMarkRemapped(pThis, GCPhys - 0xa0000);
     1264            vgaMarkRemapped(pThis, offMmio);
    12651265        }
    12661266#endif /* !IN_RC */
     
    13271327
    13281328    /* convert to VGA memory offset */
     1329    addr &= 0x1ffff;
    13291330#ifndef IN_RC
    1330     RTGCPHYS const GCPhys = addr; /* save original address */
     1331    RTGCPHYS const offMmio = addr; /* save original MMIO range offset */
    13311332#endif
    1332     addr &= 0x1ffff;
    13331333
    13341334    int const memory_map_mode = (pThis->gr[6] >> 2) & 3;
     
    13621362            /* If all planes are accessible, then map the page to the frame buffer and make it writable. */
    13631363            if (   (pThis->sr[2] & 3) == 3
    1364                 && !vgaIsRemapped(pThis, GCPhys - 0xa0000)
     1364                && !vgaIsRemapped(pThis, offMmio)
    13651365                && pThis->GCPhysVRAM)
    13661366            {
    13671367                STAM_COUNTER_INC(&pThis->StatMapPage);
    1368                 PDMDevHlpMmioMapMmio2Page(pDevIns, pThis->hMmioLegacy, GCPhys - 0xa0000,
    1369                                           pThis->hMmio2VRam, addr, X86_PTE_RW | X86_PTE_P);
    1370                 vgaMarkRemapped(pThis, GCPhys - 0xa0000);
     1368                PDMDevHlpMmioMapMmio2Page(pDevIns, pThis->hMmioLegacy, offMmio, pThis->hMmio2VRam, addr, X86_PTE_RW | X86_PTE_P);
     1369                vgaMarkRemapped(pThis, offMmio);
    13711370            }
    13721371#endif /* !IN_RC */
     
    36593658 * @callback_method_impl{FNIOMMMIONEWREAD,
    36603659 * Legacy VGA memory (0xa0000 - 0xbffff) read hook\, to be called from IOM.}
     3660 *
     3661 * @note The @a off is an absolute address in the 0xa0000 - 0xbffff range, not
     3662 *       an offset.
    36613663 */
    36623664static DECLCALLBACK(VBOXSTRICTRC) vgaMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, unsigned cb)
     
    37183720 * @callback_method_impl{FNIOMMMIONEWWRITE,
    37193721 * Legacy VGA memory (0xa0000 - 0xbffff) write hook\, to be called from IOM.}
     3722 *
     3723 * @note The @a off is an absolute address in the 0xa0000 - 0xbffff range, not
     3724 *       an offset.
    37203725 */
    37213726static DECLCALLBACK(VBOXSTRICTRC) vgaMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, unsigned cb)
     
    48754880        vgaR3UpdateDirtyBitsAndResetMonitoring(pDevIns, pThis);
    48764881
    4877     if (pThis->fRemappedVGA)
     4882    if (pThis->bmPageRemappedVGA != 0)
    48784883    {
    48794884        PDMDevHlpMmioResetRegion(pDevIns, pThis->hMmioLegacy);
     
    49044909    }
    49054910
    4906     if (pThis->fRemappedVGA)
     4911    if (pThis->bmPageRemappedVGA != 0)
    49074912    {
    49084913        PDMDevHlpMmioResetRegion(pDevIns, pThis->hMmioLegacy);
     
    61266131        AssertRC(rc);
    61276132    }
    6128     if (pThis->fRemappedVGA)
     6133    if (pThis->bmPageRemappedVGA != 0)
    61296134    {
    61306135        PDMDevHlpMmioResetRegion(pDevIns, pThis->hMmioLegacy);
  • trunk/src/VBox/Devices/Graphics/DevVGA.h

    r96407 r98065  
    362362    /** Bitmap tracking dirty pages. */
    363363    uint64_t                    bmDirtyBitmap[VGA_VRAM_MAX / GUEST_PAGE_SIZE / 64];
    364     /** Bitmap tracking remapped pages (only needs 16 bits). */
    365     uint64_t                    bmPageMapBitmap;
     364    /** Bitmap tracking which VGA memory pages in the 0xa0000-0xbffff region has
     365     * been remapped to allow direct access.
     366     * @note It's quite possible that mapping in the 0xb0000-0xbffff isn't possible,
     367     *       but we're playing safe and cover the whole VGA MMIO region here. */
     368    uint32_t                    bmPageRemappedVGA;
    366369
    367370    /** Flag indicating that there are dirty bits. This is used to optimize the handler resetting. */
    368371    bool                        fHasDirtyBits;
    369     /** Flag indicating that the VGA memory in the 0xa0000-0xbffff region has been remapped to allow direct access. */
     372    /** Flag indicating that the VGA memory in the 0xa0000-0xbffff region has been remapped to allow direct access.
     373     * @todo This is just an unnecessary summmary of bmPageMapBitmap.  */
    370374    bool                        fRemappedVGA;
    371375    /** Whether to render the guest VRAM to the framebuffer memory. False only for some LFB modes. */
     
    381385    bool                        fVMSVGAPciId;
    382386    bool                        fVMSVGAPciBarLayout;
    383     bool                        Padding4[3];
    384387#else
    385     bool                        Padding4[4+3];
     388    bool                        afPadding4[4];
    386389#endif
    387390
  • trunk/src/VBox/Devices/testcase/tstDeviceStructSize.cpp

    r96512 r98065  
    409409    CHECK_MEMBER_ALIGNMENT(VGASTATE, StatRZMemoryRead, 8);
    410410    CHECK_MEMBER_ALIGNMENT(VGASTATE, CritSectIRQ, 8);
     411    CHECK_MEMBER_ALIGNMENT(VGASTATE, bmDirtyBitmap, 8);
     412    CHECK_MEMBER_ALIGNMENT(VGASTATE, pciRegions, 8);
    411413    CHECK_MEMBER_ALIGNMENT(VMMDEV, CritSect, 8);
    412414#ifdef VBOX_WITH_PCI_PASSTHROUGH_IMPL
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