- Timestamp:
- Jun 15, 2018 12:56:01 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/em.h
r72560 r72564 205 205 EMEXITTYPE_MSR_READ, 206 206 EMEXITTYPE_MSR_WRITE, 207 EMEXITTYPE_CPUID 207 EMEXITTYPE_CPUID, 208 EMEXITTYPE_RDTSC, 209 EMEXITTYPE_MOV_CRX, 210 EMEXITTYPE_MOV_DRX, 211 212 /** @name Raw-mode only (for now), keep at end. 213 * @{ */ 214 EMEXITTYPE_INVLPG, 215 EMEXITTYPE_LLDT, 216 EMEXITTYPE_RDPMC, 217 EMEXITTYPE_CLTS, 218 EMEXITTYPE_STI, 219 EMEXITTYPE_INT, 220 EMEXITTYPE_SYSCALL, 221 EMEXITTYPE_SYSENTER, 222 EMEXITTYPE_HLT 223 /** @} */ 208 224 } EMEXITTYPE; 209 225 AssertCompileSize(EMEXITTYPE, 4); … … 243 259 VMMR0_INT_DECL(void) EMR0HistoryUpdatePC(PVMCPU pVCpu, uint64_t uFlatPC, bool fFlattened); 244 260 #endif 261 VMM_INT_DECL(EMEXITACTION) EMHistoryUpdateFlagsAndType(PVMCPU pVCpu, uint32_t uFlagsAndType); 262 VMM_INT_DECL(EMEXITACTION) EMHistoryUpdateFlagsAndTypeAndPC(PVMCPU pVCpu, uint32_t uFlagsAndType, uint64_t uFlatPC); 245 263 246 264 -
trunk/src/VBox/VMM/VMMAll/EMAll.cpp
r72560 r72564 469 469 * 470 470 * @param pVCpu The cross context virtual CPU structure. 471 * @param uFlatPC The flattened program counter (RIP). UINT64_MAX if not available.471 * @param uFlatPC The flattened program counter (RIP). 472 472 * @param fFlattened Set if RIP was subjected to CS.BASE, clear if not. 473 473 */ … … 483 483 } 484 484 #endif 485 486 487 /** 488 * Interface for convering a engine specific exit to a generic one and get guidance. 489 * 490 * @param pVCpu The cross context virtual CPU structure. 491 * @param uFlagsAndType Combined flags and type (see EMEXIT_MAKE_FLAGS_AND_TYPE). 492 * @thread EMT(pVCpu) 493 */ 494 VMM_INT_DECL(EMEXITACTION) EMHistoryUpdateFlagsAndType(PVMCPU pVCpu, uint32_t uFlagsAndType) 495 { 496 VMCPU_ASSERT_EMT(pVCpu); 497 498 /* 499 * Do the updating. 500 */ 501 AssertCompile(RT_ELEMENTS(pVCpu->em.s.aExitHistory) == 256); 502 PEMEXITENTRY pHistEntry = &pVCpu->em.s.aExitHistory[((uintptr_t)pVCpu->em.s.iNextExit - 1) & 0xff]; 503 pHistEntry->uFlagsAndType = uFlagsAndType | (pHistEntry->uFlagsAndType & (EMEXIT_F_CS_EIP | EMEXIT_F_UNFLATTENED_PC)); 504 505 /* 506 * If common exit type, we will insert/update the exit into the shared hash table. 507 */ 508 if ((uFlagsAndType & EMEXIT_F_KIND_MASK) == EMEXIT_F_KIND_EM) 509 { 510 /** @todo later */ 511 } 512 513 return EMEXITACTION_NORMAL; 514 } 515 516 517 /** 518 * Interface for convering a engine specific exit to a generic one and get 519 * guidance, supplying flattened PC too. 520 * 521 * @param pVCpu The cross context virtual CPU structure. 522 * @param uFlagsAndType Combined flags and type (see EMEXIT_MAKE_FLAGS_AND_TYPE). 523 * @param uFlatPC The flattened program counter (RIP). 524 * @thread EMT(pVCpu) 525 */ 526 VMM_INT_DECL(EMEXITACTION) EMHistoryUpdateFlagsAndTypeAndPC(PVMCPU pVCpu, uint32_t uFlagsAndType, uint64_t uFlatPC) 527 { 528 VMCPU_ASSERT_EMT(pVCpu); 529 530 /* 531 * Do the updating. 532 */ 533 AssertCompile(RT_ELEMENTS(pVCpu->em.s.aExitHistory) == 256); 534 PEMEXITENTRY pHistEntry = &pVCpu->em.s.aExitHistory[((uintptr_t)pVCpu->em.s.iNextExit - 1) & 0xff]; 535 pHistEntry->uFlagsAndType = uFlagsAndType; 536 pHistEntry->uFlatPC = uFlatPC; 537 538 /* 539 * If common exit type, we will insert/update the exit into the shared hash table. 540 */ 541 if ((uFlagsAndType & EMEXIT_F_KIND_MASK) == EMEXIT_F_KIND_EM) 542 { 543 /** @todo later */ 544 } 545 546 return EMEXITACTION_NORMAL; 547 } 485 548 486 549 -
trunk/src/VBox/VMM/VMMR3/EMR3Dbg.cpp
r72562 r72564 71 71 }; 72 72 73 VMM_INT_DECL(const char *) EMR3GetExitTypeName(uint32_t uExitType) 74 { 75 switch ((EMEXITTYPE)uExitType) 73 74 /** 75 * Translates EMEXITTYPE into a name. 76 * 77 * @returns Pointer to read-only name, NULL if unknown type. 78 * @param uExitType The exit type to name. 79 */ 80 VMM_INT_DECL(const char *) EMR3GetExitTypeName(EMEXITTYPE enmExitType) 81 { 82 switch (enmExitType) 76 83 { 77 84 case EMEXITTYPE_INVALID: return "invalid"; … … 85 92 case EMEXITTYPE_MSR_WRITE: return "MSR write"; 86 93 case EMEXITTYPE_CPUID: return "CPUID"; 94 case EMEXITTYPE_RDTSC: return "RDTSC"; 95 case EMEXITTYPE_MOV_CRX: return "MOV CRx"; 96 case EMEXITTYPE_MOV_DRX: return "MOV DRx"; 97 98 /* Raw-mode only: */ 99 case EMEXITTYPE_INVLPG: return "INVLPG"; 100 case EMEXITTYPE_LLDT: return "LLDT"; 101 case EMEXITTYPE_RDPMC: return "RDPMC"; 102 case EMEXITTYPE_CLTS: return "CLTS"; 103 case EMEXITTYPE_STI: return "STI"; 104 case EMEXITTYPE_INT: return "INT"; 105 case EMEXITTYPE_SYSCALL: return "SYSCALL"; 106 case EMEXITTYPE_SYSENTER: return "SYSENTER"; 107 case EMEXITTYPE_HLT: return "HLT"; 87 108 } 88 109 return NULL; 89 110 } 111 90 112 91 113 /** … … 103 125 { 104 126 case EMEXIT_F_KIND_EM: 105 pszExitName = EMR3GetExitTypeName( uFlagsAndType & EMEXIT_F_TYPE_MASK);127 pszExitName = EMR3GetExitTypeName((EMEXITTYPE)(uFlagsAndType & EMEXIT_F_TYPE_MASK)); 106 128 break; 107 129 -
trunk/src/VBox/VMM/VMMRC/IOMRC.cpp
r69111 r72564 218 218 { 219 219 case OP_IN: 220 EMHistoryUpdateFlagsAndType(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_IO_PORT_READ)); 220 221 return iomRCInterpretIN(pVM, pVCpu, pRegFrame, pCpu); 221 222 222 223 case OP_OUT: 224 EMHistoryUpdateFlagsAndType(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_IO_PORT_WRITE)); 223 225 return iomRCInterpretOUT(pVM, pVCpu, pRegFrame, pCpu); 224 226 225 227 case OP_INSB: 226 228 case OP_INSWD: 229 EMHistoryUpdateFlagsAndType(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_IO_PORT_STR_READ)); 227 230 return iomRCInterpretINS(pVCpu, pCpu); 228 231 229 232 case OP_OUTSB: 230 233 case OP_OUTSWD: 234 EMHistoryUpdateFlagsAndType(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_IO_PORT_STR_WRITE)); 231 235 return iomRCInterpretOUTS(pVCpu, pCpu); 232 236 -
trunk/src/VBox/VMM/VMMRC/TRPMRCHandlers.cpp
r72559 r72564 845 845 * Try handle it here, if not return to HC and emulate/interpret it there. 846 846 */ 847 switch (pCpu->pCurInstr->uOpcode) 847 uint16_t const uOpcode = pCpu->pCurInstr->uOpcode; 848 switch (uOpcode) 848 849 { 849 850 case OP_INT3: … … 856 857 case OP_INT: 857 858 { 859 EMHistoryUpdateFlagsAndType(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_INT)); 858 860 Assert(pCpu->Param1.fUse & DISUSE_IMMEDIATE8); 859 861 Assert(!(PATMIsPatchGCAddr(pVM, PC))); … … 888 890 889 891 case OP_HLT: 892 EMHistoryUpdateFlagsAndType(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_HLT)); 893 890 894 /* If it's in patch code, defer to ring-3. */ 891 895 if (PATMIsPatchGCAddr(pVM, PC)) … … 908 912 if ( !PATMIsPatchGCAddr(pVM, PC) 909 913 && !CSAMIsKnownDangerousInstr(pVM, PC)) 914 { 915 if (uOpcode == OP_MOV_CR) 916 EMHistoryUpdateFlagsAndType(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_MOV_CRX)); 917 else 918 EMHistoryUpdateFlagsAndType(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_MOV_DRX)); 910 919 break; 920 } 911 921 RT_FALL_THRU(); 912 922 case OP_INVLPG: … … 920 930 case OP_WRMSR: 921 931 { 932 /* Update history. */ 933 switch (uOpcode) 934 { 935 case OP_MOV_CR: 936 EMHistoryUpdateFlagsAndType(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_MOV_CRX)); 937 break; 938 case OP_MOV_DR: 939 EMHistoryUpdateFlagsAndType(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_MOV_DRX)); 940 break; 941 case OP_INVLPG: 942 EMHistoryUpdateFlagsAndType(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_INVLPG)); 943 break; 944 case OP_LLDT: 945 EMHistoryUpdateFlagsAndType(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_LLDT)); 946 break; 947 case OP_STI: 948 EMHistoryUpdateFlagsAndType(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_STI)); 949 break; 950 case OP_RDPMC: 951 EMHistoryUpdateFlagsAndType(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_RDPMC)); 952 break; 953 case OP_CLTS: 954 EMHistoryUpdateFlagsAndType(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_CLTS)); 955 break; 956 case OP_WBINVD: 957 EMHistoryUpdateFlagsAndType(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_CLTS)); 958 break; 959 case OP_RDMSR: 960 EMHistoryUpdateFlagsAndType(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_MSR_READ)); 961 break; 962 case OP_WRMSR: 963 EMHistoryUpdateFlagsAndType(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_MSR_WRITE)); 964 break; 965 } 966 922 967 rc = VBOXSTRICTRC_TODO(EMInterpretInstructionDisasState(pVCpu, pCpu, pRegFrame, PC, EMCODETYPE_SUPERVISOR)); 923 968 if (rc == VERR_EM_INTERPRETER) … … 952 997 TRPM_ENTER_DBG_HOOK(0xd); 953 998 954 switch (pCpu->pCurInstr->uOpcode) 999 uint16_t const uOpcode = pCpu->pCurInstr->uOpcode; 1000 switch (uOpcode) 955 1001 { 956 1002 /* … … 967 1013 case OP_INT: 968 1014 { 1015 EMHistoryUpdateFlagsAndType(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_INT)); 969 1016 Assert(pCpu->Param1.fUse & DISUSE_IMMEDIATE8); 970 1017 rc = TRPMForwardTrap(pVCpu, pRegFrame, (uint32_t)pCpu->Param1.uValue, pCpu->cbInstr, TRPM_TRAP_NO_ERRORCODE, TRPM_SOFTWARE_INT, 0xd); … … 986 1033 case OP_SYSCALL: 987 1034 case OP_SYSENTER: 1035 if (uOpcode == OP_SYSCALL) 1036 EMHistoryUpdateFlagsAndType(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_SYSCALL)); 1037 else 1038 EMHistoryUpdateFlagsAndType(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_SYSENTER)); 988 1039 #ifdef PATM_EMULATE_SYSENTER 989 1040 rc = PATMSysCall(pVM, CPUMCTX_FROM_CORE(pRegFrame), pCpu); … … 1127 1178 */ 1128 1179 if (Cpu.pCurInstr->uOpcode == OP_RDTSC) 1180 { 1181 EMHistoryUpdateFlagsAndType(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_RDTSC)); 1129 1182 return trpmGCTrap0dHandlerRdTsc(pVM, pVCpu, pRegFrame); 1183 } 1130 1184 1131 1185 /* … … 1135 1189 && (Cpu.pCurInstr->fOpType & DISOPTYPE_PORTIO)) 1136 1190 { 1191 /* IOMRCIOPortHandler updates exit history. */ 1137 1192 VBOXSTRICTRC rcStrict = IOMRCIOPortHandler(pVM, pVCpu, pRegFrame, &Cpu); 1138 1193 TRPM_EXIT_DBG_HOOK(0xd);
Note:
See TracChangeset
for help on using the changeset viewer.