SELMInline.h revision 7847c123aebebc6d3d5c1406619cfba1ab6457c1
64c02f1310b7747423957823ee09fb3608430f89nd * SELM - Internal header file.
64c02f1310b7747423957823ee09fb3608430f89nd * Copyright (C) 2006-2012 Oracle Corporation
64c02f1310b7747423957823ee09fb3608430f89nd * This file is part of VirtualBox Open Source Edition (OSE), as
64c02f1310b7747423957823ee09fb3608430f89nd * available from http://www.virtualbox.org. This file is free software;
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * you can redistribute it and/or modify it under the terms of the GNU
2e545ce2450a9953665f701bb05350f0d3f26275nd * General Public License (GPL) as published by the Free Software
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * Foundation, in version 2 as it comes in the "COPYING" file of the
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
64c02f1310b7747423957823ee09fb3608430f89nd * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
64c02f1310b7747423957823ee09fb3608430f89nd * Checks if a shadow descriptor table entry is good for the given segment
64c02f1310b7747423957823ee09fb3608430f89nd * register.
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * @returns @c true if good, @c false if not.
0066eddda7203f6345b56f77d146a759298dc635gryzor * @param pSReg The segment register.
7f5b59ccc63c0c0e3e678a168f09ee6a2f51f9d0nd * @param pShwDesc The shadow descriptor table entry.
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung * @param iSReg The segment register index (X86_SREG_XXX).
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd * @param uCpl The CPL.
64c02f1310b7747423957823ee09fb3608430f89ndDECLINLINE(bool) selmIsShwDescGoodForSReg(PCCPUMSELREG pSReg, PCX86DESC pShwDesc, uint32_t iSReg, uint32_t uCpl)
64c02f1310b7747423957823ee09fb3608430f89nd * See iemMiscValidateNewSS, iemCImpl_LoadSReg and intel+amd manuals.
64c02f1310b7747423957823ee09fb3608430f89nd return false;
64c02f1310b7747423957823ee09fb3608430f89nd return false;
64c02f1310b7747423957823ee09fb3608430f89nd if ((pShwDesc->Gen.u4Type & (X86_SEL_TYPE_CODE | X86_SEL_TYPE_WRITE)) != X86_SEL_TYPE_WRITE)
64c02f1310b7747423957823ee09fb3608430f89nd Log(("selmIsShwDescGoodForSReg: Stack must be writable\n"));
64c02f1310b7747423957823ee09fb3608430f89nd return false;
64c02f1310b7747423957823ee09fb3608430f89nd if (uCpl > (unsigned)pShwDesc->Gen.u2Dpl - pShwDesc->Gen.u1Available)
64c02f1310b7747423957823ee09fb3608430f89nd Log(("selmIsShwDescGoodForSReg: CPL(%d) > DPL(%d)\n", uCpl, pShwDesc->Gen.u2Dpl - pShwDesc->Gen.u1Available));
64c02f1310b7747423957823ee09fb3608430f89nd return false;
64c02f1310b7747423957823ee09fb3608430f89nd Log(("selmIsShwDescGoodForSReg: CS needs code segment\n"));
64c02f1310b7747423957823ee09fb3608430f89nd return false;
64c02f1310b7747423957823ee09fb3608430f89nd else if ((pShwDesc->Gen.u4Type & (X86_SEL_TYPE_CODE | X86_SEL_TYPE_READ)) == X86_SEL_TYPE_CODE)
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin Log(("selmIsShwDescGoodForSReg: iSReg=%u execute only\n", iSReg));
64c02f1310b7747423957823ee09fb3608430f89nd return false;
64c02f1310b7747423957823ee09fb3608430f89nd if ( (pShwDesc->Gen.u4Type & (X86_SEL_TYPE_CODE | X86_SEL_TYPE_CONF))
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl && ( ( (pSReg->Sel & X86_SEL_RPL) > (unsigned)pShwDesc->Gen.u2Dpl - pShwDesc->Gen.u1Available
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh && (pSReg->Sel & X86_SEL_RPL) != pShwDesc->Gen.u1Available )
64c02f1310b7747423957823ee09fb3608430f89nd || uCpl > (unsigned)pShwDesc->Gen.u2Dpl - pShwDesc->Gen.u1Available ) )
64c02f1310b7747423957823ee09fb3608430f89nd Log(("selmIsShwDescGoodForSReg: iSReg=%u DPL=%u CPL=%u RPL=%u\n", iSReg,
64c02f1310b7747423957823ee09fb3608430f89nd pShwDesc->Gen.u2Dpl - pShwDesc->Gen.u1Available, uCpl, pSReg->Sel & X86_SEL_RPL));
67c026fea89b4faf173772b5944b6aa006ca6eb0nd return false;
64c02f1310b7747423957823ee09fb3608430f89nd return true;
64c02f1310b7747423957823ee09fb3608430f89nd * Checks if a guest descriptor table entry is good for the given segment
64c02f1310b7747423957823ee09fb3608430f89nd * register.
f0fa55ff14fa0bf8fd72d989f6625de6dc3260c8igalic * @returns @c true if good, @c false if not.
f0fa55ff14fa0bf8fd72d989f6625de6dc3260c8igalic * @param pVCpu The current virtual CPU.
f0fa55ff14fa0bf8fd72d989f6625de6dc3260c8igalic * @param pSReg The segment register.
f0fa55ff14fa0bf8fd72d989f6625de6dc3260c8igalic * @param pGstDesc The guest descriptor table entry.
f0fa55ff14fa0bf8fd72d989f6625de6dc3260c8igalic * @param iSReg The segment register index (X86_SREG_XXX).
4aa603e6448b99f9371397d439795c91a93637eand * @param uCpl The CPL.
64c02f1310b7747423957823ee09fb3608430f89ndDECLINLINE(bool) selmIsGstDescGoodForSReg(PVMCPU pVCpu, PCCPUMSELREG pSReg, PCX86DESC pGstDesc, uint32_t iSReg, uint32_t uCpl)
64c02f1310b7747423957823ee09fb3608430f89nd * See iemMiscValidateNewSS, iemCImpl_LoadSReg and intel+amd manuals.
64c02f1310b7747423957823ee09fb3608430f89nd return false;
f0fa55ff14fa0bf8fd72d989f6625de6dc3260c8igalic return false;
f0fa55ff14fa0bf8fd72d989f6625de6dc3260c8igalic if ((pGstDesc->Gen.u4Type & (X86_SEL_TYPE_CODE | X86_SEL_TYPE_WRITE)) != X86_SEL_TYPE_WRITE)
f0fa55ff14fa0bf8fd72d989f6625de6dc3260c8igalic Log(("selmIsGstDescGoodForSReg: Stack must be writable\n"));
f0fa55ff14fa0bf8fd72d989f6625de6dc3260c8igalic return false;
64c02f1310b7747423957823ee09fb3608430f89nd Log(("selmIsGstDescGoodForSReg: CPL(%d) > DPL(%d)\n", uCpl, pGstDesc->Gen.u2Dpl));
64c02f1310b7747423957823ee09fb3608430f89nd return false;
727872d18412fc021f03969b8641810d8896820bhumbedooh Log(("selmIsGstDescGoodForSReg: CS needs code segment\n"));
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedooh return false;
727872d18412fc021f03969b8641810d8896820bhumbedooh else if ((pGstDesc->Gen.u4Type & (X86_SEL_TYPE_CODE | X86_SEL_TYPE_READ)) == X86_SEL_TYPE_CODE)
0d0ba3a410038e179b695446bb149cce6264e0abnd Log(("selmIsGstDescGoodForSReg: iSReg=%u execute only\n", iSReg));
0d0ba3a410038e179b695446bb149cce6264e0abnd return false;
0d0ba3a410038e179b695446bb149cce6264e0abnd if ( (pGstDesc->Gen.u4Type & (X86_SEL_TYPE_CODE | X86_SEL_TYPE_CONF))
727872d18412fc021f03969b8641810d8896820bhumbedooh && ( ( (pSReg->Sel & X86_SEL_RPL) > pGstDesc->Gen.u2Dpl
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd Log(("selmIsGstDescGoodForSReg: iSReg=%u DPL=%u CPL=%u RPL=%u InRawMode=%u\n", iSReg,
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd pGstDesc->Gen.u2Dpl, uCpl, pSReg->Sel & X86_SEL_RPL, CPUMIsGuestInRawMode(pVCpu)));
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd return false;
# ifdef VBOX_WITH_RAW_RING1
Log(("selmIsSRegStale32: Attributes changed (%#x -> %#x)\n", pSReg->Attr.u, X86DESC_GET_HID_ATTR(pShwDesc)));
Log(("selmIsSRegStale32: base changed (%#llx -> %#llx)\n", pSReg->u64Base, X86DESC_BASE(pShwDesc)));
Log(("selmIsSRegStale32: limit changed (%#x -> %#x)\n", pSReg->u32Limit, X86DESC_LIMIT_G(pShwDesc)));