VirtualBox

Changeset 12681 in vbox


Ignore:
Timestamp:
Sep 24, 2008 11:51:10 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
36983
Message:

Updates for real and protected mode without paging shadow mode.

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

Legend:

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

    r12417 r12681  
    13791379     * As with the intermediate context, AMD64 uses the PAE PDPT and PDs.
    13801380     */
    1381     pVM->pgm.s.pHC32BitPD    = (PX86PD)MMR3PageAllocLow(pVM);
    1382     pVM->pgm.s.apHCPaePDs[0] = (PX86PDPAE)MMR3PageAlloc(pVM);
    1383     pVM->pgm.s.apHCPaePDs[1] = (PX86PDPAE)MMR3PageAlloc(pVM);
     1381    pVM->pgm.s.pHC32BitPD           = (PX86PD)MMR3PageAllocLow(pVM);
     1382    pVM->pgm.s.apHCPaePDs[0]        = (PX86PDPAE)MMR3PageAlloc(pVM);
     1383    pVM->pgm.s.apHCPaePDs[1]        = (PX86PDPAE)MMR3PageAlloc(pVM);
    13841384    AssertRelease((uintptr_t)pVM->pgm.s.apHCPaePDs[0] + PAGE_SIZE == (uintptr_t)pVM->pgm.s.apHCPaePDs[1]);
    1385     pVM->pgm.s.apHCPaePDs[2] = (PX86PDPAE)MMR3PageAlloc(pVM);
     1385    pVM->pgm.s.apHCPaePDs[2]        = (PX86PDPAE)MMR3PageAlloc(pVM);
    13861386    AssertRelease((uintptr_t)pVM->pgm.s.apHCPaePDs[1] + PAGE_SIZE == (uintptr_t)pVM->pgm.s.apHCPaePDs[2]);
    1387     pVM->pgm.s.apHCPaePDs[3] = (PX86PDPAE)MMR3PageAlloc(pVM);
     1387    pVM->pgm.s.apHCPaePDs[3]        = (PX86PDPAE)MMR3PageAlloc(pVM);
    13881388    AssertRelease((uintptr_t)pVM->pgm.s.apHCPaePDs[2] + PAGE_SIZE == (uintptr_t)pVM->pgm.s.apHCPaePDs[3]);
    1389     pVM->pgm.s.pHCPaePDPT    = (PX86PDPT)MMR3PageAllocLow(pVM);
    1390     pVM->pgm.s.pHCNestedRoot = MMR3PageAllocLow(pVM);
     1389    pVM->pgm.s.pHCPaePDPT           = (PX86PDPT)MMR3PageAllocLow(pVM);
     1390    pVM->pgm.s.pHCNestedRoot        = MMR3PageAllocLow(pVM);
     1391    pVM->pgm.s.pHCNoPaging32BitPD   = (PX86PD)MMR3PageAllocLow(pVM);
    13911392
    13921393    if (    !pVM->pgm.s.pHC32BitPD
     
    13961397        ||  !pVM->pgm.s.apHCPaePDs[3]
    13971398        ||  !pVM->pgm.s.pHCPaePDPT
    1398         ||  !pVM->pgm.s.pHCNestedRoot)
     1399        ||  !pVM->pgm.s.pHCNestedRoot
     1400        ||  !pVM->pgm.s.pHCNoPaging32BitPD)
    13991401    {
    14001402        AssertMsgFailed(("Failed to allocate pages for the intermediate context!\n"));
     
    14031405
    14041406    /* get physical addresses. */
    1405     pVM->pgm.s.HCPhys32BitPD    = MMPage2Phys(pVM, pVM->pgm.s.pHC32BitPD);
     1407    pVM->pgm.s.HCPhys32BitPD      = MMPage2Phys(pVM, pVM->pgm.s.pHC32BitPD);
    14061408    Assert(MMPagePhys2Page(pVM, pVM->pgm.s.HCPhys32BitPD) == pVM->pgm.s.pHC32BitPD);
    1407     pVM->pgm.s.aHCPhysPaePDs[0] = MMPage2Phys(pVM, pVM->pgm.s.apHCPaePDs[0]);
    1408     pVM->pgm.s.aHCPhysPaePDs[1] = MMPage2Phys(pVM, pVM->pgm.s.apHCPaePDs[1]);
    1409     pVM->pgm.s.aHCPhysPaePDs[2] = MMPage2Phys(pVM, pVM->pgm.s.apHCPaePDs[2]);
    1410     pVM->pgm.s.aHCPhysPaePDs[3] = MMPage2Phys(pVM, pVM->pgm.s.apHCPaePDs[3]);
    1411     pVM->pgm.s.HCPhysPaePDPT    = MMPage2Phys(pVM, pVM->pgm.s.pHCPaePDPT);
    1412     pVM->pgm.s.HCPhysNestedRoot = MMPage2Phys(pVM, pVM->pgm.s.pHCNestedRoot);
     1409    pVM->pgm.s.aHCPhysPaePDs[0]         = MMPage2Phys(pVM, pVM->pgm.s.apHCPaePDs[0]);
     1410    pVM->pgm.s.aHCPhysPaePDs[1]         = MMPage2Phys(pVM, pVM->pgm.s.apHCPaePDs[1]);
     1411    pVM->pgm.s.aHCPhysPaePDs[2]         = MMPage2Phys(pVM, pVM->pgm.s.apHCPaePDs[2]);
     1412    pVM->pgm.s.aHCPhysPaePDs[3]         = MMPage2Phys(pVM, pVM->pgm.s.apHCPaePDs[3]);
     1413    pVM->pgm.s.HCPhysPaePDPT            = MMPage2Phys(pVM, pVM->pgm.s.pHCPaePDPT);
     1414    pVM->pgm.s.HCPhysNestedRoot         = MMPage2Phys(pVM, pVM->pgm.s.pHCNestedRoot);
     1415    pVM->pgm.s.HCPhysNoPaging32BitPD    = MMPage2Phys(pVM, pVM->pgm.s.pHCNoPaging32BitPD);
    14131416
    14141417    /*
     
    14181421    ASMMemZero32(pVM->pgm.s.pHCPaePDPT, PAGE_SIZE);
    14191422    ASMMemZero32(pVM->pgm.s.pHCNestedRoot, PAGE_SIZE);
     1423    ASMMemZero32(pVM->pgm.s.pHCNoPaging32BitPD, PAGE_SIZE);
    14201424    for (unsigned i = 0; i < RT_ELEMENTS(pVM->pgm.s.apHCPaePDs); i++)
    14211425    {
     
    29862990                break; /* (no change) */
    29872991
    2988             switch (enmHostMode)
    2989             {
    2990                 case SUPPAGINGMODE_32_BIT:
    2991                 case SUPPAGINGMODE_32_BIT_GLOBAL:
    2992                     enmShadowMode = PGMMODE_32_BIT;
    2993                     enmSwitcher = VMMSWITCHER_32_TO_32;
    2994                     break;
    2995 
    2996                 case SUPPAGINGMODE_PAE:
    2997                 case SUPPAGINGMODE_PAE_NX:
    2998                 case SUPPAGINGMODE_PAE_GLOBAL:
    2999                 case SUPPAGINGMODE_PAE_GLOBAL_NX:
    3000                     enmShadowMode = PGMMODE_PAE;
    3001                     enmSwitcher = VMMSWITCHER_PAE_TO_PAE;
    3002 #ifdef DEBUG_bird
    3003 if (getenv("VBOX_32BIT"))
    3004 {
    3005                     enmShadowMode = PGMMODE_32_BIT;
    3006                     enmSwitcher = VMMSWITCHER_PAE_TO_32;
    3007 }
    3008 #endif
    3009                     break;
    3010 
    3011                 case SUPPAGINGMODE_AMD64:
    3012                 case SUPPAGINGMODE_AMD64_GLOBAL:
    3013                 case SUPPAGINGMODE_AMD64_NX:
    3014                 case SUPPAGINGMODE_AMD64_GLOBAL_NX:
    3015                     enmShadowMode = PGMMODE_PAE;
    3016                     enmSwitcher = VMMSWITCHER_AMD64_TO_PAE;
    3017                     break;
    3018 
    3019                 default: AssertMsgFailed(("enmHostMode=%d\n", enmHostMode)); break;
    3020             }
     2992            /* Always use the 32 bits shadow mode for this case. We never execute real or protected mode without paging code
     2993             * in raw mode.
     2994             */
     2995            enmShadowMode = PGMMODE_32_BIT;
     2996            enmSwitcher = VMMSWITCHER_INVALID;
    30212997            break;
    30222998
  • trunk/src/VBox/VMM/PGMInternal.h

    r12653 r12681  
    12731273 * @{ */
    12741274/** NIL page pool IDX. */
    1275 #define NIL_PGMPOOL_IDX         0
     1275#define NIL_PGMPOOL_IDX             0
    12761276/** The first normal index. */
    1277 #define PGMPOOL_IDX_FIRST_SPECIAL 1
     1277#define PGMPOOL_IDX_FIRST_SPECIAL   1
    12781278/** Page directory (32-bit root). */
    1279 #define PGMPOOL_IDX_PD          1
     1279#define PGMPOOL_IDX_PD              1
    12801280/** The extended PAE page directory (2048 entries, works as root currently). */
    1281 #define PGMPOOL_IDX_PAE_PD      2
     1281#define PGMPOOL_IDX_PAE_PD          2
    12821282/** PAE Page Directory Table 0. */
    1283 #define PGMPOOL_IDX_PAE_PD_0    3
     1283#define PGMPOOL_IDX_PAE_PD_0        3
    12841284/** PAE Page Directory Table 1. */
    1285 #define PGMPOOL_IDX_PAE_PD_1    4
     1285#define PGMPOOL_IDX_PAE_PD_1        4
    12861286/** PAE Page Directory Table 2. */
    1287 #define PGMPOOL_IDX_PAE_PD_2    5
     1287#define PGMPOOL_IDX_PAE_PD_2        5
    12881288/** PAE Page Directory Table 3. */
    1289 #define PGMPOOL_IDX_PAE_PD_3    6
     1289#define PGMPOOL_IDX_PAE_PD_3        6
    12901290/** Page Directory Pointer Table (PAE root, not currently used). */
    1291 #define PGMPOOL_IDX_PDPT        7
     1291#define PGMPOOL_IDX_PDPT            7
    12921292/** AMD64 CR3 level index.*/
    1293 #define PGMPOOL_IDX_AMD64_CR3   8
     1293#define PGMPOOL_IDX_AMD64_CR3       8
    12941294/** Nested paging root.*/
    1295 #define PGMPOOL_IDX_NESTED_ROOT 9
     1295#define PGMPOOL_IDX_NESTED_ROOT     9
    12961296/** The first normal index. */
    1297 #define PGMPOOL_IDX_FIRST       10
     1297#define PGMPOOL_IDX_FIRST           10
    12981298/** The last valid index. (inclusive, 14 bits) */
    1299 #define PGMPOOL_IDX_LAST        0x3fff
     1299#define PGMPOOL_IDX_LAST            0x3fff
    13001300/** @} */
    13011301
     
    19981998    /** @} */
    19991999
     2000    /** @name 32-bit Shadow Paging with guest real or protected mode without paging.
     2001     * @{ */
     2002    /** The 32-Bit PD - HC Ptr. */
     2003    R3R0PTRTYPE(PX86PD)         pHCNoPaging32BitPD;
     2004    /** The Physical Address (HC) of the 32-Bit PD. */
     2005    RTHCPHYS                    HCPhysNoPaging32BitPD;
     2006    /** @} */
     2007   
    20002008    /** @name PAE Shadow Paging
    20012009     * @{ */
  • trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp

    r12674 r12681  
    655655            switch(pVM->hwaccm.s.enmShadowMode)
    656656            {
    657             case PGMMODE_REAL:
    658             case PGMMODE_PROTECTED:     /* Protected mode, no paging. */
    659                 AssertFailed();
    660                 return VERR_PGM_UNSUPPORTED_SHADOW_PAGING_MODE;
    661 
    662657            case PGMMODE_32_BIT:        /* 32-bit paging. */
    663658                break;
     
    678673#endif
    679674
     675            case PGMMODE_REAL:          /* Real mode                 -> emulated using v86 mode */
     676            case PGMMODE_PROTECTED:     /* Protected mode, no paging -> emulated using identity mapping. */
    680677            default:                    /* shut up gcc */
    681678                AssertFailed();
  • trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp

    r12674 r12681  
    803803        if (!(pCtx->cr0 & X86_CR0_PROTECTION_ENABLE))
    804804        {
     805            Assert(pCtx->tr == 0);
    805806            rc |= VMXWriteVMCS(VMX_VMCS_GUEST_TR_LIMIT,         sizeof(*pVM->hwaccm.s.vmx.pRealModeTSS));
    806807            rc |= VMXWriteVMCS(VMX_VMCS_GUEST_TR_BASE,          0);
     808
     809            val = X86_DESC_P | X86_SEL_TYPE_SYS_386_TSS_BUSY;
    807810        }
    808811        else
     
    810813            rc |= VMXWriteVMCS(VMX_VMCS_GUEST_TR_LIMIT,         pCtx->trHid.u32Limit);
    811814            rc |= VMXWriteVMCS(VMX_VMCS_GUEST_TR_BASE,          pCtx->trHid.u64Base);
    812         }
    813         val = pCtx->trHid.Attr.u;
    814 
    815         /* The TSS selector must be busy. */
    816         if ((val & 0xF) == X86_SEL_TYPE_SYS_286_TSS_AVAIL)
    817             val = (val & ~0xF) | X86_SEL_TYPE_SYS_286_TSS_BUSY;
    818         else
    819             /* Default even if no TR selector has been set (otherwise vmlaunch will fail!) */
    820             val = (val & ~0xF) | X86_SEL_TYPE_SYS_386_TSS_BUSY;
     815
     816            val = pCtx->trHid.Attr.u;
     817
     818            /* The TSS selector must be busy. */
     819            if ((val & 0xF) == X86_SEL_TYPE_SYS_286_TSS_AVAIL)
     820                val = (val & ~0xF) | X86_SEL_TYPE_SYS_286_TSS_BUSY;
     821            else
     822                /* Default even if no TR selector has been set (otherwise vmlaunch will fail!) */
     823                val = (val & ~0xF) | X86_SEL_TYPE_SYS_386_TSS_BUSY;
     824        }
    821825
    822826        rc |= VMXWriteVMCS(VMX_VMCS_GUEST_TR_ACCESS_RIGHTS, val);
     
    913917        switch(pVM->hwaccm.s.enmShadowMode)
    914918        {
    915         case PGMMODE_REAL:          /* Real mode                 -> emulated using v86 mode */
    916         case PGMMODE_PROTECTED:     /* Protected mode, no paging -> emulated using identity mapping. */
    917919        case PGMMODE_32_BIT:        /* 32-bit paging. */
    918920            break;
     
    932934            return VERR_PGM_UNSUPPORTED_SHADOW_PAGING_MODE;
    933935#endif
    934         default:                   /* shut up gcc */
     936        case PGMMODE_REAL:          /* Real mode                 -> emulated using v86 mode */
     937        case PGMMODE_PROTECTED:     /* Protected mode, no paging -> emulated using identity mapping. */
     938        default:                    /* shut up gcc */
    935939            AssertFailed();
    936940            return VERR_PGM_UNSUPPORTED_SHADOW_PAGING_MODE;
    937941        }
    938         /* Real mode emulation using v86 mode with CR4.VME (interrupt redirection using the int bitmap in the TSS) */
     942        /* Real mode emulation using v86 mode with CR4.VME (interrupt redirection using the int bitmap in the TSS and VIF support) */
    939943        if (!(pCtx->cr0 & X86_CR0_PROTECTION_ENABLE))
    940944            val |= X86_CR4_VME;
     
    942946        rc |= VMXWriteVMCS(VMX_VMCS_GUEST_CR4,              val);
    943947        Log2(("Guest CR4 %08x\n", val));
    944         /* CR4 flags owned by the host; if the guests attempts to change them, then
     948        /* All CR4 flags owned by the host; if the guests attempts to change them, then
    945949         * the VM will exit.
    946950         */
    947         val =   X86_CR4_PAE
    948               | X86_CR4_PGE
    949               | X86_CR4_PSE
    950               | X86_CR4_VMXE;
    951         pVM->hwaccm.s.vmx.cr4_mask = val;
    952 
    953         rc |= VMXWriteVMCS(VMX_VMCS_CTRL_CR4_MASK, val);
     951        pVM->hwaccm.s.vmx.cr4_mask = ~0;
     952
     953        rc |= VMXWriteVMCS(VMX_VMCS_CTRL_CR4_MASK, pVM->hwaccm.s.vmx.cr4_mask);
    954954        Log2(("Guest CR4-mask %08x\n", val));
    955955        AssertRC(rc);
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette