Changeset 45892 in vbox for trunk/src/VBox/VMM
- Timestamp:
- May 3, 2013 11:44:10 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp
r45888 r45892 3152 3152 Assert(pVCpu->hm.s.vmx.fUpdatedGuestState & HMVMX_UPDATED_GUEST_CR0); 3153 3153 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. */ 3154 3157 if ( !pVM->hm.s.vmx.fUnrestrictedGuest 3155 3158 && ( !CPUMIsGuestInRealModeEx(pCtx) … … 3165 3168 Assert( !(pCtx->cs.u32Limit & 0xfff00000) 3166 3169 || (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?!? */ 3168 3172 if (pCtx->cs.Attr.n.u4Type == 9 || pCtx->cs.Attr.n.u4Type == 11) 3169 3173 Assert(pCtx->cs.Attr.n.u2Dpl == pCtx->ss.Attr.n.u2Dpl); … … 3181 3185 Assert(!pCtx->ss.Attr.n.u2Dpl); 3182 3186 } 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)) 3184 3188 { 3185 3189 Assert((pCtx->ss.Sel & X86_SEL_RPL) == (pCtx->cs.Sel & X86_SEL_RPL)); … … 3194 3198 } 3195 3199 /* 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)) 3197 3201 { 3198 3202 Assert(pCtx->ds.Attr.n.u4Type & X86_SEL_TYPE_ACCESSED); … … 3208 3212 || (pCtx->ds.Attr.n.u4Type & X86_SEL_TYPE_READ)); 3209 3213 } 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)) 3211 3215 { 3212 3216 Assert(pCtx->es.Attr.n.u4Type & X86_SEL_TYPE_ACCESSED); … … 3222 3226 || (pCtx->es.Attr.n.u4Type & X86_SEL_TYPE_READ)); 3223 3227 } 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)) 3225 3229 { 3226 3230 Assert(pCtx->fs.Attr.n.u4Type & X86_SEL_TYPE_ACCESSED); … … 3236 3240 || (pCtx->fs.Attr.n.u4Type & X86_SEL_TYPE_READ)); 3237 3241 } 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)) 3239 3243 { 3240 3244 Assert(pCtx->gs.Attr.n.u4Type & X86_SEL_TYPE_ACCESSED); … … 3355 3359 3356 3360 /* 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), 3358 3362 ("Access bit not set for usable segment. idx=%#x sel=%#x attr %#x\n", idxBase, pSelReg, pSelReg->Attr.u)); 3359 3363 … … 5152 5156 5153 5157 /* 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 * 5155 5162 * See Intel spec. 27.3.2 "Saving Segment Registers and Descriptor-Table Registers". 5156 5163 */ 5157 5164 if (pSelReg->Attr.u & HMVMX_SEL_UNUSABLE) 5158 5165 { 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. */ 5163 5167 pSelReg->Attr.u = HMVMX_SEL_UNUSABLE; 5164 5168 }
Note:
See TracChangeset
for help on using the changeset viewer.