VirtualBox

Changeset 68262 in vbox for trunk


Ignore:
Timestamp:
Aug 3, 2017 6:30:53 AM (7 years ago)
Author:
vboxsync
Message:

VMM/HMSVMR0: Nested Hw.virt bits.

File:
1 edited

Legend:

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

    r68231 r68262  
    41654165
    41664166    /* 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. */
    41684168    if (rc == VINF_SVM_VMRUN)
     4169    {
    41694170        rc = hmR0SvmRunGuestCodeNested(pVM, pVCpu, pCtx, &cLoops);
     4171        if (rc == VINF_SVM_VMEXIT)
     4172            rc = VINF_SUCCESS;
     4173    }
    41704174#endif
    41714175
     4176    /* Fixup error codes. */
    41724177    if (rc == VERR_EM_INTERPRETER)
    41734178        rc = VINF_EM_RAW_EMULATE_INSTR;
     
    41834188
    41844189#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 */
     4196static 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
    41854211/**
    41864212 * Handles a nested-guest \#VMEXIT (for all EXITCODE values except
     
    42174243                void *pvIoBitmap = pCtx->hwvirt.svm.CTX_SUFF(pvIoBitmap);
    42184244                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);
    42264247                if (fIntercept)
    42274248                    return hmR0SvmExecVmexit(pVCpu, pCtx);
     
    54045425
    54055426/**
     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 */
     5433static 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/**
    54065450 * Performs a \#VMEXIT that happens during VMRUN emulation in hmR0SvmExecVmrun.
    54075451 *
     
    54485492     * Clear our cache of the nested-guest VMCB controls.
    54495493     */
    5450     PSVMVMCBCTRL pVmcbCtrl = &pVmcbNstGst->ctrl;
    5451     memset(pVmcbCtrl, 0, sizeof(*pVmcbCtrl));
     5494    PSVMVMCBCTRL pVmcbNstGstCtrl = &pVmcbNstGst->ctrl;
     5495    memset(pVmcbNstGstCtrl, 0, sizeof(*pVmcbNstGstCtrl));
    54525496    Assert(!CPUMIsGuestInSvmNestedHwVirtMode(pCtx));
    54535497
    54545498    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    }
    54565504
    54575505    Log(("hmR0SvmExecVmexit: Failed to write guest-VMCB at %#RGp\n", GCPhysVmcb));
     
    57325780        pCtx->hwvirt.svm.fGif = 1;
    57335781
    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);
    57435783    }
    57445784
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