Changeset 60212 in vbox
- Timestamp:
- Mar 27, 2016 11:26:41 PM (9 years ago)
- Location:
- trunk/src/VBox/ValidationKit/bootsectors
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/Config.kmk
r60195 r60212 413 413 # Update: We don't use this in 16-bit code as it causes unfavorable reloading of DS before calling 414 414 # inlined functions (e.g. iprt/asm.h). Instead we use -ecw and __cdecl where needed. 415 # Update: With -zdp the DS reloading is gone. Code is slightly larger, but seems to cure stability 416 # issues in bs3CpuBasic2_RaiseXcpt1 (workers ending up with default calling convention). 415 417 # -ecw Sets the default calling convension to __watcall () 416 418 # -q Quiet, no logos or stuff. … … 456 458 TEMPLATE_VBoxBS3KitImg_CXXTOOL = Bs3Ow16 457 459 TEMPLATE_VBoxBS3KitImg_CFLAGS = \ 458 -nt=BS3TEXT16 -nd=BS3DATA16 -nc=BS3CLASS16CODE -ec w-q -0 -wx -zl -zdp -zu -mc $(BS3_OW_DBG_OPT) -d1 -s -oa -ob -of -oi -ol -or -os -d+460 -nt=BS3TEXT16 -nd=BS3DATA16 -nc=BS3CLASS16CODE -ecc -q -0 -wx -zl -zdp -zu -mc $(BS3_OW_DBG_OPT) -d1 -s -oa -ob -of -oi -ol -or -os -d+ 459 461 TEMPLATE_VBoxBS3KitImg_CXXFLAGS = \ 460 -nt=BS3TEXT16 -nd=BS3DATA16 -nc=BS3CLASS16CODE -ec w-q -0 -wx -zl -zdp -zu -mc $(BS3_OW_DBG_OPT) -d1 -s -oa -ob -of -oi -ol -or -os -d+462 -nt=BS3TEXT16 -nd=BS3DATA16 -nc=BS3CLASS16CODE -ecc -q -0 -wx -zl -zdp -zu -mc $(BS3_OW_DBG_OPT) -d1 -s -oa -ob -of -oi -ol -or -os -d+ 461 463 TEMPLATE_VBoxBS3KitImg_CDEFS = ARCH_BITS=16 RT_ARCH_X86 462 464 -
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-template.c
r60208 r60212 87 87 * Compares trap stuff. 88 88 */ 89 static void bs3CpuBasic2_CompareTrapCtx1(PCBS3TRAPFRAME pTrapCtx, PCBS3REGCTX pStartCtx, uint16_t cbIpAdjust, uint8_t bXcpt, 90 const char *pszMode, unsigned uLine) 89 #define bs3CpuBasic2_CompareTrapCtx1 BS3_CMN_NM(bs3CpuBasic2_CompareTrapCtx1) 90 void bs3CpuBasic2_CompareTrapCtx1(PCBS3TRAPFRAME pTrapCtx, PCBS3REGCTX pStartCtx, uint16_t cbIpAdjust, uint8_t bXcpt, 91 const char *pszMode, unsigned uLine) 91 92 { 92 93 uint16_t const cErrorsBefore = Bs3TestSubErrorCount(); … … 96 97 if (Bs3TestSubErrorCount() != cErrorsBefore) 97 98 { 99 //Bs3TestPrintf("%s\n", __FUNCTION__); 98 100 Bs3TrapPrintFrame(pTrapCtx); 99 101 ASMHalt(); … … 105 107 * Compares trap stuff. 106 108 */ 107 static void bs3CpuBasic2_CompareTrapCtx2(PCBS3TRAPFRAME pTrapCtx, PCBS3REGCTX pStartCtx, uint16_t cbIpAdjust, uint8_t bXcpt, 108 uint16_t uHandlerCs, const char *pszMode, unsigned uLine) 109 #define bs3CpuBasic2_CompareTrapCtx2 BS3_CMN_NM(bs3CpuBasic2_CompareTrapCtx2) 110 void bs3CpuBasic2_CompareTrapCtx2(PCBS3TRAPFRAME pTrapCtx, PCBS3REGCTX pStartCtx, uint16_t cbIpAdjust, uint8_t bXcpt, 111 uint16_t uHandlerCs, const char *pszMode, unsigned uLine) 109 112 { 110 113 uint16_t const cErrorsBefore = Bs3TestSubErrorCount(); … … 115 118 if (Bs3TestSubErrorCount() != cErrorsBefore) 116 119 { 120 //Bs3TestPrintf("%s\n", __FUNCTION__); 117 121 Bs3TrapPrintFrame(pTrapCtx); 118 122 ASMHalt(); … … 123 127 * Compares trap stuff. 124 128 */ 125 static void bs3CpuBasic2_CompareGpCtx(PCBS3TRAPFRAME pTrapCtx, PCBS3REGCTX pStartCtx, uint16_t uErrCd, bool f16BitHandler, 126 const char *pszMode, unsigned uLine) 129 #define bs3CpuBasic2_CompareGpCtx BS3_CMN_NM(bs3CpuBasic2_CompareGpCtx) 130 void bs3CpuBasic2_CompareGpCtx(PCBS3TRAPFRAME pTrapCtx, PCBS3REGCTX pStartCtx, uint16_t uErrCd, bool f16BitHandler, 131 const char *pszMode, unsigned uLine) 127 132 { 128 133 uint16_t const cErrorsBefore = Bs3TestSubErrorCount(); … … 134 139 if (Bs3TestSubErrorCount() != cErrorsBefore) 135 140 { 141 //Bs3TestPrintf("%s\n", __FUNCTION__); 136 142 Bs3TrapPrintFrame(pTrapCtx); 137 143 ASMHalt(); … … 142 148 * Compares trap stuff. 143 149 */ 144 static void bs3CpuBasic2_CompareNpCtx(PCBS3TRAPFRAME pTrapCtx, PCBS3REGCTX pStartCtx, uint16_t uErrCd, bool f16BitHandler, 145 const char *pszMode, unsigned uLine) 150 #define bs3CpuBasic2_CompareNpCtx BS3_CMN_NM(bs3CpuBasic2_CompareNpCtx) 151 void bs3CpuBasic2_CompareNpCtx(PCBS3TRAPFRAME pTrapCtx, PCBS3REGCTX pStartCtx, uint16_t uErrCd, bool f16BitHandler, 152 const char *pszMode, unsigned uLine) 146 153 { 147 154 uint16_t const cErrorsBefore = Bs3TestSubErrorCount(); … … 153 160 if (Bs3TestSubErrorCount() != cErrorsBefore) 154 161 { 162 //Bs3TestPrintf("%s\n", __FUNCTION__); 155 163 Bs3TrapPrintFrame(pTrapCtx); 156 164 ASMHalt(); 157 165 } 158 166 } 167 168 #define bs3CpuBasic2_RaiseXcpt1Common BS3_CMN_NM(bs3CpuBasic2_RaiseXcpt1Common) 169 static void bs3CpuBasic2_RaiseXcpt1Common(uint8_t const bMode, const char * const pszMode, bool const f16BitSys, 170 uint16_t const uSysR0Cs, uint16_t const uSysR0CsConf, 171 PX86DESC const paIdt, unsigned const cIdteShift) 172 { 173 BS3TRAPFRAME TrapCtx; 174 BS3REGCTX Ctx80; 175 BS3REGCTX Ctx81; 176 BS3REGCTX Ctx82; 177 BS3REGCTX Ctx83; 178 BS3REGCTX CtxTmp; 179 PBS3REGCTX apCtx8x[4]; 180 unsigned iCtx; 181 unsigned iRing; 182 unsigned i, j, k; 183 unsigned uLine; 184 185 //uLine = 0; NOREF(uLine); NOREF(pszMode); NOREF(f16BitSys); 186 187 /* make sure they're allocated */ 188 Bs3MemZero(&Ctx80, sizeof(Ctx80)); 189 Bs3MemZero(&Ctx81, sizeof(Ctx81)); 190 Bs3MemZero(&Ctx82, sizeof(Ctx82)); 191 Bs3MemZero(&Ctx83, sizeof(Ctx83)); 192 Bs3MemZero(&CtxTmp, sizeof(CtxTmp)); 193 Bs3MemZero(&TrapCtx, sizeof(TrapCtx)); 194 195 /* Context array. */ 196 apCtx8x[0] = &Ctx80; 197 apCtx8x[1] = &Ctx81; 198 apCtx8x[2] = &Ctx82; 199 apCtx8x[3] = &Ctx83; 200 201 /* 202 * IDT entry 80 thru 83 are assigned DPLs according to the number. 203 * (We'll be useing more, but this'll do for now.) 204 */ 205 paIdt[0x80 << cIdteShift].Gate.u2Dpl = 0; 206 paIdt[0x81 << cIdteShift].Gate.u2Dpl = 1; 207 paIdt[0x82 << cIdteShift].Gate.u2Dpl = 2; 208 paIdt[0x83 << cIdteShift].Gate.u2Dpl = 3; 209 210 Bs3RegCtxSave(&Ctx80); 211 Ctx80.rsp.u -= 0x80; 212 Ctx80.rip.u = (uintptr_t)BS3_FP_OFF(&TMPL_NM(bs3CpuBasic2_Int80)); 213 # if TMPL_BITS == 32 214 BS3_DATA_NM(g_uBs3TrapEipHint) = Ctx80.rip.u32; 215 # endif 216 Bs3MemCpy(&Ctx81, &Ctx80, sizeof(Ctx80)); 217 Ctx81.rip.u = (uintptr_t)BS3_FP_OFF(&TMPL_NM(bs3CpuBasic2_Int81)); 218 Bs3MemCpy(&Ctx82, &Ctx80, sizeof(Ctx80)); 219 Ctx82.rip.u = (uintptr_t)BS3_FP_OFF(&TMPL_NM(bs3CpuBasic2_Int82)); 220 Bs3MemCpy(&Ctx83, &Ctx80, sizeof(Ctx80)); 221 Ctx83.rip.u = (uintptr_t)BS3_FP_OFF(&TMPL_NM(bs3CpuBasic2_Int83)); 222 223 /* 224 * Check that all the above gates work from ring-0. 225 */ 226 for (iCtx = 0; iCtx < RT_ELEMENTS(apCtx8x); iCtx++) 227 { 228 # if TMPL_BITS == 32 229 BS3_DATA_NM(g_uBs3TrapEipHint) = apCtx8x[iCtx]->rip.u32; 230 # endif 231 Bs3TrapSetJmpAndRestore(apCtx8x[iCtx], &TrapCtx); 232 bs3CpuBasic2_CompareTrapCtx1(&TrapCtx, apCtx8x[iCtx], 2 /*int 80h*/, 0x80+iCtx /*bXcpt*/, pszMode, iCtx); 233 } 234 235 /* 236 * Check that the gate DPL checks works. 237 */ 238 uLine = 100; 239 for (iRing = 0; iRing <= 3; iRing++) 240 { 241 for (iCtx = 0; iCtx < RT_ELEMENTS(apCtx8x); iCtx++) 242 { 243 Bs3MemCpy(&CtxTmp, apCtx8x[iCtx], sizeof(CtxTmp)); 244 Bs3RegCtxConvertToRingX(&CtxTmp, iRing); 245 # if TMPL_BITS == 32 246 BS3_DATA_NM(g_uBs3TrapEipHint) = CtxTmp.rip.u32; 247 # endif 248 Bs3TrapSetJmpAndRestore(&CtxTmp, &TrapCtx); 249 uLine++; 250 if (iCtx < iRing) 251 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &CtxTmp, ((0x80 + iCtx) << X86_TRAP_ERR_SEL_SHIFT) | X86_TRAP_ERR_IDT, 252 f16BitSys, pszMode, uLine); 253 else 254 bs3CpuBasic2_CompareTrapCtx1(&TrapCtx, &CtxTmp, 2 /*int 8xh*/, 0x80 + iCtx /*bXcpt*/, pszMode, uLine); 255 } 256 } 257 258 /* 259 * Modify the gate CS value and run the handler at a different CPL. 260 * Throw RPL variations into the mix (completely ignored) together 261 * with gate presence. 262 * 1. CPL <= GATE.DPL 263 * 2. GATE.P 264 * 3. GATE.CS.DPL <= CPL (non-conforming segments) 265 */ 266 uLine = 1000; 267 for (i = 0; i <= 3; i++) 268 { 269 for (iRing = 0; iRing <= 3; iRing++) 270 { 271 for (iCtx = 0; iCtx < RT_ELEMENTS(apCtx8x); iCtx++) 272 { 273 # if TMPL_BITS == 32 274 BS3_DATA_NM(g_uBs3TrapEipHint) = apCtx8x[iCtx]->rip.u32; 275 # endif 276 Bs3MemCpy(&CtxTmp, apCtx8x[iCtx], sizeof(CtxTmp)); 277 Bs3RegCtxConvertToRingX(&CtxTmp, iRing); 278 279 for (j = 0; j <= 3; j++) 280 { 281 uint16_t const uCs = (uSysR0Cs | j) + (i << BS3_SEL_RING_SHIFT); 282 for (k = 0; k < 2; k++) 283 { 284 uLine++; 285 /*Bs3TestPrintf("uLine=%u iCtx=%u iRing=%u i=%u uCs=%04x\n", uLine, iCtx, iRing, i, uCs);*/ 286 paIdt[(0x80 + iCtx) << cIdteShift].Gate.u16Sel = uCs; 287 paIdt[(0x80 + iCtx) << cIdteShift].Gate.u1Present = k; 288 Bs3TrapSetJmpAndRestore(&CtxTmp, &TrapCtx); 289 /*Bs3TrapPrintFrame(&TrapCtx);*/ 290 if (iCtx < iRing) 291 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &CtxTmp, ((0x80 + iCtx) << X86_TRAP_ERR_SEL_SHIFT) | X86_TRAP_ERR_IDT, 292 f16BitSys, pszMode, uLine); 293 else if (k == 0) 294 bs3CpuBasic2_CompareNpCtx(&TrapCtx, &CtxTmp, ((0x80 + iCtx) << X86_TRAP_ERR_SEL_SHIFT) | X86_TRAP_ERR_IDT, 295 f16BitSys, pszMode, uLine); 296 else if (i > iRing) 297 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &CtxTmp, uCs & X86_SEL_MASK_OFF_RPL, f16BitSys, pszMode, uLine); 298 else 299 { 300 uint16_t uExpectedCs = uCs & X86_SEL_MASK_OFF_RPL; 301 if (i <= iCtx && i <= iRing) 302 uExpectedCs |= i; 303 bs3CpuBasic2_CompareTrapCtx2(&TrapCtx, &CtxTmp, 2 /*int 8xh*/, 0x80 + iCtx /*bXcpt*/, 304 uExpectedCs, pszMode, uLine); 305 } 306 } 307 } 308 309 paIdt[(0x80 + iCtx) << cIdteShift].Gate.u16Sel = uSysR0Cs; 310 paIdt[(0x80 + iCtx) << cIdteShift].Gate.u1Present = 1; 311 } 312 } 313 } 314 BS3_ASSERT(uLine < 2000); 315 316 /* 317 * Modify the gate CS value with a conforming segment. 318 */ 319 uLine = 2000; 320 for (i = 0; i <= 3; i++) /* cs.dpl */ 321 { 322 # if TMPL_BITS == 16 323 static uint16_t s_x; 324 s_x = ASMGetBP(); 325 # endif 326 for (iRing = 0; iRing <= 3; iRing++) 327 { 328 for (iCtx = 0; iCtx < RT_ELEMENTS(apCtx8x); iCtx++) 329 { 330 Bs3MemCpy(&CtxTmp, apCtx8x[iCtx], sizeof(CtxTmp)); 331 Bs3RegCtxConvertToRingX(&CtxTmp, iRing); 332 # if TMPL_BITS == 32 333 BS3_DATA_NM(g_uBs3TrapEipHint) = CtxTmp.rip.u32; 334 # endif 335 336 for (j = 0; j <= 3; j++) /* rpl */ 337 { 338 uint16_t const uCs = (uSysR0CsConf | j) + (i << BS3_SEL_RING_SHIFT); 339 /*Bs3TestPrintf("uLine=%u iCtx=%u iRing=%u i=%u uCs=%04x\n", uLine, iCtx, iRing, i, uCs);*/ 340 paIdt[(0x80 + iCtx) << cIdteShift].Gate.u16Sel = uCs; 341 Bs3TrapSetJmpAndRestore(&CtxTmp, &TrapCtx); 342 # if TMPL_BITS == 16 343 BS3_ASSERT(s_x == ASMGetBP()); 344 #endif 345 //Bs3TestPrintf("%u/%u/%u/%u: cs=%04x hcs=%04x xcpt=%02x\n", i, iRing, iCtx, j, uCs, TrapCtx.uHandlerCs, TrapCtx.bXcpt); 346 /*Bs3TrapPrintFrame(&TrapCtx);*/ 347 uLine++; 348 if (iCtx < iRing) 349 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &CtxTmp, ((0x80 + iCtx) << X86_TRAP_ERR_SEL_SHIFT) | X86_TRAP_ERR_IDT, 350 f16BitSys, pszMode, 1);//uLine); 351 else if (i > iRing) 352 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &CtxTmp, uCs & X86_SEL_MASK_OFF_RPL, f16BitSys, pszMode, 2);//uLine); 353 else 354 bs3CpuBasic2_CompareTrapCtx1(&TrapCtx, &CtxTmp, 2 /*int 8xh*/, 0x80 + iCtx /*bXcpt*/, pszMode, 3);//uLine); 355 } 356 paIdt[(0x80 + iCtx) << cIdteShift].Gate.u16Sel = uSysR0Cs; 357 } 358 } 359 } 360 BS3_ASSERT(uLine < 3000); 361 362 /* 363 * The gates must be 64-bit in long mode.. 364 */ 365 if (cIdteShift != 0) 366 { 367 uLine = 3000; 368 for (i = 0; i <= 3; i++) 369 { 370 for (iRing = 0; iRing <= 3; iRing++) 371 { 372 for (iCtx = 0; iCtx < RT_ELEMENTS(apCtx8x); iCtx++) 373 { 374 Bs3MemCpy(&CtxTmp, apCtx8x[iCtx], sizeof(CtxTmp)); 375 Bs3RegCtxConvertToRingX(&CtxTmp, iRing); 376 377 for (j = 0; j < 2; j++) 378 { 379 static const uint16_t s_auCSes[2] = { BS3_SEL_R0_CS16, BS3_SEL_R0_CS32 }; 380 uint16_t uCs = (s_auCSes[j] | i) + (i << BS3_SEL_RING_SHIFT); 381 uLine++; 382 /*Bs3TestPrintf("uLine=%u iCtx=%u iRing=%u i=%u uCs=%04x\n", uLine, iCtx, iRing, i, uCs);*/ 383 paIdt[(0x80 + iCtx) << cIdteShift].Gate.u16Sel = uCs; 384 Bs3TrapSetJmpAndRestore(&CtxTmp, &TrapCtx); 385 /*Bs3TrapPrintFrame(&TrapCtx);*/ 386 if (iCtx < iRing) 387 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &CtxTmp, ((0x80 + iCtx) << X86_TRAP_ERR_SEL_SHIFT) | X86_TRAP_ERR_IDT, 388 f16BitSys, pszMode, uLine); 389 else 390 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &CtxTmp, uCs & X86_SEL_MASK_OFF_RPL, f16BitSys, pszMode, uLine); 391 } 392 paIdt[(0x80 + iCtx) << cIdteShift].Gate.u16Sel = uSysR0Cs; 393 } 394 } 395 } 396 BS3_ASSERT(uLine < 4000); 397 } 398 399 /* 400 * Check invalid gate types. 401 */ 402 uLine = 32000; 403 for (iRing = 0; iRing <= 3; iRing++) 404 { 405 static const uint16_t s_auCSes[] = { BS3_SEL_R0_CS16, BS3_SEL_R0_CS32, BS3_SEL_R0_CS64, 406 BS3_SEL_TSS16, BS3_SEL_TSS32, BS3_SEL_TSS64, 0, BS3_SEL_SPARE_1f }; 407 static uint16_t const s_auInvlTypes64[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 408 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 409 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }; 410 static uint16_t const s_auInvlTypes32[] = { 0, 1, 2, 3, 8, 9, 10, 11, 13, 411 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 412 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 413 /*286:*/ 12, 14, 15 }; 414 uint16_t const * const pauInvTypes = cIdteShift != 0 ? s_auInvlTypes64 : s_auInvlTypes32; 415 uint16_t const cInvTypes = cIdteShift != 0 ? RT_ELEMENTS(s_auInvlTypes64) 416 : (BS3_DATA_NM(g_uBs3CpuDetected) & BS3CPU_TYPE_MASK) < BS3CPU_80386 417 ? RT_ELEMENTS(s_auInvlTypes32) : RT_ELEMENTS(s_auInvlTypes32) - 3; 418 419 420 for (iCtx = 0; iCtx < RT_ELEMENTS(apCtx8x); iCtx++) 421 { 422 unsigned iType; 423 424 Bs3MemCpy(&CtxTmp, apCtx8x[iCtx], sizeof(CtxTmp)); 425 Bs3RegCtxConvertToRingX(&CtxTmp, iRing); 426 # if TMPL_BITS == 32 427 BS3_DATA_NM(g_uBs3TrapEipHint) = CtxTmp.rip.u32; 428 # endif 429 for (iType = 0; iType < cInvTypes; iType++) 430 { 431 uint8_t const bSavedType = paIdt[(0x80 + iCtx) << cIdteShift].Gate.u4Type; 432 paIdt[(0x80 + iCtx) << cIdteShift].Gate.u1DescType = pauInvTypes[iType] >> 4; 433 paIdt[(0x80 + iCtx) << cIdteShift].Gate.u4Type = pauInvTypes[iType] & 0xf; 434 435 for (i = 0; i < 4; i++) 436 { 437 for (j = 0; j < RT_ELEMENTS(s_auCSes); j++) 438 { 439 uint16_t uCs = (unsigned)(s_auCSes[j] - BS3_SEL_R0_FIRST) < (unsigned)(4 << BS3_SEL_RING_SHIFT) 440 ? (s_auCSes[j] | i) + (i << BS3_SEL_RING_SHIFT) 441 : s_auCSes[j] | i; 442 /*Bs3TestPrintf("uLine=%u iCtx=%u iRing=%u i=%u uCs=%04x type=%#x\n", uLine, iCtx, iRing, i, uCs, pauInvTypes[iType]);*/ 443 paIdt[(0x80 + iCtx) << cIdteShift].Gate.u16Sel = uCs; 444 Bs3TrapSetJmpAndRestore(&CtxTmp, &TrapCtx); 445 uLine++; 446 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &CtxTmp, ((0x80 + iCtx) << X86_TRAP_ERR_SEL_SHIFT) | X86_TRAP_ERR_IDT, 447 f16BitSys, pszMode, uLine); 448 449 /* Mark it not-present to check that invalid type takes precedence. */ 450 paIdt[(0x80 + iCtx) << cIdteShift].Gate.u1Present = 0; 451 Bs3TrapSetJmpAndRestore(&CtxTmp, &TrapCtx); 452 uLine++; 453 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &CtxTmp, ((0x80 + iCtx) << X86_TRAP_ERR_SEL_SHIFT) | X86_TRAP_ERR_IDT, 454 f16BitSys, pszMode, uLine); 455 paIdt[(0x80 + iCtx) << cIdteShift].Gate.u1Present = 1; 456 } 457 } 458 459 paIdt[(0x80 + iCtx) << cIdteShift].Gate.u16Sel = MY_SYS_SEL_R0_CS; 460 paIdt[(0x80 + iCtx) << cIdteShift].Gate.u4Type = bSavedType; 461 paIdt[(0x80 + iCtx) << cIdteShift].Gate.u1DescType = 0; 462 paIdt[(0x80 + iCtx) << cIdteShift].Gate.u1Present = 1; 463 } 464 } 465 } 466 BS3_ASSERT(uLine < 62000U && uLine > 32000U); 467 } 468 159 469 160 470 #endif /* once for each bitcount */ … … 165 475 * Worker for bs3CpuBasic2_TssGateEsp that tests the INT 80 from outer rings. 166 476 */ 167 static void bs3CpuBasic2_TssGateEsp_AltStackOuterRing(PCBS3REGCTX pCtx, uint8_t bRing, uint8_t *pbAltStack, size_t cbAltStack, 168 bool f16BitStack, bool f16BitTss, bool f16BitHandler, 169 const char *pszMode, unsigned uLine) 477 #define bs3CpuBasic2_TssGateEsp_AltStackOuterRing BS3_CMN_NM(bs3CpuBasic2_TssGateEsp_AltStackOuterRing) 478 void bs3CpuBasic2_TssGateEsp_AltStackOuterRing(PCBS3REGCTX pCtx, uint8_t bRing, uint8_t *pbAltStack, size_t cbAltStack, 479 bool f16BitStack, bool f16BitTss, bool f16BitHandler, 480 const char *pszMode, unsigned uLine) 170 481 { 171 482 uint8_t const cbIretFrame = f16BitHandler ? 5*2 : 5*4; … … 333 644 } 334 645 646 #ifdef __WATCOMC__ 647 DECLASM(RTCCUINTREG) ASMGetBP(void); 648 #pragma aux ASMGetBP = \ 649 "mov ax, bp" \ 650 value [ax] \ 651 modify exact [ax es bx dx cx si di bp sp]; 652 #endif 335 653 336 654 … … 339 657 uint8_t bRet = 0; 340 658 #if !BS3_MODE_IS_RM_OR_V86(TMPL_MODE) 659 #if 1 660 bs3CpuBasic2_RaiseXcpt1Common(bMode, 661 BS3_DATA_NM(TMPL_NM(g_szBs3ModeName)), 662 BS3_MODE_IS_16BIT_SYS(TMPL_MODE), 663 MY_SYS_SEL_R0_CS, 664 MY_SYS_SEL_R0_CS_CNF, 665 (PX86DESC)MyBs3Idt, 666 BS3_MODE_IS_64BIT_SYS(TMPL_MODE) ? 1 : 0); 667 #else 341 668 BS3TRAPFRAME TrapCtx; 342 669 BS3REGCTX Ctx80; … … 487 814 * Modify the gate CS value with a conforming segment. 488 815 */ 489 #if 0490 816 uLine = 2000; 491 for (i = 0; i <= 3; i++) 492 { 817 for (i = 0; i <= 3; i++) /* cs.dpl */ 818 { 819 # if TMPL_BITS == 16 820 static uint16_t s_x; 821 s_x = ASMGetBP(); 822 # endif 493 823 for (iRing = 0; iRing <= 3; iRing++) 494 824 { 495 825 for (iCtx = 0; iCtx < RT_ELEMENTS(apCtx8x); iCtx++) 496 826 { 497 uint16_t const uCs = (MY_SYS_SEL_R0_CS_CNF | i) + (i << BS3_SEL_RING_SHIFT);498 uLine++;499 /*Bs3TestPrintf("uLine=%u iCtx=%u iRing=%u i=%u uCs=%04x\n", uLine, iCtx, iRing, i, uCs);*/500 827 Bs3MemCpy(&CtxTmp, apCtx8x[iCtx], sizeof(CtxTmp)); 501 828 Bs3RegCtxConvertToRingX(&CtxTmp, iRing); 502 MyBs3Idt[0x80+iCtx].Gate.u16Sel = uCs;503 829 # if TMPL_BITS == 32 504 830 BS3_DATA_NM(g_uBs3TrapEipHint) = CtxTmp.rip.u32; 505 831 # endif 506 Bs3TrapSetJmpAndRestore(&CtxTmp, &TrapCtx); 507 /*Bs3TrapPrintFrame(&TrapCtx);*/ 508 if (iCtx < iRing) 509 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &CtxTmp, ((0x80 + iCtx) << X86_TRAP_ERR_SEL_SHIFT) | X86_TRAP_ERR_IDT, 510 f16BitSys, pszMode, uLine); 511 else if (i > iRing) 512 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &CtxTmp, uCs & X86_SEL_MASK_OFF_RPL, f16BitSys, pszMode, uLine); 513 else 514 bs3CpuBasic2_CompareTrapCtx1(&TrapCtx, &CtxTmp, 2 /*int 8xh*/, 0x80 + iCtx /*bXcpt*/, pszMode, uLine); 832 833 for (j = 0; j <= 3; j++) /* rpl */ 834 { 835 uint16_t const uCs = (MY_SYS_SEL_R0_CS_CNF | j) + (i << BS3_SEL_RING_SHIFT); 836 /*Bs3TestPrintf("uLine=%u iCtx=%u iRing=%u i=%u uCs=%04x\n", uLine, iCtx, iRing, i, uCs);*/ 837 MyBs3Idt[0x80+iCtx].Gate.u16Sel = uCs; 838 Bs3TrapSetJmpAndRestore(&CtxTmp, &TrapCtx); 839 # if TMPL_BITS == 16 840 BS3_ASSERT(s_x == ASMGetBP()); 841 #endif 842 //Bs3TestPrintf("%u/%u/%u/%u: cs=%04x hcs=%04x xcpt=%02x\n", i, iRing, iCtx, j, uCs, TrapCtx.uHandlerCs, TrapCtx.bXcpt); 843 /*Bs3TrapPrintFrame(&TrapCtx);*/ 844 uLine++; 845 if (iCtx < iRing) 846 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &CtxTmp, ((0x80 + iCtx) << X86_TRAP_ERR_SEL_SHIFT) | X86_TRAP_ERR_IDT, 847 f16BitSys, pszMode, 1);//uLine); 848 else if (i > iRing) 849 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &CtxTmp, uCs & X86_SEL_MASK_OFF_RPL, f16BitSys, pszMode, 2);//uLine); 850 else 851 bs3CpuBasic2_CompareTrapCtx1(&TrapCtx, &CtxTmp, 2 /*int 8xh*/, 0x80 + iCtx /*bXcpt*/, pszMode, 3);//uLine); 852 } 515 853 MyBs3Idt[0x80+iCtx].Gate.u16Sel = MY_SYS_SEL_R0_CS; 516 854 } … … 518 856 } 519 857 BS3_ASSERT(uLine < 3000); 520 #endif521 858 522 859 # if BS3_MODE_IS_64BIT_SYS(TMPL_MODE) … … 624 961 } 625 962 BS3_ASSERT(uLine < 62000U && uLine > 32000U); 963 # endif 626 964 627 965 #else
Note:
See TracChangeset
for help on using the changeset viewer.