VirtualBox

忽略:
時間撮記:
2008-10-27 下午01:53:04 (16 年 以前)
作者:
vboxsync
訊息:

#1865: SELM.

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/VMM/VMMGC/SELMGC.cpp

    r13144 r13577  
    100100     * 'little' adjustment we do for DPL 0 selectors.
    101101     */
    102     PX86DESC   pShadowDescr = &pVM->selm.s.paGdtGC[iGDTEntry];
     102    PX86DESC   pShadowDescr = &pVM->selm.s.paGdtRC[iGDTEntry];
    103103    if (Desc.Gen.u1DescType)
    104104    {
     
    150150    if (Sel == (pRegFrame->cs & X86_SEL_MASK))
    151151        Log(("GDT write to selector in CS register %04X\n", pRegFrame->cs));
    152     else
    153     if (Sel == (pRegFrame->ds & X86_SEL_MASK))
     152    else if (Sel == (pRegFrame->ds & X86_SEL_MASK))
    154153        Log(("GDT write to selector in DS register %04X\n", pRegFrame->ds));
    155     else
    156     if (Sel == (pRegFrame->es & X86_SEL_MASK))
     154    else if (Sel == (pRegFrame->es & X86_SEL_MASK))
    157155        Log(("GDT write to selector in ES register %04X\n", pRegFrame->es));
    158     else
    159     if (Sel == (pRegFrame->fs & X86_SEL_MASK))
     156    else if (Sel == (pRegFrame->fs & X86_SEL_MASK))
    160157        Log(("GDT write to selector in FS register %04X\n", pRegFrame->fs));
    161     else
    162     if (Sel == (pRegFrame->gs & X86_SEL_MASK))
     158    else if (Sel == (pRegFrame->gs & X86_SEL_MASK))
    163159        Log(("GDT write to selector in GS register %04X\n", pRegFrame->gs));
    164     else
    165     if (Sel == (pRegFrame->ss & X86_SEL_MASK))
     160    else if (Sel == (pRegFrame->ss & X86_SEL_MASK))
    166161        Log(("GDT write to selector in SS register %04X\n", pRegFrame->ss));
    167162#endif
     
    182177 *                      (If it's a EIP range this's the EIP, if not it's pvFault.)
    183178 */
    184 VMMRCDECL(int) selmgcGuestGDTWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPTR pvRange, uintptr_t offRange)
    185 {
    186     LogFlow(("selmgcGuestGDTWriteHandler errcode=%x fault=%VGv offRange=%08x\n", (uint32_t)uErrorCode, pvFault, offRange));
     179VMMRCDECL(int) selmRCGuestGDTWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPTR pvRange, uintptr_t offRange)
     180{
     181    LogFlow(("selmRCGuestGDTWriteHandler errcode=%x fault=%VGv offRange=%08x\n", (uint32_t)uErrorCode, pvFault, offRange));
    187182
    188183    /*
     
    218213                if (rc2 == VINF_SUCCESS)
    219214                {
    220                     STAM_COUNTER_INC(&pVM->selm.s.StatGCWriteGuestGDTHandled);
     215                    STAM_COUNTER_INC(&pVM->selm.s.StatRCWriteGuestGDTHandled);
    221216                    return rc;
    222217                }
     
    238233        VM_FF_SET(pVM, VM_FF_SELM_SYNC_GDT);
    239234    }
    240     STAM_COUNTER_INC(&pVM->selm.s.StatGCWriteGuestGDTUnhandled);
     235    STAM_COUNTER_INC(&pVM->selm.s.StatRCWriteGuestGDTUnhandled);
    241236    return rc;
    242237}
     
    255250 *                      (If it's a EIP range this's the EIP, if not it's pvFault.)
    256251 */
    257 VMMRCDECL(int) selmgcGuestLDTWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPTR pvRange, uintptr_t offRange)
     252VMMRCDECL(int) selmRCGuestLDTWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPTR pvRange, uintptr_t offRange)
    258253{
    259254    /** @todo To be implemented. */
    260     ////LogCom(("selmgcGuestLDTWriteHandler: eip=%08X pvFault=%VGv pvRange=%VGv\r\n", pRegFrame->eip, pvFault, pvRange));
     255    ////LogCom(("selmRCGuestLDTWriteHandler: eip=%08X pvFault=%VGv pvRange=%VGv\r\n", pRegFrame->eip, pvFault, pvRange));
    261256
    262257    VM_FF_SET(pVM, VM_FF_SELM_SYNC_LDT);
    263     STAM_COUNTER_INC(&pVM->selm.s.StatGCWriteGuestLDT);
     258    STAM_COUNTER_INC(&pVM->selm.s.StatRCWriteGuestLDT);
    264259    return VINF_EM_RAW_EMULATE_INSTR_LDT_FAULT;
    265260}
     
    278273 *                      (If it's a EIP range this's the EIP, if not it's pvFault.)
    279274 */
    280 VMMRCDECL(int) selmgcGuestTSSWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPTR pvRange, uintptr_t offRange)
    281 {
    282     LogFlow(("selmgcGuestTSSWriteHandler errcode=%x fault=%VGv offRange=%08x\n", (uint32_t)uErrorCode, pvFault, offRange));
     275VMMRCDECL(int) selmRCGuestTSSWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPTR pvRange, uintptr_t offRange)
     276{
     277    LogFlow(("selmRCGuestTSSWriteHandler errcode=%x fault=%VGv offRange=%08x\n", (uint32_t)uErrorCode, pvFault, offRange));
    283278
    284279    /*
     
    298293            ||  pGuestTSS->ss0  != (pVM->selm.s.Tss.ss1 & ~1)) /* undo raw-r0 */
    299294        {
    300             Log(("selmgcGuestTSSWriteHandler: R0 stack: %RTsel:%VGv -> %RTsel:%VGv\n",
     295            Log(("selmRCGuestTSSWriteHandler: R0 stack: %RTsel:%VGv -> %RTsel:%VGv\n",
    301296                 (RTSEL)(pVM->selm.s.Tss.ss1 & ~1), pVM->selm.s.Tss.esp1, (RTSEL)pGuestTSS->ss0, pGuestTSS->esp0));
    302297            pVM->selm.s.Tss.esp1 = pGuestTSS->esp0;
    303298            pVM->selm.s.Tss.ss1 = pGuestTSS->ss0 | 1;
    304             STAM_COUNTER_INC(&pVM->selm.s.StatGCWriteGuestTSSHandledChanged);
     299            STAM_COUNTER_INC(&pVM->selm.s.StatRCWriteGuestTSSHandledChanged);
    305300        }
    306301        if (CPUMGetGuestCR4(pVM) & X86_CR4_VME)
     
    331326                    AssertMsg(rc == VINF_SUCCESS, ("MMGCRamRead %VGv failed with %Vrc\n", (uint8_t *)pGuestTSS + offIntRedirBitmap + i * 8, rc));
    332327                }
    333                 STAM_COUNTER_INC(&pVM->selm.s.StatGCWriteGuestTSSRedir);
     328                STAM_COUNTER_INC(&pVM->selm.s.StatRCWriteGuestTSSRedir);
    334329            }
    335330        }
    336         STAM_COUNTER_INC(&pVM->selm.s.StatGCWriteGuestTSSHandled);
     331        STAM_COUNTER_INC(&pVM->selm.s.StatRCWriteGuestTSSHandled);
    337332    }
    338333    else
     
    340335        Assert(VBOX_FAILURE(rc));
    341336        VM_FF_SET(pVM, VM_FF_SELM_SYNC_TSS);
    342         STAM_COUNTER_INC(&pVM->selm.s.StatGCWriteGuestTSSUnhandled);
     337        STAM_COUNTER_INC(&pVM->selm.s.StatRCWriteGuestTSSUnhandled);
    343338        if (rc == VERR_EM_INTERPRETER)
    344339            rc = VINF_EM_RAW_EMULATE_INSTR_TSS_FAULT;
     
    348343
    349344
    350 
    351345/**
    352346 * \#PF Virtual Handler callback for Guest write access to the VBox shadow GDT.
     
    361355 *                      (If it's a EIP range this's the EIP, if not it's pvFault.)
    362356 */
    363 VMMRCDECL(int) selmgcShadowGDTWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPTR pvRange, uintptr_t offRange)
    364 {
    365     LogRel(("FATAL ERROR: selmgcShadowGDTWriteHandler: eip=%08X pvFault=%VGv pvRange=%VGv\r\n", pRegFrame->eip, pvFault, pvRange));
     357VMMRCDECL(int) selmRCShadowGDTWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPTR pvRange, uintptr_t offRange)
     358{
     359    LogRel(("FATAL ERROR: selmRCShadowGDTWriteHandler: eip=%08X pvFault=%VGv pvRange=%VGv\r\n", pRegFrame->eip, pvFault, pvRange));
    366360    return VERR_SELM_SHADOW_GDT_WRITE;
    367361}
    368362
     363
    369364/**
    370365 * \#PF Virtual Handler callback for Guest write access to the VBox shadow LDT.
     
    379374 *                      (If it's a EIP range this's the EIP, if not it's pvFault.)
    380375 */
    381 VMMRCDECL(int) selmgcShadowLDTWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPTR pvRange, uintptr_t offRange)
    382 {
    383     LogRel(("FATAL ERROR: selmgcShadowLDTWriteHandler: eip=%08X pvFault=%VGv pvRange=%VGv\r\n", pRegFrame->eip, pvFault, pvRange));
    384     Assert((RTRCPTR)pvFault >= pVM->selm.s.GCPtrLdt && (RTRCUINTPTR)pvFault < (RTRCUINTPTR)pVM->selm.s.GCPtrLdt + 65536 + PAGE_SIZE);
     376VMMRCDECL(int) selmRCShadowLDTWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPTR pvRange, uintptr_t offRange)
     377{
     378    LogRel(("FATAL ERROR: selmRCShadowLDTWriteHandler: eip=%08X pvFault=%VGv pvRange=%VGv\r\n", pRegFrame->eip, pvFault, pvRange));
     379    Assert((RTRCPTR)pvFault >= pVM->selm.s.pvLdtRC && (RTRCUINTPTR)pvFault < (RTRCUINTPTR)pVM->selm.s.pvLdtRC + 65536 + PAGE_SIZE);
    385380    return VERR_SELM_SHADOW_LDT_WRITE;
    386381}
    387382
     383
    388384/**
    389385 * \#PF Virtual Handler callback for Guest write access to the VBox shadow TSS.
     
    398394 *                      (If it's a EIP range this's the EIP, if not it's pvFault.)
    399395 */
    400 VMMRCDECL(int) selmgcShadowTSSWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPTR pvRange, uintptr_t offRange)
    401 {
    402     LogRel(("FATAL ERROR: selmgcShadowTSSWriteHandler: eip=%08X pvFault=%VGv pvRange=%VGv\r\n", pRegFrame->eip, pvFault, pvRange));
     396VMMRCDECL(int) selmRCShadowTSSWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPTR pvRange, uintptr_t offRange)
     397{
     398    LogRel(("FATAL ERROR: selmRCShadowTSSWriteHandler: eip=%08X pvFault=%VGv pvRange=%VGv\r\n", pRegFrame->eip, pvFault, pvRange));
    403399    return VERR_SELM_SHADOW_TSS_WRITE;
    404400}
     
    417413    if (pVM->selm.s.fSyncTSSRing0Stack)
    418414    {
    419         RCPTRTYPE(uint8_t *) GCPtrTss = (RCPTRTYPE(uint8_t *))pVM->selm.s.GCPtrGuestTss;
    420         int     rc;
    421         VBOXTSS tss;
     415        uint8_t *   GCPtrGuestTss = (uint8_t *)(uintptr_t)pVM->selm.s.GCPtrGuestTss;
     416        bool        fTriedAlready = false;
     417        int         rc;
     418        VBOXTSS     tss;
    422419
    423420        Assert(pVM->selm.s.GCPtrGuestTss && pVM->selm.s.cbMonitoredGuestTss);
    424421
    425 #ifdef IN_GC
    426         bool    fTriedAlready = false;
    427 
    428422l_tryagain:
    429         rc  = MMGCRamRead(pVM, &tss.ss0,  GCPtrTss + RT_OFFSETOF(VBOXTSS, ss0), sizeof(tss.ss0));
    430         rc |= MMGCRamRead(pVM, &tss.esp0, GCPtrTss + RT_OFFSETOF(VBOXTSS, esp0), sizeof(tss.esp0));
    431   #ifdef DEBUG
    432         rc |= MMGCRamRead(pVM, &tss.offIoBitmap, GCPtrTss + RT_OFFSETOF(VBOXTSS, offIoBitmap), sizeof(tss.offIoBitmap));
    433   #endif
     423        rc  = MMGCRamRead(pVM, &tss.ss0,  GCPtrGuestTss + RT_OFFSETOF(VBOXTSS, ss0), sizeof(tss.ss0));
     424        rc |= MMGCRamRead(pVM, &tss.esp0, GCPtrGuestTss + RT_OFFSETOF(VBOXTSS, esp0), sizeof(tss.esp0));
     425#ifdef DEBUG
     426        rc |= MMGCRamRead(pVM, &tss.offIoBitmap, GCPtrGuestTss + RT_OFFSETOF(VBOXTSS, offIoBitmap), sizeof(tss.offIoBitmap));
     427#endif
    434428
    435429        if (VBOX_FAILURE(rc))
     
    440434                /** @todo might cross page boundary */
    441435                fTriedAlready = true;
    442                 rc = PGMPrefetchPage(pVM, (RTGCPTR)(RTRCUINTPTR)GCPtrTss);
     436                rc = PGMPrefetchPage(pVM, (RTGCPTR)(uintptr_t)GCPtrGuestTss);
    443437                if (rc != VINF_SUCCESS)
    444438                    return rc;
    445439                goto l_tryagain;
    446440            }
    447             AssertMsgFailed(("Unable to read TSS structure at %08X\n", GCPtrTss));
     441            AssertMsgFailed(("Unable to read TSS structure at %RRv\n", GCPtrGuestTss));
    448442            return rc;
    449443        }
    450 
    451 #else /* !IN_GC */
    452         /* Reading too much. Could be cheaper than two seperate calls though. */
    453         rc = PGMPhysSimpleReadGCPtr(pVM, &tss, GCPtrTss, sizeof(VBOXTSS));
    454         if (VBOX_FAILURE(rc))
    455         {
    456             AssertReleaseMsgFailed(("Unable to read TSS structure at %08X\n", GCPtrTss));
    457             return rc;
    458         }
    459 #endif /* !IN_GC */
    460444
    461445#ifdef LOG_ENABLED
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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