VirtualBox

Changeset 14979 in vbox for trunk/src


Ignore:
Timestamp:
Dec 4, 2008 1:14:29 PM (16 years ago)
Author:
vboxsync
Message:

Switcher fixes

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

Legend:

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

    r14755 r14979  
    761761    PPGM pPGM = &pVM->pgm.s;
    762762
    763     /* If mappings are not supposed to be put in the shadow page table, then this function is a nop. */
    764     if (!pgmMapAreMappingsEnabled(&pVM->pgm.s))
    765         return;
    766 
    767     Assert(PGMGetGuestMode(pVM) <= PGMMODE_PAE_NX);
     763    Assert(!pgmMapAreMappingsEnabled(&pVM->pgm.s) || PGMGetGuestMode(pVM) <= PGMMODE_PAE_NX);
    768764
    769765    /*
     
    780776         */
    781777#ifndef VBOX_WITH_PGMPOOL_PAGING_ONLY
    782         if (pPGM->pShw32BitPdR3->a[iNewPDE].n.u1Present)
     778        if (   pgmMapAreMappingsEnabled(&pVM->pgm.s)
     779            && pPGM->pShw32BitPdR3->a[iNewPDE].n.u1Present)
    783780            pgmPoolFree(pVM, pPGM->pShw32BitPdR3->a[iNewPDE].u & X86_PDE_PG_MASK, PGMPOOL_IDX_PD, iNewPDE);
    784781#endif
     
    788785        pPGM->pInterPD->a[iNewPDE]        = Pde;
    789786#ifndef VBOX_WITH_PGMPOOL_PAGING_ONLY
    790         pPGM->pShw32BitPdR3->a[iNewPDE]   = Pde;
     787        if (pgmMapAreMappingsEnabled(&pVM->pgm.s))
     788            pPGM->pShw32BitPdR3->a[iNewPDE]   = Pde;
    791789#endif
    792790        /*
     
    796794        unsigned iPDE = iNewPDE * 2 % 512;
    797795#ifndef VBOX_WITH_PGMPOOL_PAGING_ONLY
    798         if (pPGM->apShwPaePDsR3[iPD]->a[iPDE].n.u1Present)
     796        if (   pgmMapAreMappingsEnabled(&pVM->pgm.s)
     797            && pPGM->apShwPaePDsR3[iPD]->a[iPDE].n.u1Present)
    799798            pgmPoolFree(pVM, pPGM->apShwPaePDsR3[iPD]->a[iPDE].u & X86_PDE_PAE_PG_MASK, PGMPOOL_IDX_PAE_PD, iNewPDE * 2);
    800799#endif
     
    803802        pPGM->apInterPaePDs[iPD]->a[iPDE] = PdePae0;
    804803#ifndef VBOX_WITH_PGMPOOL_PAGING_ONLY
    805         pPGM->apShwPaePDsR3[iPD]->a[iPDE] = PdePae0;
     804        if (pgmMapAreMappingsEnabled(&pVM->pgm.s))
     805            pPGM->apShwPaePDsR3[iPD]->a[iPDE] = PdePae0;
    806806#endif
    807807        iPDE++;
    808808#ifndef VBOX_WITH_PGMPOOL_PAGING_ONLY
    809         if (pPGM->apShwPaePDsR3[iPD]->a[iPDE].n.u1Present)
     809        if (   pgmMapAreMappingsEnabled(&pVM->pgm.s)
     810            && pPGM->apShwPaePDsR3[iPD]->a[iPDE].n.u1Present)
    810811            pgmPoolFree(pVM, pPGM->apShwPaePDsR3[iPD]->a[iPDE].u & X86_PDE_PAE_PG_MASK, PGMPOOL_IDX_PAE_PD, iNewPDE * 2 + 1);
    811812#endif
     
    814815        pPGM->apInterPaePDs[iPD]->a[iPDE] = PdePae1;
    815816#ifndef VBOX_WITH_PGMPOOL_PAGING_ONLY
    816         pPGM->apShwPaePDsR3[iPD]->a[iPDE] = PdePae1;
    817 
    818         /* Set the PGM_PDFLAGS_MAPPING flag in the page directory pointer entry. (legacy PAE guest mode) */
    819         pPGM->pShwPaePdptR3->a[iPD].u |= PGM_PLXFLAGS_MAPPING;
     817        if (pgmMapAreMappingsEnabled(&pVM->pgm.s))
     818        {
     819            pPGM->apShwPaePDsR3[iPD]->a[iPDE] = PdePae1;
     820
     821            /* Set the PGM_PDFLAGS_MAPPING flag in the page directory pointer entry. (legacy PAE guest mode) */
     822            pPGM->pShwPaePdptR3->a[iPD].u |= PGM_PLXFLAGS_MAPPING;
     823        }
    820824#endif
    821825    }
  • trunk/src/VBox/VMM/VMMSwitcher.cpp

    r14845 r14979  
    615615            {
    616616                Assert(offSrc < pSwitcher->cbCode);
    617 #if defined(RT_OS_DARWIN) && defined(VBOX_WITH_HYBIRD_32BIT_KERNEL)
     617# if defined(RT_OS_DARWIN) && defined(VBOX_WITH_HYBIRD_32BIT_KERNEL)
    618618                *uSrc.pu16 = 0x80; /* KERNEL64_CS from i386/seg.h */
    619 #else
     619# else
    620620                AssertFatalMsgFailed(("FIX_HC_64BIT_CS not implemented for this host\n"));
    621 #endif
     621# endif
     622                break;
     623            }
     624
     625            /*
     626             * 64-bit HC pointer to the CPUM instance data (no argument).
     627             */
     628            case FIX_HC_64BIT_CPUM:
     629            {
     630                Assert(offSrc < pSwitcher->cbCode);
     631                *uSrc.pu64 = pVM->pVMR0 + RT_OFFSETOF(VM, cpum);
    622632                break;
    623633            }
     
    635645            }
    636646
    637             /*
    638              * 64-bit HC pointer to the CPUM instance data (no argument).
    639              */
    640             case FIX_HC_64BIT_CPUM:
    641             {
    642                 Assert(offSrc < pSwitcher->cbCode);
    643                 *uSrc.pu64 = pVM->pVMR0 + RT_OFFSETOF(VM, cpum);
    644                 break;
    645             }
     647#if defined(RT_ARCH_X86) && defined(VBOX_WITH_64_BITS_GUESTS)
     648            case FIX_GC_64_BIT_CPUM_OFF:
     649            {
     650                uint32_t offCPUM = *u.pu32++;
     651                Assert(offCPUM < sizeof(pVM->cpum));
     652                *uSrc.pu64 = (uint32_t)(VM_RC_ADDR(pVM, &pVM->cpum) + offCPUM);
     653                break;
     654            }
     655#endif
    646656
    647657            /*
  • trunk/src/VBox/VMM/VMMSwitcher/AMD64andLegacy.mac

    r14254 r14979  
    388388    DEBUG_CHAR('4')
    389389
    390     ; 3. Load 32-bit intermediate page table.
     390    ; 3. Load intermediate page table.
    391391    FIXUP SWITCHER_FIX_INTER_CR3_GC, 1
    392392    mov     edx, 0ffffffffh
  • trunk/src/VBox/VMM/VMMSwitcher/LegacyandAMD64.mac

    r14900 r14979  
    151151
    152152    CPUM_FROM_CPUMCPU(edx)
    153     ; Load new gdt so we can do far jump after going into 64 bits mode
     153    ; Load new gdt so we can do a far jump after going into 64 bits mode
    154154    lgdt    [edx + CPUM.Hyper.gdtr]
    155155
     
    224224; 64-bit pCpum address.
    225225NAME(pCpumIC):
    226 FIXUP FIX_HC_64BIT_CPUM, 0
     226FIXUP FIX_GC_64_BIT_CPUM_OFF, 0, 0
    227227dq 0ffffffffffffffffh
    228228
     
    234234    ; Load CPUM pointer into rdx
    235235    mov     rdx, [NAME(pCpumIC) wrt rip]
    236    
     236
    237237    mov     rax, cs
    238238    mov     ds, rax
    239239    mov     es, rax
    240     mov     fs, rax
    241     mov     gs, rax
    242    
     240   
    243241    ; Setup stack; use the lss_esp, ss pair for lss
    244     DEBUG_CHAR('7')
    245     mov     rsp, 0
    246     mov     eax, [rdx + CPUM.Hyper.esp]
    247     mov     [rdx + CPUM.Hyper.lss_esp], eax
    248     lss     esp, [rdx + CPUM.Hyper.lss_esp]
     242;;    DEBUG_CHAR('7')
     243;;    mov     rsp, 0
     244;;    mov     eax, [rdx + CPUM.Hyper.esp]
     245;;    mov     [rdx + CPUM.Hyper.lss_esp], eax
     246;;    lss     esp, [rdx + CPUM.Hyper.lss_esp]
    249247
    250248    ; call the hypervisor function with rdx=pCpumCpu
    251     mov     eax, [rdx + r8 + CPUM.Hyper.eip]
    252     CPUMCPU_FROM_CPUM(rdx)   
    253     call    rax
     249;;    mov     eax, [rdx + r8 + CPUM.Hyper.eip]
     250;;    CPUMCPU_FROM_CPUM(rdx)   
     251;;    call    rax
    254252   
    255253    ; Load CPUM pointer into rdx
    256254    mov     rdx, [NAME(pCpumIC) wrt rip]
    257     CPUMCPU_FROM_CPUM(rdx)
     255;;    CPUMCPU_FROM_CPUM(rdx)
    258256   
    259257    ; Save the return code
    260     mov     [rdx + CPUMCPU.u32RetCode], eax
     258;;    mov     [rdx + CPUMCPU.u32RetCode], eax
    261259   
    262260    ; now let's switch back
     
    320318ALIGNCODE(16)
    321319BEGINPROC VMMGCGuestToHostAsm
    322     CPUMCPU_FROM_CPUM(rdx)
    323     FIXUP FIX_INTER_AMD64_CR3, 1
    324     mov     rax, 0ffffffffh
    325     mov     cr3, rax
    326     ;; We're now in the intermediate memory context!
     320    ;; We're still in the intermediate memory context!
    327321
    328322    ;;
     
    393387GLOBALNAME ICExitTarget
    394388    DEBUG_CHAR('8')
    395     FIXUP FIX_HC_CPUM_OFF, 1, 0
     389
     390    ; load the hypervisor data selector into ds & es
     391    FIXUP FIX_HYPER_DS, 1
     392    mov     eax, 0ffffh
     393    mov     ds, eax
     394    mov     es, eax
     395
     396    FIXUP FIX_GC_CPUM_OFF, 1, 0
    396397    mov     edx, 0ffffffffh
    397398    CPUMCPU_FROM_CPUM(edx)
     
    400401
    401402    ;; now we're in host memory context, let's restore regs
    402        
     403    FIXUP FIX_HC_CPUM_OFF, 1, 0
     404    mov     edx, 0ffffffffh
     405    CPUMCPU_FROM_CPUM(edx)
     406
     407       
    403408    ; activate host gdt and idt
    404409    lgdt    [edx + CPUMCPU.Host.gdtr]
     
    418423    DEBUG_CHAR('2')
    419424    lldt    [edx + CPUMCPU.Host.ldtr]
     425
    420426    ; Restore segment registers
    421427    mov     eax, [edx + CPUMCPU.Host.ds]
  • trunk/src/VBox/VMM/VMMSwitcher/VMMSwitcher.h

    r14771 r14979  
    6464#define FIX_GC_APIC_BASE_32BIT  34
    6565#define FIX_HC_64BIT_NOCHECK    35
     66#define FIX_GC_64_BIT_CPUM_OFF  36
    6667#define FIX_THE_END             255
    6768/** @} */
  • trunk/src/VBox/VMM/VMMSwitcher/VMMSwitcher.mac

    r14771 r14979  
    108108%define FIX_GC_APIC_BASE_32BIT  34
    109109%define FIX_HC_64BIT_NOCHECK    35
     110%define FIX_GC_64_BIT_CPUM_OFF  36
    110111%define FIX_THE_END             255
    111112;/** @} */
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