VirtualBox

Changeset 13048 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Oct 7, 2008 1:33:00 PM (16 years ago)
Author:
vboxsync
Message:

Real and protected mode without paging needs a special identity mapping page table in EPT mode.

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

Legend:

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

    r13025 r13048  
    530530
    531531            /* Allocate three pages for the TSS we need for real mode emulation. (2 page for the IO bitmap) */
    532             rc = PDMR3VMMDevHeapAlloc(pVM, HWACCM_VTX_TSS_SIZE, (RTR3PTR *)&pVM->hwaccm.s.vmx.pRealModeTSS);
     532            rc = PDMR3VMMDevHeapAlloc(pVM, HWACCM_VTX_TOTAL_DEVHEAP_MEM, (RTR3PTR *)&pVM->hwaccm.s.vmx.pRealModeTSS);
    533533            AssertRC(rc);
    534534            if (RT_FAILURE(rc))
     
    543543            memset(pVM->hwaccm.s.vmx.pRealModeTSS + 1, 0, PAGE_SIZE*2);
    544544            *((unsigned char *)pVM->hwaccm.s.vmx.pRealModeTSS + HWACCM_VTX_TSS_SIZE - 2) = 0xff;
     545
     546            /* Construct a 1024 element page directory with 4 MB pages for the identity mapped page table used in
     547             * real and protected mode without paging with EPT.
     548             */
     549            pVM->hwaccm.s.vmx.pRealModeEPTPageTable = (PX86PD)((char *)pVM->hwaccm.s.vmx.pRealModeTSS + PAGE_SIZE * 3);
     550            for (unsigned i=0;i<X86_PG_ENTRIES;i++)
     551            {
     552                pVM->hwaccm.s.vmx.pRealModeEPTPageTable->a[i].u = X86_PDE4M_P | X86_PDE4M_RW | X86_PDE4M_US | X86_PDE4M_A | X86_PDE4M_D | X86_PDE4M_PS | X86_PDE4M_G;
     553                pVM->hwaccm.s.vmx.pRealModeEPTPageTable->a[i].b.u10PageNo  = _4M * i;
     554            }
    545555
    546556            rc = SUPCallVMMR0Ex(pVM->pVMR0, VMMR0_DO_HWACC_SETUP_VM, 0, NULL);
  • trunk/src/VBox/VMM/HWACCMInternal.h

    r13026 r13048  
    125125#define HWACCM_MAX_RESUME_LOOPS             1024
    126126
     127/** Size for the EPT identity page table (1024 4 MB pages to cover the entire address space). */
     128#define HWACCM_EPT_IDENTITY_PG_TABLE_SIZE   PAGE_SIZE
    127129/** Size of the TSS structure + 2 pages for the IO bitmap + end byte. */
    128130#define HWACCM_VTX_TSS_SIZE                 (sizeof(VBOXTSS) + 2*PAGE_SIZE + 1)
     131/** Total guest mapped memory needed. */
     132#define HWACCM_VTX_TOTAL_DEVHEAP_MEM        (HWACCM_EPT_IDENTITY_PG_TABLE_SIZE + HWACCM_VTX_TSS_SIZE)
    129133
    130134/** HWACCM SSM version
     
    235239        /** Virtual address of the TSS page used for real mode emulation. */
    236240        R3PTRTYPE(PVBOXTSS)         pRealModeTSS;
    237 #if HC_ARCH_BITS == 32
    238         uint32_t                    padding2; /**< explicit alignment for 32-bit gcc */
    239 #endif
     241
     242        /** Virtual address of the identity page table used for real mode emulation in EPT mode. */
     243        R3PTRTYPE(PX86PD)           pRealModeEPTPageTable;
    240244
    241245        /** R0 memory object for the virtual APIC mmio cache. */
  • trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp

    r13043 r13048  
    10921092            }
    10931093        }
     1094        else
     1095        if (!(pCtx->cr0 & X86_CR0_PG))
     1096        {
     1097            /* We use 4 MB pages in our identity mapping page table for real and protected mode without paging. */
     1098            val |= X86_CR4_PSE;
     1099        }
    10941100
    10951101#ifdef HWACCM_VMX_EMULATE_REALMODE
     
    11371143            AssertRC(rc);
    11381144
    1139             /* Save the real guest CR3 in VMX_VMCS_GUEST_CR3 */
    1140             val = pCtx->cr3;
     1145            if (!(pCtx->cr0 & X86_CR0_PG))
     1146            {
     1147                RTGCPHYS GCPhys;
     1148
     1149                /* We convert it here every time as pci regions could be reconfigured. */
     1150                rc = PDMVMMDevHeapR3ToGCPhys(pVM, pVM->hwaccm.s.vmx.pRealModeEPTPageTable, &GCPhys);
     1151                AssertRC(rc);
     1152
     1153                /* We use our identity mapping page table here as we need to map guest virtual to guest physical addresses; EPT will
     1154                 * take care of the translation to host physical addresses.
     1155                 */
     1156                val = GCPhys;
     1157            }
     1158            else
     1159            {
     1160                /* Save the real guest CR3 in VMX_VMCS_GUEST_CR3 */
     1161                val = pCtx->cr3;
     1162            }
    11411163        }
    11421164        /* Save our shadow CR3 register. */
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