Changeset 65408 in vbox for trunk/src/VBox/ValidationKit
- Timestamp:
- Jan 23, 2017 4:03:35 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-pf.c32
r65396 r65408 115 115 /** Set if we can use the INVLPG instruction. */ 116 116 bool fUseInvlPg; 117 /** Physical addressing width. */ 118 uint8_t cBitsPhysWidth; 117 119 118 120 /** Reflects CR0.WP. */ … … 137 139 uint64_t au64PdeBackup[16]; 138 140 /** The PTE backup. */ 139 uint64_t au64PteBackup[X86_PG_PAE_ENTRIES]; 141 union 142 { 143 uint32_t Legacy[X86_PG_ENTRIES]; 144 uint64_t Pae[X86_PG_PAE_ENTRIES]; 145 } PteBackup; 140 146 141 147 } BS3CPUBASIC2PFSTATE; … … 378 384 static void bs3CpuBasic2Pf_RestoreFromBackups(PBS3CPUBASIC2PFSTATE pThis) 379 385 { 380 Bs3MemCpy(pThis->PgInfo.u.Legacy.pPte, pThis->au64PteBackup, pThis->cbPteBackup);386 Bs3MemCpy(pThis->PgInfo.u.Legacy.pPte, &pThis->PteBackup, pThis->cbPteBackup); 381 387 Bs3MemCpy(pThis->PgInfo.u.Legacy.pPde, pThis->au64PdeBackup, pThis->cbPdeBackup); 382 388 if (pThis->PgInfo.cEntries > 2) … … 394 400 { 395 401 uint8_t *pbOrgTest = pThis->pbOrgTest; 396 unsigned off; 397 398 for (off = X86_PAGE_SIZE - 5; off < X86_PAGE_SIZE + 2; off++) 402 unsigned offEnd = fFlags & BS3CB2PFACC_F_DIRECT ? X86_PAGE_SIZE + 1 : X86_PAGE_SIZE + 2; 403 unsigned off = fFlags & BS3CB2PFACC_F_DIRECT ? offEnd - 1 : X86_PAGE_SIZE - 5; 404 405 for (; off < offEnd; off++) 399 406 { 400 407 /* Emit a little bit of code (using the original allocation mapping) and point pCtx to it. */ … … 510 517 for (i = 0; i < 2; i++) 511 518 { 512 unsigned off = X86_PAGE_SIZE * (i + 1) - pThis->cbAccess;513 unsigned offEnd = X86_PAGE_SIZE * (i + 1) + (i == 0 ? 8 : 7);519 unsigned off = fFlags & BS3CB2PFACC_F_DIRECT ? X86_PAGE_SIZE : X86_PAGE_SIZE * (i + 1) - pThis->cbAccess; 520 unsigned offEnd = fFlags & BS3CB2PFACC_F_DIRECT ? off + 1 : X86_PAGE_SIZE * (i + 1) + (i == 0 ? 8 : 7); 514 521 515 522 for (; off < offEnd; off++) … … 542 549 } 543 550 } 551 552 if (fFlags & BS3CB2PFACC_F_DIRECT) 553 break; 544 554 } 545 555 } … … 596 606 for (i = 0; i < 2; i++) 597 607 { 598 unsigned off = X86_PAGE_SIZE * (i + 1) - pThis->cbAccess;599 unsigned offEnd = X86_PAGE_SIZE * (i + 1) + (i == 0 ? 8 : 7);608 unsigned off = fFlags & BS3CB2PFACC_F_DIRECT ? X86_PAGE_SIZE : X86_PAGE_SIZE * (i + 1) - pThis->cbAccess; 609 unsigned offEnd = fFlags & BS3CB2PFACC_F_DIRECT ? off + 1 : X86_PAGE_SIZE * (i + 1) + (i == 0 ? 8 : 7); 600 610 for (; off < offEnd; off++) 601 611 { … … 632 642 } 633 643 } 644 645 if (fFlags & BS3CB2PFACC_F_DIRECT) 646 break; 634 647 } 635 648 … … 692 705 for (i = 0; i < 2; i++) 693 706 { 694 unsigned off = X86_PAGE_SIZE * (i + 1) - pThis->cbAccess;695 unsigned offEnd = X86_PAGE_SIZE * (i + 1) + (i == 0 ? 8 : 7);707 unsigned off = fFlags & BS3CB2PFACC_F_DIRECT ? X86_PAGE_SIZE : X86_PAGE_SIZE * (i + 1) - pThis->cbAccess; 708 unsigned offEnd = fFlags & BS3CB2PFACC_F_DIRECT ? off + 1 : X86_PAGE_SIZE * (i + 1) + (i == 0 ? 8 : 7); 696 709 for (; off < offEnd; off++) 697 710 { … … 730 743 } 731 744 } 745 746 if (fFlags & BS3CB2PFACC_F_DIRECT) 747 break; 732 748 } 733 749 … … 813 829 for (i = 0; i < 2; i++) 814 830 { 815 unsigned off = X86_PAGE_SIZE * (i + 1) - pThis->cbAccess;816 unsigned offEnd = X86_PAGE_SIZE * (i + 1) + (i == 0 ? 8 : 7);831 unsigned off = fFlags & BS3CB2PFACC_F_DIRECT ? X86_PAGE_SIZE : X86_PAGE_SIZE * (i + 1) - pThis->cbAccess; 832 unsigned offEnd = fFlags & BS3CB2PFACC_F_DIRECT ? off + 1 : X86_PAGE_SIZE * (i + 1) + (i == 0 ? 8 : 7); 817 833 for (; off < offEnd; off++) 818 834 { … … 853 869 } 854 870 } 871 872 if (fFlags & BS3CB2PFACC_F_DIRECT) 873 break; 855 874 } 856 875 … … 912 931 for (i = 0; i < 2; i++) 913 932 { 914 unsigned off = X86_PAGE_SIZE * (i + 1) - pThis->cbAccess;915 unsigned offEnd = X86_PAGE_SIZE * (i + 1) + (i == 0 ? 8 : 7);933 unsigned off = fFlags & BS3CB2PFACC_F_DIRECT ? X86_PAGE_SIZE : X86_PAGE_SIZE * (i + 1) - pThis->cbAccess; 934 unsigned offEnd = fFlags & BS3CB2PFACC_F_DIRECT ? off + 1 : X86_PAGE_SIZE * (i + 1) + (i == 0 ? 8 : 7); 916 935 for (; off < offEnd; off++) 917 936 { … … 947 966 } 948 967 } 968 969 if (fFlags & BS3CB2PFACC_F_DIRECT) 970 break; 949 971 } 950 972 } … … 973 995 { 974 996 if (pThis->PgInfo.cbEntry == 4) 975 g_aStoreMethods[iStore].pfnStore(pThis->PgInfo.u.Legacy.pPte + 1, 976 ((pThis->PgInfo.u.Legacy.pPte[1].u & ~fClearMask) | fSetMask) & ~(uint32_t)pEntry->uModifyArg, 977 pThis->PgInfo.u.Legacy.pPte[1].u); 997 { 998 uint32_t const uOrg = pThis->PteBackup.Legacy[1]; 999 uint32_t uNew = ((uOrg & ~fClearMask) | fSetMask) & ~(uint32_t)pEntry->uModifyArg; 1000 uint32_t const uOld = pThis->PgInfo.u.Legacy.pPte[1].u; 1001 g_aStoreMethods[iStore].pfnStore(pThis->PgInfo.u.Legacy.pPte + 1, uNew, uOld); 1002 } 978 1003 else 979 g_aStoreMethods[iStore].pfnStore(pThis->PgInfo.u.Pae.pPte + 1, 980 ((pThis->PgInfo.u.Pae.pPte[1].au32[0] & ~fClearMask) | fSetMask) & ~(uint32_t)pEntry->uModifyArg, 981 pThis->PgInfo.u.Pae.pPte[1].au32[0]); 1004 { 1005 uint64_t const uOrg = pThis->PteBackup.Pae[1]; 1006 uint64_t uNew = ((uOrg & ~(uint64_t)fClearMask) | fSetMask) & ~(uint64_t)pEntry->uModifyArg; 1007 uint64_t const uOld = pThis->PgInfo.u.Pae.pPte[1].u; 1008 1009 g_aStoreMethods[iStore].pfnStore(&pThis->PgInfo.u.Pae.pPte[1].au32[0], (uint32_t)uNew, (uint32_t)uOld); 1010 if ((uint32_t)(uNew >> 32) != (uint32_t)(uOld >> 32)) 1011 g_aStoreMethods[iStore].pfnStore(&pThis->PgInfo.u.Pae.pPte[1].au32[1], 1012 (uint32_t)(uNew >> 32), (uint32_t)(uOld >> 32)); 1013 } 982 1014 } 983 1015 … … 986 1018 { 987 1019 if (pThis->PgInfo.cbEntry == 4) 988 g_aStoreMethods[iStore].pfnStore(pThis->PgInfo.u.Legacy.pPte + 1, 989 (pThis->PgInfo.u.Legacy.pPte[1].u & ~fClearMask) | fSetMask | RT_BIT_32(pEntry->uModifyArg), 990 pThis->PgInfo.u.Legacy.pPte[1].u); 991 else if (pEntry->uModifyArg < 32) 992 g_aStoreMethods[iStore].pfnStore(pThis->PgInfo.u.Pae.pPte + 1, 993 (pThis->PgInfo.u.Pae.pPte[1].au32[0] & ~fClearMask) | fSetMask | RT_BIT_32(pEntry->uModifyArg), 994 pThis->PgInfo.u.Pae.pPte[1].au32[0]); 1020 { 1021 uint32_t const uOrg = pThis->PteBackup.Legacy[1]; 1022 uint32_t uNew = (uOrg & ~fClearMask) | fSetMask | RT_BIT_32(pEntry->uModifyArg); 1023 uint32_t const uOld = pThis->PgInfo.u.Legacy.pPte[1].u; 1024 g_aStoreMethods[iStore].pfnStore(pThis->PgInfo.u.Legacy.pPte + 1, uNew, uOld); 1025 } 995 1026 else 996 1027 { 997 g_aStoreMethods[iStore].pfnStore(&pThis->PgInfo.u.Pae.pPte[1].au32[1], 998 pThis->PgInfo.u.Pae.pPte[1].au32[1] | RT_BIT_32(pEntry->uModifyArg - 32), 999 pThis->PgInfo.u.Pae.pPte[1].au32[1]); 1000 if (fSetMask || fClearMask) 1001 g_aStoreMethods[iStore].pfnStore(pThis->PgInfo.u.Pae.pPte + 1, 1002 (pThis->PgInfo.u.Pae.pPte[1].au32[0] & ~fClearMask) | fSetMask, 1003 pThis->PgInfo.u.Pae.pPte[1].au32[0]); 1004 } 1005 } 1006 1007 #if 0 1008 static void bs3CpuBasic2Pf_ClearBit(PBS3CPUBASIC2PFSTATE pThis, unsigned iStore, PCBS3CPUBASIC2PFMODPT pEntry, 1009 uint32_t fClearMask, uint32_t fSetMask) 1010 { 1011 if (pThis->PgInfo.cbEntry == 4) 1012 g_aStoreMethods[iStore].pfnStore(pThis->PgInfo.u.Legacy.pPte + 1, 1013 ((pThis->PgInfo.u.Legacy.pPte[1].u & ~fClearMask) | fSetMask) & ~RT_BIT_32(pEntry->uModifyArg), 1014 pThis->PgInfo.u.Legacy.pPte[1].u); 1015 else if (pEntry->uModifyArg < 32) 1016 g_aStoreMethods[iStore].pfnStore(pThis->PgInfo.u.Pae.pPte + 1, 1017 ((pThis->PgInfo.u.Pae.pPte[1].au32[0] & ~fClearMask) | fSetMask) & ~RT_BIT_32(pEntry->uModifyArg), 1018 pThis->PgInfo.u.Pae.pPte[1].au32[0]); 1019 else 1020 g_aStoreMethods[iStore].pfnStore(&pThis->PgInfo.u.Pae.pPte[1].au32[1], 1021 pThis->PgInfo.u.Pae.pPte[1].au32[1] & ~RT_BIT_32(pEntry->uModifyArg - 32), 1022 pThis->PgInfo.u.Pae.pPte[1].au32[1]); 1023 } 1024 #endif 1028 uint64_t const uOrg = pThis->PteBackup.Pae[1]; 1029 uint64_t uNew = ((uOrg & ~(uint64_t)fClearMask) | fSetMask) | RT_BIT_64(pEntry->uModifyArg); 1030 uint64_t const uOld = pThis->PgInfo.u.Pae.pPte[1].u; 1031 1032 if (pEntry->uModifyArg < 32 || (uint32_t)uNew != (uint32_t)uOld) 1033 g_aStoreMethods[iStore].pfnStore(&pThis->PgInfo.u.Pae.pPte[1].au32[0], (uint32_t)uNew, (uint32_t)uOld); 1034 if (pEntry->uModifyArg >= 32 || (uint32_t)(uNew >> 32) != (uint32_t)(uOld >> 32)) 1035 g_aStoreMethods[iStore].pfnStore(&pThis->PgInfo.u.Pae.pPte[1].au32[1], 1036 (uint32_t)(uNew >> 32), (uint32_t)(uOld >> 32)); 1037 } 1038 } 1025 1039 1026 1040 static void bs3CpuBasic2Pf_NoChange(PBS3CPUBASIC2PFSTATE pThis, unsigned iStore, PCBS3CPUBASIC2PFMODPT pEntry, 1027 1041 uint32_t fClearMask, uint32_t fSetMask) 1028 1042 { 1029 if (fClearMask || fSetMask) 1030 { 1031 if (pThis->PgInfo.cbEntry == 4) 1032 g_aStoreMethods[iStore].pfnStore(pThis->PgInfo.u.Legacy.pPte + 1, 1033 (pThis->PgInfo.u.Legacy.pPte[1].u & ~fClearMask) | fSetMask, 1034 pThis->PgInfo.u.Legacy.pPte[1].u); 1035 else 1036 g_aStoreMethods[iStore].pfnStore(pThis->PgInfo.u.Pae.pPte + 1, 1037 (pThis->PgInfo.u.Pae.pPte[1].au32[0] & ~fClearMask) | fSetMask, 1038 pThis->PgInfo.u.Pae.pPte[1].au32[0]); 1043 if (pThis->PgInfo.cbEntry == 4) 1044 { 1045 uint32_t const uOrg = pThis->PteBackup.Legacy[1]; 1046 uint32_t uNew = (uOrg & ~fClearMask) | fSetMask; 1047 uint32_t const uOld = pThis->PgInfo.u.Legacy.pPte[1].u; 1048 if (uNew != uOld) 1049 g_aStoreMethods[iStore].pfnStore(&pThis->PgInfo.u.Legacy.pPte[1], uNew, uOld); 1050 } 1051 else 1052 { 1053 uint64_t const uOrg = pThis->PteBackup.Pae[1]; 1054 uint64_t uNew = (uOrg & ~(uint64_t)fClearMask) | fSetMask; 1055 uint64_t const uOld = pThis->PgInfo.u.Pae.pPte[1].u; 1056 if (uNew != uOld) 1057 { 1058 if ((uint32_t)uNew != (uint32_t)uOld) 1059 g_aStoreMethods[iStore].pfnStore(&pThis->PgInfo.u.Pae.pPte[1].au32[0], (uint32_t)uNew, (uint32_t)uOld); 1060 if ((uint32_t)(uNew >> 32) != (uint32_t)(uOld >> 32)) 1061 g_aStoreMethods[iStore].pfnStore(&pThis->PgInfo.u.Pae.pPte[1].au32[1], 1062 (uint32_t)(uNew >> 32), (uint32_t)(uOld >> 32)); 1063 } 1039 1064 } 1040 1065 } … … 1050 1075 if (pThis->PgInfo.cbEntry == 8) 1051 1076 { 1077 /* Bits 52..63 or 62 (NXE=1). */ 1052 1078 if (pThis->PgInfo.cEntries == 3) 1053 1079 { … … 1057 1083 else if (pEntry->uModifyArg == 63 && !pThis->fNxe) 1058 1084 return true; 1085 1086 /* Reserved physical address bits. */ 1087 if (pEntry->uModifyArg < 52) 1088 { 1089 if ((uint32_t)pEntry->uModifyArg >= (uint32_t)pThis->cBitsPhysWidth) 1090 return true; 1091 } 1059 1092 } 1060 1093 return false; … … 1092 1125 { "!P", 0, 0, 0, 0, 0, X86_PTE_P, bs3CpuBasic2Pf_ClearMask, NULL }, 1093 1126 { "NX", 1, 1, 1, 1, 0, 63, bs3CpuBasic2Pf_SetBit, bs3CpuBasic2Pf_IsNxe }, 1127 { "RSVPH[32]", 0, 0, 0, 0, 1, 32, bs3CpuBasic2Pf_SetBit, bs3CpuBasic2Pf_IsPteBitReserved }, 1128 { "RSVPH[33]", 0, 0, 0, 0, 1, 33, bs3CpuBasic2Pf_SetBit, bs3CpuBasic2Pf_IsPteBitReserved }, 1129 { "RSVPH[34]", 0, 0, 0, 0, 1, 34, bs3CpuBasic2Pf_SetBit, bs3CpuBasic2Pf_IsPteBitReserved }, 1130 { "RSVPH[35]", 0, 0, 0, 0, 1, 35, bs3CpuBasic2Pf_SetBit, bs3CpuBasic2Pf_IsPteBitReserved }, 1131 { "RSVPH[36]", 0, 0, 0, 0, 1, 36, bs3CpuBasic2Pf_SetBit, bs3CpuBasic2Pf_IsPteBitReserved }, 1132 { "RSVPH[37]", 0, 0, 0, 0, 1, 37, bs3CpuBasic2Pf_SetBit, bs3CpuBasic2Pf_IsPteBitReserved }, 1133 { "RSVPH[38]", 0, 0, 0, 0, 1, 38, bs3CpuBasic2Pf_SetBit, bs3CpuBasic2Pf_IsPteBitReserved }, 1134 { "RSVPH[39]", 0, 0, 0, 0, 1, 39, bs3CpuBasic2Pf_SetBit, bs3CpuBasic2Pf_IsPteBitReserved }, 1135 { "RSVPH[40]", 0, 0, 0, 0, 1, 40, bs3CpuBasic2Pf_SetBit, bs3CpuBasic2Pf_IsPteBitReserved }, 1136 { "RSVPH[41]", 0, 0, 0, 0, 1, 41, bs3CpuBasic2Pf_SetBit, bs3CpuBasic2Pf_IsPteBitReserved }, 1137 { "RSVPH[42]", 0, 0, 0, 0, 1, 42, bs3CpuBasic2Pf_SetBit, bs3CpuBasic2Pf_IsPteBitReserved }, 1138 { "RSVPH[43]", 0, 0, 0, 0, 1, 43, bs3CpuBasic2Pf_SetBit, bs3CpuBasic2Pf_IsPteBitReserved }, 1139 { "RSVPH[44]", 0, 0, 0, 0, 1, 44, bs3CpuBasic2Pf_SetBit, bs3CpuBasic2Pf_IsPteBitReserved }, 1140 { "RSVPH[45]", 0, 0, 0, 0, 1, 45, bs3CpuBasic2Pf_SetBit, bs3CpuBasic2Pf_IsPteBitReserved }, 1141 { "RSVPH[46]", 0, 0, 0, 0, 1, 46, bs3CpuBasic2Pf_SetBit, bs3CpuBasic2Pf_IsPteBitReserved }, 1142 { "RSVPH[47]", 0, 0, 0, 0, 1, 47, bs3CpuBasic2Pf_SetBit, bs3CpuBasic2Pf_IsPteBitReserved }, 1143 { "RSVPH[48]", 0, 0, 0, 0, 1, 48, bs3CpuBasic2Pf_SetBit, bs3CpuBasic2Pf_IsPteBitReserved }, 1144 { "RSVPH[49]", 0, 0, 0, 0, 1, 49, bs3CpuBasic2Pf_SetBit, bs3CpuBasic2Pf_IsPteBitReserved }, 1145 { "RSVPH[50]", 0, 0, 0, 0, 1, 50, bs3CpuBasic2Pf_SetBit, bs3CpuBasic2Pf_IsPteBitReserved }, 1146 { "RSVPH[51]", 0, 0, 0, 0, 1, 51, bs3CpuBasic2Pf_SetBit, bs3CpuBasic2Pf_IsPteBitReserved }, 1094 1147 { "RSV[52]", 0, 0, 0, 0, 1, 52, bs3CpuBasic2Pf_SetBit, bs3CpuBasic2Pf_IsPteBitReserved }, 1095 1148 { "RSV[53]", 0, 0, 0, 0, 1, 53, bs3CpuBasic2Pf_SetBit, bs3CpuBasic2Pf_IsPteBitReserved }, … … 1134 1187 unsigned iStore; 1135 1188 unsigned iAccessor; 1136 // uint32_t const fPfId = fNxe ? X86_TRAP_PF_ID : 0;1189 unsigned iOuter; 1137 1190 uint32_t const fPfIdMask = fNxe ? UINT32_MAX : ~X86_TRAP_PF_ID; 1138 1191 BS3REGCTX aCtxts[4]; … … 1184 1237 * Check the U bit on PTE level. We only mess with the 2nd page. 1185 1238 */ 1186 { 1187 uint32_t const fAccessor = BS3CB2PFACC_F_PAGE_LEVEL; 1239 for (iOuter = 0; iOuter < 2; iOuter++) 1240 { 1241 uint32_t const fAccessor = (iOuter == 0 ? BS3CB2PFACC_F_DIRECT : 0) | BS3CB2PFACC_F_PAGE_LEVEL; 1188 1242 bool const fWp = RT_BOOL(ASMGetCR0() & X86_CR0_WP); 1189 1243 unsigned iPteWrk; … … 1194 1248 BS3CPUBASIC2PFMODPT EffWrk; 1195 1249 const BS3CPUBASIC2PFMODPT *pPteWrk = &g_aPteWorkers[iPteWrk]; 1196 if ( 1250 if (pPteWrk->pfnApplicable && !pPteWrk->pfnApplicable(pThis, pPteWrk)) 1197 1251 continue; 1198 1252 … … 1252 1306 #endif 1253 1307 1254 /*1255 * Again, but redoing everything for each accessor.1256 */1257 for (iStore = 0; iStore < RT_ELEMENTS(g_aStoreMethods); iStore++)1258 {1259 pThis->pszStore = g_aStoreMethods[iStore].pszName;1260 1261 for (iRing = 0; iRing < 4; iRing++)1262 {1263 PBS3REGCTX const pCtx = &aCtxts[iRing];1264 1308 #define CHECK_AD_BITS(a_fExpectedAD) \ 1265 1309 do { \ … … 1274 1318 } \ 1275 1319 } while (0) 1320 1321 /* 1322 * Again, but redoing everything for each accessor. 1323 */ 1324 for (iStore = 0; iStore < RT_ELEMENTS(g_aStoreMethods); iStore++) 1325 { 1326 pThis->pszStore = g_aStoreMethods[iStore].pszName; 1327 1328 for (iRing = 0; iRing < 4; iRing++) 1329 { 1330 PBS3REGCTX const pCtx = &aCtxts[iRing]; 1276 1331 1277 1332 if ( EffWrk.fReserved … … 1364 1419 1365 1420 /* 1366 * ...1421 * Again, but using invalidate page. 1367 1422 */ 1368 1423 if (pThis->fUseInvlPg) 1424 { 1425 bs3CpuBasic2Pf_RestoreFromBackups(pThis); 1426 1427 for (iStore = 0; iStore < RT_ELEMENTS(g_aStoreMethods); iStore++) 1428 { 1429 pThis->pszStore = g_aStoreMethods[iStore].pszName; 1430 1431 for (iRing = 0; iRing < 4; iRing++) 1432 { 1433 PBS3REGCTX const pCtx = &aCtxts[iRing]; 1434 1435 if ( EffWrk.fReserved 1436 || !EffWrk.fPresent 1437 || (!EffWrk.fUser && iRing == 3)) 1438 { 1439 uint32_t const fPfBase = ( EffWrk.fReserved ? X86_TRAP_PF_P | X86_TRAP_PF_RSVD 1440 : EffWrk.fPresent ? X86_TRAP_PF_P : 0) 1441 | (iRing == 3 ? X86_TRAP_PF_US : 0); 1442 for (iAccessor = 0; iAccessor < RT_ELEMENTS(g_aAccessors); iAccessor++) 1443 { 1444 pThis->pszAccessor = g_aAccessors[iAccessor].pszName; 1445 1446 pPteWrk->pfnModify(pThis, iStore, pPteWrk, 0, 0); 1447 ASMInvalidatePage((uintptr_t)pThis->pbTest + X86_PAGE_SIZE); 1448 g_aAccessors[iAccessor].pfnAccessor(pThis, pCtx, fAccessor, X86_XCPT_PF, 1449 fPfBase | (g_aAccessors[iAccessor].fAccess & fPfIdMask)); 1450 CHECK_AD_BITS(0); 1451 1452 pPteWrk->pfnModify(pThis, iStore, pPteWrk, X86_PTE_A | X86_PTE_D, 0); 1453 ASMInvalidatePage((uintptr_t)pThis->pbTest + X86_PAGE_SIZE); 1454 g_aAccessors[iAccessor].pfnAccessor(pThis, pCtx, fAccessor, X86_XCPT_PF, 1455 fPfBase | (g_aAccessors[iAccessor].fAccess & fPfIdMask)); 1456 CHECK_AD_BITS(0); 1457 } 1458 } 1459 else 1460 { 1461 uint32_t const fPfBase = X86_TRAP_PF_P | (iRing == 3 ? X86_TRAP_PF_US : 0); 1462 for (iAccessor = 0; iAccessor < RT_ELEMENTS(g_aAccessors); iAccessor++) 1463 { 1464 pThis->pszAccessor = g_aAccessors[iAccessor].pszName; 1465 if ( ( (g_aAccessors[iAccessor].fAccess & X86_TRAP_PF_ID) 1466 && EffWrk.fNoExecute) 1467 || ( (g_aAccessors[iAccessor].fAccess & X86_TRAP_PF_RW) 1468 && !EffWrk.fWriteable 1469 && (fWp || iRing == 3)) ) 1470 { 1471 uint32_t const fErrCd = fPfBase | (g_aAccessors[iAccessor].fAccess & fPfIdMask); 1472 1473 pPteWrk->pfnModify(pThis, iStore, pPteWrk, X86_PTE_A | X86_PTE_D, 0); 1474 ASMInvalidatePage((uintptr_t)pThis->pbTest + X86_PAGE_SIZE); 1475 g_aAccessors[iAccessor].pfnAccessor(pThis, pCtx, fAccessor, X86_XCPT_PF, fErrCd); 1476 CHECK_AD_BITS(0); 1477 1478 pPteWrk->pfnModify(pThis, iStore, pPteWrk, 0, X86_PTE_A | X86_PTE_D); 1479 ASMInvalidatePage((uintptr_t)pThis->pbTest + X86_PAGE_SIZE); 1480 g_aAccessors[iAccessor].pfnAccessor(pThis, pCtx, fAccessor, X86_XCPT_PF, fErrCd); 1481 CHECK_AD_BITS(X86_PTE_A | X86_PTE_D); 1482 1483 pPteWrk->pfnModify(pThis, iStore, pPteWrk, X86_PTE_A, X86_PTE_D); 1484 ASMInvalidatePage((uintptr_t)pThis->pbTest + X86_PAGE_SIZE); 1485 g_aAccessors[iAccessor].pfnAccessor(pThis, pCtx, fAccessor, X86_XCPT_PF, fErrCd); 1486 CHECK_AD_BITS(X86_PTE_D); 1487 1488 pPteWrk->pfnModify(pThis, iStore, pPteWrk, X86_PTE_D, X86_PTE_A); 1489 ASMInvalidatePage((uintptr_t)pThis->pbTest + X86_PAGE_SIZE); 1490 g_aAccessors[iAccessor].pfnAccessor(pThis, pCtx, fAccessor, X86_XCPT_PF, fErrCd); 1491 CHECK_AD_BITS(X86_PTE_A); 1492 } 1493 else 1494 { 1495 uint32_t const fExpectedAD = (g_aAccessors[iAccessor].fAccess & X86_TRAP_PF_RW) 1496 ? X86_PTE_A | X86_PTE_D : X86_PTE_A; 1497 1498 pPteWrk->pfnModify(pThis, iStore, pPteWrk, X86_PTE_A | X86_PTE_D, 0); 1499 ASMInvalidatePage((uintptr_t)pThis->pbTest + X86_PAGE_SIZE); 1500 g_aAccessors[iAccessor].pfnAccessor(pThis, pCtx, fAccessor, X86_XCPT_UD, UINT8_MAX); 1501 CHECK_AD_BITS(fExpectedAD); 1502 1503 pPteWrk->pfnModify(pThis, iStore, pPteWrk, 0, X86_PTE_A | X86_PTE_D); 1504 ASMInvalidatePage((uintptr_t)pThis->pbTest + X86_PAGE_SIZE); 1505 g_aAccessors[iAccessor].pfnAccessor(pThis, pCtx, fAccessor, X86_XCPT_UD, UINT8_MAX); 1506 CHECK_AD_BITS(X86_PTE_A | X86_PTE_D); 1507 1508 pPteWrk->pfnModify(pThis, iStore, pPteWrk, X86_PTE_A, X86_PTE_D); 1509 ASMInvalidatePage((uintptr_t)pThis->pbTest + X86_PAGE_SIZE); 1510 g_aAccessors[iAccessor].pfnAccessor(pThis, pCtx, fAccessor, X86_XCPT_UD, UINT8_MAX); 1511 CHECK_AD_BITS(fExpectedAD | X86_PTE_D); 1512 1513 pPteWrk->pfnModify(pThis, iStore, pPteWrk, X86_PTE_D, X86_PTE_A); 1514 ASMInvalidatePage((uintptr_t)pThis->pbTest + X86_PAGE_SIZE); 1515 g_aAccessors[iAccessor].pfnAccessor(pThis, pCtx, fAccessor, X86_XCPT_UD, UINT8_MAX); 1516 CHECK_AD_BITS(fExpectedAD | X86_PTE_A); 1517 } 1518 } 1519 } 1520 } 1521 } 1522 1523 bs3CpuBasic2Pf_RestoreFromBackups(pThis); 1524 } 1369 1525 } 1370 1526 } … … 1398 1554 State.pCmnMode++; 1399 1555 State.fUseInvlPg = (g_uBs3CpuDetected & BS3CPU_TYPE_MASK) >= BS3CPU_80486; 1556 1557 /* Figure physical addressing width. */ 1558 State.cBitsPhysWidth = 32; 1559 if ( (g_uBs3CpuDetected & BS3CPU_F_CPUID) 1560 && (ASMCpuId_EDX(1) & (X86_CPUID_FEATURE_EDX_PSE36 | X86_CPUID_FEATURE_EDX_PAE)) ) 1561 State.cBitsPhysWidth = 36; 1562 1563 if ( (g_uBs3CpuDetected & BS3CPU_F_CPUID_EXT_LEAVES) 1564 && ASMCpuId_EAX(0x80000000) >= 0x80000008) 1565 { 1566 uint8_t cBits = (uint8_t)ASMCpuId_EAX(0x80000008); 1567 if (cBits >= 32 && cBits <= 52) 1568 State.cBitsPhysWidth = cBits; 1569 else 1570 Bs3TestPrintf("CPUID 0x80000008: Physical bitcount out of range: %u\n", cBits); 1571 } 1572 //Bs3TestPrintf("Physical bitcount: %u\n", State.cBitsPhysWidth); 1400 1573 1401 1574 /* … … 1460 1633 1461 1634 /* Back up the structures. */ 1462 Bs3MemCpy( State.au64PteBackup, State.PgInfo.u.Legacy.pPte, State.cbPteBackup);1635 Bs3MemCpy(&State.PteBackup, State.PgInfo.u.Legacy.pPte, State.cbPteBackup); 1463 1636 Bs3MemCpy(State.au64PdeBackup, State.PgInfo.u.Legacy.pPde, State.cbPdeBackup); 1464 1637 if (State.PgInfo.cEntries > 2)
Note:
See TracChangeset
for help on using the changeset viewer.