VirtualBox

Ignore:
Timestamp:
Mar 31, 2015 2:09:10 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
99322
Message:

VMM/GIM: Add hypercall support and KVM spinlock support.

File:
1 edited

Legend:

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

    r55001 r55037  
    296296static FNSVMEXITHANDLER hmR0SvmExitXcptPF;
    297297static FNSVMEXITHANDLER hmR0SvmExitXcptNM;
     298static FNSVMEXITHANDLER hmR0SvmExitXcptUD;
    298299static FNSVMEXITHANDLER hmR0SvmExitXcptMF;
    299300static FNSVMEXITHANDLER hmR0SvmExitXcptDB;
     
    669670    Assert(pVM->hm.s.svm.fSupported);
    670671
     672    pVM->hm.s.fTrapXcptUD             = GIMShouldTrapXcptUD(pVM);
     673    uint32_t const fGimXcptIntercepts = pVM->hm.s.fTrapXcptUD ? RT_BIT(X86_XCPT_UD) : 0;
    671674    for (VMCPUID i = 0; i < pVM->cCpus; i++)
    672675    {
     
    783786        pVmcb->ctrl.u32InterceptCtrl1 |= SVM_CTRL1_INTERCEPT_TASK_SWITCH;
    784787#endif
     788
     789        /* Apply the exceptions intercepts needed by the GIM provider. */
     790        pVmcb->ctrl.u32InterceptException |= fGimXcptIntercepts;
    785791
    786792        /*
     
    34763482            return hmR0SvmExitXcptNM(pVCpu, pCtx, pSvmTransient);
    34773483
     3484        case SVM_EXIT_EXCEPTION_6:  /* X86_XCPT_UD */
     3485            return hmR0SvmExitXcptUD(pVCpu, pCtx, pSvmTransient);
     3486
    34783487        case SVM_EXIT_EXCEPTION_10:  /* X86_XCPT_MF */
    34793488            return hmR0SvmExitXcptMF(pVCpu, pCtx, pSvmTransient);
     
    35823591                case SVM_EXIT_EXCEPTION_4:             /* X86_XCPT_OF */
    35833592                case SVM_EXIT_EXCEPTION_5:             /* X86_XCPT_BR */
    3584                 case SVM_EXIT_EXCEPTION_6:             /* X86_XCPT_UD */
     3593                /* case SVM_EXIT_EXCEPTION_6: */       /* X86_XCPT_UD - Handled above. */
    35853594                /*   SVM_EXIT_EXCEPTION_7: */          /* X86_XCPT_NM - Handled above. */
    35863595                case SVM_EXIT_EXCEPTION_8:             /* X86_XCPT_DF */
     
    36193628                            /** @todo Investigate this later. */
    36203629                            STAM_COUNTER_INC(&pVCpu->hm.s.StatExitGuestBP);
    3621                             break;
    3622 
    3623                         case X86_XCPT_UD:
    3624                             STAM_COUNTER_INC(&pVCpu->hm.s.StatExitGuestUD);
    36253630                            break;
    36263631
     
    41524157    {
    41534158        PSVMVMCB pVmcb = (PSVMVMCB)pVCpu->hm.s.svm.pvVmcb;
     4159        Assert(pVmcb->ctrl.u64NextRIP - pCtx->rip == cb);
    41544160        pCtx->rip = pVmcb->ctrl.u64NextRIP;
    41554161    }
     
    50035009        if (GIMAreHypercallsEnabled(pVCpu))
    50045010            rc = GIMHypercall(pVCpu, pCtx);
    5005     }
    5006 
    5007     if (rc != VINF_SUCCESS)
     5011
     5012        /* If the hypercall changes anything other than guest general-purpose registers,
     5013           we would need to reload the guest changed bits on VM-reentry. */
     5014    }
     5015
     5016    if (RT_SUCCESS(rc))
     5017        hmR0SvmUpdateRip(pVCpu, pCtx, 3);
     5018    else
    50085019        hmR0SvmSetPendingXcptUD(pVCpu);
    50095020    return VINF_SUCCESS;
     
    52025213
    52035214/**
     5215 * #VMEXIT handler for undefined opcode (SVM_EXIT_EXCEPTION_6).
     5216 * Conditional #VMEXIT.
     5217 */
     5218HMSVM_EXIT_DECL hmR0SvmExitXcptUD(PVMCPU pVCpu, PCPUMCTX pCtx, PSVMTRANSIENT pSvmTransient)
     5219{
     5220    HMSVM_VALIDATE_EXIT_HANDLER_PARAMS();
     5221
     5222    HMSVM_CHECK_EXIT_DUE_TO_EVENT_DELIVERY();
     5223
     5224    STAM_COUNTER_INC(&pVCpu->hm.s.StatExitGuestUD);
     5225
     5226    PVM pVM = pVCpu->CTX_SUFF(pVM);
     5227    if (   pVM->hm.s.fTrapXcptUD
     5228        && GIMAreHypercallsEnabled(pVCpu))
     5229    {
     5230        int rc = GIMXcptUD(pVCpu, pCtx);
     5231        if (RT_SUCCESS(rc))
     5232        {
     5233            /* If the exception handler changes anything other than guest general-purpose registers,
     5234               we would need to reload the guest changed bits on VM-reentry. */
     5235            hmR0SvmUpdateRip(pVCpu, pCtx, 3);
     5236            return VINF_SUCCESS;
     5237        }
     5238    }
     5239
     5240    hmR0SvmSetPendingXcptUD(pVCpu);
     5241    return VINF_SUCCESS;
     5242}
     5243
     5244
     5245/**
    52045246 * #VMEXIT handler for math-fault exceptions (SVM_EXIT_EXCEPTION_10).
    52055247 * Conditional #VMEXIT.
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