VirtualBox

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


Ignore:
Timestamp:
May 3, 2013 11:44:10 AM (12 years ago)
Author:
vboxsync
Message:

VMM/HMVMXR0: Some clarification regarding the unusable bit.

File:
1 edited

Legend:

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

    r45888 r45892  
    31523152    Assert(pVCpu->hm.s.vmx.fUpdatedGuestState & HMVMX_UPDATED_GUEST_CR0);
    31533153    Assert(pVCpu->hm.s.vmx.fUpdatedGuestState & HMVMX_UPDATED_GUEST_RFLAGS);
     3154
     3155    /* NOTE: The reason we check for attribute value 0 and not just the unusable bit here is because hmR0VmxWriteSegmentReg()
     3156     * only updates the VMCS bits with the unusable bit and doesn't change the guest-context value. */
    31543157    if (   !pVM->hm.s.vmx.fUnrestrictedGuest
    31553158        && (   !CPUMIsGuestInRealModeEx(pCtx)
     
    31653168        Assert(   !(pCtx->cs.u32Limit & 0xfff00000)
    31663169               || (pCtx->cs.Attr.n.u1Granularity));
    3167         Assert(pCtx->cs.Attr.u && pCtx->cs.Attr.u != HMVMX_SEL_UNUSABLE);  /* CS cannot be loaded with NULL in protected mode. */
     3170        /* CS cannot be loaded with NULL in protected mode. */
     3171        Assert(pCtx->cs.Attr.u && !(pCtx->cs.Attr.u & HMVMX_SEL_UNUSABLE)); /** @todo is this really true even for 64-bit CS?!? */
    31683172        if (pCtx->cs.Attr.n.u4Type == 9 || pCtx->cs.Attr.n.u4Type == 11)
    31693173            Assert(pCtx->cs.Attr.n.u2Dpl == pCtx->ss.Attr.n.u2Dpl);
     
    31813185            Assert(!pCtx->ss.Attr.n.u2Dpl);
    31823186        }
    3183         if (pCtx->ss.Attr.u && pCtx->ss.Attr.u != HMVMX_SEL_UNUSABLE)
     3187        if (pCtx->ss.Attr.u && !(pCtx->ss.Attr.u & HMVMX_SEL_UNUSABLE))
    31843188        {
    31853189            Assert((pCtx->ss.Sel & X86_SEL_RPL) == (pCtx->cs.Sel & X86_SEL_RPL));
     
    31943198        }
    31953199        /* DS, ES, FS, GS - only check for usable selectors, see hmR0VmxWriteSegmentReg(). */
    3196         if (pCtx->ds.Attr.u && pCtx->ds.Attr.u != HMVMX_SEL_UNUSABLE)
     3200        if (pCtx->ds.Attr.u && !(pCtx->ds.Attr.u & HMVMX_SEL_UNUSABLE))
    31973201        {
    31983202            Assert(pCtx->ds.Attr.n.u4Type & X86_SEL_TYPE_ACCESSED);
     
    32083212                   || (pCtx->ds.Attr.n.u4Type & X86_SEL_TYPE_READ));
    32093213        }
    3210         if (pCtx->es.Attr.u && pCtx->es.Attr.u != HMVMX_SEL_UNUSABLE)
     3214        if (pCtx->es.Attr.u && !(pCtx->es.Attr.u & HMVMX_SEL_UNUSABLE))
    32113215        {
    32123216            Assert(pCtx->es.Attr.n.u4Type & X86_SEL_TYPE_ACCESSED);
     
    32223226                   || (pCtx->es.Attr.n.u4Type & X86_SEL_TYPE_READ));
    32233227        }
    3224         if (pCtx->fs.Attr.u && pCtx->fs.Attr.u != HMVMX_SEL_UNUSABLE)
     3228        if (pCtx->fs.Attr.u && !(pCtx->fs.Attr.u & HMVMX_SEL_UNUSABLE))
    32253229        {
    32263230            Assert(pCtx->fs.Attr.n.u4Type & X86_SEL_TYPE_ACCESSED);
     
    32363240                   || (pCtx->fs.Attr.n.u4Type & X86_SEL_TYPE_READ));
    32373241        }
    3238         if (pCtx->gs.Attr.u && pCtx->gs.Attr.u != HMVMX_SEL_UNUSABLE)
     3242        if (pCtx->gs.Attr.u && !(pCtx->gs.Attr.u & HMVMX_SEL_UNUSABLE))
    32393243        {
    32403244            Assert(pCtx->gs.Attr.n.u4Type & X86_SEL_TYPE_ACCESSED);
     
    33553359
    33563360    /* Validate segment access rights. Refer to Intel spec. "26.3.1.2 Checks on Guest Segment Registers". */
    3357     AssertMsg((u32Access == HMVMX_SEL_UNUSABLE) || (u32Access & X86_SEL_TYPE_ACCESSED),
     3361    AssertMsg((u32Access & HMVMX_SEL_UNUSABLE) || (u32Access & X86_SEL_TYPE_ACCESSED),
    33583362              ("Access bit not set for usable segment. idx=%#x sel=%#x attr %#x\n", idxBase, pSelReg, pSelReg->Attr.u));
    33593363
     
    51525156
    51535157    /*
    5154      * If VT-x marks the segment as unusable, the rest of the attributes are undefined.
     5158     * If VT-x marks the segment as unusable, the rest of the attributes are undefined with certain exceptions (some bits in
     5159     * CS, SS). Regardless, we have to clear the bits here and only retain the unusable bit because the unusable bit is specific
     5160     * to VT-x, everyone else relies on the attribute being zero and have no clue what the unusable bit is.
     5161     *
    51555162     * See Intel spec. 27.3.2 "Saving Segment Registers and Descriptor-Table Registers".
    51565163     */
    51575164    if (pSelReg->Attr.u & HMVMX_SEL_UNUSABLE)
    51585165    {
    5159         Assert(idxSel != VMX_VMCS16_GUEST_FIELD_TR);
    5160         /** @todo r=ramshankar: This can't be right for CS, SS which have exceptions for
    5161          *        certain bits, they're not all undefined. Consider ORing
    5162          *        HMVMX_SEL_UNUSABLE instead? */
     5166        Assert(idxSel != VMX_VMCS16_GUEST_FIELD_TR);          /* TR is the only selector that can never be unusable. */
    51635167        pSelReg->Attr.u = HMVMX_SEL_UNUSABLE;
    51645168    }
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