VirtualBox

Changeset 12763 in vbox


Ignore:
Timestamp:
Sep 26, 2008 11:01:01 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
37092
Message:

Fixed IF handling for real mode. (iopl=3, no need for VIF)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp

    r12756 r12763  
    461461    uint32_t    iGate = VMX_EXIT_INTERRUPTION_INFO_VECTOR(intInfo);
    462462    if (iGate == 0xE)
    463         Log2(("VMXR0InjectEvent: Injecting interrupt %d at %VGv error code=%08x CR2=%08x intInfo=%08x\n", iGate, pCtx->rip, errCode, pCtx->cr2, intInfo));
     463        LogFlow(("VMXR0InjectEvent: Injecting interrupt %d at %VGv error code=%08x CR2=%08x intInfo=%08x\n", iGate, pCtx->rip, errCode, pCtx->cr2, intInfo));
    464464    else
    465465    if (iGate < 0x20)
    466         Log2(("VMXR0InjectEvent: Injecting interrupt %d at %VGv error code=%08x\n", iGate, pCtx->rip, errCode));
     466        LogFlow(("VMXR0InjectEvent: Injecting interrupt %d at %VGv error code=%08x\n", iGate, pCtx->rip, errCode));
    467467    else
    468468    {
    469         Log2(("INJ-EI: %x at %VGv\n", iGate, pCtx->rip));
     469        LogFlow(("INJ-EI: %x at %VGv\n", iGate, pCtx->rip));
    470470        Assert(!VM_FF_ISSET(pVM, VM_FF_INHIBIT_INTERRUPTS));
    471471        Assert(pCtx->eflags.u32 & X86_EFL_IF);
     
    515515        if (!(pCtx->eflags.u32 & X86_EFL_IF))
    516516        {
    517             Log2(("Enable irq window exit!\n"));
    518             pVM->hwaccm.s.vmx.proc_ctls |= VMX_VMCS_CTRL_PROC_EXEC_CONTROLS_IRQ_WINDOW_EXIT;
    519             rc = VMXWriteVMCS(VMX_VMCS_CTRL_PROC_EXEC_CONTROLS, pVM->hwaccm.s.vmx.proc_ctls);
    520             AssertRC(rc);
     517            if (!(pVM->hwaccm.s.vmx.proc_ctls & VMX_VMCS_CTRL_PROC_EXEC_CONTROLS_IRQ_WINDOW_EXIT))
     518            {
     519                LogFlow(("Enable irq window exit!\n"));
     520                pVM->hwaccm.s.vmx.proc_ctls |= VMX_VMCS_CTRL_PROC_EXEC_CONTROLS_IRQ_WINDOW_EXIT;
     521                rc = VMXWriteVMCS(VMX_VMCS_CTRL_PROC_EXEC_CONTROLS, pVM->hwaccm.s.vmx.proc_ctls);
     522                AssertRC(rc);
     523            }
     524            /* else nothing to do but wait */
    521525        }
    522526        else
     
    739743        if (pVM->hwaccm.s.vmx.enmCurrGuestMode != enmGuestMode)
    740744        {
     745            /* Correct weird requirements for switching to protected mode. */
    741746            if (    pVM->hwaccm.s.vmx.enmCurrGuestMode == PGMMODE_REAL
    742                 &&  enmGuestMode == PGMMODE_PROTECTED)
    743             {
    744                 pCtx->csHid.Attr.n.u2Dpl = 0;
    745                 pCtx->dsHid.Attr.n.u2Dpl = 0;
    746                 pCtx->esHid.Attr.n.u2Dpl = 0;
    747                 pCtx->fsHid.Attr.n.u2Dpl = 0;
    748                 pCtx->gsHid.Attr.n.u2Dpl = 0;
    749                 pCtx->ssHid.Attr.n.u2Dpl = 0;
     747                &&  enmGuestMode >= PGMMODE_PROTECTED)
     748            {
     749                /* DPL of all hidden selector registers must match the current CPL (0). */
     750                pCtx->csHid.Attr.n.u2Dpl  = 0;
     751                pCtx->csHid.Attr.n.u4Type = X86_SEL_TYPE_CODE | X86_SEL_TYPE_RW_ACC;
     752
     753                pCtx->dsHid.Attr.n.u2Dpl  = 0;
     754                pCtx->esHid.Attr.n.u2Dpl  = 0;
     755                pCtx->fsHid.Attr.n.u2Dpl  = 0;
     756                pCtx->gsHid.Attr.n.u2Dpl  = 0;
     757                pCtx->ssHid.Attr.n.u2Dpl  = 0;
     758
     759                /* RPL of all selectors must match the current CPL (0). */
     760                pCtx->cs &= ~X86_SEL_RPL;
     761                pCtx->ds &= ~X86_SEL_RPL;
     762                pCtx->es &= ~X86_SEL_RPL;
     763                pCtx->fs &= ~X86_SEL_RPL;
     764                pCtx->gs &= ~X86_SEL_RPL;
     765                pCtx->ss &= ~X86_SEL_RPL;
     766            }
     767            else
     768            /* Switching from protected mode to real mode. */
     769            if (    pVM->hwaccm.s.vmx.enmCurrGuestMode >= PGMMODE_PROTECTED
     770                &&  enmGuestMode == PGMMODE_REAL)
     771            {
     772                /* The selector value & base must be adjusted or else... */
     773                pCtx->cs = pCtx->csHid.u64Base >> 4;
     774                pCtx->ds = pCtx->dsHid.u64Base >> 4;
     775                pCtx->es = pCtx->esHid.u64Base >> 4;
     776                pCtx->fs = pCtx->fsHid.u64Base >> 4;
     777                pCtx->gs = pCtx->gsHid.u64Base >> 4;
     778                pCtx->ss = pCtx->ssHid.u64Base >> 4;
     779
     780                pCtx->dsHid.u64Base &= 0xfffff;
     781                pCtx->esHid.u64Base &= 0xfffff;
     782                pCtx->fsHid.u64Base &= 0xfffff;
     783                pCtx->gsHid.u64Base &= 0xfffff;
     784
    750785            }
    751786            pVM->hwaccm.s.vmx.enmCurrGuestMode = enmGuestMode;
     
    10391074    {
    10401075        eflags.Bits.u1VM   = 1;
    1041         eflags.Bits.u1VIF  = pCtx->eflags.Bits.u1IF;
    10421076        eflags.Bits.u2IOPL = 3;
    10431077    }
     
    16131647        /* Hide our emulation flags */
    16141648        pCtx->eflags.Bits.u1VM   = 0;
    1615         pCtx->eflags.Bits.u1IF   = pCtx->eflags.Bits.u1VIF;
    1616         pCtx->eflags.Bits.u1VIF  = 0;
    16171649        pCtx->eflags.Bits.u2IOPL = 0;
    16181650
     
    19301962    case VMX_EXIT_IRQ_WINDOW:           /* 7 Interrupt window. */
    19311963        /* Clear VM-exit on IF=1 change. */
    1932         Log2(("VMX_EXIT_IRQ_WINDOW %VGv\n", pCtx->rip));
     1964        LogFlow(("VMX_EXIT_IRQ_WINDOW %VGv pending=%d IF=%d\n", pCtx->rip, VM_FF_ISPENDING(pVM, (VM_FF_INTERRUPT_APIC|VM_FF_INTERRUPT_PIC)), pCtx->eflags.Bits.u1IF));
    19331965        pVM->hwaccm.s.vmx.proc_ctls &= ~VMX_VMCS_CTRL_PROC_EXEC_CONTROLS_IRQ_WINDOW_EXIT;
    19341966        rc = VMXWriteVMCS(VMX_VMCS_CTRL_PROC_EXEC_CONTROLS, pVM->hwaccm.s.vmx.proc_ctls);
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