VirtualBox

Changeset 46594 in vbox for trunk


Ignore:
Timestamp:
Jun 17, 2013 2:35:56 PM (12 years ago)
Author:
vboxsync
Message:

VMM/HMSVMR0: AMD-V bits.

File:
1 edited

Legend:

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

    r46588 r46594  
    101101#define HMSVM_VMCB_CLEAN_NP                     RT_BIT(4)
    102102/** Control registers (CR0, CR3, CR4, EFER). */
    103 #define HMSVM_VMCB_CLEAN_CRX                    RT_BIT(5)
     103#define HMSVM_VMCB_CLEAN_CRX_EFER               RT_BIT(5)
    104104/** Debug registers (DR6, DR7). */
    105105#define HMSVM_VMCB_CLEAN_DRX                    RT_BIT(6)
     
    955955
    956956        pVmcb->guest.u64CR0 = u64GuestCR0;
    957         pVmcb->ctrl.u64VmcbCleanBits &= ~HMSVM_VMCB_CLEAN_CRX;
     957        pVmcb->ctrl.u64VmcbCleanBits &= ~HMSVM_VMCB_CLEAN_CRX_EFER;
    958958        pVCpu->hm.s.fContextUseFlags &= ~HM_CHANGED_GUEST_CR0;
    959959    }
     
    992992            pVmcb->guest.u64CR3 = PGMGetHyperCR3(pVCpu);
    993993
    994         pVmcb->ctrl.u64VmcbCleanBits &= ~HMSVM_VMCB_CLEAN_CRX;
     994        pVmcb->ctrl.u64VmcbCleanBits &= ~HMSVM_VMCB_CLEAN_CRX_EFER;
    995995        pVCpu->hm.s.fContextUseFlags &= HM_CHANGED_GUEST_CR3;
    996996    }
     
    10371037
    10381038        pVmcb->guest.u64CR4 = u64GuestCR4;
    1039         pVmcb->ctrl.u64VmcbCleanBits &= ~HMSVM_VMCB_CLEAN_CRX;
     1039        pVmcb->ctrl.u64VmcbCleanBits &= ~HMSVM_VMCB_CLEAN_CRX_EFER;
    10401040        pVCpu->hm.s.fContextUseFlags &= ~HM_CHANGED_GUEST_CR4;
    10411041    }
     
    11261126     * See AMD spec. 15.5.1 "Basic Operation" | "Canonicalization and Consistency Checks".
    11271127     */
    1128     pVmcb->guest.u64EFER = pCtx->msrEFER | MSR_K6_EFER_SVME;
     1128    if (pVCpu->hm.s.fContextUseFlags & HM_CHANGED_SVM_GUEST_EFER_MSR
     1129    {
     1130        pVmcb->guest.u64EFER = pCtx->msrEFER | MSR_K6_EFER_SVME;
     1131        pVmcb->ctrl.u64VmcbCleanBits &= ~HMSVM_VMCB_CLEAN_CRX_EFER;
     1132        pVCpu->hm.s.fContextUseFlags &= ~HM_CHANGED_SVM_GUEST_EFER_MSR;
     1133    }
    11291134
    11301135    /* 64-bit MSRs. */
     
    11371142    {
    11381143        /* If the guest isn't in 64-bit mode, clear MSR_K6_LME bit from guest EFER otherwise AMD-V expects amd64 shadow paging. */
    1139         pVmcb->guest.u64EFER &= ~MSR_K6_EFER_LME;
    1140     }
     1144        if (pCtx->msrEFER & MSR_K6_EFER_LME)
     1145        {
     1146            pVmcb->guest.u64EFER &= ~MSR_K6_EFER_LME;
     1147            pVmcb->ctrl.u64VmcbCleanBits &= ~HMSVM_VMCB_CLEAN_CRX_EFER;
     1148        }
     1149    }
     1150
    11411151
    11421152    /** @todo The following are used in 64-bit only (SYSCALL/SYSRET) but they might
     
    28852895static int hmR0SvmEmulateMovTpr(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx)
    28862896{
    2887     int rc;
    28882897    Log4(("Emulated VMMCall TPR access replacement at RIP=%RGv\n", pCtx->rip));
    2889 
    28902898    for (;;)
    28912899    {
     
    29002908        {
    29012909            case HMTPRINSTR_READ:
    2902                 rc = PDMApicGetTPR(pVCpu, &u8Tpr, &fPending, NULL /* pu8PendingIrq */);
     2910            {
     2911                int rc = PDMApicGetTPR(pVCpu, &u8Tpr, &fPending, NULL /* pu8PendingIrq */);
    29032912                AssertRC(rc);
    29042913
     
    29072916                pCtx->rip += pPatch->cbOp;
    29082917                break;
     2918            }
    29092919
    29102920            case HMTPRINSTR_WRITE_REG:
    29112921            case HMTPRINSTR_WRITE_IMM:
     2922            {
    29122923                if (pPatch->enmType == HMTPRINSTR_WRITE_REG)
    29132924                {
    29142925                    uint32_t u32Val;
    2915                     rc = DISFetchReg32(CPUMCTX2CORE(pCtx), pPatch->uSrcOperand, &u32Val);
     2926                    int rc = DISFetchReg32(CPUMCTX2CORE(pCtx), pPatch->uSrcOperand, &u32Val);
    29162927                    AssertRC(rc);
    29172928                    u8Tpr = u32Val;
     
    29202931                    u8Tpr = (uint8_t)pPatch->uSrcOperand;
    29212932
    2922                 rc = PDMApicSetTPR(pVCpu, u8Tpr);
    2923                 AssertRC(rc);
     2933                int rc2 = PDMApicSetTPR(pVCpu, u8Tpr);
     2934                AssertRC(rc2);
    29242935                pCtx->rip += pPatch->cbOp;
    29252936                break;
     2937            }
    29262938
    29272939            default:
     
    32473259        rc = EMInterpretWrmsr(pVCpu->CTX_SUFF(pVM), pVCpu, CPUMCTX2CORE(pCtx));
    32483260        AssertMsg(rc == VINF_SUCCESS || rc == VERR_EM_INTERPRETER, ("hmR0SvmExitMsr: EMInterpretWrmsr failed rc=%Rrc\n", rc));
     3261
     3262        if (pCtx->ecx == MSR_K6_EFER)
     3263            pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_SVM_GUEST_EFER_MSR;
    32493264    }
    32503265    else
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