VirtualBox

Changeset 60780 in vbox


Ignore:
Timestamp:
May 2, 2016 9:03:50 AM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
106978
Message:

iemMemApplySegment: handle NULL segments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IEMAll.cpp

    r60779 r60780  
    62366236            RTGCPTR32 GCPtrLast32  = GCPtrFirst32 + (uint32_t)cbMem - 1;
    62376237
    6238             Assert(pSel->Attr.n.u1Present);
    6239             Assert(pSel->Attr.n.u1DescType);
    6240             if (!(pSel->Attr.n.u4Type & X86_SEL_TYPE_CODE))
     6238            if (   pSel->Attr.n.u1Present
     6239                && !pSel->Attr.n.u1Unusable)
    62416240            {
    6242                 if (   (fAccess & IEM_ACCESS_TYPE_WRITE)
    6243                     && !(pSel->Attr.n.u4Type & X86_SEL_TYPE_WRITE) )
    6244                     return iemRaiseSelectorInvalidAccess(pIemCpu, iSegReg, fAccess);
    6245 
    6246                 if (!IEM_IS_REAL_OR_V86_MODE(pIemCpu))
     6241                Assert(pSel->Attr.n.u1DescType);
     6242                if (!(pSel->Attr.n.u4Type & X86_SEL_TYPE_CODE))
    62476243                {
    6248                     /** @todo CPL check. */
     6244                    if (   (fAccess & IEM_ACCESS_TYPE_WRITE)
     6245                        && !(pSel->Attr.n.u4Type & X86_SEL_TYPE_WRITE) )
     6246                        return iemRaiseSelectorInvalidAccess(pIemCpu, iSegReg, fAccess);
     6247
     6248                    if (!IEM_IS_REAL_OR_V86_MODE(pIemCpu))
     6249                    {
     6250                        /** @todo CPL check. */
     6251                    }
     6252
     6253                    /*
     6254                     * There are two kinds of data selectors, normal and expand down.
     6255                     */
     6256                    if (!(pSel->Attr.n.u4Type & X86_SEL_TYPE_DOWN))
     6257                    {
     6258                        if (   GCPtrFirst32 > pSel->u32Limit
     6259                            || GCPtrLast32  > pSel->u32Limit) /* yes, in real mode too (since 80286). */
     6260                            return iemRaiseSelectorBounds(pIemCpu, iSegReg, fAccess);
     6261                    }
     6262                    else
     6263                    {
     6264                       /*
     6265                        * The upper boundary is defined by the B bit, not the G bit!
     6266                        */
     6267                       if (   GCPtrFirst32 < pSel->u32Limit + UINT32_C(1)
     6268                           || GCPtrLast32  > (pSel->Attr.n.u1DefBig ? UINT32_MAX : UINT32_C(0xffff)))
     6269                          return iemRaiseSelectorBounds(pIemCpu, iSegReg, fAccess);
     6270                    }
     6271                    *pGCPtrMem = GCPtrFirst32 += (uint32_t)pSel->u64Base;
    62496272                }
    6250 
    6251                 /*
    6252                  * There are two kinds of data selectors, normal and expand down.
    6253                  */
    6254                 if (!(pSel->Attr.n.u4Type & X86_SEL_TYPE_DOWN))
     6273                else
    62556274                {
     6275
     6276                    /*
     6277                     * Code selector and usually be used to read thru, writing is
     6278                     * only permitted in real and V8086 mode.
     6279                     */
     6280                    if (   (   (fAccess & IEM_ACCESS_TYPE_WRITE)
     6281                            || (   (fAccess & IEM_ACCESS_TYPE_READ)
     6282                               && !(pSel->Attr.n.u4Type & X86_SEL_TYPE_READ)) )
     6283                        && !IEM_IS_REAL_OR_V86_MODE(pIemCpu) )
     6284                        return iemRaiseSelectorInvalidAccess(pIemCpu, iSegReg, fAccess);
     6285
    62566286                    if (   GCPtrFirst32 > pSel->u32Limit
    62576287                        || GCPtrLast32  > pSel->u32Limit) /* yes, in real mode too (since 80286). */
    62586288                        return iemRaiseSelectorBounds(pIemCpu, iSegReg, fAccess);
     6289
     6290                    if (!IEM_IS_REAL_OR_V86_MODE(pIemCpu))
     6291                    {
     6292                        /** @todo CPL check. */
     6293                    }
     6294
     6295                    *pGCPtrMem  = GCPtrFirst32 += (uint32_t)pSel->u64Base;
    62596296                }
    6260                 else
    6261                 {
    6262                    /*
    6263                     * The upper boundary is defined by the B bit, not the G bit!
    6264                     */
    6265                    if (   GCPtrFirst32 < pSel->u32Limit + UINT32_C(1)
    6266                        || GCPtrLast32  > (pSel->Attr.n.u1DefBig ? UINT32_MAX : UINT32_C(0xffff)))
    6267                       return iemRaiseSelectorBounds(pIemCpu, iSegReg, fAccess);
    6268                 }
    6269                 *pGCPtrMem = GCPtrFirst32 += (uint32_t)pSel->u64Base;
    62706297            }
    62716298            else
    6272             {
    6273 
    6274                 /*
    6275                  * Code selector and usually be used to read thru, writing is
    6276                  * only permitted in real and V8086 mode.
    6277                  */
    6278                 if (   (   (fAccess & IEM_ACCESS_TYPE_WRITE)
    6279                         || (   (fAccess & IEM_ACCESS_TYPE_READ)
    6280                            && !(pSel->Attr.n.u4Type & X86_SEL_TYPE_READ)) )
    6281                     && !IEM_IS_REAL_OR_V86_MODE(pIemCpu) )
    6282                     return iemRaiseSelectorInvalidAccess(pIemCpu, iSegReg, fAccess);
    6283 
    6284                 if (   GCPtrFirst32 > pSel->u32Limit
    6285                     || GCPtrLast32  > pSel->u32Limit) /* yes, in real mode too (since 80286). */
    6286                     return iemRaiseSelectorBounds(pIemCpu, iSegReg, fAccess);
    6287 
    6288                 if (!IEM_IS_REAL_OR_V86_MODE(pIemCpu))
    6289                 {
    6290                     /** @todo CPL check. */
    6291                 }
    6292 
    6293                 *pGCPtrMem  = GCPtrFirst32 += (uint32_t)pSel->u64Base;
    6294             }
     6299                return iemRaiseGeneralProtectionFault0(pIemCpu);
    62956300            return VINF_SUCCESS;
    62966301        }
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