VirtualBox

Changeset 2896 in vbox


Ignore:
Timestamp:
May 28, 2007 1:35:58 PM (18 years ago)
Author:
vboxsync
Message:

More preparations for emulation of real and protected mode without paging in VMX.

Location:
trunk/src/VBox/VMM
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/HWACCM.cpp

    r2811 r2896  
    115115    memset(pVM->hwaccm.s.vmx.pVMCS, 0, PAGE_SIZE);
    116116
    117     /* Reuse those two pages for AMD SVM. (one is active; never both) */
    118     pVM->hwaccm.s.svm.pHState     = pVM->hwaccm.s.vmx.pVMXON;
    119     pVM->hwaccm.s.svm.pHStatePhys = pVM->hwaccm.s.vmx.pVMXONPhys;
    120     pVM->hwaccm.s.svm.pVMCB       = pVM->hwaccm.s.vmx.pVMCS;
    121     pVM->hwaccm.s.svm.pVMCBPhys   = pVM->hwaccm.s.vmx.pVMCSPhys;
    122 
    123     /* Allocate one page for the SVM host control structure (used for vmsave/vmload). */
    124     pVM->hwaccm.s.svm.pVMCBHost = SUPContAlloc(1, &pVM->hwaccm.s.svm.pVMCBHostPhys);
    125     if (pVM->hwaccm.s.svm.pVMCBHost == 0)
     117    /* Allocate one page for the TSS we need for real mode emulation. */
     118    pVM->hwaccm.s.vmx.pRealModeTSS = (PVBOXTSS)SUPContAlloc(1, &pVM->hwaccm.s.vmx.pRealModeTSSPhys);
     119    if (pVM->hwaccm.s.vmx.pRealModeTSS == 0)
    126120    {
    127121        AssertMsgFailed(("SUPContAlloc failed!!\n"));
    128122        return VERR_NO_MEMORY;
    129123    }
    130     memset(pVM->hwaccm.s.svm.pVMCBHost, 0, PAGE_SIZE);
     124    /* We initialize it properly later as we can reuse it for SVM */
     125    memset(pVM->hwaccm.s.vmx.pRealModeTSS, 0, PAGE_SIZE);
     126
     127    /* Reuse those three pages for AMD SVM. (one is active; never both) */
     128    pVM->hwaccm.s.svm.pHState       = pVM->hwaccm.s.vmx.pVMXON;
     129    pVM->hwaccm.s.svm.pHStatePhys   = pVM->hwaccm.s.vmx.pVMXONPhys;
     130    pVM->hwaccm.s.svm.pVMCB         = pVM->hwaccm.s.vmx.pVMCS;
     131    pVM->hwaccm.s.svm.pVMCBPhys     = pVM->hwaccm.s.vmx.pVMCSPhys;
     132    pVM->hwaccm.s.svm.pVMCBHost     = pVM->hwaccm.s.vmx.pRealModeTSS;
     133    pVM->hwaccm.s.svm.pVMCBHostPhys = pVM->hwaccm.s.vmx.pRealModeTSSPhys;
    131134
    132135    /* Allocate 12 KB for the IO bitmap (doesn't seem to be a way to convince SVM not to use it) */
     
    419422            pVM->hwaccm.s.fInitialized = true;
    420423
     424            /* The I/O bitmap starts right after the virtual interrupt redirection bitmap. Outside the TSS on purpose; the CPU will not check it
     425             * for I/O operations. */
     426            pVM->hwaccm.s.vmx.pRealModeTSS->offIoBitmap = sizeof(*pVM->hwaccm.s.vmx.pRealModeTSS);
     427            /* Bit set to 0 means redirection enabled. */
     428            memset(pVM->hwaccm.s.vmx.pRealModeTSS->IntRedirBitmap, 0x0, sizeof(pVM->hwaccm.s.vmx.pRealModeTSS->IntRedirBitmap));
     429
    421430            int rc = SUPCallVMMR0(pVM->pVMR0, VMMR0_DO_HWACC_SETUP_VM, NULL);
    422431            AssertRC(rc);
     
    524533        pVM->hwaccm.s.vmx.pVMCS = 0;
    525534    }
    526     if (pVM->hwaccm.s.svm.pVMCBHost)
    527     {
    528         SUPContFree(pVM->hwaccm.s.svm.pVMCBHost, 1);
    529         pVM->hwaccm.s.svm.pVMCBHost = 0;
     535    if (pVM->hwaccm.s.vmx.pRealModeTSS)
     536    {
     537        SUPContFree(pVM->hwaccm.s.vmx.pRealModeTSS, 1);
     538        pVM->hwaccm.s.vmx.pRealModeTSS = 0;
    530539    }
    531540    if (pVM->hwaccm.s.svm.pIOBitmap)
     
    595604    /** @note The context supplied by REM is partial. If we add more checks here, be sure to verify that REM provides this info! */
    596605
     606#ifndef HWACCM_VMX_EMULATE_ALL
    597607    /* Too early for VMX. */
    598608    if (pCtx->idtr.pIdt == 0 || pCtx->idtr.cbIdt == 0 || pCtx->tr == 0)
     
    608618    if (!(pCtx->cr0 & X86_CR0_WRITE_PROTECT))
    609619        return false;
     620#endif
    610621
    611622    if (pVM->hwaccm.s.vmx.fEnabled)
     
    613624        /* if bit N is set in cr0_fixed0, then it must be set in the guest's cr0. */
    614625        mask = (uint32_t)pVM->hwaccm.s.vmx.msr.vmx_cr0_fixed0;
    615         /** @note We ignore the NE bit here on purpose; see vmmr0\hwaccmr0.cpp for details. */
     626        /* Note: We ignore the NE bit here on purpose; see vmmr0\hwaccmr0.cpp for details. */
    616627        mask &= ~X86_CR0_NE;
    617 
     628#ifdef HWACCM_VMX_EMULATE_ALL
     629        /* Note: We ignore the PE & PG bits here on purpose; we emulate real and protected mode without paging. */
     630        mask &= ~(X86_CR0_PG|X86_CR0_PE);
     631#endif
    618632        if ((pCtx->cr0 & mask) != mask)
    619633            return false;
     
    638652        return true;
    639653    }
    640 #if 0
    641     else
    642     if (pVM->hwaccm.s.svm.fEnabled)
    643     {
    644         pVM->hwaccm.s.fActive = true;
    645         return true;
    646     }
    647 #endif
    648654
    649655    return false;
  • trunk/src/VBox/VMM/HWACCMInternal.h

    r2811 r2896  
    113113/** @name HWACCM SSM version
    114114 */
    115 #define HWACCM_SSM_VERSION                  2
     115#define HWACCM_SSM_VERSION                  3
    116116
    117117/**
     
    159159        /** Virtual address of the VMXON page. */
    160160        void                       *pVMXON;
     161
     162        /** Physical address of the TSS page used for real mode emulation. */
     163        RTHCPHYS                    pRealModeTSSPhys;
     164        /** Virtual address of the TSS page used for real mode emulation. */
     165        PVBOXTSS                    pRealModeTSS;
    161166
    162167        /** Host CR4 value (set by ring-0 VMX init) */
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