Changeset 47260 in vbox
- Timestamp:
- Jul 19, 2013 1:58:55 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 87389
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp
r47239 r47260 3523 3523 3524 3524 3525 /** 3526 * Advances the guest RIP in the if the NRIP_SAVE feature is supported by the 3527 * CPU, otherwise advances the RIP by @a cb bytes. 3528 * 3529 * @param pVCpu Pointer to the VMCPU. 3530 * @param pCtx Pointer to the guest-CPU context. 3531 * @param cb RIP increment value in bytes. 3532 * 3533 * @remarks Use this function only from #VMEXIT's where the NRIP value is valid 3534 * when NRIP_SAVE is supported by the CPU! 3535 */ 3536 DECLINLINE(void) hmR0SvmUpdateRip(PVMCPU pVCpu, PCPUMCTX pCtx, uint32_t cb) 3537 { 3538 if (pVCpu->CTX_SUFF(pVM)->hm.s.svm.u32Features & AMD_CPUID_SVM_FEATURE_EDX_NRIP_SAVE) 3539 { 3540 PSVMVMCB pVmcb = (PSVMVMCB)pVCpu->hm.s.svm.pvVmcb; 3541 pCtx->rip = pVmcb->ctrl.u64NextRIP; 3542 } 3543 else 3544 pCtx->rip += cb; 3545 } 3546 3547 3525 3548 /* -=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */ 3526 3549 /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #VMEXIT handlers -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */ … … 3564 3587 { 3565 3588 HMSVM_VALIDATE_EXIT_HANDLER_PARAMS(); 3566 pCtx->rip += 2; /* Hardcoded opcode, AMD-V doesn't give us this information. */ 3589 3590 hmR0SvmUpdateRip(pVCpu, pCtx, 2); 3567 3591 STAM_COUNTER_INC(&pVCpu->hm.s.StatExitWbinvd); 3568 3592 return VINF_SUCCESS; … … 3576 3600 { 3577 3601 HMSVM_VALIDATE_EXIT_HANDLER_PARAMS(); 3578 pCtx->rip += 2; /* Hardcoded opcode, AMD-V doesn't give us this information. */ 3602 3603 hmR0SvmUpdateRip(pVCpu, pCtx, 2); 3579 3604 STAM_COUNTER_INC(&pVCpu->hm.s.StatExitInvd); 3580 3605 return VINF_SUCCESS; … … 3591 3616 int rc = EMInterpretCpuId(pVM, pVCpu, CPUMCTX2CORE(pCtx)); 3592 3617 if (RT_LIKELY(rc == VINF_SUCCESS)) 3593 pCtx->rip += 2; /* Hardcoded opcode, AMD-V doesn't give us this information. */3618 hmR0SvmUpdateRip(pVCpu, pCtx, 2); 3594 3619 else 3595 3620 { … … 3612 3637 if (RT_LIKELY(rc == VINF_SUCCESS)) 3613 3638 { 3614 pCtx->rip += 2; /* Hardcoded opcode, AMD-V doesn't give us this information. */3639 hmR0SvmUpdateRip(pVCpu, pCtx, 2); 3615 3640 pSvmTransient->fUpdateTscOffsetting = true; 3616 3641 } … … 3634 3659 if (RT_LIKELY(rc == VINF_SUCCESS)) 3635 3660 { 3636 pCtx->rip += 3; /* Hardcoded opcode, AMD-V doesn't give us this information. */3661 hmR0SvmUpdateRip(pVCpu, pCtx, 3); 3637 3662 pSvmTransient->fUpdateTscOffsetting = true; 3638 3663 } … … 3655 3680 int rc = EMInterpretRdpmc(pVCpu->CTX_SUFF(pVM), pVCpu, CPUMCTX2CORE(pCtx)); 3656 3681 if (RT_LIKELY(rc == VINF_SUCCESS)) 3657 pCtx->rip += 2; /* Hardcoded opcode, AMD-V doesn't give us this information. */3682 hmR0SvmUpdateRip(pVCpu, pCtx, 2); 3658 3683 else 3659 3684 { … … 3689 3714 { 3690 3715 HMSVM_VALIDATE_EXIT_HANDLER_PARAMS(); 3691 pCtx->rip++; /* Hardcoded opcode, AMD-V doesn't give us this information. */3716 hmR0SvmUpdateRip(pVCpu, pCtx, 1); 3692 3717 int rc = EMShouldContinueAfterHalt(pVCpu, pCtx) ? VINF_SUCCESS : VINF_EM_HALT; 3693 3718 STAM_COUNTER_INC(&pVCpu->hm.s.StatExitHlt); … … 3704 3729 int rc = EMInterpretMonitor(pVCpu->CTX_SUFF(pVM), pVCpu, CPUMCTX2CORE(pCtx)); 3705 3730 if (RT_LIKELY(rc == VINF_SUCCESS)) 3706 pCtx->rip += 3; /* Hardcoded opcode, AMD-V doesn't give us this information. */3731 hmR0SvmUpdateRip(pVCpu, pCtx, 3); 3707 3732 else 3708 3733 { … … 3726 3751 || rc == VINF_SUCCESS) 3727 3752 { 3728 pCtx->rip += 3; /* Hardcoded opcode, AMD-V doesn't give us this information. */3753 hmR0SvmUpdateRip(pVCpu, pCtx, 3); 3729 3754 3730 3755 if ( rc == VINF_EM_HALT … … 3842 3867 PVM pVM = pVCpu->CTX_SUFF(pVM); 3843 3868 3844 /** @todo r=ramshankar: This cannot be right if prefixes are involved. When3845 * NRIP_SAVE isn't available we have to disassemble the instruction. */3846 3869 int rc; 3847 3870 if (pVmcb->ctrl.u64ExitInfo1 == SVM_EXIT1_MSR_WRITE) … … 3860 3883 pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_SVM_GUEST_APIC_STATE; 3861 3884 } 3862 pCtx->rip += 2; /* Hardcoded opcode, AMD-V doesn't give us this information. */3885 hmR0SvmUpdateRip(pVCpu, pCtx, 2); 3863 3886 return VINF_SUCCESS; 3864 3887 } 3865 3888 3866 rc = EMInterpretWrmsr(pVM, pVCpu, CPUMCTX2CORE(pCtx)); 3867 if (RT_LIKELY(rc == VINF_SUCCESS)) 3868 pCtx->rip += 2; /* Hardcoded opcode, AMD-V doesn't give us this information. */ 3889 if (pVM->hm.s.svm.u32Features & AMD_CPUID_SVM_FEATURE_EDX_NRIP_SAVE) 3890 { 3891 rc = EMInterpretWrmsr(pVM, pVCpu, CPUMCTX2CORE(pCtx)); 3892 if (RT_LIKELY(rc == VINF_SUCCESS)) 3893 pCtx->rip = pVmcb->ctrl.u64NextRIP; 3894 else 3895 AssertMsg(rc == VERR_EM_INTERPRETER, ("hmR0SvmExitMsr: EMInterpretWrmsr failed rc=%Rrc\n", rc)); 3896 } 3869 3897 else 3870 AssertMsg(rc == VERR_EM_INTERPRETER, ("hmR0SvmExitMsr: EMInterpretWrmsr failed rc=%Rrc\n", rc)); 3898 { 3899 VBOXSTRICTRC rcStrict = EMInterpretInstruction(pVCpu, CPUMCTX2CORE(pCtx), 0 /* pvFault */); 3900 rc = VBOXSTRICTRC_VAL(rcStrict); 3901 if (RT_UNLIKELY(rc != VINF_SUCCESS)) 3902 AssertMsg(rc == VERR_EM_INTERPRETER, ("hmR0SvmExitMsr: WrMsr. EMInterpretInstruction failed rc=%Rrc\n", rc)); 3903 /* RIP updated by EMInterpretInstruction(). */ 3904 } 3871 3905 3872 3906 /* If this is an X2APIC WRMSR access, update the APIC state as well. */ … … 3888 3922 /* MSR Read access. */ 3889 3923 STAM_COUNTER_INC(&pVCpu->hm.s.StatExitRdmsr); 3890 rc = EMInterpretRdmsr(pVM, pVCpu, CPUMCTX2CORE(pCtx)); 3891 if (RT_LIKELY(rc == VINF_SUCCESS)) 3892 pCtx->rip += 2; /* Hardcoded opcode, AMD-V doesn't give us this information. */ 3924 Assert(pVmcb->ctrl.u64ExitInfo1 == SVM_EXIT1_MSR_READ); 3925 3926 if (pVM->hm.s.svm.u32Features & AMD_CPUID_SVM_FEATURE_EDX_NRIP_SAVE) 3927 { 3928 rc = EMInterpretRdmsr(pVM, pVCpu, CPUMCTX2CORE(pCtx)); 3929 if (RT_LIKELY(rc == VINF_SUCCESS)) 3930 pCtx->rip = pVmcb->ctrl.u64NextRIP; 3931 else 3932 AssertMsg(rc == VERR_EM_INTERPRETER, ("hmR0SvmExitMsr: EMInterpretRdmsr failed rc=%Rrc\n", rc)); 3933 } 3893 3934 else 3894 AssertMsg(rc == VERR_EM_INTERPRETER, ("hmR0SvmExitMsr: EMInterpretRdmsr failed rc=%Rrc\n", rc)); 3935 { 3936 VBOXSTRICTRC rcStrict = EMInterpretInstruction(pVCpu, CPUMCTX2CORE(pCtx), 0); 3937 rc = VBOXSTRICTRC_VAL(rcStrict); 3938 if (RT_UNLIKELY(rc != VINF_SUCCESS)) 3939 AssertMsg(rc == VERR_EM_INTERPRETER, ("hmR0SvmExitMsr: RdMsr. EMInterpretInstruction failed rc=%Rrc\n", rc)); 3940 /* RIP updated by EMInterpretInstruction(). */ 3941 } 3895 3942 } 3896 3943
Note:
See TracChangeset
for help on using the changeset viewer.