Changeset 101535 in vbox
- Timestamp:
- Oct 20, 2023 9:53:15 PM (16 months ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/IEMAllN8veRecompiler.cpp
r101523 r101535 2960 2960 # error "Port me!" 2961 2961 # endif 2962 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 2962 2963 return off; 2963 2964 } … … 2989 2990 pbCodeBuf[off++] = 0x0b; /* or edx, eax */ 2990 2991 pbCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, X86_GREG_xDX, X86_GREG_xAX); 2992 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 2991 2993 2992 2994 /* Jump to non-zero status return path. */ … … 3015 3017 # error "port me" 3016 3018 #endif 3019 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 3017 3020 return off; 3018 3021 } … … 3201 3204 * Make the call. 3202 3205 */ 3203 #ifdef RT_ARCH_AMD64 3204 off = iemNativeEmitLoadGprImm64(pReNative, off, X86_GREG_xAX, pfnCImpl); 3205 3206 uint8_t *pbCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 2); 3207 AssertReturn(pbCodeBuf, UINT32_MAX); 3208 pbCodeBuf[off++] = 0xff; /* call rax */ 3209 pbCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, 2, X86_GREG_xAX); 3210 3211 # if defined(VBOXSTRICTRC_STRICT_ENABLED) && defined(RT_OS_WINDOWS) 3206 off = iemNativeEmitCallImm(pReNative, off, pfnCImpl); 3207 3208 #if defined(RT_ARCH_AMD64) && defined(VBOXSTRICTRC_STRICT_ENABLED) && defined(RT_OS_WINDOWS) 3212 3209 off = iemNativeEmitLoadGprByBpU32(pReNative, off, X86_GREG_xAX, IEMNATIVE_FP_OFF_IN_SHADOW_ARG0); /* rcStrict (see above) */ 3213 # endif3214 3215 #elif defined(RT_ARCH_ARM64)3216 off = iemNativeEmitLoadGprImm64(pReNative, off, IEMNATIVE_REG_FIXED_TMP0, pfnCImpl);3217 3218 uint32_t *pu32CodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1);3219 AssertReturn(pu32CodeBuf, UINT32_MAX);3220 pu32CodeBuf[off++] = Armv8A64MkInstrBlr(IEMNATIVE_REG_FIXED_TMP0);3221 3222 #else3223 # error "Port me!"3224 3210 #endif 3225 3211 … … 3347 3333 /* iemNativeHlpExecStatusCodeFiddling(PVMCPUCC pVCpu, int rc, uint8_t idxInstr) */ 3348 3334 #ifdef RT_ARCH_AMD64 3349 /*3350 * AMD64:3351 */3352 uint8_t *pbCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 20);3353 AssertReturn(pbCodeBuf, UINT32_MAX);3354 3355 /* Call helper and jump to return point. */3356 3335 # ifdef RT_OS_WINDOWS 3357 3336 # ifdef IEMNATIVE_WITH_INSTRUCTION_COUNTING … … 3371 3350 # endif 3372 3351 3373 #elif defined(RT_ARCH_ARM64) 3374 /* 3375 * ARM64: 3376 */ 3352 #else 3377 3353 off = iemNativeEmitLoadGprFromGpr(pReNative, off, IEMNATIVE_CALL_ARG1_GREG, IEMNATIVE_CALL_RET_GREG); 3378 3354 off = iemNativeEmitLoadGprFromGpr(pReNative, off, IEMNATIVE_CALL_ARG0_GREG, IEMNATIVE_REG_FIXED_PVMCPU); 3379 3355 /* IEMNATIVE_CALL_ARG2_GREG is already set. */ 3380 off = iemNativeEmitLoadGprImm64(pReNative, off, IEMNATIVE_REG_FIXED_TMP0, (uintptr_t)iemNativeHlpExecStatusCodeFiddling);3381 AssertReturn(off != UINT32_MAX, UINT32_MAX);3382 #else3383 # error "port me"3384 3356 #endif 3385 3357 … … 3477 3449 # error "port me" 3478 3450 #endif 3451 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 3479 3452 3480 3453 return iemNativeEmitRcFiddling(pReNative, off, idxReturn); … … 3583 3556 # error "port me" 3584 3557 #endif 3558 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 3585 3559 return off; 3586 3560 } -
trunk/src/VBox/VMM/include/IEMN8veRecompiler.h
r101523 r101535 473 473 * IEMNATIVEINSTR units. */ 474 474 uint32_t cInstrBufAlloc; 475 uint32_t uPadding; /* We don't keep track of this here... */ 475 #ifdef VBOX_STRICT 476 /** Strict: How far the last iemNativeInstrBufEnsure() checked. */ 477 uint32_t offInstrBufChecked; 478 #else 479 uint32_t uPadding; /* We don't keep track of the size here... */ 480 #endif 476 481 /** Fixed temporary code buffer for native recompilation. */ 477 482 PIEMNATIVEINSTR pInstrBuf; … … 595 600 DECL_FORCE_INLINE(PIEMNATIVEINSTR) iemNativeInstrBufEnsure(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint32_t cInstrReq) 596 601 { 597 if (RT_LIKELY(off + (uint64_t)cInstrReq <= pReNative->cInstrBufAlloc)) 602 uint64_t const offChecked = off + (uint64_t)cInstrReq; 603 if (RT_LIKELY(offChecked <= pReNative->cInstrBufAlloc)) 604 { 605 #ifdef VBOX_STRICT 606 pReNative->offInstrBufChecked = offChecked; 607 #endif 598 608 return pReNative->pInstrBuf; 609 } 599 610 return iemNativeInstrBufEnsureSlow(pReNative, off, cInstrReq); 600 611 } 612 613 /** 614 * Checks that we didn't exceed the space requested in the last 615 * iemNativeInstrBufEnsure() call. */ 616 #define IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(a_pReNative, a_off) \ 617 AssertMsg((a_off) <= (a_pReNative)->offInstrBufChecked, \ 618 ("off=%#x offInstrBufChecked=%#x\n", (a_off), (a_pReNative)->offInstrBufChecked)) 601 619 602 620 … … 636 654 # error "port me" 637 655 #endif 656 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 638 657 return off; 639 658 } … … 663 682 # error "port me" 664 683 #endif 665 RT_NOREF(pReNative);684 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 666 685 return off; 667 686 } … … 760 779 # error "port me" 761 780 #endif 781 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 762 782 return off; 763 783 } … … 791 811 # error "port me" 792 812 #endif 813 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 793 814 return off; 794 815 } … … 853 874 pu32CodeBuf[off++] = Armv8A64MkInstrStLdRegIdx(enmOperation, iGpr, IEMNATIVE_REG_FIXED_PVMCPU, IEMNATIVE_REG_FIXED_TMP); 854 875 } 876 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 855 877 return off; 856 878 } … … 873 895 pbCodeBuf[off++] = 0x8b; 874 896 off = iemNativeEmitGprByVCpuDisp(pbCodeBuf,off,iGpr, offVCpu); 897 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 875 898 876 899 #elif RT_ARCH_ARM64 … … 898 921 pbCodeBuf[off++] = 0x8b; 899 922 off = iemNativeEmitGprByVCpuDisp(pbCodeBuf, off, iGpr, offVCpu); 923 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 900 924 901 925 #elif RT_ARCH_ARM64 … … 924 948 pbCodeBuf[off++] = 0xb7; 925 949 off = iemNativeEmitGprByVCpuDisp(pbCodeBuf, off, iGpr, offVCpu); 950 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 926 951 927 952 #elif RT_ARCH_ARM64 … … 950 975 pbCodeBuf[off++] = 0xb6; 951 976 off = iemNativeEmitGprByVCpuDisp(pbCodeBuf, off, iGpr, offVCpu); 977 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 952 978 953 979 #elif RT_ARCH_ARM64 … … 976 1002 pbCodeBuf[off++] = 0x89; 977 1003 off = iemNativeEmitGprByVCpuDisp(pbCodeBuf,off,iGpr, offVCpu); 1004 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 978 1005 979 1006 #elif RT_ARCH_ARM64 … … 1000 1027 pbCodeBuf[off++] = 0x89; 1001 1028 off = iemNativeEmitGprByVCpuDisp(pbCodeBuf, off, iGpr, offVCpu); 1029 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 1002 1030 1003 1031 #elif RT_ARCH_ARM64 … … 1025 1053 pbCodeBuf[off++] = 0x89; 1026 1054 off = iemNativeEmitGprByVCpuDisp(pbCodeBuf, off, iGpr, offVCpu); 1055 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 1027 1056 1028 1057 #elif RT_ARCH_ARM64 … … 1049 1078 pbCodeBuf[off++] = 0x88; 1050 1079 off = iemNativeEmitGprByVCpuDisp(pbCodeBuf, off, iGpr, offVCpu); 1080 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 1051 1081 1052 1082 #elif RT_ARCH_ARM64 … … 1087 1117 # error "port me" 1088 1118 #endif 1119 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 1089 1120 return off; 1090 1121 } … … 1094 1125 * Common bit of iemNativeEmitLoadGprByBp and friends. 1095 1126 */ 1096 DECL_FORCE_INLINE(uint32_t) iemNativeEmitGprByBpDisp(uint8_t *pbCodeBuf, uint32_t off, uint8_t iGprReg, int32_t offDisp) 1127 DECL_FORCE_INLINE(uint32_t) iemNativeEmitGprByBpDisp(uint8_t *pbCodeBuf, uint32_t off, uint8_t iGprReg, int32_t offDisp, 1128 PIEMRECOMPILERSTATE pReNativeAssert) 1097 1129 { 1098 1130 if (offDisp < 128 && offDisp >= -128) … … 1109 1141 pbCodeBuf[off++] = RT_BYTE4((uint32_t)offDisp); 1110 1142 } 1143 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNativeAssert, off); RT_NOREF(pReNativeAssert); 1111 1144 return off; 1112 1145 } … … 1128 1161 pbCodeBuf[off++] = X86_OP_REX_W | X86_OP_REX_R; 1129 1162 pbCodeBuf[off++] = 0x8b; 1130 return iemNativeEmitGprByBpDisp(pbCodeBuf, off, iGprDst, offDisp );1163 return iemNativeEmitGprByBpDisp(pbCodeBuf, off, iGprDst, offDisp, pReNative); 1131 1164 } 1132 1165 #endif … … 1145 1178 pbCodeBuf[off++] = X86_OP_REX_R; 1146 1179 pbCodeBuf[off++] = 0x8b; 1147 return iemNativeEmitGprByBpDisp(pbCodeBuf, off, iGprDst, offDisp );1180 return iemNativeEmitGprByBpDisp(pbCodeBuf, off, iGprDst, offDisp, pReNative); 1148 1181 } 1149 1182 #endif … … 1164 1197 pbCodeBuf[off++] = X86_OP_REX_W | X86_OP_REX_R; 1165 1198 pbCodeBuf[off++] = 0x8d; 1166 return iemNativeEmitGprByBpDisp(pbCodeBuf, off, iGprDst, offDisp );1199 return iemNativeEmitGprByBpDisp(pbCodeBuf, off, iGprDst, offDisp, pReNative); 1167 1200 } 1168 1201 #endif … … 1185 1218 pbCodeBuf[off++] = X86_OP_REX_W | X86_OP_REX_R; 1186 1219 pbCodeBuf[off++] = 0x89; 1187 return iemNativeEmitGprByBpDisp(pbCodeBuf, off, iGprSrc, offDisp );1220 return iemNativeEmitGprByBpDisp(pbCodeBuf, off, iGprSrc, offDisp, pReNative); 1188 1221 1189 1222 #elif defined(RT_ARCH_ARM64) … … 1212 1245 IEMNATIVE_REG_FIXED_TMP0, kArmv8A64InstrLdStExtend_Sxtw); 1213 1246 } 1247 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 1214 1248 return off; 1215 1249 … … 1253 1287 pbCodeBuf[off++] = RT_BYTE3(uImm64); 1254 1288 pbCodeBuf[off++] = RT_BYTE4(uImm64); 1289 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 1255 1290 return off; 1256 1291 } … … 1291 1326 pbCodeBuf[off++] = RT_BYTE4(iSubtrahend); 1292 1327 } 1328 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 1293 1329 return off; 1294 1330 } … … 1319 1355 # error "Port me" 1320 1356 #endif 1357 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 1321 1358 return off; 1322 1359 } … … 1356 1393 # error "Port me" 1357 1394 #endif 1395 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 1358 1396 return off; 1359 1397 } … … 1395 1433 # error "Port me" 1396 1434 #endif 1435 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 1397 1436 return off; 1398 1437 } … … 1465 1504 # error "Port me" 1466 1505 #endif 1506 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 1467 1507 return off; 1468 1508 } … … 1518 1558 # error "Port me" 1519 1559 #endif 1560 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 1520 1561 return off; 1521 1562 } … … 1549 1590 # error "Port me" 1550 1591 #endif 1592 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 1551 1593 return off; 1552 1594 } … … 1575 1617 # error "Port me" 1576 1618 #endif 1619 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 1577 1620 return off; 1578 1621 } … … 1591 1634 pu32CodeBuf[off++] = Armv8A64MkInstrAddSubReg(true /*fSub*/, ARMV8_A64_REG_XZR /*iRegResult*/, iGprLeft, iGprRight, 1592 1635 f64Bit, true /*fSetFlags*/, cShift, enmShift); 1636 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 1593 1637 return off; 1594 1638 } … … 1609 1653 pbCodeBuf[off++] = 0x3b; 1610 1654 pbCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, iGprLeft & 7, iGprRight & 7); 1655 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 1611 1656 1612 1657 #elif defined(RT_ARCH_ARM64) … … 1635 1680 pbCodeBuf[off++] = 0x3b; 1636 1681 pbCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, iGprLeft & 7, iGprRight & 7); 1682 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 1637 1683 1638 1684 #elif defined(RT_ARCH_ARM64) … … 1700 1746 # error "Port me!" 1701 1747 #endif 1748 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 1702 1749 return off; 1703 1750 } … … 1754 1801 # error "Port me!" 1755 1802 #endif 1803 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 1756 1804 return off; 1757 1805 } … … 1868 1916 # error "Port me!" 1869 1917 #endif 1918 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 1870 1919 return off; 1871 1920 } … … 1993 2042 # error "port me" 1994 2043 #endif 2044 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 1995 2045 return off; 1996 2046 }
Note:
See TracChangeset
for help on using the changeset viewer.