VirtualBox

Changeset 61605 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jun 9, 2016 8:18:20 AM (9 years ago)
Author:
vboxsync
Message:

VMM/HMSVMR0: Don't try to use NRIP_SAVE feature for #UD #VMEXITs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp

    r61544 r61605  
    42354235}
    42364236
    4237 
    4238 /**
    4239  * Advances the guest RIP in the if the NRIP_SAVE feature is supported by the
    4240  * CPU, otherwise advances the RIP by @a cb bytes.
     4237/**
     4238 * Updates interrupt shadow for the current RIP.
     4239 */
     4240#define HMSVM_UPDATE_INTR_SHADOW(pVCpu, pCtx) \
     4241    do { \
     4242        /* Update interrupt shadow. */ \
     4243        if (   VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_INHIBIT_INTERRUPTS) \
     4244            && pCtx->rip != EMGetInhibitInterruptsPC(pVCpu)) \
     4245            VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INHIBIT_INTERRUPTS); \
     4246    } while (0)
     4247
     4248/**
     4249 * Advances the guest RIP making use of the CPU's NRIP_SAVE feature if
     4250 * supported, otherwise advances the RIP by the number of bytes specified in
     4251 * @a cb.
    42414252 *
    42424253 * @param   pVCpu       The cross context virtual CPU structure.
     
    42454256 *
    42464257 * @remarks Use this function only from \#VMEXIT's where the NRIP value is valid
    4247  *          when NRIP_SAVE is supported by the CPU!
    4248  */
    4249 DECLINLINE(void) hmR0SvmUpdateRip(PVMCPU pVCpu, PCPUMCTX pCtx, uint32_t cb)
     4258 *          when NRIP_SAVE is supported by the CPU, otherwise use
     4259 *          hmR0SvmAdvanceRipDumb!
     4260 */
     4261DECLINLINE(void) hmR0SvmAdvanceRipHwAssist(PVMCPU pVCpu, PCPUMCTX pCtx, uint32_t cb)
    42504262{
    42514263    if (pVCpu->CTX_SUFF(pVM)->hm.s.svm.u32Features & AMD_CPUID_SVM_FEATURE_EDX_NRIP_SAVE)
    42524264    {
    42534265        PSVMVMCB pVmcb = (PSVMVMCB)pVCpu->hm.s.svm.pvVmcb;
     4266        Assert(pVmcb->ctrl.u64NextRIP);
    42544267        Assert(pVmcb->ctrl.u64NextRIP - pCtx->rip == cb);
    42554268        pCtx->rip = pVmcb->ctrl.u64NextRIP;
     
    42584271        pCtx->rip += cb;
    42594272
    4260     /* Update interrupt shadow. */
    4261     if (   VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_INHIBIT_INTERRUPTS)
    4262         && pCtx->rip != EMGetInhibitInterruptsPC(pVCpu))
    4263         VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INHIBIT_INTERRUPTS);
    4264 }
     4273    HMSVM_UPDATE_INTR_SHADOW(pVCpu, pCtx);
     4274}
     4275
     4276
     4277/**
     4278 * Advances the guest RIP by the number of bytes specified in @a cb. This does
     4279 * not make use of any hardware features to determine the instruction length.
     4280 *
     4281 * @param   pVCpu       The cross context virtual CPU structure.
     4282 * @param   pCtx        Pointer to the guest-CPU context.
     4283 * @param   cb          RIP increment value in bytes.
     4284 */
     4285DECLINLINE(void) hmR0SvmAdvanceRipDumb(PVMCPU pVCpu, PCPUMCTX pCtx, uint32_t cb)
     4286{
     4287    pCtx->rip += cb;
     4288    HMSVM_UPDATE_INTR_SHADOW(pVCpu, pCtx);
     4289}
     4290#undef HMSVM_UPDATE_INTR_SHADOW
    42654291
    42664292
     
    43054331    HMSVM_VALIDATE_EXIT_HANDLER_PARAMS();
    43064332
    4307     hmR0SvmUpdateRip(pVCpu, pCtx, 2);
     4333    hmR0SvmAdvanceRipHwAssist(pVCpu, pCtx, 2);
    43084334    STAM_COUNTER_INC(&pVCpu->hm.s.StatExitWbinvd);
    43094335    int rc = VINF_SUCCESS;
     
    43204346    HMSVM_VALIDATE_EXIT_HANDLER_PARAMS();
    43214347
    4322     hmR0SvmUpdateRip(pVCpu, pCtx, 2);
     4348    hmR0SvmAdvanceRipHwAssist(pVCpu, pCtx, 2);
    43234349    STAM_COUNTER_INC(&pVCpu->hm.s.StatExitInvd);
    43244350    int rc = VINF_SUCCESS;
     
    43384364    if (RT_LIKELY(rc == VINF_SUCCESS))
    43394365    {
    4340         hmR0SvmUpdateRip(pVCpu, pCtx, 2);
     4366        hmR0SvmAdvanceRipHwAssist(pVCpu, pCtx, 2);
    43414367        HMSVM_CHECK_SINGLE_STEP(pVCpu, rc);
    43424368    }
     
    43614387    if (RT_LIKELY(rc == VINF_SUCCESS))
    43624388    {
    4363         hmR0SvmUpdateRip(pVCpu, pCtx, 2);
     4389        hmR0SvmAdvanceRipHwAssist(pVCpu, pCtx, 2);
    43644390        pSvmTransient->fUpdateTscOffsetting = true;
    43654391
     
    43864412    if (RT_LIKELY(rc == VINF_SUCCESS))
    43874413    {
    4388         hmR0SvmUpdateRip(pVCpu, pCtx, 3);
     4414        hmR0SvmAdvanceRipHwAssist(pVCpu, pCtx, 3);
    43894415        pSvmTransient->fUpdateTscOffsetting = true;
    43904416        HMSVM_CHECK_SINGLE_STEP(pVCpu, rc);
     
    44094435    if (RT_LIKELY(rc == VINF_SUCCESS))
    44104436    {
    4411         hmR0SvmUpdateRip(pVCpu, pCtx, 2);
     4437        hmR0SvmAdvanceRipHwAssist(pVCpu, pCtx, 2);
    44124438        HMSVM_CHECK_SINGLE_STEP(pVCpu, rc);
    44134439    }
     
    44474473    HMSVM_VALIDATE_EXIT_HANDLER_PARAMS();
    44484474
    4449     hmR0SvmUpdateRip(pVCpu, pCtx, 1);
     4475    hmR0SvmAdvanceRipHwAssist(pVCpu, pCtx, 1);
    44504476    int rc = EMShouldContinueAfterHalt(pVCpu, pCtx) ? VINF_SUCCESS : VINF_EM_HALT;
    44514477    HMSVM_CHECK_SINGLE_STEP(pVCpu, rc);
     
    44664492    if (RT_LIKELY(rc == VINF_SUCCESS))
    44674493    {
    4468         hmR0SvmUpdateRip(pVCpu, pCtx, 3);
     4494        hmR0SvmAdvanceRipHwAssist(pVCpu, pCtx, 3);
    44694495        HMSVM_CHECK_SINGLE_STEP(pVCpu, rc);
    44704496    }
     
    44904516        ||  rc == VINF_SUCCESS)
    44914517    {
    4492         hmR0SvmUpdateRip(pVCpu, pCtx, 3);
     4518        hmR0SvmAdvanceRipHwAssist(pVCpu, pCtx, 3);
    44934519
    44944520        if (   rc == VINF_EM_HALT
     
    46294655                HMCPU_CF_SET(pVCpu, HM_CHANGED_SVM_GUEST_APIC_STATE);
    46304656            }
    4631             hmR0SvmUpdateRip(pVCpu, pCtx, 2);
     4657            hmR0SvmAdvanceRipHwAssist(pVCpu, pCtx, 2);
    46324658            rc = VINF_SUCCESS;
    46334659            HMSVM_CHECK_SINGLE_STEP(pVCpu, rc);
     
    52075233            {
    52085234                if (rcStrict == VINF_SUCCESS)
    5209                     hmR0SvmUpdateRip(pVCpu, pCtx, 3 /* cbInstr */);
     5235                    hmR0SvmAdvanceRipHwAssist(pVCpu, pCtx, 3 /* cbInstr */);
    52105236                else
    52115237                    Assert(   rcStrict == VINF_GIM_HYPERCALL_CONTINUING
     
    54515477        if (rcStrict == VINF_SUCCESS)
    54525478        {
    5453             hmR0SvmUpdateRip(pVCpu, pCtx, cbInstr);
     5479            /* #UD #VMEXIT does not have valid NRIP information, manually advance RIP. See @bugref{7270#c170}. */
     5480            hmR0SvmAdvanceRipDumb(pVCpu, pCtx, cbInstr);
    54545481            rc = VINF_SUCCESS;
    54555482        }
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