Changeset 93927 in vbox
- Timestamp:
- Feb 24, 2022 3:28:28 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/VMXAllTemplate.cpp.h
r93926 r93927 10232 10232 10233 10233 PVMXVMCSINFO pVmcsInfo = pVmxTransient->pVmcsInfo; 10234 int rc = vmxHCImportGuestState(pVCpu, pVmcsInfo, IEM_CPUMCTX_EXTRN_MUST_MASK); 10235 AssertRCReturn(rc, rc); 10236 10237 vmxHCReadExitQualVmcs(pVCpu, pVmxTransient); 10238 vmxHCReadExitInstrLenVmcs(pVCpu, pVmxTransient); 10239 vmxHCReadGuestPhysicalAddrVmcs(pVCpu, pVmxTransient); 10240 10241 RTGCPHYS const GCPhysNested = pVmxTransient->uGuestPhysicalAddr; 10242 uint64_t const uExitQual = pVmxTransient->uExitQual; 10243 10244 RTGCPTR GCPtrNested; 10245 bool const fIsLinearAddrValid = RT_BOOL(uExitQual & VMX_EXIT_QUAL_EPT_LINEAR_ADDR_VALID); 10246 if (fIsLinearAddrValid) 10247 { 10248 vmxHCReadGuestLinearAddrVmcs(pVCpu, pVmxTransient); 10249 GCPtrNested = pVmxTransient->uGuestLinearAddr; 10250 } 10251 else 10252 GCPtrNested = 0; 10253 10254 RTGCUINT const uErr = ((uExitQual & VMX_EXIT_QUAL_EPT_ACCESS_INSTR_FETCH) ? X86_TRAP_PF_ID : 0) 10255 | ((uExitQual & VMX_EXIT_QUAL_EPT_ACCESS_WRITE) ? X86_TRAP_PF_RW : 0) 10256 | ((uExitQual & ( VMX_EXIT_QUAL_EPT_ENTRY_READ 10257 | VMX_EXIT_QUAL_EPT_ENTRY_WRITE 10258 | VMX_EXIT_QUAL_EPT_ENTRY_EXECUTE)) ? X86_TRAP_PF_P : 0); 10259 10260 PGMPTWALK Walk; 10261 PCPUMCTX pCtx = &pVCpu->cpum.GstCtx; 10262 VBOXSTRICTRC rcStrict = PGMR0NestedTrap0eHandlerNestedPaging(pVCpu, PGMMODE_EPT, uErr, CPUMCTX2CORE(pCtx), GCPhysNested, 10263 fIsLinearAddrValid, GCPtrNested, &Walk); 10264 if (RT_SUCCESS(rcStrict)) 10265 { 10266 if (rcStrict == VINF_SUCCESS) 10267 ASMAtomicUoOrU64(&VCPU_2_VMXSTATE(pVCpu).fCtxChanged, HM_CHANGED_GUEST_RIP | HM_CHANGED_GUEST_RFLAGS); 10268 else if (rcStrict == VINF_IEM_RAISED_XCPT) 10269 { 10270 ASMAtomicUoOrU64(&VCPU_2_VMXSTATE(pVCpu).fCtxChanged, HM_CHANGED_RAISED_XCPT_MASK); 10271 rcStrict = VINF_SUCCESS; 10272 } 10273 return rcStrict; 10274 } 10275 10276 vmxHCReadIdtVectoringInfoVmcs(pVCpu, pVmxTransient); 10277 vmxHCReadIdtVectoringErrorCodeVmcs(pVCpu, pVmxTransient); 10278 10279 VMXVEXITEVENTINFO ExitEventInfo; 10280 RT_ZERO(ExitEventInfo); 10281 ExitEventInfo.uIdtVectoringInfo = pVmxTransient->uIdtVectoringInfo; 10282 ExitEventInfo.uIdtVectoringErrCode = pVmxTransient->uIdtVectoringErrorCode; 10283 10284 if (Walk.fFailed & PGM_WALKFAIL_EPT_VIOLATION) 10285 { 10286 VMXVEXITINFO ExitInfo; 10287 RT_ZERO(ExitInfo); 10288 ExitInfo.uReason = VMX_EXIT_EPT_VIOLATION; 10289 ExitInfo.cbInstr = pVmxTransient->cbExitInstr; 10290 ExitInfo.u64Qual = pVmxTransient->uExitQual; 10291 ExitInfo.u64GuestLinearAddr = pVmxTransient->uGuestLinearAddr; 10292 ExitInfo.u64GuestPhysAddr = pVmxTransient->uGuestPhysicalAddr; 10293 return IEMExecVmxVmexitEptViolation(pVCpu, &ExitInfo, &ExitEventInfo); 10294 } 10295 10296 Assert(Walk.fFailed & PGM_WALKFAIL_EPT_MISCONFIG); 10297 return IEMExecVmxVmexitEptMisconfig(pVCpu, pVmxTransient->uGuestPhysicalAddr, &ExitEventInfo); 10234 PVMXVMCSINFO pVmcsInfo = pVmxTransient->pVmcsInfo; 10235 if (CPUMIsGuestVmxProcCtls2Set(&pVCpu->cpum.GstCtx, VMX_PROC_CTLS2_EPT)) 10236 { 10237 int rc = vmxHCImportGuestState(pVCpu, pVmcsInfo, IEM_CPUMCTX_EXTRN_MUST_MASK); 10238 AssertRCReturn(rc, rc); 10239 10240 vmxHCReadExitQualVmcs(pVCpu, pVmxTransient); 10241 vmxHCReadExitInstrLenVmcs(pVCpu, pVmxTransient); 10242 vmxHCReadGuestPhysicalAddrVmcs(pVCpu, pVmxTransient); 10243 10244 RTGCPHYS const GCPhysNested = pVmxTransient->uGuestPhysicalAddr; 10245 uint64_t const uExitQual = pVmxTransient->uExitQual; 10246 10247 RTGCPTR GCPtrNested; 10248 bool const fIsLinearAddrValid = RT_BOOL(uExitQual & VMX_EXIT_QUAL_EPT_LINEAR_ADDR_VALID); 10249 if (fIsLinearAddrValid) 10250 { 10251 vmxHCReadGuestLinearAddrVmcs(pVCpu, pVmxTransient); 10252 GCPtrNested = pVmxTransient->uGuestLinearAddr; 10253 } 10254 else 10255 GCPtrNested = 0; 10256 10257 RTGCUINT const uErr = ((uExitQual & VMX_EXIT_QUAL_EPT_ACCESS_INSTR_FETCH) ? X86_TRAP_PF_ID : 0) 10258 | ((uExitQual & VMX_EXIT_QUAL_EPT_ACCESS_WRITE) ? X86_TRAP_PF_RW : 0) 10259 | ((uExitQual & ( VMX_EXIT_QUAL_EPT_ENTRY_READ 10260 | VMX_EXIT_QUAL_EPT_ENTRY_WRITE 10261 | VMX_EXIT_QUAL_EPT_ENTRY_EXECUTE)) ? X86_TRAP_PF_P : 0); 10262 10263 PGMPTWALK Walk; 10264 PCPUMCTX pCtx = &pVCpu->cpum.GstCtx; 10265 VBOXSTRICTRC rcStrict = PGMR0NestedTrap0eHandlerNestedPaging(pVCpu, PGMMODE_EPT, uErr, CPUMCTX2CORE(pCtx), GCPhysNested, 10266 fIsLinearAddrValid, GCPtrNested, &Walk); 10267 if (RT_SUCCESS(rcStrict)) 10268 { 10269 if (rcStrict == VINF_SUCCESS) 10270 ASMAtomicUoOrU64(&VCPU_2_VMXSTATE(pVCpu).fCtxChanged, HM_CHANGED_GUEST_RIP | HM_CHANGED_GUEST_RFLAGS); 10271 else if (rcStrict == VINF_IEM_RAISED_XCPT) 10272 { 10273 ASMAtomicUoOrU64(&VCPU_2_VMXSTATE(pVCpu).fCtxChanged, HM_CHANGED_RAISED_XCPT_MASK); 10274 rcStrict = VINF_SUCCESS; 10275 } 10276 return rcStrict; 10277 } 10278 10279 vmxHCReadIdtVectoringInfoVmcs(pVCpu, pVmxTransient); 10280 vmxHCReadIdtVectoringErrorCodeVmcs(pVCpu, pVmxTransient); 10281 10282 VMXVEXITEVENTINFO ExitEventInfo; 10283 RT_ZERO(ExitEventInfo); 10284 ExitEventInfo.uIdtVectoringInfo = pVmxTransient->uIdtVectoringInfo; 10285 ExitEventInfo.uIdtVectoringErrCode = pVmxTransient->uIdtVectoringErrorCode; 10286 10287 if (Walk.fFailed & PGM_WALKFAIL_EPT_VIOLATION) 10288 { 10289 VMXVEXITINFO ExitInfo; 10290 RT_ZERO(ExitInfo); 10291 ExitInfo.uReason = VMX_EXIT_EPT_VIOLATION; 10292 ExitInfo.cbInstr = pVmxTransient->cbExitInstr; 10293 ExitInfo.u64Qual = pVmxTransient->uExitQual; 10294 ExitInfo.u64GuestLinearAddr = pVmxTransient->uGuestLinearAddr; 10295 ExitInfo.u64GuestPhysAddr = pVmxTransient->uGuestPhysicalAddr; 10296 return IEMExecVmxVmexitEptViolation(pVCpu, &ExitInfo, &ExitEventInfo); 10297 } 10298 10299 Assert(Walk.fFailed & PGM_WALKFAIL_EPT_MISCONFIG); 10300 return IEMExecVmxVmexitEptMisconfig(pVCpu, pVmxTransient->uGuestPhysicalAddr, &ExitEventInfo); 10301 } 10302 10303 return vmxHCExitEptViolation(pVCpu, pVmxTransient); 10298 10304 } 10299 10305 … … 10309 10315 10310 10316 PVMXVMCSINFO pVmcsInfo = pVmxTransient->pVmcsInfo; 10311 int rc = vmxHCImportGuestState(pVCpu, pVmcsInfo, IEM_CPUMCTX_EXTRN_MUST_MASK); 10312 AssertRCReturn(rc, rc); 10313 10314 vmxHCReadGuestPhysicalAddrVmcs(pVCpu, pVmxTransient); 10315 10316 PGMPTWALK Walk; 10317 PCPUMCTX pCtx = &pVCpu->cpum.GstCtx; 10318 RTGCPHYS const GCPhysNested = pVmxTransient->uGuestPhysicalAddr; 10319 VBOXSTRICTRC rcStrict = PGMR0NestedTrap0eHandlerNestedPaging(pVCpu, PGMMODE_EPT, X86_TRAP_PF_RSVD, CPUMCTX2CORE(pCtx), 10320 GCPhysNested, false /* fIsLinearAddrValid */, 10321 0 /* GCPtrNested*/, &Walk); 10322 if (RT_SUCCESS(rcStrict)) 10323 return VINF_EM_RAW_EMULATE_INSTR; 10324 10325 vmxHCReadIdtVectoringInfoVmcs(pVCpu, pVmxTransient); 10326 vmxHCReadIdtVectoringErrorCodeVmcs(pVCpu, pVmxTransient); 10327 10328 VMXVEXITEVENTINFO ExitEventInfo; 10329 RT_ZERO(ExitEventInfo); 10330 ExitEventInfo.uIdtVectoringInfo = pVmxTransient->uIdtVectoringInfo; 10331 ExitEventInfo.uIdtVectoringErrCode = pVmxTransient->uIdtVectoringErrorCode; 10332 10333 return IEMExecVmxVmexitEptMisconfig(pVCpu, pVmxTransient->uGuestPhysicalAddr, &ExitEventInfo); 10317 if (CPUMIsGuestVmxProcCtls2Set(&pVCpu->cpum.GstCtx, VMX_PROC_CTLS2_EPT)) 10318 { 10319 int rc = vmxHCImportGuestState(pVCpu, pVmcsInfo, IEM_CPUMCTX_EXTRN_MUST_MASK); 10320 AssertRCReturn(rc, rc); 10321 10322 vmxHCReadGuestPhysicalAddrVmcs(pVCpu, pVmxTransient); 10323 10324 PGMPTWALK Walk; 10325 PCPUMCTX pCtx = &pVCpu->cpum.GstCtx; 10326 RTGCPHYS const GCPhysNested = pVmxTransient->uGuestPhysicalAddr; 10327 VBOXSTRICTRC rcStrict = PGMR0NestedTrap0eHandlerNestedPaging(pVCpu, PGMMODE_EPT, X86_TRAP_PF_RSVD, CPUMCTX2CORE(pCtx), 10328 GCPhysNested, false /* fIsLinearAddrValid */, 10329 0 /* GCPtrNested*/, &Walk); 10330 if (RT_SUCCESS(rcStrict)) 10331 return VINF_EM_RAW_EMULATE_INSTR; 10332 10333 vmxHCReadIdtVectoringInfoVmcs(pVCpu, pVmxTransient); 10334 vmxHCReadIdtVectoringErrorCodeVmcs(pVCpu, pVmxTransient); 10335 10336 VMXVEXITEVENTINFO ExitEventInfo; 10337 RT_ZERO(ExitEventInfo); 10338 ExitEventInfo.uIdtVectoringInfo = pVmxTransient->uIdtVectoringInfo; 10339 ExitEventInfo.uIdtVectoringErrCode = pVmxTransient->uIdtVectoringErrorCode; 10340 10341 return IEMExecVmxVmexitEptMisconfig(pVCpu, pVmxTransient->uGuestPhysicalAddr, &ExitEventInfo); 10342 } 10343 10344 return vmxHCExitEptMisconfig(pVCpu, pVmxTransient); 10334 10345 } 10335 10346 # endif /* VBOX_WITH_NESTED_HWVIRT_VMX_EPT */
Note:
See TracChangeset
for help on using the changeset viewer.