- Timestamp:
- Mar 23, 2017 2:34:13 PM (8 years ago)
- Location:
- trunk/src/VBox/ValidationKit/bootsectors
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1-template.c
r66216 r66226 162 162 uint8_t offCurImm; 163 163 /** Buffer for assembling the current instruction. */ 164 uint8_t abCurInstr[2 5];164 uint8_t abCurInstr[24]; 165 165 166 166 /** Set if the encoding can't be tested in the same ring as this test code. 167 167 * This is used to deal with encodings modifying SP/ESP/RSP. */ 168 168 bool fSameRingNotOkay; 169 /** Whether to work the extended context too. */ 170 bool fWorkExtCtx; 169 171 /** The aOperands index of the modrm.reg operand (if applicable). */ 170 172 uint8_t iRegOp; … … 228 230 BS3REGCTX aInitialCtxs[4]; 229 231 230 /** The extended context . */232 /** The extended context we're working on (input, expected output). */ 231 233 PBS3EXTCTX pExtCtx; 234 /** The extended result context (analoguous to TrapFrame). */ 235 PBS3EXTCTX pResultExtCtx; 232 236 /** The initial extended context. */ 233 237 PBS3EXTCTX pInitialExtCtx; … … 1303 1307 1304 1308 1305 static bool Bs3Cg3SetupAvx(PBS3CG1STATE pThis)1306 {1307 return true;1308 }1309 1310 1311 1309 /** 1312 * Sets up SSE .1310 * Sets up SSE and maybe AVX. 1313 1311 * 1314 1312 * @returns true (if successful, false if not and the SSE instructions ends up … … 1316 1314 * @param pThis The state. 1317 1315 */ 1318 static bool Bs3Cg3SetupSse (PBS3CG1STATE pThis)1316 static bool Bs3Cg3SetupSseAndAvx(PBS3CG1STATE pThis) 1319 1317 { 1320 ASMSetCR4(ASMGetCR4() | X86_CR4_OSFXSR | X86_CR4_OSXMMEEXCPT); 1318 if (!pThis->fWorkExtCtx) 1319 { 1320 unsigned i; 1321 uint32_t cr0 = ASMGetCR0(); 1322 uint32_t cr4 = ASMGetCR4(); 1323 1324 cr0 &= ~(X86_CR0_TS | X86_CR0_MP | X86_CR0_EM); 1325 cr0 |= X86_CR0_NE; 1326 ASMSetCR0(cr0); 1327 if (pThis->pExtCtx->enmMethod == BS3EXTCTXMETHOD_XSAVE) 1328 { 1329 cr4 |= X86_CR4_OSFXSR | X86_CR4_OSXMMEEXCPT | X86_CR4_OSXSAVE; 1330 ASMSetCR4(cr4); 1331 ASMSetXcr0(pThis->pExtCtx->fXcr0); 1332 } 1333 else 1334 { 1335 cr4 |= X86_CR4_OSFXSR | X86_CR4_OSXMMEEXCPT; 1336 ASMSetCR4(cr4); 1337 } 1338 1339 for (i = 0; i < RT_ELEMENTS(pThis->aInitialCtxs); i++) 1340 { 1341 pThis->aInitialCtxs[i].cr0.u32 = cr0; 1342 pThis->aInitialCtxs[i].cr4.u32 = cr4; 1343 } 1344 pThis->fWorkExtCtx = true; 1345 } 1346 1321 1347 return true; 1322 1348 } … … 1383 1409 case BS3CG1CPU_SSE: 1384 1410 if (fEdx & X86_CPUID_FEATURE_EDX_SSE) 1385 return Bs3Cg3SetupSse (pThis);1411 return Bs3Cg3SetupSseAndAvx(pThis); 1386 1412 return false; 1387 1413 case BS3CG1CPU_SSE2: 1388 1414 if (fEdx & X86_CPUID_FEATURE_EDX_SSE2) 1389 return Bs3Cg3SetupSse (pThis);1415 return Bs3Cg3SetupSseAndAvx(pThis); 1390 1416 return false; 1391 1417 case BS3CG1CPU_SSE3: 1392 1418 if (fEcx & X86_CPUID_FEATURE_ECX_SSE3) 1393 return Bs3Cg3SetupSse (pThis);1419 return Bs3Cg3SetupSseAndAvx(pThis); 1394 1420 return false; 1395 1421 case BS3CG1CPU_AVX: 1396 1422 if (fEcx & X86_CPUID_FEATURE_ECX_AVX) 1397 return Bs3Cg3Setup Avx(pThis);1423 return Bs3Cg3SetupSseAndAvx(pThis); 1398 1424 return false; 1399 1425 default: BS3_ASSERT(0); /* impossible */ … … 1411 1437 case BS3CG1CPU_AVX2: 1412 1438 if (fEbx & X86_CPUID_STEXT_FEATURE_EBX_AVX2) 1413 return Bs3Cg3Setup Avx(pThis);1439 return Bs3Cg3SetupSseAndAvx(pThis); 1414 1440 return false; 1415 1441 default: BS3_ASSERT(0); return false; /* impossible */ … … 1682 1708 else if ( pThis->pExtCtx->enmMethod != BS3EXTCTXMETHOD_ANCIENT 1683 1709 && offField - sizeof(BS3REGCTX) <= RT_UOFFSETOF(BS3EXTCTX, Ctx.x87.aXMM[15]) ) 1710 { 1711 if (!pThis->fWorkExtCtx) 1712 return Bs3TestFailedF("Extended context disabled: Field %d @ %#x LB %u\n", idxField, offField, cbDst); 1684 1713 PtrField.pb = (uint8_t *)pThis->pExtCtx + offField - sizeof(BS3REGCTX); 1714 } 1685 1715 /** @todo other FPU fields and FPU state formats. */ 1686 1716 else … … 1795 1825 unsigned const offField = g_aoffBs3Cg1DstFields[idxField]; 1796 1826 1827 if (!pThis->fWorkExtCtx) 1828 return Bs3TestFailedF("Extended context disabled: Field %d @ %#x LB %u\n", idxField, offField, cbDst); 1829 1797 1830 /* Copy the value into the union, doing the zero padding / extending. */ 1798 1831 Bs3MemCpy(&Value, pbCode, cbValue); … … 1831 1864 else 1832 1865 return Bs3TestFailedF("TODO: implement me: cbDst=%d idxField=%d (AVX and other weird state)", cbDst, idxField); 1833 1834 1866 } 1835 1867 … … 1888 1920 * Check the register content. 1889 1921 */ 1890 if (RT_LIKELY(Bs3TestCheckRegCtxEx(&pThis->TrapFrame.Ctx, &pThis->Ctx,1922 bool fOkay = Bs3TestCheckRegCtxEx(&pThis->TrapFrame.Ctx, &pThis->Ctx, 1891 1923 cbAdjustPc, 0 /*cbSpAdjust*/, 0 /*fExtraEfl*/, 1892 pThis->pszMode, iEncoding))) 1924 pThis->pszMode, iEncoding); 1925 1926 /* 1927 * Check memory output operands. 1928 */ 1929 iOperand = pThis->cOperands; 1930 while (iOperand-- > 0) 1931 if (pThis->aOperands[iOperand].enmLocation == BS3CG1OPLOC_MEM_RW) 1932 { 1933 BS3PTRUNION PtrUnion; 1934 PtrUnion.pb = &pThis->pbDataPg[X86_PAGE_SIZE - pThis->aOperands[iOperand].off]; 1935 switch (pThis->aOperands[iOperand].cbOp) 1936 { 1937 case 1: 1938 if (*PtrUnion.pu8 == pThis->MemOp.ab[0]) 1939 continue; 1940 Bs3TestFailedF("op%u: Wrote %#04RX8, expected %#04RX8", iOperand, *PtrUnion.pu8, pThis->MemOp.ab[0]); 1941 break; 1942 case 2: 1943 if (*PtrUnion.pu16 == pThis->MemOp.au16[0]) 1944 continue; 1945 Bs3TestFailedF("op%u: Wrote %#06RX16, expected %#06RX16", 1946 iOperand, *PtrUnion.pu16, pThis->MemOp.au16[0]); 1947 break; 1948 case 4: 1949 if (*PtrUnion.pu32 == pThis->MemOp.au32[0]) 1950 continue; 1951 Bs3TestFailedF("op%u: Wrote %#010RX32, expected %#010RX32", 1952 iOperand, *PtrUnion.pu32, pThis->MemOp.au32[0]); 1953 break; 1954 case 8: 1955 if (*PtrUnion.pu64 == pThis->MemOp.au64[0]) 1956 continue; 1957 Bs3TestFailedF("op%u: Wrote %#018RX64, expected %#018RX64", 1958 iOperand, *PtrUnion.pu64, pThis->MemOp.au64[0]); 1959 break; 1960 default: 1961 if (Bs3MemCmp(PtrUnion.pb, pThis->MemOp.ab, pThis->aOperands[iOperand].cbOp) == 0) 1962 continue; 1963 Bs3TestFailedF("op%u: Wrote %.*Rhxs, expected %.*Rhxs", 1964 iOperand, 1965 pThis->aOperands[iOperand].cbOp, PtrUnion.pb, 1966 pThis->aOperands[iOperand].cbOp, pThis->MemOp.ab); 1967 break; 1968 } 1969 fOkay = false; 1970 } 1971 1972 /* 1973 * Check extended context if enabled. 1974 */ 1975 if (pThis->fWorkExtCtx) 1893 1976 { 1977 PBS3EXTCTX pExpect = pThis->pExtCtx; 1978 PBS3EXTCTX pResult = pThis->pResultExtCtx; 1979 unsigned i; 1980 if ( pExpect->enmMethod == BS3EXTCTXMETHOD_XSAVE 1981 || pExpect->enmMethod == BS3EXTCTXMETHOD_FXSAVE) 1982 { 1983 /* Compare the x87 state, ASSUMING XCR0 bit 1 is set. */ 1984 #define CHECK_FIELD(a_Field, a_szFmt) \ 1985 if (pResult->Ctx.a_Field != pExpect->Ctx.a_Field) fOkay = Bs3TestFailedF(a_szFmt, pResult->Ctx.a_Field, pExpect->Ctx.a_Field) 1986 CHECK_FIELD(x87.FCW, "FCW: %#06x, expected %#06x"); 1987 CHECK_FIELD(x87.FSW, "FSW: %#06x, expected %#06x"); 1988 CHECK_FIELD(x87.FTW, "FTW: %#06x, expected %#06x"); 1989 //CHECK_FIELD(x87.FOP, "FOP: %#06x, expected %#06x"); 1990 //CHECK_FIELD(x87.FPUIP, "FPUIP: %#010x, expected %#010x"); 1991 //CHECK_FIELD(x87.CS, "FPUCS: %#06x, expected %#06x"); 1992 //CHECK_FIELD(x87.Rsrvd1, "Rsrvd1: %#06x, expected %#06x"); 1993 //CHECK_FIELD(x87.DP, "FPUDP: %#010x, expected %#010x"); 1994 //CHECK_FIELD(x87.DS, "FPUDS: %#06x, expected %#06x"); 1995 //CHECK_FIELD(x87.Rsrvd2, "Rsrvd2: %#06x, expected %#06x"); 1996 CHECK_FIELD(x87.MXCSR, "MXCSR: %#010x, expected %#010x"); 1997 //CHECK_FIELD(x87.MXCSR_MASK, "MXCSR_MASK: %#010x, expected %#010x"); 1998 #undef CHECK_FIELD 1999 for (i = 0; i < RT_ELEMENTS(pExpect->Ctx.x87.aRegs); i++) 2000 if ( pResult->Ctx.x87.aRegs[i].au64[0] != pExpect->Ctx.x87.aRegs[i].au64[0] 2001 || pResult->Ctx.x87.aRegs[i].au16[4] != pExpect->Ctx.x87.aRegs[i].au16[4]) 2002 fOkay = Bs3TestFailedF("ST[%u]: %c m=%#RX64 e=%d, expected %c m=%#RX64 e=%d", i, 2003 pResult->Ctx.x87.aRegs[i].r80Ex.s.fSign ? '-' : '+', 2004 pResult->Ctx.x87.aRegs[i].r80Ex.s.u64Mantissa, 2005 pResult->Ctx.x87.aRegs[i].r80Ex.s.uExponent, 2006 pExpect->Ctx.x87.aRegs[i].r80Ex.s.fSign ? '-' : '+', 2007 pExpect->Ctx.x87.aRegs[i].r80Ex.s.u64Mantissa, 2008 pExpect->Ctx.x87.aRegs[i].r80Ex.s.uExponent); 2009 for (i = 0; i < (ARCH_BITS == 64 ? 16 : 8); i++) 2010 if ( pResult->Ctx.x87.aXMM[i].au64[0] != pExpect->Ctx.x87.aXMM[i].au64[0] 2011 || pResult->Ctx.x87.aXMM[i].au64[1] != pExpect->Ctx.x87.aXMM[i].au64[1]) 2012 fOkay = Bs3TestFailedF("XMM%u: %#010RX64'%08RX64, expected %#010RX64'%08RX64", i, 2013 pResult->Ctx.x87.aXMM[i].au64[0], 2014 pResult->Ctx.x87.aXMM[i].au64[1], 2015 pExpect->Ctx.x87.aXMM[i].au64[0], 2016 pExpect->Ctx.x87.aXMM[i].au64[1]); 2017 } 2018 else 2019 fOkay = Bs3TestFailedF("Unsupported extended CPU context method: %d", pExpect->enmMethod); 2020 1894 2021 /* 1895 * Check memory output operands.2022 * Done. 1896 2023 */ 1897 bool fOkay = true;1898 iOperand = pThis->cOperands;1899 while (iOperand-- > 0)1900 if (pThis->aOperands[iOperand].enmLocation == BS3CG1OPLOC_MEM_RW)1901 {1902 BS3PTRUNION PtrUnion;1903 PtrUnion.pb = &pThis->pbDataPg[X86_PAGE_SIZE - pThis->aOperands[iOperand].off];1904 switch (pThis->aOperands[iOperand].cbOp)1905 {1906 case 1:1907 if (*PtrUnion.pu8 == pThis->MemOp.ab[0])1908 continue;1909 Bs3TestFailedF("op%u: Wrote %#04RX8, expected %#04RX8", iOperand, *PtrUnion.pu8, pThis->MemOp.ab[0]);1910 break;1911 case 2:1912 if (*PtrUnion.pu16 == pThis->MemOp.au16[0])1913 continue;1914 Bs3TestFailedF("op%u: Wrote %#06RX16, expected %#06RX16",1915 iOperand, *PtrUnion.pu16, pThis->MemOp.au16[0]);1916 break;1917 case 4:1918 if (*PtrUnion.pu32 == pThis->MemOp.au32[0])1919 continue;1920 Bs3TestFailedF("op%u: Wrote %#010RX32, expected %#010RX32",1921 iOperand, *PtrUnion.pu32, pThis->MemOp.au32[0]);1922 break;1923 case 8:1924 if (*PtrUnion.pu64 == pThis->MemOp.au64[0])1925 continue;1926 Bs3TestFailedF("op%u: Wrote %#018RX64, expected %#018RX64",1927 iOperand, *PtrUnion.pu64, pThis->MemOp.au64[0]);1928 break;1929 default:1930 if (Bs3MemCmp(PtrUnion.pb, pThis->MemOp.ab, pThis->aOperands[iOperand].cbOp) == 0)1931 continue;1932 Bs3TestFailedF("op%u: Wrote %.*Rhxs, expected %.*Rhxs",1933 iOperand,1934 pThis->aOperands[iOperand].cbOp, PtrUnion.pb,1935 pThis->aOperands[iOperand].cbOp, pThis->MemOp.ab);1936 break;1937 }1938 fOkay = false;1939 }1940 2024 if (fOkay) 1941 2025 return true; … … 2069 2153 Bs3MemFree(pThis->pbDataPg, X86_PAGE_SIZE); 2070 2154 } 2071 Bs3ExtCtxFree(pThis->pExtCtx); 2072 Bs3ExtCtxFree(pThis->pInitialExtCtx); 2155 2156 if (pThis->pExtCtx) 2157 Bs3MemFree(pThis->pExtCtx, pThis->pExtCtx->cb * 3); 2158 2159 pThis->pbCodePg = NULL; 2160 pThis->pbDataPg = NULL; 2161 pThis->pExtCtx = NULL; 2162 pThis->pResultExtCtx = NULL; 2163 pThis->pInitialExtCtx = NULL; 2073 2164 } 2074 2165 … … 2086 2177 : !BS3_MODE_IS_64BIT_CODE(bMode) ? BS3MEMKIND_TILED : BS3MEMKIND_FLAT32; 2087 2178 unsigned iRing; 2179 unsigned cb; 2180 unsigned i; 2181 uint64_t fFlags; 2182 PBS3EXTCTX pExtCtx; 2088 2183 2089 2184 Bs3MemSet(pThis, 0, sizeof(*pThis)); … … 2100 2195 2101 2196 /* Allocate extended context structures. */ 2102 pThis->pExtCtx = Bs3ExtCtxAlloc(0, BS3MEMKIND_TILED); 2103 pThis->pInitialExtCtx = Bs3ExtCtxAlloc(0, BS3MEMKIND_TILED); 2104 if (!pThis->pExtCtx || !pThis->pInitialExtCtx) 2105 return Bs3TestFailed("Bs3ExtCtxAlloc failed"); 2197 cb = Bs3ExtCtxGetSize(&fFlags); 2198 pExtCtx = Bs3MemAlloc(BS3MEMKIND_TILED, cb * 3); 2199 if (!pExtCtx) 2200 return Bs3TestFailedF("Bs3MemAlloc(tiled,%#x)", cb * 3); 2201 pThis->pExtCtx = pExtCtx; 2202 pThis->pResultExtCtx = (PBS3EXTCTX)((uint8_t BS3_FAR *)pExtCtx + cb); 2203 pThis->pInitialExtCtx = (PBS3EXTCTX)((uint8_t BS3_FAR *)pExtCtx + cb + cb); 2204 2205 Bs3ExtCtxInit(pThis->pExtCtx, cb, fFlags); 2206 Bs3ExtCtxInit(pThis->pResultExtCtx, cb, fFlags); 2207 Bs3ExtCtxInit(pThis->pInitialExtCtx, cb, fFlags); 2208 //Bs3TestPrintf("fCR0=%RX64 cbExtCtx=%#x method=%d\n", fFlags, cb, pExtCtx->enmMethod); 2106 2209 2107 2210 /* Allocate guarded exectuable and data memory. */ … … 2235 2338 } 2236 2339 2237 ASMCompilerBarrier(); 2340 /* 2341 * Create an initial extended CPU context. 2342 */ 2343 pExtCtx = pThis->pInitialExtCtx; 2344 if ( pExtCtx->enmMethod == BS3EXTCTXMETHOD_FXSAVE 2345 || pExtCtx->enmMethod == BS3EXTCTXMETHOD_XSAVE) 2346 { 2347 pExtCtx->Ctx.x87.FCW = X86_FCW_MASK_ALL | X86_FCW_PC_64 | X86_FCW_RC_NEAREST; 2348 pExtCtx->Ctx.x87.FSW = 0; 2349 pExtCtx->Ctx.x87.MXCSR = X86_MXSCR_IM | X86_MXSCR_DM | X86_MXSCR_RC_NEAREST; 2350 pExtCtx->Ctx.x87.MXCSR_MASK = 0; 2351 for (i = 0; i < RT_ELEMENTS(pExtCtx->Ctx.x87.aRegs); i++) 2352 { 2353 pExtCtx->Ctx.x87.aRegs[i].au16[0] = i << 4; 2354 pExtCtx->Ctx.x87.aRegs[i].au16[1] = i << 4; 2355 pExtCtx->Ctx.x87.aRegs[i].au16[2] = i << 4; 2356 pExtCtx->Ctx.x87.aRegs[i].au16[3] = i << 4; 2357 } 2358 for (i = 0; i < RT_ELEMENTS(pExtCtx->Ctx.x87.aXMM); i++) 2359 { 2360 pExtCtx->Ctx.x87.aXMM[i].au16[0] = i; 2361 pExtCtx->Ctx.x87.aXMM[i].au16[1] = i; 2362 pExtCtx->Ctx.x87.aXMM[i].au16[2] = i; 2363 pExtCtx->Ctx.x87.aXMM[i].au16[3] = i; 2364 pExtCtx->Ctx.x87.aXMM[i].au16[4] = i; 2365 pExtCtx->Ctx.x87.aXMM[i].au16[5] = i; 2366 pExtCtx->Ctx.x87.aXMM[i].au16[6] = i; 2367 pExtCtx->Ctx.x87.aXMM[i].au16[7] = i; 2368 } 2369 if (pExtCtx->fXcr0 & XSAVE_C_YMM) 2370 for (i = 0; i < RT_ELEMENTS(pExtCtx->Ctx.x.u.Intel.YmmHi.aYmmHi); i++) 2371 { 2372 pExtCtx->Ctx.x.u.Intel.YmmHi.aYmmHi[i].au16[0] = i << 8; 2373 pExtCtx->Ctx.x.u.Intel.YmmHi.aYmmHi[i].au16[1] = i << 8; 2374 pExtCtx->Ctx.x.u.Intel.YmmHi.aYmmHi[i].au16[2] = i << 8; 2375 pExtCtx->Ctx.x.u.Intel.YmmHi.aYmmHi[i].au16[3] = i << 8; 2376 pExtCtx->Ctx.x.u.Intel.YmmHi.aYmmHi[i].au16[4] = i << 8; 2377 pExtCtx->Ctx.x.u.Intel.YmmHi.aYmmHi[i].au16[5] = i << 8; 2378 pExtCtx->Ctx.x.u.Intel.YmmHi.aYmmHi[i].au16[6] = i << 8; 2379 pExtCtx->Ctx.x.u.Intel.YmmHi.aYmmHi[i].au16[7] = i << 8; 2380 } 2381 2382 } 2383 //else if (pExtCtx->enmMethod == BS3EXTCTXMETHOD_ANCIENT) 2384 else 2385 return Bs3TestFailedF("Unsupported extended CPU context method: %d", pExtCtx->enmMethod); 2386 2238 2387 return true; 2239 2388 } … … 2343 2492 2344 2493 Bs3MemCpy(&pThis->Ctx, &pThis->aInitialCtxs[iRing], sizeof(pThis->Ctx)); 2494 if (pThis->fWorkExtCtx) 2495 Bs3ExtCtxCopy(pThis->pExtCtx, pThis->pInitialExtCtx); 2345 2496 if (BS3_MODE_IS_PAGED(pThis->bMode)) 2346 2497 { … … 2363 2514 BS3CG1_DPRINTF(("dbg: Running test #%u\n", pThis->iTest)); 2364 2515 //Bs3RegCtxPrint(&pThis->Ctx); 2516 if (pThis->fWorkExtCtx) 2517 Bs3ExtCtxRestore(pThis->pExtCtx); 2365 2518 Bs3TrapSetJmpAndRestore(&pThis->Ctx, &pThis->TrapFrame); 2519 if (pThis->fWorkExtCtx) 2520 Bs3ExtCtxSave(pThis->pResultExtCtx); 2366 2521 BS3CG1_DPRINTF(("dbg: bXcpt=%#x rip=%RX64 -> %RX64\n", 2367 2522 pThis->TrapFrame.bXcpt, pThis->Ctx.rip.u, pThis->TrapFrame.Ctx.rip.u)); … … 2408 2563 BS3_DECL_FAR(uint8_t) BS3_CMN_NM(Bs3Cg1Worker)(uint8_t bMode) 2409 2564 { 2410 uint8_t bRet = 1; 2411 #if 1 2412 BS3CG1STATE This; 2413 2414 # if 0 2565 uint8_t bRet = 1; 2566 BS3CG1STATE This; 2567 2568 #if 0 2415 2569 /* (for debugging) */ 2416 if (bMode < BS3_MODE_ LM16)2570 if (bMode < BS3_MODE_PE16) 2417 2571 return BS3TESTDOMODE_SKIPPED; 2418 # 2572 #endif 2419 2573 2420 2574 if (BS3_CMN_NM(Bs3Cg1Init)(&This, bMode)) … … 2424 2578 } 2425 2579 Bs3Cg1Destroy(&This); 2426 #else2427 PBS3CG1STATE pThis = (PBS3CG1STATE)Bs3MemAlloc(BS3MEMKIND_REAL, sizeof(*pThis));2428 if (pThis)2429 {2430 if (BS3_CMN_NM(Bs3Cg1Init)(pThis, bMode))2431 {2432 bRet = BS3_CMN_NM(Bs3Cg1WorkerInner)(pThis);2433 Bs3TestSubDone();2434 }2435 Bs3Cg1Destroy(pThis);2436 Bs3MemFree(pThis, sizeof(*pThis));2437 }2438 #endif2439 2580 2440 2581 #if 0 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk
r66214 r66226 114 114 bs3-cmn-ExtCtxAlloc.c \ 115 115 bs3-cmn-ExtCtxFree.c \ 116 bs3-cmn-ExtCtxCopy.c \ 116 117 bs3-cmn-SelFar32ToFlat32.c \ 117 118 bs3-cmn-SelFar32ToFlat32NoClobber.asm \ … … 198 199 ../../../Runtime/common/asm/ASMSerializeInstruction-rdtscp.asm \ 199 200 ../../../Runtime/common/asm/ASMCpuIdExSlow.asm \ 201 ../../../Runtime/common/asm/ASMGetXcr0.asm \ 202 ../../../Runtime/common/asm/ASMSetXcr0.asm \ 200 203 201 204 # The 16-bit BS3Kit library. -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ExtCtxAlloc.c
r66214 r66226 33 33 34 34 #undef Bs3ExtCtxAlloc 35 BS3_CMN_DEF(PBS3EXTCTX, Bs3ExtCtxAlloc,( uint16_t fFlags,BS3MEMKIND enmKind))35 BS3_CMN_DEF(PBS3EXTCTX, Bs3ExtCtxAlloc,(BS3MEMKIND enmKind)) 36 36 { 37 uint16_t cbExtCtx = Bs3ExtCtxGetSize(fFlags); 37 uint64_t fFlags; 38 uint16_t cbExtCtx = Bs3ExtCtxGetSize(&fFlags); 38 39 PBS3EXTCTX pExtCtx = (PBS3EXTCTX)Bs3MemAlloc(enmKind, cbExtCtx); 39 40 if (pExtCtx) -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ExtCtxGetSize.c
r66214 r66226 34 34 35 35 #undef Bs3ExtCtxGetSize 36 BS3_CMN_DEF(uint16_t, Bs3ExtCtxGetSize,(uint 16_tfFlags))36 BS3_CMN_DEF(uint16_t, Bs3ExtCtxGetSize,(uint64_t BS3_FAR *pfFlags)) 37 37 { 38 38 uint32_t fEcx, fEdx; 39 BS3_ASSERT(fFlags == 0);39 *pfFlags = 0; 40 40 41 41 ASMCpuIdExSlow(1, 0, 0, 0, NULL, NULL, &fEcx, &fEdx); 42 #if 1 /* To disable xsave/xrstor till IEM groks it... */ 42 43 if (fEcx & X86_CPUID_FEATURE_ECX_XSAVE) 43 44 { 44 ASMCpuIdExSlow(13, 0, 0, 0, NULL, NULL, &fEcx, NULL); 45 uint32_t fEax; 46 ASMCpuIdExSlow(13, 0, 0, 0, &fEax, NULL, &fEcx, &fEdx); 45 47 if ( fEcx >= sizeof(X86FXSTATE) + sizeof(X86XSAVEHDR) 46 48 && fEcx < _32K) 49 { 50 *pfFlags = fEax | ((uint64_t)fEdx << 32); 47 51 return RT_OFFSETOF(BS3EXTCTX, Ctx) + RT_ALIGN(fEcx, 256); 52 } 48 53 } 54 #endif 49 55 if (fEdx & X86_CPUID_FEATURE_EDX_FXSR) 50 56 return RT_OFFSETOF(BS3EXTCTX, Ctx) + sizeof(X86FXSTATE); -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ExtCtxInit.c
r66214 r66226 34 34 35 35 #undef Bs3ExtCtxInit 36 BS3_CMN_DEF(PBS3EXTCTX, Bs3ExtCtxInit,(PBS3EXTCTX pExtCtx, uint16_t cbExtCtx, uint 16_t fFlags))36 BS3_CMN_DEF(PBS3EXTCTX, Bs3ExtCtxInit,(PBS3EXTCTX pExtCtx, uint16_t cbExtCtx, uint64_t fFlags)) 37 37 { 38 BS3_ASSERT(fFlags == 0);39 40 38 Bs3MemSet(pExtCtx, 0, cbExtCtx); 41 39 if (cbExtCtx >= RT_OFFSETOF(BS3EXTCTX, Ctx) + sizeof(X86FXSTATE) + sizeof(X86XSAVEHDR)) 40 { 41 BS3_ASSERT(fFlags & XSAVE_C_X87); 42 42 pExtCtx->enmMethod = BS3EXTCTXMETHOD_XSAVE; 43 pExtCtx->Ctx.x.Hdr.bmXState = fFlags; 44 } 43 45 else if (cbExtCtx >= RT_OFFSETOF(BS3EXTCTX, Ctx) + sizeof(X86FXSTATE)) 46 { 47 BS3_ASSERT(fFlags == 0); 44 48 pExtCtx->enmMethod = BS3EXTCTXMETHOD_FXSAVE; 49 } 45 50 else 46 51 { 52 BS3_ASSERT(fFlags == 0); 47 53 BS3_ASSERT(cbExtCtx >= RT_OFFSETOF(BS3EXTCTX, Ctx) + sizeof(X86FPUSTATE)); 48 54 pExtCtx->enmMethod = BS3EXTCTXMETHOD_ANCIENT; … … 50 56 pExtCtx->cb = cbExtCtx; 51 57 pExtCtx->u16Magic = BS3EXTCTX_MAGIC; 58 pExtCtx->fXcr0 = fFlags; 52 59 return pExtCtx; 53 60 } -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-autostubs.kmk
r66214 r66226 51 51 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3SwitchFromV86To16BitAndCallC) 52 52 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3ExtCtxAlloc) 53 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3ExtCtxCopy) 53 54 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3ExtCtxInit) 54 55 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TrapSetHandler) -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-define.h
r66214 r66226 32 32 #define Bs3A20EnableViaPortA BS3_CMN_MANGLER(Bs3A20EnableViaPortA) 33 33 #define Bs3ExtCtxAlloc BS3_CMN_MANGLER(Bs3ExtCtxAlloc) 34 #define Bs3ExtCtxCopy BS3_CMN_MANGLER(Bs3ExtCtxCopy) 34 35 #define Bs3ExtCtxFree BS3_CMN_MANGLER(Bs3ExtCtxFree) 35 36 #define Bs3ExtCtxGetSize BS3_CMN_MANGLER(Bs3ExtCtxGetSize) -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-undef.h
r66214 r66226 32 32 #undef Bs3A20EnableViaPortA 33 33 #undef Bs3ExtCtxAlloc 34 #undef Bs3ExtCtxCopy 34 35 #undef Bs3ExtCtxFree 35 36 #undef Bs3ExtCtxGetSize -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h
r66216 r66226 2680 2680 /** The method used to save and restore the context (BS3EXTCTXMETHOD). */ 2681 2681 uint8_t enmMethod; 2682 uint8_t abPadding0[3]; 2683 /** XSAVE_C_XXX. */ 2684 uint64_t fXcr0; 2682 2685 2683 2686 /** Explicit alignment padding. */ 2684 uint8_t abPadding[64 - 2 - 2 - 1 ];2687 uint8_t abPadding[64 - 2 - 2 - 1 - 3 - 8]; 2685 2688 2686 2689 /** The context, variable size (see above). … … 2711 2714 * 2712 2715 * @returns The new extended CPU context structure. 2713 * @param fFlags Flags, MBZ.2714 2716 * @param enmKind The kind of allocation to make. 2715 2717 */ 2716 BS3_CMN_PROTO_STUB(PBS3EXTCTX, Bs3ExtCtxAlloc,( uint16_t fFlags,BS3MEMKIND enmKind));2718 BS3_CMN_PROTO_STUB(PBS3EXTCTX, Bs3ExtCtxAlloc,(BS3MEMKIND enmKind)); 2717 2719 2718 2720 /** … … 2728 2730 * 2729 2731 * @returns size in bytes of the whole structure. 2732 * @param pfFlags Where to return flags for Bs3ExtCtxInit. 2730 2733 * @note Use Bs3ExtCtxAlloc when possible. 2731 2734 */ 2732 BS3_CMN_PROTO_STUB(uint16_t, Bs3ExtCtxGetSize,(uint 16_tfFlags));2735 BS3_CMN_PROTO_STUB(uint16_t, Bs3ExtCtxGetSize,(uint64_t *pfFlags)); 2733 2736 2734 2737 /** … … 2737 2740 * @param pExtCtx The extended CPU context. 2738 2741 * @param cbExtCtx The size of the @a pExtCtx allocation. 2739 * @param fFlags Flags, MBZ.2740 */ 2741 BS3_CMN_PROTO_STUB(PBS3EXTCTX, Bs3ExtCtxInit,(PBS3EXTCTX pExtCtx, uint16_t cbExtCtx, uint 16_t fFlags));2742 * @param fFlags XSAVE_C_XXX flags. 2743 */ 2744 BS3_CMN_PROTO_STUB(PBS3EXTCTX, Bs3ExtCtxInit,(PBS3EXTCTX pExtCtx, uint16_t cbExtCtx, uint64_t fFlags)); 2742 2745 2743 2746 /** … … 2756 2759 */ 2757 2760 BS3_CMN_PROTO_STUB(void, Bs3ExtCtxRestore,(PBS3EXTCTX pExtCtx)); 2761 2762 /** 2763 * Copies the state from one context to another. 2764 * 2765 * @returns pDst 2766 * @param pDst The destination extended CPU context. 2767 * @param pSrc The source extended CPU context. 2768 */ 2769 BS3_CMN_PROTO_STUB(PBS3EXTCTX, Bs3ExtCtxCopy,(PBS3EXTCTX pDst, PCBS3EXTCTX pSrc)); 2758 2770 2759 2771 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac
r66214 r66226 1425 1425 .cb resw 1 ; uint16_t cb; 1426 1426 .enmMethod resb 1 ; uint8_t enmMethod; 1427 alignb 64 1427 alignb 8 1428 .fXcr0 resq 1 1429 alignb 64 1428 1430 .Ctx resb 512 1429 1431 endstruc
Note:
See TracChangeset
for help on using the changeset viewer.