- Timestamp:
- Apr 18, 2013 5:56:25 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp
r45609 r45617 2806 2806 | X86_CR0_CD /* Bit ignored on VM-entry and VM-exit. Don't let the guest modify the host CR0.CD */ 2807 2807 | X86_CR0_NW; /* Bit ignored on VM-entry and VM-exit. Don't let the guest modify the host CR0.NW */ 2808 2809 /* We don't need to intercept changes to CR0.PE with unrestricted guests. */2810 2808 if (pVM->hm.s.vmx.fUnrestrictedGuest) 2811 2809 u64CR0Mask &= ~X86_CR0_PE; 2810 /* Enable this later. */ 2811 /* if (pVM->hm.s.fNestedPaging) 2812 u64CR0Mask &= ~X86_CR0_WP; */ 2812 2813 2813 2814 /* If the guest FPU state is active, don't need to VM-exit on writes to FPU related bits in CR0. */ … … 2835 2836 if (pVCpu->hm.s.fContextUseFlags & HM_CHANGED_GUEST_CR3) 2836 2837 { 2837 uint64_t u64GuestCR3 = 0;2838 RTGCPHYS GCPhysGuestCR3 = NIL_RTGCPHYS; 2838 2839 if (pVM->hm.s.fNestedPaging) 2839 2840 { … … 2874 2875 /* The guest's view of its CR3 is unblemished with Nested Paging when the guest is using paging or we 2875 2876 have Unrestricted Execution to handle the guest when it's not using paging. */ 2876 u64GuestCR3 = pCtx->cr3;2877 GCPhysGuestCR3 = pCtx->cr3; 2877 2878 } 2878 2879 else … … 2891 2892 AssertRCReturn(rc, rc); 2892 2893 2893 u64GuestCR3 = GCPhys;2894 GCPhysGuestCR3 = GCPhys; 2894 2895 } 2895 2896 } … … 2897 2898 { 2898 2899 /* Non-nested paging case, just use the hypervisor's CR3. */ 2899 u64GuestCR3 = PGMGetHyperCR3(pVCpu);2900 } 2901 2902 Log(("Load: VMX_VMCS_GUEST_CR3=%#R X64\n", u64GuestCR3));2903 rc = VMXWriteVmcsGstN(VMX_VMCS_GUEST_CR3, u64GuestCR3);2900 GCPhysGuestCR3 = PGMGetHyperCR3(pVCpu); 2901 } 2902 2903 Log(("Load: VMX_VMCS_GUEST_CR3=%#RGv\n", GCPhysGuestCR3)); 2904 rc = VMXWriteVmcsGstN(VMX_VMCS_GUEST_CR3, GCPhysGuestCR3); 2904 2905 AssertRCReturn(rc, rc); 2905 2906 … … 2912 2913 if (pVCpu->hm.s.fContextUseFlags & HM_CHANGED_GUEST_CR4) 2913 2914 { 2914 uint64_t u64GuestCR4 = pCtx->cr4; 2915 uint32_t u64GuestCR4 = pCtx->cr4; 2916 Assert(!(pCtx->cr4 >> 32)); 2915 2917 2916 2918 /* The guest's view of its CR4 is unblemished. */ … … 3057 3059 Assert(fInterceptDB == false); /* If we are not single stepping in DBGF, there is no need to intercept #DB. */ 3058 3060 3061 3059 3062 /* 3060 3063 * If the guest is using its DRx registers and the host DRx does not yet contain the guest DRx values, … … 3062 3065 * The same for the hypervisor DRx registers, priority is for the guest here. 3063 3066 */ 3064 if ( (pCtx->dr[7] & (X86_DR7_ENABLED_MASK | X86_DR7_GD)) 3065 && !CPUMIsGuestDebugStateActive(pVCpu)) 3066 { 3067 /* Save the host and load the guest debug registers. This will make the guest debug state active. */ 3068 rc = CPUMR0LoadGuestDebugState(pVM, pVCpu, pCtx, true /* include DR6 */); 3069 AssertRC(rc); 3067 if (pCtx->dr[7] & (X86_DR7_ENABLED_MASK | X86_DR7_GD)) 3068 { 3069 if (!CPUMIsGuestDebugStateActive(pVCpu)) 3070 { 3071 rc = CPUMR0LoadGuestDebugState(pVM, pVCpu, pCtx, true /* include DR6 */); 3072 AssertRC(rc); 3073 STAM_COUNTER_INC(&pVCpu->hm.s.StatDRxArmed); 3074 } 3070 3075 Assert(CPUMIsGuestDebugStateActive(pVCpu)); 3071 3076 Assert(fInterceptMovDRx == false); 3072 STAM_COUNTER_INC(&pVCpu->hm.s.StatDRxArmed);3073 }3074 else if ( CPUMGetHyperDR7(pVCpu) & (X86_DR7_ENABLED_MASK | X86_DR7_GD)3075 &&!CPUMIsHyperDebugStateActive(pVCpu))3076 {3077 /* Save the host and load the hypervisor debug registers. This will make the hyper debug state active. */3078 rc = CPUMR0LoadHyperDebugState(pVM, pVCpu, pCtx, true /* include DR6 */);3079 AssertRC(rc);3077 } 3078 else if (CPUMGetHyperDR7(pVCpu) & (X86_DR7_ENABLED_MASK | X86_DR7_GD)) 3079 { 3080 if (!CPUMIsHyperDebugStateActive(pVCpu)) 3081 { 3082 rc = CPUMR0LoadHyperDebugState(pVM, pVCpu, pCtx, true /* include DR6 */); 3083 AssertRC(rc); 3084 } 3080 3085 Assert(CPUMIsHyperDebugStateActive(pVCpu)); 3081 3086 fInterceptMovDRx = true; 3082 3087 } 3083 else 3084 Assert(fInterceptMovDRx == false); /* No need to intercept MOV DRx if DBGF is not active nor the guest is debugging. */ 3088 else if (!CPUMIsGuestDebugStateActive(pVCpu)) 3089 { 3090 /* For the first time we would need to intercept MOV DRx accesses even when the guest debug state isn't active. */ 3091 fInterceptMovDRx = true; 3092 } 3085 3093 3086 3094 /* Update the exception bitmap regarding intercepting #DB generated by the guest. */ … … 7228 7236 { 7229 7237 VMX_VALIDATE_EXIT_HANDLER_PARAMS(); 7238 PVM pVM = pVCpu->CTX_SUFF(pVM); 7239 Assert(!pVM->hm.s.fNestedPaging); 7240 7230 7241 int rc = hmR0VmxReadExitQualificationVmcs(pVCpu, pVmxTransient); 7231 7242 rc |= hmR0VmxSaveGuestControlRegs(pVCpu, pMixedCtx); 7232 7243 AssertRCReturn(rc, rc); 7233 7244 7234 PVM pVM = pVCpu->CTX_SUFF(pVM);7235 7245 VBOXSTRICTRC rc2 = EMInterpretInvlpg(pVM, pVCpu, CPUMCTX2CORE(pMixedCtx), pVmxTransient->uExitQualification); 7236 7246 rc = VBOXSTRICTRC_VAL(rc2); … … 7241 7251 AssertMsg(rc == VERR_EM_INTERPRETER, ("hmR0VmxExitInvlpg: EMInterpretInvlpg %#RGv failed with %Rrc\n", 7242 7252 pVmxTransient->uExitQualification, rc)); 7243 rc = VERR_EM_INTERPRETER;7244 7253 } 7245 7254 STAM_COUNTER_INC(&pVCpu->hm.s.StatExitInvlpg); … … 8219 8228 && !CPUMIsHyperDebugStateActive(pVCpu)) 8220 8229 { 8221 Assert(!CPUMIsGuestDebugStateActive(pVCpu));8222 8223 8230 /* Don't intercept MOV DRx. */ 8224 8231 pVCpu->hm.s.vmx.u32ProcCtls &= ~VMX_VMCS_CTRL_PROC_EXEC_CONTROLS_MOV_DR_EXIT; … … 8244 8251 } 8245 8252 8246 /** @todo clear VMX_VMCS_CTRL_PROC_EXEC_CONTROLS_MOV_DR_EXIT after the first8247 * time and restore DRx registers afterwards */8248 8253 /* 8249 8254 * EMInterpretDRx[Write|Read]() calls CPUMIsGuestIn64BitCode() which requires EFER, CS. EFER is always up-to-date, see … … 8879 8884 AssertRCReturn(rc, rc); 8880 8885 8881 Log(("#PF: cr2=%#RGv cs:rip=%#04x:%#RGv uErrCode %#RX32 \n", pVmxTransient->uExitQualification, pMixedCtx->cs.Sel,8882 pMixedCtx->rip, pVmxTransient->uExitIntrErrorCode ));8886 Log(("#PF: cr2=%#RGv cs:rip=%#04x:%#RGv uErrCode %#RX32 cr3=%#RGv\n", pVmxTransient->uExitQualification, pMixedCtx->cs.Sel, 8887 pMixedCtx->rip, pVmxTransient->uExitIntrErrorCode, pMixedCtx->cr3)); 8883 8888 8884 8889 TRPMAssertXcptPF(pVCpu, pVmxTransient->uExitQualification, (RTGCUINT)pVmxTransient->uExitIntrErrorCode);
Note:
See TracChangeset
for help on using the changeset viewer.