VirtualBox

Changeset 46557 in vbox


Ignore:
Timestamp:
Jun 14, 2013 12:47:59 PM (11 years ago)
Author:
vboxsync
Message:

VMM: AMD-V bits.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/hm_svm.h

    r46551 r46557  
    259259/** MONITOR instruction. */
    260260#define SVM_EXIT_MONITOR                0x8A
    261 /** MWAIT instruction uncond. */
    262 #define SVM_EXIT_MWAIT_UNCOND           0x8B
    263 /** MWAIT instruction when armed. */
     261/** MWAIT instruction. */
     262#define SVM_EXIT_MWAIT                  0x8B
     263/** MWAIT instruction, when armed. */
    264264#define SVM_EXIT_MWAIT_ARMED            0x8C
    265265/** Nested paging: host-level page fault occurred (EXITINFO1 contains fault errorcode; EXITINFO2 contains the guest physical address causing the fault). */
     
    394394#define SVM_CTRL2_INTERCEPT_MONITOR           RT_BIT(10)
    395395/** 11 Intercept MWAIT instruction unconditionally. */
    396 #define SVM_CTRL2_INTERCEPT_MWAIT_UNCOND      RT_BIT(11)
     396#define SVM_CTRL2_INTERCEPT_MWAIT             RT_BIT(11)
    397397/** 12 Intercept MWAIT instruction when armed. */
    398398#define SVM_CTRL2_INTERCEPT_MWAIT_ARMED       RT_BIT(12)
  • trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp

    r46551 r46557  
    575575                                        | SVM_CTRL2_INTERCEPT_WBINVD        /* WBINVD causes a VM-exit. */
    576576                                        | SVM_CTRL2_INTERCEPT_MONITOR       /* MONITOR causes a VM-exit. */
    577                                         | SVM_CTRL2_INTERCEPT_MWAIT_UNCOND; /* MWAIT causes a VM-exit. */
     577                                        | SVM_CTRL2_INTERCEPT_MWAIT;        /* MWAIT causes a VM-exit. */
    578578
    579579        /* CR0, CR4 reads must be intercepted, our shadow values are not necessarily the same as the guest's. */
     
    26322632    switch (pSvmTransient->u64ExitCode)
    26332633    {
     2634        case SVM_EXIT_CPUID:
     2635            return hmR0SvmExitCpuid(pVCpu, pCtx, pSvmTransient);
     2636
     2637        case SVM_EXIT_RDTSC:
     2638            return hmR0SvmExitRdtsc(pVCpu, pCtx, pSvmTransient);
     2639
     2640        case SVM_EXIT_RDTSCP:
     2641            return hmR0SvmExitRdtscp(pVCpu, pCtx, pSvmTransient);
     2642
     2643        case SVM_EXIT_MONITOR:
     2644            return hmR0SvmExitMonitor(pVCpu, pCtx, pSvmTransient);
     2645
     2646        case SVM_EXIT_MWAIT:
     2647            return hmR0SvmExitMwait(pVCpu, pCtx, pSvmTransient);
     2648
    26342649        case SVM_EXIT_WRITE_CR0:
    26352650        case SVM_EXIT_WRITE_CR3:
     
    26572672        case SVM_EXIT_INVD:
    26582673            return hmR0SvmExitInvd(pVCpu, pCtx, pSvmTransient);
     2674
     2675        case SVM_EXIT_RDPMC:
     2676            return hmR0SvmExitRdpmc(pVCpu, pCtx, pSvmTransient);
     2677
     2678        case SVM_EXIT_READ_DR0:     case SVM_EXIT_READ_DR1:     case SVM_EXIT_READ_DR2:     case SVM_EXIT_READ_DR3:
     2679        case SVM_EXIT_READ_DR6:     case SVM_EXIT_READ_DR7:     case SVM_EXIT_READ_DR8:     case SVM_EXIT_READ_DR9:
     2680        case SVM_EXIT_READ_DR10:    case SVM_EXIT_READ_DR11:    case SVM_EXIT_READ_DR12:    case SVM_EXIT_READ_DR13:
     2681        case SVM_EXIT_READ_DR14:    case SVM_EXIT_READ_DR15:
     2682            return hmR0SvmExitReadDRx(pVCpu, pCtx, pSvmTransient);
     2683
     2684        case SVM_EXIT_WRITE_DR0:    case SVM_EXIT_WRITE_DR1:    case SVM_EXIT_WRITE_DR2:    case SVM_EXIT_WRITE_DR3:
     2685        case SVM_EXIT_WRITE_DR6:    case SVM_EXIT_WRITE_DR7:    case SVM_EXIT_WRITE_DR8:    case SVM_EXIT_WRITE_DR9:
     2686        case SVM_EXIT_WRITE_DR10:   case SVM_EXIT_WRITE_DR11:   case SVM_EXIT_WRITE_DR12:   case SVM_EXIT_WRITE_DR13:
     2687        case SVM_EXIT_WRITE_DR14:   case SVM_EXIT_WRITE_DR15:
     2688            return hmR0SvmExitWriteDRx(pVCpu, pCtx, pSvmTransient);
    26592689
    26602690        default:
     
    26702700                return hmR0SvmExitSetPendingXcptUD(pVCpu, pCtx, pSvmTransient);
    26712701
    2672             case SVM_EXIT_MWAIT_ARMED:
    2673             case SVM_EXIT_PAUSE:
    2674             case SVM_EXIT_IDTR_READ:
    2675             case SVM_EXIT_GDTR_READ:
    2676             case SVM_EXIT_LDTR_READ:
    2677             case SVM_EXIT_TR_READ:
    2678             case SVM_EXIT_IDTR_WRITE:
    2679             case SVM_EXIT_GDTR_WRITE:
    2680             case SVM_EXIT_LDTR_WRITE:
    2681             case SVM_EXIT_TR_WRITE:
    2682             case SVM_EXIT_CR0_SEL_WRITE:
    2683             case SVM_EXIT_READ_CR1:     case SVM_EXIT_WRITE_CR1:
    2684             case SVM_EXIT_READ_CR2:     case SVM_EXIT_WRITE_CR2:
    2685             case SVM_EXIT_READ_CR5:     case SVM_EXIT_WRITE_CR5:
    2686             case SVM_EXIT_READ_CR6:     case SVM_EXIT_WRITE_CR6:
    2687             case SVM_EXIT_READ_CR7:     case SVM_EXIT_WRITE_CR7:
    2688             case SVM_EXIT_READ_CR8:
    2689             case SVM_EXIT_READ_CR9:     case SVM_EXIT_WRITE_CR9:
    2690             case SVM_EXIT_READ_CR10:    case SVM_EXIT_WRITE_CR10:
    2691             case SVM_EXIT_READ_CR11:    case SVM_EXIT_WRITE_CR11:
    2692             case SVM_EXIT_READ_CR12:    case SVM_EXIT_WRITE_CR12:
    2693             case SVM_EXIT_READ_CR13:    case SVM_EXIT_WRITE_CR13:
    2694             case SVM_EXIT_READ_CR14:    case SVM_EXIT_WRITE_CR14:
    2695             case SVM_EXIT_READ_CR15:    case SVM_EXIT_WRITE_CR15:
    26962702            default:
    26972703            {
     
    27412747 *
    27422748 * @return VBox status code.
    2743  * @param   pVCpu           Pointer to the VMCPU.
     2749 * @param   pVCpu     hmR0SvmExitReadDRx      Pointer to the VMCPU.
    27442750 * @param   pCpu            Pointer to the disassembler state.
    27452751 * @param   pRegFrame       Pointer to the register frame.
     
    29142920 * #VMEXIT handler for RDTSCP (SVM_EXIT_RDTSCP). Conditional #VMEXIT.
    29152921 */
    2916 HMSVM_EXIT_DECL hmR0SvmExitRdtsc(PVMCPU pVCpu, PCPUMCTX pCtx, PSVMTRANSIENT pSvmTransient)
     2922HMSVM_EXIT_DECL hmR0SvmExitRdtscp(PVMCPU pVCpu, PCPUMCTX pCtx, PSVMTRANSIENT pSvmTransient)
    29172923{
    29182924    HMSVM_VALIDATE_EXIT_HANDLER_PARAMS();
     
    29983004
    29993005/**
    3000  * #VMEXIT handler for MWAIT (SVM_EXIT_MWAIT_UNCOND). Conditional #VMEXIT.
    3001  */
    3002 HMSVM_EXIT_DECL hmR0SvmExitMonitor(PVMCPU pVCpu, PCPUMCTX pCtx, PSVMTRANSIENT pSvmTransient)
     3006 * #VMEXIT handler for MWAIT (SVM_EXIT_MWAIT). Conditional #VMEXIT.
     3007 */
     3008HMSVM_EXIT_DECL hmR0SvmExitMwait(PVMCPU pVCpu, PCPUMCTX pCtx, PSVMTRANSIENT pSvmTransient)
    30033009{
    30043010    HMSVM_VALIDATE_EXIT_HANDLER_PARAMS();
     
    31503156
    31513157
     3158/**
     3159 * #VMEXIT handler for DRx read (SVM_EXIT_READ_DRx). Conditional #VMEXIT.
     3160 */
     3161HMSVM_EXIT_DECL hmR0SvmExitReadDRx(PVMCPU pVCpu, PCPUMCTX pCtx, PSVMTRANSIENT pSvmTransient)
     3162{
     3163    HMSVM_VALIDATE_EXIT_HANDLER_PARAMS();
     3164    STAM_COUNTER_INC(&pVCpu->hm.s.StatExitDRxRead);
     3165
     3166    /* We should -not- get this VM-exit if the guest is debugging. */
     3167    if (CPUMIsGuestDebugStateActive(pVCpu))
     3168    {
     3169        AssertMsgFailed(("hmR0SvmExitReadDRx: Unexpected exit. pVCpu=%p pCtx=%p\n", pVCpu, pCtx));
     3170        return VERR_SVM_UNEXPECTED_EXIT;
     3171    }
     3172
     3173    if (   !DBGFIsStepping(pVCpu)
     3174        && !CPUMIsHyperDebugStateActive(pVCpu))
     3175    {
     3176        /* Don't intercept DRx read and writes. */
     3177        PSVMVMCB pVmcb = (PSVMVMCB)pVCpu->hm.s.svm.pvVmcb;
     3178        pVmcb->ctrl.u16InterceptRdDRx = 0;
     3179        pVmcb->ctrl.u16InterceptWrDRx = 0;
     3180        pVmcb->ctrl.u64VmcbCleanBits &= ~HMSVM_VMCB_CLEAN_INTERCEPTS;
     3181
     3182        /* Save the host & load the guest debug state, restart execution of the MOV DRx instruction. */
     3183        PVM pVM = pVCpu->CTX_SUFF(pVM);
     3184        rc = CPUMR0LoadGuestDebugState(pVM, pVCpu, pCtx, true /* include DR6 */);
     3185        AssertRC(rc);
     3186        Assert(CPUMIsGuestDebugStateActive(pVCpu));
     3187
     3188        STAM_COUNTER_INC(&pVCpu->hm.s.StatDRxContextSwitch);
     3189        return VINF_SUCCESS;
     3190    }
     3191
     3192    /** @todo Decode assist.  */
     3193    int rc = EMInterpretInstruction(pVCpu, CPUMCTX2CORE(pCtx), 0 /* pvFault */);
     3194    if (RT_LIKELY(rc == VINF_SUCCESS))
     3195    {
     3196        /* Not necessary for read accesses but whatever doesn't hurt for now, will be fixed with decode assist. */
     3197        pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_GUEST_DEBUG;
     3198    }
     3199    else
     3200        Assert(c == VERR_EM_INTERPRETER);
     3201    return rc;
     3202}
     3203
     3204
     3205/**
     3206 * #VMEXIT handler for DRx write (SVM_EXIT_WRITE_DRx). Conditional #VMEXIT.
     3207 */
     3208HMSVM_EXIT_DECL hmR0SvmExitWriteDRx(PVMCPU pVCpu, PCPUMCTX pCtx, PSVMTRANSIENT pSvmTransient)
     3209{
     3210    /* For now it's the same since we interpret the instruction anyway. Will change when using of Decode Assist is implemented. */
     3211    int rc = hmR0SvmExitReadDRx(pVCpu, pCtx, pSvmTransient);
     3212    STAM_COUNTER_INC(&pVCpu->hm.s.StatExitDRxWrite);
     3213    STAM_COUNTER_DEC(&pVCpu->hm.s.StatExitDRxRead);
     3214    return rc;
     3215}
     3216
     3217
  • trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp

    r46444 r46557  
    394394                                        | SVM_CTRL2_INTERCEPT_WBINVD
    395395                                        | SVM_CTRL2_INTERCEPT_MONITOR
    396                                         | SVM_CTRL2_INTERCEPT_MWAIT_UNCOND; /* don't execute mwait or else we'll idle inside the
     396                                        | SVM_CTRL2_INTERCEPT_MWAIT;        /* don't execute mwait or else we'll idle inside the
    397397                                                                               guest (host thinks the cpu load is high) */
    398398
     
    26182618        break;
    26192619
    2620     case SVM_EXIT_MWAIT_UNCOND:
     2620    case SVM_EXIT_MWAIT:
    26212621        Log2(("SVM: mwait\n"));
    26222622        STAM_COUNTER_INC(&pVCpu->hm.s.StatExitMwait);
  • trunk/src/VBox/VMM/VMMR3/HM.cpp

    r46379 r46557  
    252252    EXIT_REASON(SVM_EXIT_MSR                ,124, "RDMSR or WRMSR access to protected MSR."),
    253253    EXIT_REASON(SVM_EXIT_TASK_SWITCH        ,125, "Task switch."),
    254     EXIT_REASON(SVM_EXIT_FERR_FREEZE        ,126, "FP legacy handling enabled, and processor is frozen in an x87/mmx instruction waiting for an interrupt"),
     254    EXIT_REASON(SVM_EXIT_FERR_FREEZE        ,126, "Legacy FPU handling enabled; processor is frozen in an x87/mmx instruction waiting for an interrupt"),
    255255    EXIT_REASON(SVM_EXIT_SHUTDOWN           ,127, "Shutdown."),
    256256    EXIT_REASON(SVM_EXIT_VMRUN              ,128, "VMRUN instruction."),
     
    265265    EXIT_REASON(SVM_EXIT_WBINVD             ,137, "WBINVD instruction."),
    266266    EXIT_REASON(SVM_EXIT_MONITOR            ,138, "MONITOR instruction."),
    267     EXIT_REASON(SVM_EXIT_MWAIT_UNCOND       ,139, "MWAIT instruction unconditional."),
     267    EXIT_REASON(SVM_EXIT_MWAIT              ,139, "MWAIT instruction."),
    268268    EXIT_REASON(SVM_EXIT_MWAIT_ARMED        ,140, "MWAIT instruction when armed."),
    269269    EXIT_REASON(SVM_EXIT_NPF                ,1024, "Nested paging: host-level page fault occurred (EXITINFO1 contains fault errorcode; EXITINFO2 contains the guest physical address causing the fault)."),
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