Changeset 101505 in vbox for trunk/src/VBox/VMM/VMMAll
- Timestamp:
- Oct 18, 2023 11:02:20 PM (16 months ago)
- Location:
- trunk/src/VBox/VMM/VMMAll
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/IEMAllN8vePython.py
r101484 r101505 51 51 'IEM_MC_DEFER_TO_CIMPL_3_RET_THREADED': (None, True, True, ), 52 52 53 'IEM_MC_ADVANCE_RIP_AND_FINISH_THREADED_PC16': (None, True, False,),53 'IEM_MC_ADVANCE_RIP_AND_FINISH_THREADED_PC16': (None, True, True, ), 54 54 'IEM_MC_ADVANCE_RIP_AND_FINISH_THREADED_PC32': (None, True, True, ), 55 'IEM_MC_ADVANCE_RIP_AND_FINISH_THREADED_PC64': (None, True, False,),55 'IEM_MC_ADVANCE_RIP_AND_FINISH_THREADED_PC64': (None, True, True, ), 56 56 57 57 'IEM_MC_ADVANCE_RIP_AND_FINISH_THREADED_PC16_WITH_FLAGS': (None, True, False, ), 58 'IEM_MC_ADVANCE_RIP_AND_FINISH_THREADED_PC32_WITH_FLAGS': (None, True, False, 58 'IEM_MC_ADVANCE_RIP_AND_FINISH_THREADED_PC32_WITH_FLAGS': (None, True, False, ), 59 59 'IEM_MC_ADVANCE_RIP_AND_FINISH_THREADED_PC64_WITH_FLAGS': (None, True, False, ), 60 60 … … 76 76 77 77 'IEM_MC_REL_JMP_S8_AND_FINISH_THREADED_PC16': (None, True, False, ), 78 'IEM_MC_REL_JMP_S8_AND_FINISH_THREADED_PC32': (None, True, False, ),78 'IEM_MC_REL_JMP_S8_AND_FINISH_THREADED_PC32': (None, True, False, ), 79 79 'IEM_MC_REL_JMP_S8_AND_FINISH_THREADED_PC64': (None, True, False, ), 80 80 'IEM_MC_REL_JMP_S16_AND_FINISH_THREADED_PC16': (None, True, False, ), -
trunk/src/VBox/VMM/VMMAll/IEMAllN8veRecompiler.cpp
r101490 r101505 173 173 Elf64_Shdr aShdrs[5]; 174 174 # else 175 Elf64_Shdr aShdrs[ 6];176 Elf64_Phdr aPhdrs[ 3];175 Elf64_Shdr aShdrs[7]; 176 Elf64_Phdr aPhdrs[2]; 177 177 # endif 178 178 /** The dwarf ehframe data for the chunk. */ 179 179 uint8_t abEhFrame[512]; 180 180 char szzStrTab[128]; 181 Elf64_Sym aSymbols[ 1];181 Elf64_Sym aSymbols[3]; 182 182 # ifdef IEMNATIVE_USE_GDB_JIT_ET_DYN 183 Elf64_Sym aDynSyms[2]; 183 184 Elf64_Dyn aDyn[6]; 184 185 # endif … … 353 354 354 355 355 static int iemExecMemAllocatorGrow(P IEMEXECMEMALLOCATOR pExecMemAllocator);356 static int iemExecMemAllocatorGrow(PVMCPUCC pVCpu, PIEMEXECMEMALLOCATOR pExecMemAllocator); 356 357 357 358 … … 520 521 if (pExecMemAllocator->cChunks < pExecMemAllocator->cMaxChunks) 521 522 { 522 int rc = iemExecMemAllocatorGrow(p ExecMemAllocator);523 int rc = iemExecMemAllocatorGrow(pVCpu, pExecMemAllocator); 523 524 AssertLogRelRCReturn(rc, NULL); 524 525 … … 641 642 */ 642 643 static int 643 iemExecMemAllocatorInitAndRegisterUnwindInfoForChunk(PIEMEXECMEMALLOCATOR pExecMemAllocator, void *pvChunk, uint32_t idxChunk) 644 { 644 iemExecMemAllocatorInitAndRegisterUnwindInfoForChunk(PVMCPUCC pVCpu, PIEMEXECMEMALLOCATOR pExecMemAllocator, 645 void *pvChunk, uint32_t idxChunk) 646 { 647 RT_NOREF(pVCpu); 648 645 649 /* 646 650 * The AMD64 unwind opcodes. … … 821 825 */ 822 826 static int 823 iemExecMemAllocatorInitAndRegisterUnwindInfoForChunk(PIEMEXECMEMALLOCATOR pExecMemAllocator, void *pvChunk, uint32_t idxChunk) 827 iemExecMemAllocatorInitAndRegisterUnwindInfoForChunk(PVMCPUCC pVCpu, PIEMEXECMEMALLOCATOR pExecMemAllocator, 828 void *pvChunk, uint32_t idxChunk) 824 829 { 825 830 PIEMEXECMEMCHUNKEHFRAME const pEhFrame = &pExecMemAllocator->paEhFrames[idxChunk]; … … 951 956 952 957 RT_ZERO(*pSymFile); 953 /* The ELF header: */ 958 959 /* 960 * The ELF header: 961 */ 954 962 pSymFile->EHdr.e_ident[0] = ELFMAG0; 955 963 pSymFile->EHdr.e_ident[1] = ELFMAG1; … … 997 1005 memcpy(&pSymFile->szzStrTab[offStrTab], a_szStr, sizeof(a_szStr)); \ 998 1006 offStrTab += sizeof(a_szStr); \ 1007 Assert(offStrTab < sizeof(pSymFile->szzStrTab)); \ 999 1008 } while (0) 1009 #define APPEND_STR_FMT(a_szStr, ...) do { \ 1010 offStrTab += RTStrPrintf(&pSymFile->szzStrTab[offStrTab], sizeof(pSymFile->szzStrTab) - offStrTab, a_szStr, __VA_ARGS__); \ 1011 offStrTab++; \ 1012 Assert(offStrTab < sizeof(pSymFile->szzStrTab)); \ 1013 } while (0) 1014 1015 /* 1016 * Section headers. 1017 */ 1000 1018 /* Section header #0: NULL */ 1001 1019 unsigned i = 0; … … 1048 1066 /* Section header: .symbols */ 1049 1067 pSymFile->aShdrs[i].sh_name = offStrTab; 1050 # if defined(IEMNATIVE_USE_GDB_JIT_ET_DYN)1051 APPEND_STR(".dynsym");1052 pSymFile->aShdrs[i].sh_type = SHT_DYNSYM;1053 # else1054 1068 APPEND_STR(".symtab"); 1055 1069 pSymFile->aShdrs[i].sh_type = SHT_SYMTAB; 1056 # endif1057 1070 pSymFile->aShdrs[i].sh_flags = SHF_ALLOC; 1058 1071 pSymFile->aShdrs[i].sh_offset … … 1064 1077 pSymFile->aShdrs[i].sh_entsize = sizeof(pSymFile->aSymbols[0]); 1065 1078 i++; 1079 1080 # if defined(IEMNATIVE_USE_GDB_JIT_ET_DYN) 1081 /* Section header: .symbols */ 1082 pSymFile->aShdrs[i].sh_name = offStrTab; 1083 APPEND_STR(".dynsym"); 1084 pSymFile->aShdrs[i].sh_type = SHT_DYNSYM; 1085 pSymFile->aShdrs[i].sh_flags = SHF_ALLOC; 1086 pSymFile->aShdrs[i].sh_offset 1087 = pSymFile->aShdrs[i].sh_addr = RT_UOFFSETOF(GDBJITSYMFILE, aDynSyms); 1088 pSymFile->aShdrs[i].sh_size = sizeof(pSymFile->aDynSyms); 1089 pSymFile->aShdrs[i].sh_link = iShStrTab; 1090 pSymFile->aShdrs[i].sh_info = RT_ELEMENTS(pSymFile->aDynSyms); 1091 pSymFile->aShdrs[i].sh_addralign = sizeof(pSymFile->aDynSyms[0].st_value); 1092 pSymFile->aShdrs[i].sh_entsize = sizeof(pSymFile->aDynSyms[0]); 1093 i++; 1094 # endif 1066 1095 1067 1096 # if defined(IEMNATIVE_USE_GDB_JIT_ET_DYN) … … 1082 1111 1083 1112 /* Section header: .text */ 1113 unsigned const iShText = i; 1084 1114 pSymFile->aShdrs[i].sh_name = offStrTab; 1085 1115 APPEND_STR(".text"); … … 1106 1136 * The program headers: 1107 1137 */ 1108 /* Headers and whatnot up to .dynamic: */1138 /* Everything in a single LOAD segment: */ 1109 1139 i = 0; 1110 1140 pSymFile->aPhdrs[i].p_type = PT_LOAD; … … 1114 1144 = pSymFile->aPhdrs[i].p_paddr = 0; 1115 1145 pSymFile->aPhdrs[i].p_filesz /* Size of segment in file. */ 1116 = pSymFile->aPhdrs[i].p_memsz = RT_UOFFSETOF(GDBJITSYMFILE, aDyn);1146 = pSymFile->aPhdrs[i].p_memsz = pExecMemAllocator->cbChunk - offSymFileInChunk; 1117 1147 pSymFile->aPhdrs[i].p_align = HOST_PAGE_SIZE; 1118 1148 i++; 1119 /* .dynamic*/1149 /* The .dynamic segment. */ 1120 1150 pSymFile->aPhdrs[i].p_type = PT_DYNAMIC; 1121 1151 pSymFile->aPhdrs[i].p_flags = PF_R; … … 1127 1157 pSymFile->aPhdrs[i].p_align = sizeof(pSymFile->aDyn[0].d_tag); 1128 1158 i++; 1129 /* The rest of the chunk. */1130 pSymFile->aPhdrs[i].p_type = PT_LOAD;1131 pSymFile->aPhdrs[i].p_flags = PF_X | PF_R;1132 pSymFile->aPhdrs[i].p_offset1133 = pSymFile->aPhdrs[i].p_vaddr1134 = pSymFile->aPhdrs[i].p_paddr = sizeof(GDBJITSYMFILE);1135 pSymFile->aPhdrs[i].p_filesz /* Size of segment in file. */1136 = pSymFile->aPhdrs[i].p_memsz = pExecMemAllocator->cbChunk - offSymFileInChunk - sizeof(GDBJITSYMFILE);1137 pSymFile->aPhdrs[i].p_align = 1;1138 i++;1139 1159 1140 1160 Assert(i == RT_ELEMENTS(pSymFile->aPhdrs)); 1141 1161 1142 /* The dynamic section: */ 1162 /* 1163 * The dynamic section: 1164 */ 1143 1165 i = 0; 1144 1166 pSymFile->aDyn[i].d_tag = DT_SONAME; 1145 1167 pSymFile->aDyn[i].d_un.d_val = offStrTab; 1146 APPEND_STR ("iem-native.so");1168 APPEND_STR_FMT("iem-exec-chunk-%u-%u", pVCpu->idCpu, idxChunk); 1147 1169 i++; 1148 1170 pSymFile->aDyn[i].d_tag = DT_STRTAB; … … 1153 1175 i++; 1154 1176 pSymFile->aDyn[i].d_tag = DT_SYMTAB; 1155 pSymFile->aDyn[i].d_un.d_ptr = RT_UOFFSETOF(GDBJITSYMFILE, a Symbols);1177 pSymFile->aDyn[i].d_un.d_ptr = RT_UOFFSETOF(GDBJITSYMFILE, aDynSyms); 1156 1178 i++; 1157 1179 pSymFile->aDyn[i].d_tag = DT_SYMENT; 1158 pSymFile->aDyn[i].d_un.d_val = sizeof(pSymFile->a Symbols[0]);1180 pSymFile->aDyn[i].d_un.d_val = sizeof(pSymFile->aDynSyms[0]); 1159 1181 i++; 1160 1182 pSymFile->aDyn[i].d_tag = DT_NULL; 1161 1183 i++; 1162 1184 Assert(i == RT_ELEMENTS(pSymFile->aDyn)); 1185 # endif /* IEMNATIVE_USE_GDB_JIT_ET_DYN */ 1186 1187 /* 1188 * Symbol tables: 1189 */ 1190 /** @todo gdb doesn't seem to really like this ... */ 1191 i = 0; 1192 pSymFile->aSymbols[i].st_name = 0; 1193 pSymFile->aSymbols[i].st_shndx = SHN_UNDEF; 1194 pSymFile->aSymbols[i].st_value = 0; 1195 pSymFile->aSymbols[i].st_size = 0; 1196 pSymFile->aSymbols[i].st_info = ELF64_ST_INFO(STB_LOCAL, STT_NOTYPE); 1197 pSymFile->aSymbols[i].st_other = 0 /* STV_DEFAULT */; 1198 # ifdef IEMNATIVE_USE_GDB_JIT_ET_DYN 1199 pSymFile->aDynSyms[0] = pSymFile->aSymbols[i]; 1163 1200 # endif 1164 1165 /* Symbol table: */ 1166 i = 0; 1167 pSymFile->aSymbols[i].st_name = offStrTab; 1168 APPEND_STR("iem_exec_chunk"); 1201 i++; 1202 1203 pSymFile->aSymbols[i].st_name = 0; 1169 1204 pSymFile->aSymbols[i].st_shndx = SHN_ABS; 1170 pSymFile->aSymbols[i].st_value = (uintptr_t)pvChunk;1171 pSymFile->aSymbols[i].st_size = pExecMemAllocator->cbChunk;1172 pSymFile->aSymbols[i].st_info = ELF64_ST_INFO(STB_LOCAL, STT_F UNC);1205 pSymFile->aSymbols[i].st_value = 0; 1206 pSymFile->aSymbols[i].st_size = 0; 1207 pSymFile->aSymbols[i].st_info = ELF64_ST_INFO(STB_LOCAL, STT_FILE); 1173 1208 pSymFile->aSymbols[i].st_other = 0 /* STV_DEFAULT */; 1174 1209 i++; 1210 1211 pSymFile->aSymbols[i].st_name = offStrTab; 1212 APPEND_STR_FMT("iem_exec_chunk_%u_%u", pVCpu->idCpu, idxChunk); 1213 # if 0 1214 pSymFile->aSymbols[i].st_shndx = iShText; 1215 pSymFile->aSymbols[i].st_value = 0; 1216 # else 1217 pSymFile->aSymbols[i].st_shndx = SHN_ABS; 1218 pSymFile->aSymbols[i].st_value = (uintptr_t)(pSymFile + 1); 1219 # endif 1220 pSymFile->aSymbols[i].st_size = pSymFile->aShdrs[iShText].sh_size; 1221 pSymFile->aSymbols[i].st_info = ELF64_ST_INFO(STB_GLOBAL, STT_FUNC); 1222 pSymFile->aSymbols[i].st_other = 0 /* STV_DEFAULT */; 1223 # ifdef IEMNATIVE_USE_GDB_JIT_ET_DYN 1224 pSymFile->aDynSyms[1] = pSymFile->aSymbols[i]; 1225 pSymFile->aDynSyms[1].st_value = (uintptr_t)(pSymFile + 1); 1226 # endif 1227 i++; 1228 1175 1229 Assert(i == RT_ELEMENTS(pSymFile->aSymbols)); 1176 1230 Assert(offStrTab < sizeof(pSymFile->szzStrTab)); 1177 1231 1178 /* The GDB JIT entry: */ 1232 /* 1233 * The GDB JIT entry and informing GDB. 1234 */ 1179 1235 pEhFrame->GdbJitEntry.pbSymFile = (uint8_t *)pSymFile; 1180 1236 # if 1 … … 1201 1257 RTCritSectLeave(&g_IemNativeGdbJitLock); 1202 1258 1203 # endif /* IEMNATIVE_USE_GDB_JIT */ 1259 # else /* !IEMNATIVE_USE_GDB_JIT */ 1260 RT_NOREF(pVCpu); 1261 # endif /* !IEMNATIVE_USE_GDB_JIT */ 1204 1262 1205 1263 return VINF_SUCCESS; … … 1216 1274 * regular allocator function when it's out of memory. 1217 1275 */ 1218 static int iemExecMemAllocatorGrow(P IEMEXECMEMALLOCATOR pExecMemAllocator)1276 static int iemExecMemAllocatorGrow(PVMCPUCC pVCpu, PIEMEXECMEMALLOCATOR pExecMemAllocator) 1219 1277 { 1220 1278 /* Check that we've room for growth. */ … … 1322 1380 * (This sets pvUnwindInfo.) 1323 1381 */ 1324 rc = iemExecMemAllocatorInitAndRegisterUnwindInfoForChunk(p ExecMemAllocator, pvChunk, idxChunk);1382 rc = iemExecMemAllocatorInitAndRegisterUnwindInfoForChunk(pVCpu, pExecMemAllocator, pvChunk, idxChunk); 1325 1383 if (RT_SUCCESS(rc)) 1326 1384 #endif … … 1344 1402 #endif 1345 1403 RTMemPageFree(pvChunk, pExecMemAllocator->cbChunk); 1404 RT_NOREF(pVCpu); 1346 1405 return rc; 1347 1406 } … … 1459 1518 while (cbInitial < (uint64_t)pExecMemAllocator->cChunks * pExecMemAllocator->cbChunk) 1460 1519 { 1461 int rc = iemExecMemAllocatorGrow(p ExecMemAllocator);1520 int rc = iemExecMemAllocatorGrow(pVCpu, pExecMemAllocator); 1462 1521 AssertLogRelRCReturn(rc, rc); 1463 1522 } … … 2868 2927 uint64_t uParam0, uint64_t uParam1, uint64_t uParam2) 2869 2928 { 2870 #ifdef VBOX_STRICT 2871 off = iemNativeEmitMarker(pReNative, off); 2872 AssertReturn(off != UINT32_MAX, UINT32_MAX); 2873 #endif 2929 iemNativeRegFlushGuestShadows(pReNative, UINT64_MAX); /** @todo optimize this */ 2930 off = iemNativeRegMoveAndFreeAndFlushAtCall(pReNative, off, 4, false /*fFreeArgVars*/); 2874 2931 2875 2932 /* … … 2943 3000 static int32_t iemNativeEmitThreadedCall(PIEMRECOMPILERSTATE pReNative, uint32_t off, PCIEMTHRDEDCALLENTRY pCallEntry) 2944 3001 { 2945 #ifdef VBOX_STRICT2946 off = iemNativeEmitMarker(pReNative, off);2947 AssertReturn(off != UINT32_MAX, UINT32_MAX);2948 #endif2949 3002 iemNativeRegFlushGuestShadows(pReNative, UINT64_MAX); /** @todo optimize this */ 2950 3003 off = iemNativeRegMoveAndFreeAndFlushAtCall(pReNative, off, 4, false /*fFreeArgVars*/); … … 3359 3412 3360 3413 3414 /** Same as iemRegAddToRip64AndFinishingNoFlags. */ 3415 DECLINLINE(uint32_t) iemNativeEmitAddToRip64AndFinishingNoFlags(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t cbInstr) 3416 { 3417 /* Allocate a temporary PC register. */ 3418 uint8_t const idxPcReg = iemNativeRegAllocTmpForGuestReg(pReNative, &off, kIemNativeGstReg_Pc, kIemNativeGstRegUse_ForUpdate); 3419 AssertReturn(idxPcReg != UINT8_MAX, UINT32_MAX); 3420 3421 /* Perform the addition and store the result. */ 3422 off = iemNativeEmitAddGprImm8(pReNative, off, idxPcReg, cbInstr); 3423 off = iemNativeEmitStoreGprToVCpuU64(pReNative, off, idxPcReg, RT_UOFFSETOF(VMCPU, cpum.GstCtx.rip)); 3424 3425 /* Free but don't flush the PC register. */ 3426 iemNativeRegFreeTmp(pReNative, idxPcReg); 3427 3428 return off; 3429 } 3430 3361 3431 /** Same as iemRegAddToEip32AndFinishingNoFlags. */ 3362 3432 DECLINLINE(uint32_t) iemNativeEmitAddToEip32AndFinishingNoFlags(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t cbInstr) 3363 3433 { 3364 3434 /* Allocate a temporary PC register. */ 3365 /** @todo this is not strictly required on AMD64, we could emit alternative3366 * code here if we don't get a tmp register... */3367 3435 uint8_t const idxPcReg = iemNativeRegAllocTmpForGuestReg(pReNative, &off, kIemNativeGstReg_Pc, kIemNativeGstRegUse_ForUpdate); 3368 3436 AssertReturn(idxPcReg != UINT8_MAX, UINT32_MAX); … … 3377 3445 return off; 3378 3446 } 3447 3448 3449 /** Same as iemRegAddToIp16AndFinishingNoFlags. */ 3450 DECLINLINE(uint32_t) iemNativeEmitAddToIp16AndFinishingNoFlags(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t cbInstr) 3451 { 3452 /* Allocate a temporary PC register. */ 3453 uint8_t const idxPcReg = iemNativeRegAllocTmpForGuestReg(pReNative, &off, kIemNativeGstReg_Pc, kIemNativeGstRegUse_ForUpdate); 3454 AssertReturn(idxPcReg != UINT8_MAX, UINT32_MAX); 3455 3456 /* Perform the addition and store the result. */ 3457 off = iemNativeEmitAddGpr32Imm8(pReNative, off, idxPcReg, cbInstr); 3458 off = iemNativeEmitClear16UpGpr(pReNative, off, idxPcReg); 3459 off = iemNativeEmitStoreGprToVCpuU64(pReNative, off, idxPcReg, RT_UOFFSETOF(VMCPU, cpum.GstCtx.rip)); 3460 3461 /* Free but don't flush the PC register. */ 3462 iemNativeRegFreeTmp(pReNative, idxPcReg); 3463 3464 return off; 3465 } 3466 3379 3467 3380 3468 /* … … 3474 3562 while (cCallsLeft-- > 0) 3475 3563 { 3564 #ifdef VBOX_STRICT 3565 off = iemNativeEmitMarker(pReNative, off, RT_MAKE_U32(pTb->Thrd.cCalls - cCallsLeft - 1, pCallEntry->enmFunction)); 3566 AssertReturn(off != UINT32_MAX, pTb); 3567 #endif 3476 3568 PFNIEMNATIVERECOMPFUNC const pfnRecom = g_apfnIemNativeRecompileFunctions[pCallEntry->enmFunction]; 3477 3569 if (pfnRecom) /** @todo stats on this. */ -
trunk/src/VBox/VMM/VMMAll/IEMAllThrdPython.py
r101484 r101505 1590 1590 1591 1591 if ThrdFnVar.ksVariation_16_Pre386 in dByVari: 1592 if not fSimple: 1593 aoCases.append(Case('IEMMODE_16BIT | IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK | 16', None)); # fall thru 1592 1594 aoCases.append(Case('IEMMODE_16BIT | IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK', ThrdFnVar.ksVariation_16_Pre386)); 1593 1595 if ThrdFnVar.ksVariation_16f_Pre386 in dByVari: # should be nested under previous if, but line too long. 1596 if not fSimple: 1597 aoCases.append(Case('IEMMODE_16BIT | IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK | 32 | 16', None)); # fall thru 1594 1598 aoCases.append(Case('IEMMODE_16BIT | IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK | 32', ThrdFnVar.ksVariation_16f_Pre386)); 1595 1599
Note:
See TracChangeset
for help on using the changeset viewer.