VirtualBox

Changeset 80814 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Sep 16, 2019 7:45:42 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
133381
Message:

VMM/CPUM: Nested VMX: bugref:9180 Fix I/O bitmap accesses now that we don't have 2 different I/O bitmaps to check.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp

    r80806 r80814  
    24502450     * If any bit corresponding to the I/O access is set, we must cause a VM-exit.
    24512451     */
    2452     uint8_t const *pbIoBitmap   = (uint8_t const *)pvIoBitmap;
    2453     signed int     cBitsToCheck = cbAccess;                     /* Number of permission bits to check for this access. */
    2454     while (cBitsToCheck > 0)
    2455     {
    2456         uint16_t const offPerm    = uPort >> 3;                 /* Byte offset of the port. */
    2457         uint16_t const idxPermBit = uPort - (offPerm << 3);     /* Bit offset within byte. */
    2458         Assert(idxPermBit < 8);
    2459         uint8_t const  fMask = RT_BIT(idxPermBit);              /* Mask of the permission bit to check within the byte. */
    2460         uint8_t const  bPerm = *(pbIoBitmap + offPerm);         /* The bitmap content at the byte offset of the port. */
    2461 
    2462         /* If any bit for the access is 1, we must cause a VM-exit. */
    2463         if (bPerm & fMask)
    2464             return true;
    2465 
    2466         /* Move to the next permission bit. */
    2467         --cBitsToCheck;
    2468         ++uPort;
    2469     }
     2452    uint8_t const *pbIoBitmap = (uint8_t const *)pvIoBitmap;
     2453    uint16_t const offPerm    = uPort >> 3;                         /* Byte offset of the port. */
     2454    uint16_t const idxPermBit = uPort - (offPerm << 3);             /* Bit offset within byte. */
     2455    Assert(idxPermBit < 8);
     2456    static const uint8_t s_afMask[] = { 0x0, 0x1, 0x3, 0x7, 0xf };  /* Bit-mask for all access sizes. */
     2457    uint16_t const fMask = s_afMask[cbAccess] << idxPermBit;        /* Bit-mask of the access. */
     2458
     2459    /* Fetch 8 or 16-bits depending on whether the access spans 8-bit boundary. */
     2460    RTUINT16U uPerm;
     2461    uPerm.s.Lo = *(pbIoBitmap + offPerm);
     2462    if (idxPermBit + cbAccess > 8)
     2463        uPerm.s.Hi = *(pbIoBitmap + 1 + offPerm);
     2464    else
     2465        uPerm.s.Hi = 0;
     2466
     2467    /* If any bit for the access is 1, we must cause a VM-exit. */
     2468    if (uPerm.u & fMask)
     2469        return true;
    24702470
    24712471    return false;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette