VirtualBox

Changeset 78371 in vbox for trunk/src


Ignore:
Timestamp:
May 3, 2019 8:21:44 AM (6 years ago)
Author:
vboxsync
Message:

VMM: Move VT-x/AMD-V helpers that are based on CPU specs to CPUM in preparation of upcoming changes. It is better placed in CPUM if say NEM in future needs to implement nested VT-x/AMD-V.

Location:
trunk/src/VBox/VMM
Files:
7 edited

Legend:

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

    r78220 r78371  
    31623162}
    31633163
     3164
     3165/**
     3166 * Gets the read and write permission bits for an MSR in an MSR bitmap.
     3167 *
     3168 * @returns VMXMSRPM_XXX - the MSR permission.
     3169 * @param   pvMsrBitmap     Pointer to the MSR bitmap.
     3170 * @param   idMsr           The MSR to get permissions for.
     3171 *
     3172 * @sa      hmR0VmxSetMsrPermission.
     3173 */
     3174VMM_INT_DECL(uint32_t) CPUMGetVmxMsrPermission(void const *pvMsrBitmap, uint32_t idMsr)
     3175{
     3176    AssertPtrReturn(pvMsrBitmap, VMXMSRPM_EXIT_RD | VMXMSRPM_EXIT_WR);
     3177
     3178    uint8_t const * const pbMsrBitmap = (uint8_t const * const)pvMsrBitmap;
     3179
     3180    /*
     3181     * MSR Layout:
     3182     *   Byte index            MSR range            Interpreted as
     3183     * 0x000 - 0x3ff    0x00000000 - 0x00001fff    Low MSR read bits.
     3184     * 0x400 - 0x7ff    0xc0000000 - 0xc0001fff    High MSR read bits.
     3185     * 0x800 - 0xbff    0x00000000 - 0x00001fff    Low MSR write bits.
     3186     * 0xc00 - 0xfff    0xc0000000 - 0xc0001fff    High MSR write bits.
     3187     *
     3188     * A bit corresponding to an MSR within the above range causes a VM-exit
     3189     * if the bit is 1 on executions of RDMSR/WRMSR.  If an MSR falls out of
     3190     * the MSR range, it always cause a VM-exit.
     3191     *
     3192     * See Intel spec. 24.6.9 "MSR-Bitmap Address".
     3193     */
     3194    uint32_t const offBitmapRead  = 0;
     3195    uint32_t const offBitmapWrite = 0x800;
     3196    uint32_t       offMsr;
     3197    uint32_t       iBit;
     3198    if (idMsr <= UINT32_C(0x00001fff))
     3199    {
     3200        offMsr = 0;
     3201        iBit   = idMsr;
     3202    }
     3203    else if (idMsr - UINT32_C(0xc0000000) <= UINT32_C(0x00001fff))
     3204    {
     3205        offMsr = 0x400;
     3206        iBit   = idMsr - UINT32_C(0xc0000000);
     3207    }
     3208    else
     3209    {
     3210        LogFunc(("Warning! Out of range MSR %#RX32\n", idMsr));
     3211        return VMXMSRPM_EXIT_RD | VMXMSRPM_EXIT_WR;
     3212    }
     3213
     3214    /*
     3215     * Get the MSR read permissions.
     3216     */
     3217    uint32_t fRet;
     3218    uint32_t const offMsrRead = offBitmapRead + offMsr;
     3219    Assert(offMsrRead + (iBit >> 3) < offBitmapWrite);
     3220    if (ASMBitTest(pbMsrBitmap + offMsrRead, iBit))
     3221        fRet = VMXMSRPM_EXIT_RD;
     3222    else
     3223        fRet = VMXMSRPM_ALLOW_RD;
     3224
     3225    /*
     3226     * Get the MSR write permissions.
     3227     */
     3228    uint32_t const offMsrWrite = offBitmapWrite + offMsr;
     3229    Assert(offMsrWrite + (iBit >> 3) < X86_PAGE_4K_SIZE);
     3230    if (ASMBitTest(pbMsrBitmap + offMsrWrite, iBit))
     3231        fRet |= VMXMSRPM_EXIT_WR;
     3232    else
     3233        fRet |= VMXMSRPM_ALLOW_WR;
     3234
     3235    Assert(VMXMSRPM_IS_FLAG_VALID(fRet));
     3236    return fRet;
     3237}
     3238
     3239
     3240/**
     3241 * Gets the permission bits for the specified I/O port from the given I/O bitmaps.
     3242 *
     3243 * @returns @c true if the I/O port access must cause a VM-exit, @c false otherwise.
     3244 * @param   pvIoBitmapA     Pointer to I/O bitmap A.
     3245 * @param   pvIoBitmapB     Pointer to I/O bitmap B.
     3246 * @param   uPort           The I/O port being accessed.
     3247 * @param   cbAccess        The size of the I/O access in bytes (1, 2 or 4 bytes).
     3248 */
     3249VMM_INT_DECL(bool) CPUMGetVmxIoBitmapPermission(void const *pvIoBitmapA, void const *pvIoBitmapB, uint16_t uPort,
     3250                                                uint8_t cbAccess)
     3251{
     3252    Assert(cbAccess == 1 || cbAccess == 2 || cbAccess == 4);
     3253
     3254    /*
     3255     * If the I/O port access wraps around the 16-bit port I/O space,
     3256     * we must cause a VM-exit.
     3257     *
     3258     * See Intel spec. 25.1.3 "Instructions That Cause VM Exits Conditionally".
     3259     */
     3260    /** @todo r=ramshankar: Reading 1, 2, 4 bytes at ports 0xffff, 0xfffe and 0xfffc
     3261     *        respectively are valid and do not constitute a wrap around from what I
     3262     *        understand. Verify this later. */
     3263    uint32_t const uPortLast = uPort + cbAccess;
     3264    if (uPortLast > 0x10000)
     3265        return true;
     3266
     3267    /* Read the appropriate bit from the corresponding IO bitmap. */
     3268    void const *pvIoBitmap = uPort < 0x8000 ? pvIoBitmapA : pvIoBitmapB;
     3269    return ASMBitTest(pvIoBitmap, uPort);
     3270}
     3271
     3272
     3273/**
     3274 * Determines whether an IOIO intercept is active for the nested-guest or not.
     3275 *
     3276 * @param   pvIoBitmap      Pointer to the nested-guest IO bitmap.
     3277 * @param   u16Port         The IO port being accessed.
     3278 * @param   enmIoType       The type of IO access.
     3279 * @param   cbReg           The IO operand size in bytes.
     3280 * @param   cAddrSizeBits   The address size bits (for 16, 32 or 64).
     3281 * @param   iEffSeg         The effective segment number.
     3282 * @param   fRep            Whether this is a repeating IO instruction (REP prefix).
     3283 * @param   fStrIo          Whether this is a string IO instruction.
     3284 * @param   pIoExitInfo     Pointer to the SVMIOIOEXITINFO struct to be filled.
     3285 *                          Optional, can be NULL.
     3286 */
     3287VMM_INT_DECL(bool) CPUMIsSvmIoInterceptActive(void *pvIoBitmap, uint16_t u16Port, SVMIOIOTYPE enmIoType, uint8_t cbReg,
     3288                                              uint8_t cAddrSizeBits, uint8_t iEffSeg, bool fRep, bool fStrIo,
     3289                                              PSVMIOIOEXITINFO pIoExitInfo)
     3290{
     3291    Assert(cAddrSizeBits == 16 || cAddrSizeBits == 32 || cAddrSizeBits == 64);
     3292    Assert(cbReg == 1 || cbReg == 2 || cbReg == 4 || cbReg == 8);
     3293
     3294    /*
     3295     * The IOPM layout:
     3296     * Each bit represents one 8-bit port. That makes a total of 0..65535 bits or
     3297     * two 4K pages.
     3298     *
     3299     * For IO instructions that access more than a single byte, the permission bits
     3300     * for all bytes are checked; if any bit is set to 1, the IO access is intercepted.
     3301     *
     3302     * Since it's possible to do a 32-bit IO access at port 65534 (accessing 4 bytes),
     3303     * we need 3 extra bits beyond the second 4K page.
     3304     */
     3305    static const uint16_t s_auSizeMasks[] = { 0, 1, 3, 0, 0xf, 0, 0, 0 };
     3306
     3307    uint16_t const offIopm   = u16Port >> 3;
     3308    uint16_t const fSizeMask = s_auSizeMasks[(cAddrSizeBits >> SVM_IOIO_OP_SIZE_SHIFT) & 7];
     3309    uint8_t  const cShift    = u16Port - (offIopm << 3);
     3310    uint16_t const fIopmMask = (1 << cShift) | (fSizeMask << cShift);
     3311
     3312    uint8_t const *pbIopm = (uint8_t *)pvIoBitmap;
     3313    Assert(pbIopm);
     3314    pbIopm += offIopm;
     3315    uint16_t const u16Iopm = *(uint16_t *)pbIopm;
     3316    if (u16Iopm & fIopmMask)
     3317    {
     3318        if (pIoExitInfo)
     3319        {
     3320            static const uint32_t s_auIoOpSize[] =
     3321            { SVM_IOIO_32_BIT_OP, SVM_IOIO_8_BIT_OP, SVM_IOIO_16_BIT_OP, 0, SVM_IOIO_32_BIT_OP, 0, 0, 0 };
     3322
     3323            static const uint32_t s_auIoAddrSize[] =
     3324            { 0, SVM_IOIO_16_BIT_ADDR, SVM_IOIO_32_BIT_ADDR, 0, SVM_IOIO_64_BIT_ADDR, 0, 0, 0 };
     3325
     3326            pIoExitInfo->u         = s_auIoOpSize[cbReg & 7];
     3327            pIoExitInfo->u        |= s_auIoAddrSize[(cAddrSizeBits >> 4) & 7];
     3328            pIoExitInfo->n.u1Str   = fStrIo;
     3329            pIoExitInfo->n.u1Rep   = fRep;
     3330            pIoExitInfo->n.u3Seg   = iEffSeg & 7;
     3331            pIoExitInfo->n.u1Type  = enmIoType;
     3332            pIoExitInfo->n.u16Port = u16Port;
     3333        }
     3334        return true;
     3335    }
     3336
     3337    /** @todo remove later (for debugging as VirtualBox always traps all IO
     3338     *        intercepts). */
     3339    AssertMsgFailed(("CPUMSvmIsIOInterceptActive: We expect an IO intercept here!\n"));
     3340    return false;
     3341}
     3342
     3343
     3344/**
     3345 * Gets the MSR permission bitmap byte and bit offset for the specified MSR.
     3346 *
     3347 * @returns VBox status code.
     3348 * @param   idMsr       The MSR being requested.
     3349 * @param   pbOffMsrpm  Where to store the byte offset in the MSR permission
     3350 *                      bitmap for @a idMsr.
     3351 * @param   puMsrpmBit  Where to store the bit offset starting at the byte
     3352 *                      returned in @a pbOffMsrpm.
     3353 */
     3354VMM_INT_DECL(int) CPUMGetSvmMsrpmOffsetAndBit(uint32_t idMsr, uint16_t *pbOffMsrpm, uint8_t *puMsrpmBit)
     3355{
     3356    Assert(pbOffMsrpm);
     3357    Assert(puMsrpmBit);
     3358
     3359    /*
     3360     * MSRPM Layout:
     3361     * Byte offset          MSR range
     3362     * 0x000  - 0x7ff       0x00000000 - 0x00001fff
     3363     * 0x800  - 0xfff       0xc0000000 - 0xc0001fff
     3364     * 0x1000 - 0x17ff      0xc0010000 - 0xc0011fff
     3365     * 0x1800 - 0x1fff              Reserved
     3366     *
     3367     * Each MSR is represented by 2 permission bits (read and write).
     3368     */
     3369    if (idMsr <= 0x00001fff)
     3370    {
     3371        /* Pentium-compatible MSRs. */
     3372        uint32_t const bitoffMsr = idMsr << 1;
     3373        *pbOffMsrpm = bitoffMsr >> 3;
     3374        *puMsrpmBit = bitoffMsr & 7;
     3375        return VINF_SUCCESS;
     3376    }
     3377
     3378    if (   idMsr >= 0xc0000000
     3379        && idMsr <= 0xc0001fff)
     3380    {
     3381        /* AMD Sixth Generation x86 Processor MSRs. */
     3382        uint32_t const bitoffMsr = (idMsr - 0xc0000000) << 1;
     3383        *pbOffMsrpm = 0x800 + (bitoffMsr >> 3);
     3384        *puMsrpmBit = bitoffMsr & 7;
     3385        return VINF_SUCCESS;
     3386    }
     3387
     3388    if (   idMsr >= 0xc0010000
     3389        && idMsr <= 0xc0011fff)
     3390    {
     3391        /* AMD Seventh and Eighth Generation Processor MSRs. */
     3392        uint32_t const bitoffMsr = (idMsr - 0xc0010000) << 1;
     3393        *pbOffMsrpm = 0x1000 + (bitoffMsr >> 3);
     3394        *puMsrpmBit = bitoffMsr & 7;
     3395        return VINF_SUCCESS;
     3396    }
     3397
     3398    *pbOffMsrpm = 0;
     3399    *puMsrpmBit = 0;
     3400    return VERR_OUT_OF_RANGE;
     3401}
     3402
  • trunk/src/VBox/VMM/VMMAll/HMSVMAll.cpp

    r78220 r78371  
    319319#endif /* !IN_RC */
    320320
    321 /**
    322  * Gets the MSR permission bitmap byte and bit offset for the specified MSR.
    323  *
    324  * @returns VBox status code.
    325  * @param   idMsr       The MSR being requested.
    326  * @param   pbOffMsrpm  Where to store the byte offset in the MSR permission
    327  *                      bitmap for @a idMsr.
    328  * @param   puMsrpmBit  Where to store the bit offset starting at the byte
    329  *                      returned in @a pbOffMsrpm.
    330  */
    331 VMM_INT_DECL(int) HMGetSvmMsrpmOffsetAndBit(uint32_t idMsr, uint16_t *pbOffMsrpm, uint8_t *puMsrpmBit)
    332 {
    333     Assert(pbOffMsrpm);
    334     Assert(puMsrpmBit);
    335 
    336     /*
    337      * MSRPM Layout:
    338      * Byte offset          MSR range
    339      * 0x000  - 0x7ff       0x00000000 - 0x00001fff
    340      * 0x800  - 0xfff       0xc0000000 - 0xc0001fff
    341      * 0x1000 - 0x17ff      0xc0010000 - 0xc0011fff
    342      * 0x1800 - 0x1fff              Reserved
    343      *
    344      * Each MSR is represented by 2 permission bits (read and write).
    345      */
    346     if (idMsr <= 0x00001fff)
    347     {
    348         /* Pentium-compatible MSRs. */
    349         uint32_t const bitoffMsr = idMsr << 1;
    350         *pbOffMsrpm = bitoffMsr >> 3;
    351         *puMsrpmBit = bitoffMsr & 7;
    352         return VINF_SUCCESS;
    353     }
    354 
    355     if (   idMsr >= 0xc0000000
    356         && idMsr <= 0xc0001fff)
    357     {
    358         /* AMD Sixth Generation x86 Processor MSRs. */
    359         uint32_t const bitoffMsr = (idMsr - 0xc0000000) << 1;
    360         *pbOffMsrpm = 0x800 + (bitoffMsr >> 3);
    361         *puMsrpmBit = bitoffMsr & 7;
    362         return VINF_SUCCESS;
    363     }
    364 
    365     if (   idMsr >= 0xc0010000
    366         && idMsr <= 0xc0011fff)
    367     {
    368         /* AMD Seventh and Eighth Generation Processor MSRs. */
    369         uint32_t const bitoffMsr = (idMsr - 0xc0010000) << 1;
    370         *pbOffMsrpm = 0x1000 + (bitoffMsr >> 3);
    371         *puMsrpmBit = bitoffMsr & 7;
    372         return VINF_SUCCESS;
    373     }
    374 
    375     *pbOffMsrpm = 0;
    376     *puMsrpmBit = 0;
    377     return VERR_OUT_OF_RANGE;
    378 }
    379 
    380 
    381 /**
    382  * Determines whether an IOIO intercept is active for the nested-guest or not.
    383  *
    384  * @param   pvIoBitmap      Pointer to the nested-guest IO bitmap.
    385  * @param   u16Port         The IO port being accessed.
    386  * @param   enmIoType       The type of IO access.
    387  * @param   cbReg           The IO operand size in bytes.
    388  * @param   cAddrSizeBits   The address size bits (for 16, 32 or 64).
    389  * @param   iEffSeg         The effective segment number.
    390  * @param   fRep            Whether this is a repeating IO instruction (REP prefix).
    391  * @param   fStrIo          Whether this is a string IO instruction.
    392  * @param   pIoExitInfo     Pointer to the SVMIOIOEXITINFO struct to be filled.
    393  *                          Optional, can be NULL.
    394  */
    395 VMM_INT_DECL(bool) HMIsSvmIoInterceptActive(void *pvIoBitmap, uint16_t u16Port, SVMIOIOTYPE enmIoType, uint8_t cbReg,
    396                                             uint8_t cAddrSizeBits, uint8_t iEffSeg, bool fRep, bool fStrIo,
    397                                             PSVMIOIOEXITINFO pIoExitInfo)
    398 {
    399     Assert(cAddrSizeBits == 16 || cAddrSizeBits == 32 || cAddrSizeBits == 64);
    400     Assert(cbReg == 1 || cbReg == 2 || cbReg == 4 || cbReg == 8);
    401 
    402     /*
    403      * The IOPM layout:
    404      * Each bit represents one 8-bit port. That makes a total of 0..65535 bits or
    405      * two 4K pages.
    406      *
    407      * For IO instructions that access more than a single byte, the permission bits
    408      * for all bytes are checked; if any bit is set to 1, the IO access is intercepted.
    409      *
    410      * Since it's possible to do a 32-bit IO access at port 65534 (accessing 4 bytes),
    411      * we need 3 extra bits beyond the second 4K page.
    412      */
    413     static const uint16_t s_auSizeMasks[] = { 0, 1, 3, 0, 0xf, 0, 0, 0 };
    414 
    415     uint16_t const offIopm   = u16Port >> 3;
    416     uint16_t const fSizeMask = s_auSizeMasks[(cAddrSizeBits >> SVM_IOIO_OP_SIZE_SHIFT) & 7];
    417     uint8_t  const cShift    = u16Port - (offIopm << 3);
    418     uint16_t const fIopmMask = (1 << cShift) | (fSizeMask << cShift);
    419 
    420     uint8_t const *pbIopm = (uint8_t *)pvIoBitmap;
    421     Assert(pbIopm);
    422     pbIopm += offIopm;
    423     uint16_t const u16Iopm = *(uint16_t *)pbIopm;
    424     if (u16Iopm & fIopmMask)
    425     {
    426         if (pIoExitInfo)
    427         {
    428             static const uint32_t s_auIoOpSize[] =
    429             { SVM_IOIO_32_BIT_OP, SVM_IOIO_8_BIT_OP, SVM_IOIO_16_BIT_OP, 0, SVM_IOIO_32_BIT_OP, 0, 0, 0 };
    430 
    431             static const uint32_t s_auIoAddrSize[] =
    432             { 0, SVM_IOIO_16_BIT_ADDR, SVM_IOIO_32_BIT_ADDR, 0, SVM_IOIO_64_BIT_ADDR, 0, 0, 0 };
    433 
    434             pIoExitInfo->u         = s_auIoOpSize[cbReg & 7];
    435             pIoExitInfo->u        |= s_auIoAddrSize[(cAddrSizeBits >> 4) & 7];
    436             pIoExitInfo->n.u1Str   = fStrIo;
    437             pIoExitInfo->n.u1Rep   = fRep;
    438             pIoExitInfo->n.u3Seg   = iEffSeg & 7;
    439             pIoExitInfo->n.u1Type  = enmIoType;
    440             pIoExitInfo->n.u16Port = u16Port;
    441         }
    442         return true;
    443     }
    444 
    445     /** @todo remove later (for debugging as VirtualBox always traps all IO
    446      *        intercepts). */
    447     AssertMsgFailed(("CPUMSvmIsIOInterceptActive: We expect an IO intercept here!\n"));
    448     return false;
    449 }
    450 
    451321
    452322/**
  • trunk/src/VBox/VMM/VMMAll/HMVMXAll.cpp

    r78220 r78371  
    859859
    860860/**
    861  * Gets the read and write permission bits for an MSR in an MSR bitmap.
    862  *
    863  * @returns VMXMSRPM_XXX - the MSR permission.
    864  * @param   pvMsrBitmap     Pointer to the MSR bitmap.
    865  * @param   idMsr           The MSR to get permissions for.
    866  *
    867  * @sa      hmR0VmxSetMsrPermission.
    868  */
    869 VMM_INT_DECL(uint32_t) HMGetVmxMsrPermission(void const *pvMsrBitmap, uint32_t idMsr)
    870 {
    871     AssertPtrReturn(pvMsrBitmap, VMXMSRPM_EXIT_RD | VMXMSRPM_EXIT_WR);
    872 
    873     uint8_t const * const pbMsrBitmap = (uint8_t const * const)pvMsrBitmap;
    874 
    875     /*
    876      * MSR Layout:
    877      *   Byte index            MSR range            Interpreted as
    878      * 0x000 - 0x3ff    0x00000000 - 0x00001fff    Low MSR read bits.
    879      * 0x400 - 0x7ff    0xc0000000 - 0xc0001fff    High MSR read bits.
    880      * 0x800 - 0xbff    0x00000000 - 0x00001fff    Low MSR write bits.
    881      * 0xc00 - 0xfff    0xc0000000 - 0xc0001fff    High MSR write bits.
    882      *
    883      * A bit corresponding to an MSR within the above range causes a VM-exit
    884      * if the bit is 1 on executions of RDMSR/WRMSR.  If an MSR falls out of
    885      * the MSR range, it always cause a VM-exit.
    886      *
    887      * See Intel spec. 24.6.9 "MSR-Bitmap Address".
    888      */
    889     uint32_t const offBitmapRead  = 0;
    890     uint32_t const offBitmapWrite = 0x800;
    891     uint32_t       offMsr;
    892     uint32_t       iBit;
    893     if (idMsr <= UINT32_C(0x00001fff))
    894     {
    895         offMsr = 0;
    896         iBit   = idMsr;
    897     }
    898     else if (idMsr - UINT32_C(0xc0000000) <= UINT32_C(0x00001fff))
    899     {
    900         offMsr = 0x400;
    901         iBit   = idMsr - UINT32_C(0xc0000000);
    902     }
    903     else
    904     {
    905         LogFunc(("Warning! Out of range MSR %#RX32\n", idMsr));
    906         return VMXMSRPM_EXIT_RD | VMXMSRPM_EXIT_WR;
    907     }
    908 
    909     /*
    910      * Get the MSR read permissions.
    911      */
    912     uint32_t fRet;
    913     uint32_t const offMsrRead = offBitmapRead + offMsr;
    914     Assert(offMsrRead + (iBit >> 3) < offBitmapWrite);
    915     if (ASMBitTest(pbMsrBitmap + offMsrRead, iBit))
    916         fRet = VMXMSRPM_EXIT_RD;
    917     else
    918         fRet = VMXMSRPM_ALLOW_RD;
    919 
    920     /*
    921      * Get the MSR write permissions.
    922      */
    923     uint32_t const offMsrWrite = offBitmapWrite + offMsr;
    924     Assert(offMsrWrite + (iBit >> 3) < X86_PAGE_4K_SIZE);
    925     if (ASMBitTest(pbMsrBitmap + offMsrWrite, iBit))
    926         fRet |= VMXMSRPM_EXIT_WR;
    927     else
    928         fRet |= VMXMSRPM_ALLOW_WR;
    929 
    930     Assert(VMXMSRPM_IS_FLAG_VALID(fRet));
    931     return fRet;
    932 }
    933 
    934 
    935 /**
    936  * Gets the permission bits for the specified I/O port from the given I/O bitmaps.
    937  *
    938  * @returns @c true if the I/O port access must cause a VM-exit, @c false otherwise.
    939  * @param   pvIoBitmapA     Pointer to I/O bitmap A.
    940  * @param   pvIoBitmapB     Pointer to I/O bitmap B.
    941  * @param   uPort           The I/O port being accessed.
    942  * @param   cbAccess        The size of the I/O access in bytes (1, 2 or 4 bytes).
    943  */
    944 VMM_INT_DECL(bool) HMGetVmxIoBitmapPermission(void const *pvIoBitmapA, void const *pvIoBitmapB, uint16_t uPort, uint8_t cbAccess)
    945 {
    946     Assert(cbAccess == 1 || cbAccess == 2 || cbAccess == 4);
    947 
    948     /*
    949      * If the I/O port access wraps around the 16-bit port I/O space,
    950      * we must cause a VM-exit.
    951      *
    952      * See Intel spec. 25.1.3 "Instructions That Cause VM Exits Conditionally".
    953      */
    954     /** @todo r=ramshankar: Reading 1, 2, 4 bytes at ports 0xffff, 0xfffe and 0xfffc
    955      *        respectively are valid and do not constitute a wrap around from what I
    956      *        understand. Verify this later. */
    957     uint32_t const uPortLast = uPort + cbAccess;
    958     if (uPortLast > 0x10000)
    959         return true;
    960 
    961     /* Read the appropriate bit from the corresponding IO bitmap. */
    962     void const *pvIoBitmap = uPort < 0x8000 ? pvIoBitmapA : pvIoBitmapB;
    963     return ASMBitTest(pvIoBitmap, uPort);
    964 }
    965 
    966 
    967 /**
    968861 * Dumps the virtual VMCS state to the release log.
    969862 *
  • trunk/src/VBox/VMM/VMMAll/IEMAllCImplSvmInstr.cpp.h

    r77902 r78371  
    990990    SVMIOIOEXITINFO IoExitInfo;
    991991    void *pvIoBitmap = pVCpu->cpum.GstCtx.hwvirt.svm.CTX_SUFF(pvIoBitmap);
    992     bool const fIntercept = HMIsSvmIoInterceptActive(pvIoBitmap, u16Port, enmIoType, cbReg, cAddrSizeBits, iEffSeg, fRep,
     992    bool const fIntercept = CPUMIsSvmIoInterceptActive(pvIoBitmap, u16Port, enmIoType, cbReg, cAddrSizeBits, iEffSeg, fRep,
    993993                                                       fStrIo, &IoExitInfo);
    994994    if (fIntercept)
     
    10391039    uint16_t offMsrpm;
    10401040    uint8_t  uMsrpmBit;
    1041     int rc = HMGetSvmMsrpmOffsetAndBit(idMsr, &offMsrpm, &uMsrpmBit);
     1041    int rc = CPUMGetSvmMsrpmOffsetAndBit(idMsr, &offMsrpm, &uMsrpmBit);
    10421042    if (RT_SUCCESS(rc))
    10431043    {
  • trunk/src/VBox/VMM/VMMAll/IEMAllCImplVmxInstr.cpp.h

    r78239 r78371  
    30643064        Assert(pbIoBitmapA);
    30653065        Assert(pbIoBitmapB);
    3066         return HMGetVmxIoBitmapPermission(pbIoBitmapA, pbIoBitmapB, u16Port, cbAccess);
     3066        return CPUMGetVmxIoBitmapPermission(pbIoBitmapA, pbIoBitmapB, u16Port, cbAccess);
    30673067    }
    30683068
     
    77597759    {
    77607760        Assert(pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pvMsrBitmap));
    7761         uint32_t fMsrpm = HMGetVmxMsrPermission(pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pvMsrBitmap), idMsr);
     7761        uint32_t fMsrpm = CPUMGetVmxMsrPermission(pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pvMsrBitmap), idMsr);
    77627762        if (uExitReason == VMX_EXIT_RDMSR)
    77637763            return RT_BOOL(fMsrpm & VMXMSRPM_EXIT_RD);
  • trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp

    r78220 r78371  
    872872    uint16_t    offMsrpm;
    873873    uint8_t     uMsrpmBit;
    874     int rc = HMGetSvmMsrpmOffsetAndBit(idMsr, &offMsrpm, &uMsrpmBit);
     874    int rc = CPUMGetSvmMsrpmOffsetAndBit(idMsr, &offMsrpm, &uMsrpmBit);
    875875    AssertRC(rc);
    876876
     
    51455145    const bool        fStrIo        = pIoExitInfo->n.u1Str;
    51465146
    5147     return HMIsSvmIoInterceptActive(pvIoBitmap, u16Port, enmIoType, cbReg, cAddrSizeBits, iEffSeg, fRep, fStrIo,
     5147    return CPUMIsSvmIoInterceptActive(pvIoBitmap, u16Port, enmIoType, cbReg, cAddrSizeBits, iEffSeg, fRep, fStrIo,
    51485148                                      NULL /* pIoExitInfo */);
    51495149}
     
    52375237                uint16_t offMsrpm;
    52385238                uint8_t  uMsrpmBit;
    5239                 int rc = HMGetSvmMsrpmOffsetAndBit(idMsr, &offMsrpm, &uMsrpmBit);
     5239                int rc = CPUMGetSvmMsrpmOffsetAndBit(idMsr, &offMsrpm, &uMsrpmBit);
    52405240                if (RT_SUCCESS(rc))
    52415241                {
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r78370 r78371  
    15501550 *                          include both a read -and- a write permission!
    15511551 *
    1552  * @sa      HMGetVmxMsrPermission.
     1552 * @sa      CPUMGetVmxMsrPermission.
    15531553 * @remarks Can be called with interrupts disabled.
    15541554 */
     
    22072207        if (pVmcsInfo->u32ProcCtls & VMX_PROC_CTLS_USE_MSR_BITMAPS)
    22082208        {
    2209             uint32_t const fMsrpm = HMGetVmxMsrPermission(pVmcsInfo->pvMsrBitmap, pGuestMsrLoad->u32Msr);
     2209            uint32_t const fMsrpm = CPUMGetVmxMsrPermission(pVmcsInfo->pvMsrBitmap, pGuestMsrLoad->u32Msr);
    22102210            if (fIsEferMsr)
    22112211            {
     
    29052905#ifdef VBOX_STRICT
    29062906    Assert(pVmcsInfo->pvMsrBitmap);
    2907     uint32_t const fMsrpmEfer = HMGetVmxMsrPermission(pVmcsInfo->pvMsrBitmap, MSR_K6_EFER);
     2907    uint32_t const fMsrpmEfer = CPUMGetVmxMsrPermission(pVmcsInfo->pvMsrBitmap, MSR_K6_EFER);
    29082908    Assert(fMsrpmEfer == VMXMSRPM_EXIT_RD_WR);
    29092909#endif
     
    1083910839 * @param   pcLoops     Pointer to the number of executed loops.
    1084010840 *
    10841  * @sa      hmR0VmxRunGuestCodeNormal().
     10841 * @sa      hmR0VmxRunGuestCodeNormal.
    1084210842 */
    1084310843static VBOXSTRICTRC hmR0VmxRunGuestCodeNested(PVMCPU pVCpu, uint32_t *pcLoops)
     
    1367113671        {
    1367213672            Assert(pVmcsInfo->pvMsrBitmap);
    13673             uint32_t fMsrpm = HMGetVmxMsrPermission(pVmcsInfo->pvMsrBitmap, idMsr);
     13673            uint32_t fMsrpm = CPUMGetVmxMsrPermission(pVmcsInfo->pvMsrBitmap, idMsr);
    1367413674            if (fMsrpm & VMXMSRPM_ALLOW_RD)
    1367513675            {
     
    1381613816                    {
    1381713817                        Assert(pVmcsInfo->pvMsrBitmap);
    13818                         uint32_t fMsrpm = HMGetVmxMsrPermission(pVmcsInfo->pvMsrBitmap, idMsr);
     13818                        uint32_t fMsrpm = CPUMGetVmxMsrPermission(pVmcsInfo->pvMsrBitmap, idMsr);
    1381913819                        if (fMsrpm & VMXMSRPM_ALLOW_WR)
    1382013820                        {
     
    1487014870 * Hacks its way around the lovely mesa driver's backdoor accesses.
    1487114871 *
    14872  * @sa hmR0SvmHandleMesaDrvGp
     14872 * @sa hmR0SvmHandleMesaDrvGp.
    1487314873 */
    1487414874static int hmR0VmxHandleMesaDrvGp(PVMCPU pVCpu, PVMXTRANSIENT pVmxTransient, PCPUMCTX pCtx)
     
    1489014890 *
    1489114891 * @returns true if it is, false if it isn't.
    14892  * @sa      hmR0SvmIsMesaDrvGp
     14892 * @sa      hmR0SvmIsMesaDrvGp.
    1489314893 */
    1489414894DECLINLINE(bool) hmR0VmxIsMesaDrvGp(PVMCPU pVCpu, PVMXTRANSIENT pVmxTransient, PCPUMCTX pCtx)
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