- Timestamp:
- Aug 3, 2017 6:30:53 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp
r68231 r68262 4165 4165 4166 4166 /* Re-check the nested-guest condition here as we may be transitioning from the normal 4167 execution loop into the nested-guest . */4167 execution loop into the nested-guest, hence this is not placed in the 'else' part above. */ 4168 4168 if (rc == VINF_SVM_VMRUN) 4169 { 4169 4170 rc = hmR0SvmRunGuestCodeNested(pVM, pVCpu, pCtx, &cLoops); 4171 if (rc == VINF_SVM_VMEXIT) 4172 rc = VINF_SUCCESS; 4173 } 4170 4174 #endif 4171 4175 4176 /* Fixup error codes. */ 4172 4177 if (rc == VERR_EM_INTERPRETER) 4173 4178 rc = VINF_EM_RAW_EMULATE_INSTR; … … 4183 4188 4184 4189 #ifdef VBOX_WITH_NESTED_HWVIRT 4190 /** 4191 * Determines whether an IOIO intercept is active for the nested-guest or not. 4192 * 4193 * @param pvIoBitmap Pointer to the nested-guest IO bitmap. 4194 * @param pIoExitInfo Pointer to the SVMIOIOEXITINFO. 4195 */ 4196 static bool hmR0SvmIsIoInterceptActive(void *pvIoBitmap, PSVMIOIOEXITINFO pIoExitInfo) 4197 { 4198 const uint16_t u16Port = pIoExitInfo->n.u16Port; 4199 const SVMIOIOTYPE enmIoType = (SVMIOIOTYPE)pIoExitInfo->n.u1Type; 4200 const uint8_t cbReg = (pIoExitInfo->u >> SVM_IOIO_OP_SIZE_SHIFT) & 7; 4201 const uint8_t cAddrSizeBits = (pIoExitInfo->u >> SVM_IOIO_ADDR_SIZE_SHIFT) << 4; 4202 const uint8_t iEffSeg = pIoExitInfo->n.u3SEG; 4203 const bool fRep = pIoExitInfo->n.u1REP; 4204 const bool fStrIo = pIoExitInfo->n.u1STR; 4205 4206 return HMSvmIsIOInterceptActive(pvIoBitmap, u16Port, enmIoType, cbReg, cAddrSizeBits, iEffSeg, fRep, fStrIo, 4207 NULL /* pIoExitInfo */); 4208 } 4209 4210 4185 4211 /** 4186 4212 * Handles a nested-guest \#VMEXIT (for all EXITCODE values except … … 4217 4243 void *pvIoBitmap = pCtx->hwvirt.svm.CTX_SUFF(pvIoBitmap); 4218 4244 SVMIOIOEXITINFO IoExitInfo; 4219 IoExitInfo.u = (uint32_t)pVmcbNstGst->ctrl.u64ExitInfo1; 4220 bool const fIntercept = HMSvmIsIOInterceptActive(pvIoBitmap, IoExitInfo.n.u16Port, 4221 (SVMIOIOTYPE)IoExitInfo.n.u1Type, 4222 (IoExitInfo.u >> SVM_IOIO_OP_SIZE_SHIFT) & 7, 4223 (IoExitInfo.u >> SVM_IOIO_ADDR_SIZE_SHIFT) << 4, 4224 IoExitInfo.n.u3SEG, IoExitInfo.n.u1REP, IoExitInfo.n.u1STR, 4225 NULL /* pIoExitInfo */); 4245 IoExitInfo.u = pVmcbNstGst->ctrl.u64ExitInfo1; 4246 bool const fIntercept = hmR0SvmIsIoInterceptActive(pvIoBitmap, &IoExitInfo); 4226 4247 if (fIntercept) 4227 4248 return hmR0SvmExecVmexit(pVCpu, pCtx); … … 5404 5425 5405 5426 /** 5427 * Performs an SVM world-switch (VMRUN, \#VMEXIT) updating PGM and HM internals. 5428 * 5429 * @returns VBox status code. 5430 * @param pVCpu The cross context virtual CPU structure. 5431 * @param pCtx The guest-CPU context. 5432 */ 5433 static int hmR0SvmNstGstWorldSwitch(PVMCPU pVCpu, PCPUMCTX pCtx) 5434 { 5435 /** @todo What about informing PGM about CR0.WP? */ 5436 PGMFlushTLB(pVCpu, pCtx->cr3, true /* fGlobal */); 5437 5438 /* Inform CPUM (recompiler), can later be removed. */ 5439 CPUMSetChangedFlags(pVCpu, CPUM_CHANGED_ALL); 5440 5441 /* 5442 * Inform PGM about paging mode changes. 5443 * We include X86_CR0_PE because PGM doesn't handle paged-real mode yet. 5444 */ 5445 return PGMChangeMode(pVCpu, pCtx->cr0 | X86_CR0_PE, pCtx->cr4, pCtx->msrEFER); 5446 } 5447 5448 5449 /** 5406 5450 * Performs a \#VMEXIT that happens during VMRUN emulation in hmR0SvmExecVmrun. 5407 5451 * … … 5448 5492 * Clear our cache of the nested-guest VMCB controls. 5449 5493 */ 5450 PSVMVMCBCTRL pVmcb Ctrl = &pVmcbNstGst->ctrl;5451 memset(pVmcb Ctrl, 0, sizeof(*pVmcbCtrl));5494 PSVMVMCBCTRL pVmcbNstGstCtrl = &pVmcbNstGst->ctrl; 5495 memset(pVmcbNstGstCtrl, 0, sizeof(*pVmcbNstGstCtrl)); 5452 5496 Assert(!CPUMIsGuestInSvmNestedHwVirtMode(pCtx)); 5453 5497 5454 5498 if (RT_SUCCESS(rc)) 5455 return VINF_SVM_VMEXIT; 5499 { 5500 rc = hmR0SvmNstGstWorldSwitch(pVCpu, pCtx); 5501 if (rc == VINF_SUCCESS) 5502 rc = VINF_SVM_VMEXIT; 5503 } 5456 5504 5457 5505 Log(("hmR0SvmExecVmexit: Failed to write guest-VMCB at %#RGp\n", GCPhysVmcb)); … … 5732 5780 pCtx->hwvirt.svm.fGif = 1; 5733 5781 5734 /* 5735 * Inform PGM about paging mode changes. 5736 * We include X86_CR0_PE because PGM doesn't handle paged-real mode yet. 5737 */ 5738 /** @todo What about informing PGM about CR0.WP? */ 5739 PGMFlushTLB(pVCpu, pCtx->cr3, true /* fGlobal */); 5740 5741 int rc = PGMChangeMode(pVCpu, pVmcbNstGstState->u64CR0 | X86_CR0_PE, pVmcbNstGstState->u64CR4, pCtx->msrEFER); 5742 return rc; 5782 return hmR0SvmNstGstWorldSwitch(pVCpu, pCtx); 5743 5783 } 5744 5784
Note:
See TracChangeset
for help on using the changeset viewer.