Changeset 12657 in vbox
- Timestamp:
- Sep 22, 2008 6:29:06 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 36948
- Location:
- trunk
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/cpum.h
r12603 r12657 350 350 /** @} */ 351 351 352 /* padding to get 32byte aligned size */ 353 //// uint32_t padding[6]; 352 #if 0 353 /*& Padding to align the size on a 64 byte boundrary. */ 354 uint32_t padding[6]; 355 #endif 354 356 } CPUMCTX; 355 357 #pragma pack() … … 363 365 /** 364 366 * Selector hidden registers. (version 1.6) 367 * @todo move to CPUMInteral.h 365 368 */ 366 369 typedef struct CPUMSELREGHID_VER1_6 … … 378 381 /** 379 382 * CPU context. (Version 1.6) 383 * @todo move to CPUMInteral.h 380 384 */ 381 385 #pragma pack(1) … … 582 586 } CPUMCPUIDFEATURE; 583 587 584 /* 588 /** 585 589 * CPU Vendor. 586 590 */ … … 688 692 * @{ */ 689 693 694 695 CPUMDECL(bool) CPUMIsGuestIn16BitCode(PVM pVM); 696 CPUMDECL(bool) CPUMIsGuestIn32BitCode(PVM pVM); 697 CPUMDECL(CPUMCPUVENDOR) CPUMGetCPUVendor(PVM pVM); 698 690 699 /** 691 700 * Tests if the guest is running in real mode or not. … … 742 751 return (pCtx->msrEFER & MSR_K6_EFER_LMA) == MSR_K6_EFER_LMA; 743 752 } 744 745 /**746 * Tests if the guest is running in 16 bits paged protected or not.747 *748 * @returns true if in paged protected mode, otherwise false.749 * @param pVM The VM handle.750 */751 CPUMDECL(bool) CPUMIsGuestIn16BitCode(PVM pVM);752 753 /**754 * Tests if the guest is running in 32 bits paged protected or not.755 *756 * @returns true if in paged protected mode, otherwise false.757 * @param pVM The VM handle.758 */759 CPUMDECL(bool) CPUMIsGuestIn32BitCode(PVM pVM);760 753 761 754 /** … … 789 782 } 790 783 791 /**792 * Gets the CPU vendor793 *794 * @returns CPU vendor795 * @param pVM The VM handle.796 */797 CPUMDECL(CPUMCPUVENDOR) CPUMGetCPUVendor(PVM pVM);798 799 800 784 /** @} */ 801 802 785 803 786 … … 868 851 /** @} */ 869 852 870 CPUMDECL(void) CPUMPushHyper(PVM pVM, uint32_t u32); 871 872 /** 873 * Sets or resets an alternative hypervisor context core. 874 * 875 * This is called when we get a hypervisor trap set switch the context 876 * core with the trap frame on the stack. It is called again to reset 877 * back to the default context core when resuming hypervisor execution. 878 * 879 * @param pVM The VM handle. 880 * @param pCtxCore Pointer to the alternative context core or NULL 881 * to go back to the default context core. 882 */ 883 CPUMDECL(void) CPUMHyperSetCtxCore(PVM pVM, PCPUMCTXCORE pCtxCore); 884 885 886 /** 887 * Queries the pointer to the internal CPUMCTX structure 888 * 889 * @returns VBox status code. 890 * @param pVM Handle to the virtual machine. 891 * @param ppCtx Receives the CPUMCTX pointer when successful. 892 */ 893 CPUMDECL(int) CPUMQueryGuestCtxPtr(PVM pVM, PCPUMCTX *ppCtx); 894 895 /** 896 * Queries the pointer to the internal CPUMCTX structure for the hypervisor. 897 * 898 * @returns VBox status code. 899 * @param pVM Handle to the virtual machine. 900 * @param ppCtx Receives the hyper CPUMCTX pointer when successful. 901 */ 902 CPUMDECL(int) CPUMQueryHyperCtxPtr(PVM pVM, PCPUMCTX *ppCtx); 903 904 905 /** 906 * Gets the pointer to the internal CPUMCTXCORE structure. 907 * This is only for reading in order to save a few calls. 908 * 909 * @param pVM Handle to the virtual machine. 910 */ 853 CPUMDECL(void) CPUMPushHyper(PVM pVM, uint32_t u32); 854 CPUMDECL(void) CPUMHyperSetCtxCore(PVM pVM, PCPUMCTXCORE pCtxCore); 855 CPUMDECL(int) CPUMQueryGuestCtxPtr(PVM pVM, PCPUMCTX *ppCtx); 856 CPUMDECL(int) CPUMQueryHyperCtxPtr(PVM pVM, PCPUMCTX *ppCtx); 911 857 CPUMDECL(PCCPUMCTXCORE) CPUMGetGuestCtxCore(PVM pVM); 912 913 /**914 * Gets the pointer to the internal CPUMCTXCORE structure for the hypervisor.915 * This is only for reading in order to save a few calls.916 *917 * @param pVM Handle to the virtual machine.918 */919 858 CPUMDECL(PCCPUMCTXCORE) CPUMGetHyperCtxCore(PVM pVM); 920 921 /** 922 * Sets the guest context core registers. 923 * 924 * @param pVM Handle to the virtual machine. 925 * @param pCtxCore The new context core values. 926 */ 927 CPUMDECL(void) CPUMSetGuestCtxCore(PVM pVM, PCCPUMCTXCORE pCtxCore); 928 929 930 /** 931 * Transforms the guest CPU state to raw-ring mode. 932 * 933 * This function will change the any of the cs and ss register with DPL=0 to DPL=1. 934 * 935 * @returns VBox status. (recompiler failure) 936 * @param pVM VM handle. 937 * @param pCtxCore The context core (for trap usage). 938 * @see @ref pg_raw 939 */ 940 CPUMDECL(int) CPUMRawEnter(PVM pVM, PCPUMCTXCORE pCtxCore); 941 942 /** 943 * Transforms the guest CPU state from raw-ring mode to correct values. 944 * 945 * This function will change any selector registers with DPL=1 to DPL=0. 946 * 947 * @returns Adjusted rc. 948 * @param pVM VM handle. 949 * @param rc Raw mode return code 950 * @param pCtxCore The context core (for trap usage). 951 * @see @ref pg_raw 952 */ 953 CPUMDECL(int) CPUMRawLeave(PVM pVM, PCPUMCTXCORE pCtxCore, int rc); 954 955 /** 956 * Gets the EFLAGS while we're in raw-mode. 957 * 958 * @returns The eflags. 959 * @param pVM The VM handle. 960 * @param pCtxCore The context core. 961 */ 962 CPUMDECL(uint32_t) CPUMRawGetEFlags(PVM pVM, PCPUMCTXCORE pCtxCore); 963 964 /** 965 * Updates the EFLAGS while we're in raw-mode. 966 * 967 * @param pVM The VM handle. 968 * @param pCtxCore The context core. 969 * @param eflags The new EFLAGS value. 970 */ 971 CPUMDECL(void) CPUMRawSetEFlags(PVM pVM, PCPUMCTXCORE pCtxCore, uint32_t eflags); 972 973 /** 974 * Lazily sync in the FPU/XMM state 975 * 976 * This function will change any selector registers with DPL=1 to DPL=0. 977 * 978 * @returns VBox status code. 979 * @param pVM VM handle. 980 */ 981 CPUMDECL(int) CPUMHandleLazyFPU(PVM pVM); 982 983 984 /** 985 * Restore host FPU/XMM state 986 * 987 * @returns VBox status code. 988 * @param pVM VM handle. 989 */ 990 CPUMDECL(int) CPUMRestoreHostFPUState(PVM pVM); 859 CPUMDECL(void) CPUMSetGuestCtxCore(PVM pVM, PCCPUMCTXCORE pCtxCore); 860 CPUMDECL(int) CPUMRawEnter(PVM pVM, PCPUMCTXCORE pCtxCore); 861 CPUMDECL(int) CPUMRawLeave(PVM pVM, PCPUMCTXCORE pCtxCore, int rc); 862 CPUMDECL(uint32_t) CPUMRawGetEFlags(PVM pVM, PCPUMCTXCORE pCtxCore); 863 CPUMDECL(void) CPUMRawSetEFlags(PVM pVM, PCPUMCTXCORE pCtxCore, uint32_t eflags); 864 CPUMDECL(int) CPUMHandleLazyFPU(PVM pVM); 865 CPUMDECL(int) CPUMRestoreHostFPUState(PVM pVM); 991 866 992 867 /** @name Changed flags … … 1011 886 /** @} */ 1012 887 1013 /** 1014 * Gets and resets the changed flags (CPUM_CHANGED_*). 1015 * 1016 * @returns The changed flags. 1017 * @param pVM VM handle. 1018 */ 1019 CPUMDECL(unsigned) CPUMGetAndClearChangedFlagsREM(PVM pVM); 1020 1021 /** 1022 * Sets the specified changed flags (CPUM_CHANGED_*). 1023 * 1024 * @param pVM The VM handle. 1025 */ 1026 CPUMDECL(void) CPUMSetChangedFlags(PVM pVM, uint32_t fChangedFlags); 1027 1028 /** 1029 * Checks if the CPU supports the FXSAVE and FXRSTOR instruction. 1030 * @returns true if supported. 1031 * @returns false if not supported. 1032 * @param pVM The VM handle. 1033 */ 1034 CPUMDECL(bool) CPUMSupportsFXSR(PVM pVM); 1035 1036 /** 1037 * Checks if the host OS uses the SYSENTER / SYSEXIT instructions. 1038 * @returns true if used. 1039 * @returns false if not used. 1040 * @param pVM The VM handle. 1041 */ 1042 CPUMDECL(bool) CPUMIsHostUsingSysEnter(PVM pVM); 1043 1044 /** 1045 * Checks if the host OS uses the SYSCALL / SYSRET instructions. 1046 * @returns true if used. 1047 * @returns false if not used. 1048 * @param pVM The VM handle. 1049 */ 1050 CPUMDECL(bool) CPUMIsHostUsingSysCall(PVM pVM); 1051 1052 /** 1053 * Checks if we activated the FPU/XMM state of the guest OS 1054 * @returns true if we did. 1055 * @returns false if not. 1056 * @param pVM The VM handle. 1057 */ 1058 CPUMDECL(bool) CPUMIsGuestFPUStateActive(PVM pVM); 1059 1060 /** 1061 * Deactivate the FPU/XMM state of the guest OS 1062 * @param pVM The VM handle. 1063 */ 1064 CPUMDECL(void) CPUMDeactivateGuestFPUState(PVM pVM); 1065 1066 /** 1067 * Checks if the guest debug state is active 1068 * 1069 * @returns boolean 1070 * @param pVM VM handle. 1071 */ 1072 CPUMDECL(bool) CPUMIsGuestDebugStateActive(PVM pVM); 1073 1074 /** 1075 * Mark the guest's debug state as inactive 1076 * 1077 * @returns boolean 1078 * @param pVM VM handle. 1079 */ 1080 CPUMDECL(void) CPUMDeactivateGuestDebugtate(PVM pVM); 1081 1082 1083 /** 1084 * Checks if the hidden selector registers are valid 1085 * @returns true if they are. 1086 * @returns false if not. 1087 * @param pVM The VM handle. 1088 */ 1089 CPUMDECL(bool) CPUMAreHiddenSelRegsValid(PVM pVM); 1090 1091 /** 1092 * Checks if the hidden selector registers are valid 1093 * @param pVM The VM handle. 1094 * @param fValid Valid or not 1095 */ 1096 CPUMDECL(void) CPUMSetHiddenSelRegsValid(PVM pVM, bool fValid); 1097 1098 /** 1099 * Get the current privilege level of the guest. 1100 * 1101 * @returns cpl 1102 * @param pVM VM Handle. 1103 * @param pRegFrame Trap register frame. 1104 */ 1105 CPUMDECL(uint32_t) CPUMGetGuestCPL(PVM pVM, PCPUMCTXCORE pCtxCore); 888 CPUMDECL(unsigned) CPUMGetAndClearChangedFlagsREM(PVM pVM); 889 CPUMDECL(void) CPUMSetChangedFlags(PVM pVM, uint32_t fChangedFlags); 890 CPUMDECL(bool) CPUMSupportsFXSR(PVM pVM); 891 CPUMDECL(bool) CPUMIsHostUsingSysEnter(PVM pVM); 892 CPUMDECL(bool) CPUMIsHostUsingSysCall(PVM pVM); 893 CPUMDECL(bool) CPUMIsGuestFPUStateActive(PVM pVM); 894 CPUMDECL(void) CPUMDeactivateGuestFPUState(PVM pVM); 895 CPUMDECL(bool) CPUMIsGuestDebugStateActive(PVM pVM); 896 CPUMDECL(void) CPUMDeactivateGuestDebugState(PVM pVM); 897 CPUMDECL(bool) CPUMAreHiddenSelRegsValid(PVM pVM); 898 CPUMDECL(void) CPUMSetHiddenSelRegsValid(PVM pVM, bool fValid); 899 CPUMDECL(uint32_t) CPUMGetGuestCPL(PVM pVM, PCPUMCTXCORE pCtxCore); 1106 900 1107 901 /** … … 1120 914 } CPUMMODE; 1121 915 1122 /** 1123 * Gets the current guest CPU mode. 1124 * 1125 * If paging mode is what you need, check out PGMGetGuestMode(). 1126 * 1127 * @returns The CPU mode. 1128 * @param pVM The VM handle. 1129 */ 1130 CPUMDECL(CPUMMODE) CPUMGetGuestMode(PVM pVM); 916 CPUMDECL(CPUMMODE) CPUMGetGuestMode(PVM pVM); 1131 917 1132 918 … … 1137 923 */ 1138 924 1139 /** 1140 * Initializes the CPUM. 1141 * 1142 * @returns VBox status code. 1143 * @param pVM The VM to operate on. 1144 */ 1145 CPUMR3DECL(int) CPUMR3Init(PVM pVM); 1146 1147 /** 1148 * Applies relocations to data and code managed by this 1149 * component. This function will be called at init and 1150 * whenever the VMM need to relocate it self inside the GC. 1151 * 1152 * The CPUM will update the addresses used by the switcher. 1153 * 1154 * @param pVM The VM. 1155 */ 1156 CPUMR3DECL(void) CPUMR3Relocate(PVM pVM); 1157 1158 /** 1159 * Terminates the CPUM. 1160 * 1161 * Termination means cleaning up and freeing all resources, 1162 * the VM it self is at this point powered off or suspended. 1163 * 1164 * @returns VBox status code. 1165 * @param pVM The VM to operate on. 1166 */ 1167 CPUMR3DECL(int) CPUMR3Term(PVM pVM); 1168 1169 /** 1170 * Resets the CPU. 1171 * 1172 * @param pVM The VM handle. 1173 */ 1174 CPUMR3DECL(void) CPUMR3Reset(PVM pVM); 1175 1176 /** 1177 * Queries the pointer to the internal CPUMCTX structure 1178 * 1179 * @returns VBox status code. 1180 * @param pVM Handle to the virtual machine. 1181 * @param ppCtx Receives the CPUMCTX GC pointer when successful. 1182 */ 1183 CPUMR3DECL(int) CPUMR3QueryGuestCtxGCPtr(PVM pVM, RCPTRTYPE(PCPUMCTX) *ppCtx); 1184 1185 1186 #ifdef DEBUG 1187 /** 1188 * Debug helper - Saves guest context on raw mode entry (for fatal dump) 1189 * 1190 * @internal 1191 */ 1192 CPUMR3DECL(void) CPUMR3SaveEntryCtx(PVM pVM); 1193 #endif 1194 1195 /** 1196 * API for controlling a few of the CPU features found in CR4. 1197 * 1198 * Currently only X86_CR4_TSD is accepted as input. 1199 * 1200 * @returns VBox status code. 1201 * 1202 * @param pVM The VM handle. 1203 * @param fOr The CR4 OR mask. 1204 * @param fAnd The CR4 AND mask. 1205 */ 1206 CPUMR3DECL(int) CPUMR3SetCR4Feature(PVM pVM, RTHCUINTREG fOr, RTHCUINTREG fAnd); 925 CPUMR3DECL(int) CPUMR3Init(PVM pVM); 926 CPUMR3DECL(void) CPUMR3Relocate(PVM pVM); 927 CPUMR3DECL(int) CPUMR3Term(PVM pVM); 928 CPUMR3DECL(void) CPUMR3Reset(PVM pVM); 929 CPUMR3DECL(int) CPUMR3QueryGuestCtxGCPtr(PVM pVM, RCPTRTYPE(PCPUMCTX) *ppCtx); 930 # ifdef DEBUG 931 CPUMR3DECL(void) CPUMR3SaveEntryCtx(PVM pVM); 932 # endif 933 CPUMR3DECL(int) CPUMR3SetCR4Feature(PVM pVM, RTHCUINTREG fOr, RTHCUINTREG fAnd); 1207 934 1208 935 /** @} */ 1209 #endif 936 #endif /* IN_RING3 */ 1210 937 1211 938 #ifdef IN_GC … … 1227 954 * 1228 955 * This function does not return! 1229 * 1230 */ 1231 DECLASM(void) CPUMGCCallGuestTrapHandler(PCPUMCTXCORE pRegFrame, uint32_t selCS, RTRCPTR pHandler, uint32_t eflags, uint32_t selSS, RTRCPTR pEsp); 1232 1233 /** 1234 * Performs an iret to V86 code 1235 * Assumes a trap stack frame has already been setup on the guest's stack! 1236 * 1237 * @param pRegFrame Original trap/interrupt context 1238 * 1239 * This function does not return! 1240 */ 1241 CPUMGCDECL(void) CPUMGCCallV86Code(PCPUMCTXCORE pRegFrame); 956 */ 957 DECLASM(void) CPUMGCCallGuestTrapHandler(PCPUMCTXCORE pRegFrame, uint32_t selCS, RTRCPTR pHandler, uint32_t eflags, uint32_t selSS, RTRCPTR pEsp); 958 CPUMGCDECL(void) CPUMGCCallV86Code(PCPUMCTXCORE pRegFrame); 1242 959 1243 960 /** @} */ 1244 #endif 961 #endif /* IN_GC */ 1245 962 1246 963 #ifdef IN_RING0 … … 1249 966 * @{ 1250 967 */ 1251 1252 /**1253 * Does Ring-0 CPUM initialization.1254 *1255 * This is mainly to check that the Host CPU mode is compatible1256 * with VBox.1257 *1258 * @returns VBox status code.1259 * @param pVM The VM to operate on.1260 */1261 968 CPUMR0DECL(int) CPUMR0Init(PVM pVM); 1262 1263 /**1264 * Lazily sync in the FPU/XMM state1265 *1266 * @returns VBox status code.1267 * @param pVM VM handle.1268 * @param pCtx CPU context1269 */1270 969 CPUMR0DECL(int) CPUMR0LoadGuestFPU(PVM pVM, PCPUMCTX pCtx); 1271 1272 /**1273 * Save guest FPU/XMM state1274 *1275 * @returns VBox status code.1276 * @param pVM VM handle.1277 * @param pCtx CPU context1278 */1279 970 CPUMR0DECL(int) CPUMR0SaveGuestFPU(PVM pVM, PCPUMCTX pCtx); 1280 1281 /**1282 * Save guest debug state1283 *1284 * @returns VBox status code.1285 * @param pVM VM handle.1286 * @param pCtx CPU context1287 * @param fDR6 Include DR6 or not1288 */1289 971 CPUMR0DECL(int) CPUMR0SaveGuestDebugState(PVM pVM, PCPUMCTX pCtx, bool fDR6); 1290 1291 /**1292 * Lazily sync in the debug state1293 *1294 * @returns VBox status code.1295 * @param pVM VM handle.1296 * @param pCtx CPU context1297 * @param fDR6 Include DR6 or not1298 */1299 972 CPUMR0DECL(int) CPUMR0LoadGuestDebugState(PVM pVM, PCPUMCTX pCtx, bool fDR6); 1300 973 1301 974 /** @} */ 1302 #endif 975 #endif /* IN_RING0 */ 1303 976 1304 977 /** @} */ -
trunk/include/VBox/cpumdis.h
r8155 r12657 44 44 45 45 #ifdef IN_RING3 46 47 /**48 * Disassemble an instruction and return the information in the provided structure.49 *50 * @returns VBox status code.51 * @param pVM VM Handle52 * @param pCtx CPU context53 * @param GCPtrPC Program counter (relative to CS) to disassemble from.54 * @param pCpu Disassembly state55 * @param pszPrefix String prefix for logging (debug only)56 *57 */58 46 CPUMR3DECL(int) CPUMR3DisasmInstrCPU(PVM pVM, PCPUMCTX pCtx, RTGCPTR GCPtrPC, PDISCPUSTATE pCpu, const char *pszPrefix); 59 47 60 48 # ifdef DEBUG 61 /** 62 * Disassemble an instruction and dump it to the log 63 * 64 * @returns VBox status code. 65 * @param pVM VM Handle 66 * @param pCtx CPU context 67 * @param pc GC instruction pointer 68 * @param prefix String prefix for logging 69 * 70 * @deprecated Use DBGFR3DisasInstrCurrentLog(). 71 */ 49 /** @deprecated Use DBGFR3DisasInstrCurrentLog(). */ 72 50 CPUMR3DECL(void) CPUMR3DisasmInstr(PVM pVM, PCPUMCTX pCtx, RTGCPTR pc, char *prefix); 73 74 /** 75 * Disassemble an instruction and dump it to the log 76 * 77 * @returns VBox status code. 78 * @param pVM VM Handle 79 * @param pCtx CPU context 80 * @param pc GC instruction pointer 81 * @param prefix String prefix for logging 82 * @param nrInstructions 83 * 84 * @deprecated Create new DBGFR3Disas function to do this. 85 */ 51 /** @deprecated Create new DBGFR3Disas function to do this. */ 86 52 CPUMR3DECL(void) CPUMR3DisasmBlock(PVM pVM, PCPUMCTX pCtx, RTGCPTR pc, char *prefix, int nrInstructions); 87 88 53 # else 89 # define CPUMR3DisasmInstr(pVM, pCtx, pc, prefix) 90 # define CPUMR3DisasmBlock(pVM, pCtx, pc, prefix, nrInstructions) 54 /** @deprecated Use DBGFR3DisasInstrCurrentLog(). */ 55 # define CPUMR3DisasmInstr(pVM, pCtx, pc, prefix) do {} while (0) 56 /** @deprecated Create new DBGFR3Disas function to do this. */ 57 # define CPUMR3DisasmBlock(pVM, pCtx, pc, prefix, nrInstructions) do {} while (0) 91 58 # endif 92 59 -
trunk/include/VBox/vm.h
r12579 r12657 466 466 STAMPROFILEADV StatSwitcherTSS; 467 467 468 /** @todo Realign everything on 64 byte boundraries to better match the 469 * cache-line size. */ 468 470 /* padding - the unions must be aligned on 32 bytes boundraries. */ 469 uint32_t padding[HC_ARCH_BITS == 32 ? 4 : 6];471 uint32_t padding[HC_ARCH_BITS == 32 ? 4+8 : 6]; 470 472 471 473 /** CPUM part. */ … … 635 637 } rem; 636 638 637 #if HC_ARCH_BITS == 64638 639 /** Padding for aligning the cpu array on a 64 byte boundrary. */ 639 uint32_t u32Reserved2[HC_ARCH_BITS == 32 ? 0 : 8]; 640 #endif 640 uint32_t u32Reserved2[8]; 641 641 642 642 /** -
trunk/include/VBox/vm.mac
r12545 r12657 93 93 .StatSwitcherTSS resb STAMPROFILEADV_size 94 94 95 alignb 3295 alignb 64 96 96 .cpum resb 4416 97 97 .vmm resb 1024 -
trunk/src/VBox/VMM/CPUM.cpp
r12600 r12657 28 28 * There are three CPU contexts, the most important one is the guest one (GC). 29 29 * When running in raw-mode (RC) there is a special hyper context for the VMM 30 * that floats around inside the guest address space. When running in raw-mode31 * or when using 64-bit guests on a 32-bit host, CPUM also maintains a host32 * context for saving and restoring registers accross world switches. This latter33 * is done in cooperation with theworld switcher (@see pg_vmm).30 * part that floats around inside the guest address space. When running in 31 * raw-mode, CPUM also maintains a host context for saving and restoring 32 * registers accross world switches. This latter is done in cooperation with the 33 * world switcher (@see pg_vmm). 34 34 */ 35 35 … … 65 65 *******************************************************************************/ 66 66 /** The saved state version. */ 67 #define CPUM_SAVED_STATE_VERSION 8 68 /** The saved state version of 1.6, used for backwards compatability. */ 67 69 #define CPUM_SAVED_STATE_VERSION_VER1_6 6 68 #define CPUM_SAVED_STATE_VERSION 869 70 70 71 … … 85 86 /** Pointer to a cpu info dump type. */ 86 87 typedef CPUMDUMPTYPE *PCPUMDUMPTYPE; 88 87 89 88 90 /******************************************************************************* … … 119 121 * Setup any fixed pointers and offsets. 120 122 */ 121 pVM->cpum.s.offVM = RT_OFFSETOF(VM, cpum);122 pVM->cpum.s.pCPUMHC = &pVM->cpum.s;123 123 pVM->cpum.s.pHyperCoreR3 = CPUMCTX2CORE(&pVM->cpum.s.Hyper); 124 124 pVM->cpum.s.pHyperCoreR0 = VM_R0_ADDR(pVM, CPUMCTX2CORE(&pVM->cpum.s.Hyper)); … … 130 130 * Check that the CPU supports the minimum features we require. 131 131 */ 132 /** @todo check the contract! */133 132 if (!ASMHasCpuId()) 134 133 { … … 510 509 * Load CPUID overrides from configuration. 511 510 */ 511 /** @cfgm{CPUM/CPUID/[000000xx|800000xx|c000000x]/[eax|ebx|ecx|edx],32-bit} 512 * Overloads the CPUID leaf values. */ 512 513 PCPUMCPUID pCpuId = &pCPUM->aGuestCpuIdStd[0]; 513 514 uint32_t cElements = RT_ELEMENTS(pCPUM->aGuestCpuIdStd); … … 603 604 * Switcher pointers. 604 605 */ 605 pVM->cpum.s.pCPUMGC = VM_GUEST_ADDR(pVM, &pVM->cpum.s); 606 pVM->cpum.s.pHyperCoreGC = MMHyperCCToRC(pVM, pVM->cpum.s.pHyperCoreR3); 607 Assert(pVM->cpum.s.pHyperCoreGC != NIL_RTGCPTR); 606 pVM->cpum.s.pHyperCoreRC = MMHyperCCToRC(pVM, pVM->cpum.s.pHyperCoreR3); 607 Assert(pVM->cpum.s.pHyperCoreRC != NIL_RTRCPTR); 608 608 } 609 609 … … 714 714 pCtx->fpu.FCW = 0x37f; 715 715 716 /* Intel ® 64 and IA-32 Architectures Software Developers Manual Volume 3A, Table 8-1. IA-32 Processor States Following Power-up, Reset, or INIT */716 /* Intel 64 and IA-32 Architectures Software Developer's Manual Volume 3A, Table 8-1. IA-32 Processor States Following Power-up, Reset, or INIT */ 717 717 pCtx->fpu.MXCSR = 0x1F80; 718 718 … … 765 765 } 766 766 767 767 768 /** 768 769 * Load a version 1.6 CPUMCTX structure. … … 774 775 static void cpumR3LoadCPUM1_6(PVM pVM, CPUMCTX_VER1_6 *pCpumctx16) 775 776 { 776 #define CPUMCTX16_LOADREG(regname) pVM->cpum.s.Guest.regname = pCpumctx16->regname; 777 778 #define CPUMCTX16_LOADDRXREG(regname) pVM->cpum.s.Guest.dr[regname] = pCpumctx16->dr##regname; 779 780 #define CPUMCTX16_LOADHIDREG(regname) \ 781 pVM->cpum.s.Guest.regname##Hid.u64Base = pCpumctx16->regname##Hid.u32Base; \ 782 pVM->cpum.s.Guest.regname##Hid.u32Limit = pCpumctx16->regname##Hid.u32Limit; \ 783 pVM->cpum.s.Guest.regname##Hid.Attr = pCpumctx16->regname##Hid.Attr; 784 785 #define CPUMCTX16_LOADSEGREG(regname) \ 786 pVM->cpum.s.Guest.regname = pCpumctx16->regname; \ 787 CPUMCTX16_LOADHIDREG(regname); 788 789 pVM->cpum.s.Guest.fpu = pCpumctx16->fpu; 777 #define CPUMCTX16_LOADREG(RegName) \ 778 pVM->cpum.s.Guest.RegName = pCpumctx16->RegName; 779 780 #define CPUMCTX16_LOADDRXREG(RegName) \ 781 pVM->cpum.s.Guest.dr[RegName] = pCpumctx16->dr##RegName; 782 783 #define CPUMCTX16_LOADHIDREG(RegName) \ 784 pVM->cpum.s.Guest.RegName##Hid.u64Base = pCpumctx16->RegName##Hid.u32Base; \ 785 pVM->cpum.s.Guest.RegName##Hid.u32Limit = pCpumctx16->RegName##Hid.u32Limit; \ 786 pVM->cpum.s.Guest.RegName##Hid.Attr = pCpumctx16->RegName##Hid.Attr; 787 788 #define CPUMCTX16_LOADSEGREG(RegName) \ 789 pVM->cpum.s.Guest.RegName = pCpumctx16->RegName; \ 790 CPUMCTX16_LOADHIDREG(RegName); 791 792 pVM->cpum.s.Guest.fpu = pCpumctx16->fpu; 790 793 791 794 CPUMCTX16_LOADREG(rax); … … 851 854 CPUMCTX16_LOADHIDREG(tr); 852 855 856 #undef CPUMCTX16_LOADSEGREG 853 857 #undef CPUMCTX16_LOADHIDREG 854 #undef CPUMCTX16_LOAD SEGREG858 #undef CPUMCTX16_LOADDRXREG 855 859 #undef CPUMCTX16_LOADREG 856 860 } 861 857 862 858 863 /** … … 977 982 * Format the flags. 978 983 */ 979 static struct984 static const struct 980 985 { 981 986 const char *pszSet; const char *pszClear; uint32_t fFlag; … … 1039 1044 case CPUMDUMPTYPE_TERSE: 1040 1045 if (CPUMIsGuestIn64BitCode(pVM, pCtxCore)) 1041 {1042 1046 pHlp->pfnPrintf(pHlp, 1043 1047 "%srax=%016RX64 %srbx=%016RX64 %srcx=%016RX64 %srdx=%016RX64\n" … … 1053 1057 pszPrefix, (RTSEL)pCtxCore->cs, pszPrefix, (RTSEL)pCtxCore->ss, pszPrefix, (RTSEL)pCtxCore->ds, pszPrefix, (RTSEL)pCtxCore->es, 1054 1058 pszPrefix, (RTSEL)pCtxCore->fs, pszPrefix, (RTSEL)pCtxCore->gs, pszPrefix, efl); 1055 }1056 1059 else 1057 1060 pHlp->pfnPrintf(pHlp, … … 1067 1070 case CPUMDUMPTYPE_DEFAULT: 1068 1071 if (CPUMIsGuestIn64BitCode(pVM, pCtxCore)) 1069 {1070 1072 pHlp->pfnPrintf(pHlp, 1071 1073 "%srax=%016RX64 %srbx=%016RX64 %srcx=%016RX64 %srdx=%016RX64\n" … … 1085 1087 pszPrefix, pCtx->cr0, pszPrefix, pCtx->cr2, pszPrefix, pCtx->cr3, pszPrefix, pCtx->cr4, 1086 1088 pszPrefix, pCtx->gdtr.pGdt, pCtx->gdtr.cbGdt, pszPrefix, (RTSEL)pCtx->ldtr); 1087 }1088 1089 else 1089 1090 pHlp->pfnPrintf(pHlp, … … 1103 1104 case CPUMDUMPTYPE_VERBOSE: 1104 1105 if (CPUMIsGuestIn64BitCode(pVM, pCtxCore)) 1105 {1106 1106 pHlp->pfnPrintf(pHlp, 1107 1107 "%srax=%016RX64 %srbx=%016RX64 %srcx=%016RX64 %srdx=%016RX64\n" … … 1141 1141 pszPrefix, (RTSEL)pCtx->tr, pCtx->trHid.u64Base, pCtx->trHid.u32Limit, pCtx->trHid.Attr.u, 1142 1142 pszPrefix, pCtx->SysEnter.cs, pCtx->SysEnter.eip, pCtx->SysEnter.esp); 1143 }1144 1143 else 1145 1144 pHlp->pfnPrintf(pHlp, … … 1181 1180 pszPrefix, pCtx->fpu.MXCSR, pszPrefix, pCtx->fpu.MXCSR_MASK); 1182 1181 1183 1184 1182 pHlp->pfnPrintf(pHlp, 1185 1183 "MSR:\n" … … 1198 1196 pszPrefix, pCtx->msrSFMASK, 1199 1197 pszPrefix, pCtx->msrKERNELGSBASE); 1200 1201 1198 break; 1202 1199 } … … 1276 1273 cpumR3InfoOne(pVM, &pVM->cpum.s.Guest, CPUMCTX2CORE(&pVM->cpum.s.Guest), pHlp, enmType, ""); 1277 1274 } 1275 1278 1276 1279 1277 /** … … 2260 2258 * @param pc GC instruction pointer 2261 2259 * @param prefix String prefix for logging 2260 * 2262 2261 * @deprecated Use DBGFR3DisasInstrCurrentLog(). 2263 *2264 2262 */ 2265 2263 CPUMR3DECL(void) CPUMR3DisasmInstr(PVM pVM, PCPUMCTX pCtx, RTGCPTR pc, char *prefix) 2266 2264 { 2267 DISCPUSTATE cpu;2268 2269 CPUMR3DisasmInstrCPU(pVM, pCtx, pc, &cpu, prefix); 2270 } 2265 DISCPUSTATE Cpu; 2266 CPUMR3DisasmInstrCPU(pVM, pCtx, pc, &Cpu, prefix); 2267 } 2268 2271 2269 2272 2270 /** … … 2280 2278 * @param nrInstructions 2281 2279 * 2280 * @deprecated Create new DBGFR3Disas function to do this. 2282 2281 */ 2283 2282 CPUMR3DECL(void) CPUMR3DisasmBlock(PVM pVM, PCPUMCTX pCtx, RTGCPTR pc, char *prefix, int nrInstructions) 2284 2283 { 2285 for (int i=0;i<nrInstructions;i++)2284 for (int i = 0; i < nrInstructions; i++) 2286 2285 { 2287 2286 DISCPUSTATE cpu; … … 2292 2291 } 2293 2292 2293 2294 /** 2295 * Debug helper - Saves guest context on raw mode entry (for fatal dump) 2296 * 2297 * @internal 2298 */ 2299 CPUMR3DECL(void) CPUMR3SaveEntryCtx(PVM pVM) 2300 { 2301 pVM->cpum.s.GuestEntry = pVM->cpum.s.Guest; 2302 } 2303 2294 2304 #endif /* DEBUG */ 2295 2296 #ifdef DEBUG2297 /**2298 * Debug helper - Saves guest context on raw mode entry (for fatal dump)2299 *2300 * @internal2301 */2302 CPUMR3DECL(void) CPUMR3SaveEntryCtx(PVM pVM)2303 {2304 pVM->cpum.s.GuestEntry = pVM->cpum.s.Guest;2305 }2306 #endif /* DEBUG */2307 2308 2305 2309 2306 /** -
trunk/src/VBox/VMM/CPUMInternal.h
r10687 r12657 85 85 86 86 /** 87 * The save host CPU state.87 * The saved host CPU state. 88 88 * 89 89 * @remark The special VBOX_WITH_HYBIRD_32BIT_KERNEL checks here are for the 10.4.x series … … 189 189 CPUMSYSENTER SysEnter; 190 190 191 /* padding to get 32byte aligned size */192 uint8_t auPadding[24 ];191 /* padding to get 64byte aligned size */ 192 uint8_t auPadding[24+32]; 193 193 194 194 #elif HC_ARCH_BITS == 64 || defined(VBOX_WITH_HYBIRD_32BIT_KERNEL) … … 236 236 /* padding to get 32byte aligned size */ 237 237 # ifdef VBOX_WITH_HYBIRD_32BIT_KERNEL 238 uint8_t auPadding[16 ];238 uint8_t auPadding[16+32]; 239 239 # else 240 uint8_t auPadding[8 ];240 uint8_t auPadding[8+32]; 241 241 # endif 242 242 … … 244 244 # error HC_ARCH_BITS not defined 245 245 #endif 246 } CPUMHOSTCTX, *PCPUMHOSTCTX; 247 248 249 /** 250 * Converts a CPUM pointer into a VM pointer. 251 * @returns Pointer to the VM structure the CPUM is part of. 252 * @param pCPUM Pointer to CPUM instance data. 253 */ 254 #define CPUM2VM(pCPUM) ( (PVM)((char*)pCPUM - pCPUM->offVM) ) 246 } CPUMHOSTCTX; 247 /** Pointer to the saved host CPU state. */ 248 typedef CPUMHOSTCTX *PCPUMHOSTCTX; 255 249 256 250 … … 258 252 * CPUM Data (part of VM) 259 253 */ 260 #pragma pack(1)261 254 typedef struct CPUM 262 255 { 263 /** Offset to the VM structure. */264 RTUINT offVM;265 /** Pointer to CPU structure in GC. */266 RCPTRTYPE(struct CPUM *) pCPUMGC;267 /** Pointer to CPU structure in HC. */268 R3R0PTRTYPE(struct CPUM *) pCPUMHC;269 270 /** Force 32byte alignment of the next member. */271 uint32_t padding[4 + (HC_ARCH_BITS == 32)];272 273 256 /** 274 257 * Saved host context. Only valid while inside GC. 275 * Must be aligned on 16byte boundrary.276 */ 277 CPUMHOSTCTX Host;258 * Aligned on a 64-byte boundrary. 259 */ 260 CPUMHOSTCTX Host; 278 261 279 262 /** 280 263 * Hypervisor context. 281 * Must be aligned on 16byte boundrary.282 */ 283 CPUMCTX Hyper;264 * Aligned on a 64-byte boundrary. 265 */ 266 CPUMCTX Hyper; 284 267 285 268 /** 286 269 * Guest context. 287 * Must be aligned on 16byte boundrary.288 */ 289 CPUMCTX Guest;270 * Aligned on a 64-byte boundrary. 271 */ 272 CPUMCTX Guest; 290 273 291 274 … … 294 277 /** Pointer to the current hypervisor core context - R3Ptr. */ 295 278 R0PTRTYPE(PCPUMCTXCORE) pHyperCoreR0; 296 /** Pointer to the current hypervisor core context - GCPtr. */297 RCPTRTYPE(PCPUMCTXCORE) pHyperCore GC;279 /** Pointer to the current hypervisor core context - RCPtr. */ 280 RCPTRTYPE(PCPUMCTXCORE) pHyperCoreRC; 298 281 299 282 /** Use flags. 300 283 * These flags indicates both what is to be used and what have been used. 301 284 */ 302 uint32_t fUseFlags;285 uint32_t fUseFlags; 303 286 304 287 /** Changed flags. … … 307 290 * See the CPUM_CHANGED_* defines for what we keep track of. 308 291 */ 309 uint32_t fChanged;292 uint32_t fChanged; 310 293 311 294 /** Hidden selector registers state. 312 295 * Valid (hw accelerated raw mode) or not (normal raw mode) 313 296 */ 314 uint32_t fValidHiddenSelRegs;297 uint32_t fValidHiddenSelRegs; 315 298 316 299 /** Host CPU Features - ECX */ … … 321 304 /** ecx part */ 322 305 X86CPUIDFEATECX ecx; 323 } 306 } CPUFeatures; 324 307 /** Host extended CPU features. */ 325 308 struct 326 309 { 327 310 /** edx part */ 328 uint32_t edx;311 uint32_t edx; 329 312 /** ecx part */ 330 uint32_t ecx;331 } 313 uint32_t ecx; 314 } CPUFeaturesExt; 332 315 333 316 /* CPU manufacturer. */ … … 337 320 struct 338 321 { 339 uint32_t AndMask;340 uint32_t OrMask;322 uint32_t AndMask; 323 uint32_t OrMask; 341 324 } CR4; 342 325 … … 354 337 CPUMCPUID GuestCpuIdDef; 355 338 339 /** Align the next member, and thereby the structure, on a 64-byte boundrary. */ 340 uint8_t abPadding2[HC_ARCH_BITS == 32 ? 56 : 44]; 341 356 342 /** 357 343 * Guest context on raw mode entry. 358 * This a debug feature. 359 */ 360 CPUMCTX GuestEntry; 361 } CPUM, *PCPUM; 362 #pragma pack() 363 364 #ifdef IN_RING3 365 366 #endif 344 * This a debug feature, see CPUMR3SaveEntryCtx. 345 */ 346 CPUMCTX GuestEntry; 347 } CPUM; 348 /** Pointer to the CPUM instance data residing in the shared VM structure. */ 349 typedef CPUM *PCPUM; 367 350 368 351 __BEGIN_DECLS … … 384 367 385 368 #endif 369 -
trunk/src/VBox/VMM/CPUMInternal.mac
r12600 r12657 1 1 ; $Id$ 2 2 ;; @file 3 ; CPUM - Internal header file .3 ; CPUM - Internal header file (asm). 4 4 ; 5 5 … … 37 37 %define CPUM_HANDLER_CTXCORE_IN_EBP RT_BIT(31) 38 38 39 %define VMMGCRET_USED_FPU 040000000h40 41 %define FPUSTATE_SIZE 51239 %define VMMGCRET_USED_FPU 040000000h 40 41 %define FPUSTATE_SIZE 512 42 42 43 43 ;; if anyone figures how to do %if HC_ARCH_BITS == 64 || defined(VBOX_WITH_HYBIRD_32BIT_KERNEL) in … … 50 50 51 51 struc CPUM 52 .offVM resd 153 .pCPUMGC RTGCPTR32_RES 1 ; Guest Context pointer54 .pCPUMHC RTHCPTR_RES 1 ; Host Context pointer55 56 57 52 ; 58 53 ; Host context state 59 54 ; 60 alignb 3261 55 .Host.fpu resb FPUSTATE_SIZE 62 56 … … 169 163 ; 170 164 ; Hypervisor Context. 171 ; (Identical to .Host.*) 172 ; 173 alignb 32 ; the padding 165 ; 166 alignb 64 ; the padding 174 167 .Hyper.fpu resb FPUSTATE_SIZE 175 168 … … 266 259 .Hyper.trHid.Attr resd 1 267 260 268 ; padding269 ;;;; .Hyper.padding resd 6270 271 272 261 273 262 ; 274 263 ; Guest context state 275 ; (Identical to the two above chunks)276 ; 277 alignb 32264 ; (Identical to the .Hyper chunk above.) 265 ; 266 alignb 64 278 267 .Guest.fpu resb FPUSTATE_SIZE 279 268 … … 370 359 .Guest.trHid.Attr resd 1 371 360 372 ; padding373 ;;;; .Guest.padding resd 6374 375 376 361 377 362 ; 378 363 ; Other stuff. 379 364 ; 380 alignb 32365 alignb 64 381 366 ; hypervisor core context. 382 367 .pHyperCoreR3 RTR3PTR_RES 1 383 368 .pHyperCoreR0 RTR0PTR_RES 1 384 .pHyperCore GC RTGCPTR32_RES1369 .pHyperCoreRC RTRCPTR_RES 1 385 370 ;... 386 371 .fUseFlags resd 1 … … 415 400 .GuestCpuIdDef resb 16 416 401 402 alignb 64 417 403 ; CPUMCTX debug stuff... 418 404 .GuestEntry resb 1024 419 420 405 endstruc 421 406 -
trunk/src/VBox/VMM/VMMAll/CPUMAllA.asm
r10687 r12657 266 266 ENDPROC CPUMLoadFPUAsm 267 267 268 268 269 ;; 269 270 ; Restores the guest's FPU/XMM state … … 285 286 ret 286 287 ENDPROC CPUMSaveFPUAsm 288 287 289 288 290 ;; … … 310 312 movdqa xmm6, [xDX + CPUMCTX.fpu + X86FXSTATE.aXMM + 16*6] 311 313 movdqa xmm7, [xDX + CPUMCTX.fpu + X86FXSTATE.aXMM + 16*7] 312 314 313 315 %ifdef RT_ARCH_AMD64 314 316 test qword [xDX + CPUMCTX.msrEFER], MSR_K6_EFER_LMA 315 317 jz CPUMLoadXMMAsm_done 316 318 317 319 movdqa xmm8, [xDX + CPUMCTX.fpu + X86FXSTATE.aXMM + 16*8] 318 320 movdqa xmm9, [xDX + CPUMCTX.fpu + X86FXSTATE.aXMM + 16*9] … … 354 356 movdqa [xDX + CPUMCTX.fpu + X86FXSTATE.aXMM + 16*6], xmm6 355 357 movdqa [xDX + CPUMCTX.fpu + X86FXSTATE.aXMM + 16*7], xmm7 356 358 357 359 %ifdef RT_ARCH_AMD64 358 360 test qword [xDX + CPUMCTX.msrEFER], MSR_K6_EFER_LMA … … 367 369 movdqa [xDX + CPUMCTX.fpu + X86FXSTATE.aXMM + 16*14], xmm14 368 370 movdqa [xDX + CPUMCTX.fpu + X86FXSTATE.aXMM + 16*15], xmm15 369 371 370 372 CPUMSaveXMMAsm_done: 371 373 %endif … … 396 398 ENDPROC CPUMSetFCW 397 399 400 398 401 ;; 399 402 ; Get the FPU control word … … 408 411 409 412 ;; 410 ; Set the MXCSR; 413 ; Set the MXCSR; 411 414 ; 412 415 ; @param u32MXCSR x86:[esp+4] GCC:rdi MSC:rcx New MXCSR … … 428 431 ENDPROC CPUMSetMXCSR 429 432 433 430 434 ;; 431 435 ; Get the MXCSR -
trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp
r12600 r12657 1 1 /* $Id$ */ 2 2 /** @file 3 * CPUM - CPU Monitor(/Manager) - Get s and Sets.3 * CPUM - CPU Monitor(/Manager) - Getters and Setters. 4 4 */ 5 5 … … 38 38 39 39 40 41 40 /** Disable stack frame pointer generation here. */ 42 41 #if defined(_MSC_VER) && !defined(DEBUG) … … 58 57 CPUMDECL(void) CPUMHyperSetCtxCore(PVM pVM, PCPUMCTXCORE pCtxCore) 59 58 { 60 LogFlow(("CPUMHyperSetCtxCore: %p/%p/%p -> %p\n", pVM->cpum.s.CTX ALLSUFF(pHyperCore), pCtxCore));59 LogFlow(("CPUMHyperSetCtxCore: %p/%p/%p -> %p\n", pVM->cpum.s.CTX_SUFF(pHyperCore), pCtxCore)); 61 60 if (!pCtxCore) 62 61 { … … 64 63 pVM->cpum.s.pHyperCoreR3 = (R3PTRTYPE(PCPUMCTXCORE))VM_R3_ADDR(pVM, pCtxCore); 65 64 pVM->cpum.s.pHyperCoreR0 = (R0PTRTYPE(PCPUMCTXCORE))VM_R0_ADDR(pVM, pCtxCore); 66 pVM->cpum.s.pHyperCore GC = (RCPTRTYPE(PCPUMCTXCORE))VM_GUEST_ADDR(pVM, pCtxCore);65 pVM->cpum.s.pHyperCoreRC = (RCPTRTYPE(PCPUMCTXCORE))VM_GUEST_ADDR(pVM, pCtxCore); 67 66 } 68 67 else … … 70 69 pVM->cpum.s.pHyperCoreR3 = (R3PTRTYPE(PCPUMCTXCORE))MMHyperCCToR3(pVM, pCtxCore); 71 70 pVM->cpum.s.pHyperCoreR0 = (R0PTRTYPE(PCPUMCTXCORE))MMHyperCCToR0(pVM, pCtxCore); 72 pVM->cpum.s.pHyperCore GC = (RCPTRTYPE(PCPUMCTXCORE))MMHyperCCToRC(pVM, pCtxCore);71 pVM->cpum.s.pHyperCoreRC = (RCPTRTYPE(PCPUMCTXCORE))MMHyperCCToRC(pVM, pCtxCore); 73 72 } 74 73 } … … 83 82 CPUMDECL(PCCPUMCTXCORE) CPUMGetHyperCtxCore(PVM pVM) 84 83 { 85 return pVM->cpum.s.CTX ALLSUFF(pHyperCore);84 return pVM->cpum.s.CTX_SUFF(pHyperCore); 86 85 } 87 86 … … 105 104 } 106 105 106 107 107 CPUMDECL(void) CPUMSetHyperGDTR(PVM pVM, uint32_t addr, uint16_t limit) 108 108 { … … 112 112 } 113 113 114 114 115 CPUMDECL(void) CPUMSetHyperIDTR(PVM pVM, uint32_t addr, uint16_t limit) 115 116 { … … 119 120 } 120 121 122 121 123 CPUMDECL(void) CPUMSetHyperCR3(PVM pVM, uint32_t cr3) 122 124 { … … 124 126 } 125 127 128 126 129 CPUMDECL(void) CPUMSetHyperCS(PVM pVM, RTSEL SelCS) 127 130 { 128 pVM->cpum.s.CTXALLSUFF(pHyperCore)->cs = SelCS; 129 } 131 pVM->cpum.s.CTX_SUFF(pHyperCore)->cs = SelCS; 132 } 133 130 134 131 135 CPUMDECL(void) CPUMSetHyperDS(PVM pVM, RTSEL SelDS) 132 136 { 133 pVM->cpum.s.CTXALLSUFF(pHyperCore)->ds = SelDS; 134 } 137 pVM->cpum.s.CTX_SUFF(pHyperCore)->ds = SelDS; 138 } 139 135 140 136 141 CPUMDECL(void) CPUMSetHyperES(PVM pVM, RTSEL SelES) 137 142 { 138 pVM->cpum.s.CTXALLSUFF(pHyperCore)->es = SelES; 139 } 143 pVM->cpum.s.CTX_SUFF(pHyperCore)->es = SelES; 144 } 145 140 146 141 147 CPUMDECL(void) CPUMSetHyperFS(PVM pVM, RTSEL SelFS) 142 148 { 143 pVM->cpum.s.CTXALLSUFF(pHyperCore)->fs = SelFS; 144 } 149 pVM->cpum.s.CTX_SUFF(pHyperCore)->fs = SelFS; 150 } 151 145 152 146 153 CPUMDECL(void) CPUMSetHyperGS(PVM pVM, RTSEL SelGS) 147 154 { 148 pVM->cpum.s.CTXALLSUFF(pHyperCore)->gs = SelGS; 149 } 155 pVM->cpum.s.CTX_SUFF(pHyperCore)->gs = SelGS; 156 } 157 150 158 151 159 CPUMDECL(void) CPUMSetHyperSS(PVM pVM, RTSEL SelSS) 152 160 { 153 pVM->cpum.s.CTXALLSUFF(pHyperCore)->ss = SelSS; 154 } 161 pVM->cpum.s.CTX_SUFF(pHyperCore)->ss = SelSS; 162 } 163 155 164 156 165 CPUMDECL(void) CPUMSetHyperESP(PVM pVM, uint32_t u32ESP) 157 166 { 158 pVM->cpum.s.CTXALLSUFF(pHyperCore)->esp = u32ESP; 159 } 167 pVM->cpum.s.CTX_SUFF(pHyperCore)->esp = u32ESP; 168 } 169 160 170 161 171 CPUMDECL(int) CPUMSetHyperEFlags(PVM pVM, uint32_t Efl) 162 172 { 163 pVM->cpum.s.CTXALLSUFF(pHyperCore)->eflags.u32 = Efl; 164 return VINF_SUCCESS; 165 } 173 pVM->cpum.s.CTX_SUFF(pHyperCore)->eflags.u32 = Efl; 174 return VINF_SUCCESS; 175 } 176 166 177 167 178 CPUMDECL(void) CPUMSetHyperEIP(PVM pVM, uint32_t u32EIP) 168 179 { 169 pVM->cpum.s.CTXALLSUFF(pHyperCore)->eip = u32EIP; 170 } 180 pVM->cpum.s.CTX_SUFF(pHyperCore)->eip = u32EIP; 181 } 182 171 183 172 184 CPUMDECL(void) CPUMSetHyperTR(PVM pVM, RTSEL SelTR) … … 175 187 } 176 188 189 177 190 CPUMDECL(void) CPUMSetHyperLDTR(PVM pVM, RTSEL SelLDTR) 178 191 { 179 192 pVM->cpum.s.Hyper.ldtr = SelLDTR; 180 193 } 194 181 195 182 196 CPUMDECL(void) CPUMSetHyperDR0(PVM pVM, RTGCUINTREG uDr0) … … 186 200 } 187 201 202 188 203 CPUMDECL(void) CPUMSetHyperDR1(PVM pVM, RTGCUINTREG uDr1) 189 204 { … … 192 207 } 193 208 209 194 210 CPUMDECL(void) CPUMSetHyperDR2(PVM pVM, RTGCUINTREG uDr2) 195 211 { … … 198 214 } 199 215 216 200 217 CPUMDECL(void) CPUMSetHyperDR3(PVM pVM, RTGCUINTREG uDr3) 201 218 { … … 204 221 } 205 222 223 206 224 CPUMDECL(void) CPUMSetHyperDR6(PVM pVM, RTGCUINTREG uDr6) 207 225 { … … 210 228 } 211 229 230 212 231 CPUMDECL(void) CPUMSetHyperDR7(PVM pVM, RTGCUINTREG uDr7) 213 232 { … … 219 238 CPUMDECL(RTSEL) CPUMGetHyperCS(PVM pVM) 220 239 { 221 return pVM->cpum.s.CTXALLSUFF(pHyperCore)->cs; 222 } 240 return pVM->cpum.s.CTX_SUFF(pHyperCore)->cs; 241 } 242 223 243 224 244 CPUMDECL(RTSEL) CPUMGetHyperDS(PVM pVM) 225 245 { 226 return pVM->cpum.s.CTXALLSUFF(pHyperCore)->ds; 227 } 246 return pVM->cpum.s.CTX_SUFF(pHyperCore)->ds; 247 } 248 228 249 229 250 CPUMDECL(RTSEL) CPUMGetHyperES(PVM pVM) 230 251 { 231 return pVM->cpum.s.CTXALLSUFF(pHyperCore)->es; 232 } 252 return pVM->cpum.s.CTX_SUFF(pHyperCore)->es; 253 } 254 233 255 234 256 CPUMDECL(RTSEL) CPUMGetHyperFS(PVM pVM) 235 257 { 236 return pVM->cpum.s.CTXALLSUFF(pHyperCore)->fs; 237 } 258 return pVM->cpum.s.CTX_SUFF(pHyperCore)->fs; 259 } 260 238 261 239 262 CPUMDECL(RTSEL) CPUMGetHyperGS(PVM pVM) 240 263 { 241 return pVM->cpum.s.CTXALLSUFF(pHyperCore)->gs; 242 } 264 return pVM->cpum.s.CTX_SUFF(pHyperCore)->gs; 265 } 266 243 267 244 268 CPUMDECL(RTSEL) CPUMGetHyperSS(PVM pVM) 245 269 { 246 return pVM->cpum.s.CTXALLSUFF(pHyperCore)->ss; 247 } 248 249 #if 0 /* these are not correct. */ 250 251 CPUMDECL(uint32_t) CPUMGetHyperCR0(PVM pVM) 252 { 253 return pVM->cpum.s.Hyper.cr0; 254 } 255 256 CPUMDECL(uint32_t) CPUMGetHyperCR2(PVM pVM) 257 { 258 return pVM->cpum.s.Hyper.cr2; 259 } 260 261 CPUMDECL(uint32_t) CPUMGetHyperCR3(PVM pVM) 262 { 263 return pVM->cpum.s.Hyper.cr3; 264 } 265 266 CPUMDECL(uint32_t) CPUMGetHyperCR4(PVM pVM) 267 { 268 return pVM->cpum.s.Hyper.cr4; 269 } 270 271 #endif /* not correct */ 270 return pVM->cpum.s.CTX_SUFF(pHyperCore)->ss; 271 } 272 272 273 273 274 CPUMDECL(uint32_t) CPUMGetHyperEAX(PVM pVM) 274 275 { 275 return pVM->cpum.s.CTXALLSUFF(pHyperCore)->eax; 276 } 276 return pVM->cpum.s.CTX_SUFF(pHyperCore)->eax; 277 } 278 277 279 278 280 CPUMDECL(uint32_t) CPUMGetHyperEBX(PVM pVM) 279 281 { 280 return pVM->cpum.s.CTXALLSUFF(pHyperCore)->ebx; 281 } 282 return pVM->cpum.s.CTX_SUFF(pHyperCore)->ebx; 283 } 284 282 285 283 286 CPUMDECL(uint32_t) CPUMGetHyperECX(PVM pVM) 284 287 { 285 return pVM->cpum.s.CTXALLSUFF(pHyperCore)->ecx; 286 } 288 return pVM->cpum.s.CTX_SUFF(pHyperCore)->ecx; 289 } 290 287 291 288 292 CPUMDECL(uint32_t) CPUMGetHyperEDX(PVM pVM) 289 293 { 290 return pVM->cpum.s.CTXALLSUFF(pHyperCore)->edx; 291 } 294 return pVM->cpum.s.CTX_SUFF(pHyperCore)->edx; 295 } 296 292 297 293 298 CPUMDECL(uint32_t) CPUMGetHyperESI(PVM pVM) 294 299 { 295 return pVM->cpum.s.CTXALLSUFF(pHyperCore)->esi; 296 } 300 return pVM->cpum.s.CTX_SUFF(pHyperCore)->esi; 301 } 302 297 303 298 304 CPUMDECL(uint32_t) CPUMGetHyperEDI(PVM pVM) 299 305 { 300 return pVM->cpum.s.CTXALLSUFF(pHyperCore)->edi; 301 } 306 return pVM->cpum.s.CTX_SUFF(pHyperCore)->edi; 307 } 308 302 309 303 310 CPUMDECL(uint32_t) CPUMGetHyperEBP(PVM pVM) 304 311 { 305 return pVM->cpum.s.CTXALLSUFF(pHyperCore)->ebp; 306 } 312 return pVM->cpum.s.CTX_SUFF(pHyperCore)->ebp; 313 } 314 307 315 308 316 CPUMDECL(uint32_t) CPUMGetHyperESP(PVM pVM) 309 317 { 310 return pVM->cpum.s.CTXALLSUFF(pHyperCore)->esp; 311 } 318 return pVM->cpum.s.CTX_SUFF(pHyperCore)->esp; 319 } 320 312 321 313 322 CPUMDECL(uint32_t) CPUMGetHyperEFlags(PVM pVM) 314 323 { 315 return pVM->cpum.s.CTXALLSUFF(pHyperCore)->eflags.u32; 316 } 324 return pVM->cpum.s.CTX_SUFF(pHyperCore)->eflags.u32; 325 } 326 317 327 318 328 CPUMDECL(uint32_t) CPUMGetHyperEIP(PVM pVM) 319 329 { 320 return pVM->cpum.s.CTXALLSUFF(pHyperCore)->eip; 321 } 330 return pVM->cpum.s.CTX_SUFF(pHyperCore)->eip; 331 } 332 322 333 323 334 CPUMDECL(uint64_t) CPUMGetHyperRIP(PVM pVM) 324 335 { 325 return pVM->cpum.s.CTXALLSUFF(pHyperCore)->rip; 326 } 336 return pVM->cpum.s.CTX_SUFF(pHyperCore)->rip; 337 } 338 327 339 328 340 CPUMDECL(uint32_t) CPUMGetHyperIDTR(PVM pVM, uint16_t *pcbLimit) … … 333 345 } 334 346 347 335 348 CPUMDECL(uint32_t) CPUMGetHyperGDTR(PVM pVM, uint16_t *pcbLimit) 336 349 { … … 340 353 } 341 354 355 342 356 CPUMDECL(RTSEL) CPUMGetHyperLDTR(PVM pVM) 343 357 { … … 345 359 } 346 360 361 347 362 CPUMDECL(RTGCUINTREG) CPUMGetHyperDR0(PVM pVM) 348 363 { … … 350 365 } 351 366 367 352 368 CPUMDECL(RTGCUINTREG) CPUMGetHyperDR1(PVM pVM) 353 369 { … … 355 371 } 356 372 373 357 374 CPUMDECL(RTGCUINTREG) CPUMGetHyperDR2(PVM pVM) 358 375 { … … 360 377 } 361 378 379 362 380 CPUMDECL(RTGCUINTREG) CPUMGetHyperDR3(PVM pVM) 363 381 { … … 365 383 } 366 384 385 367 386 CPUMDECL(RTGCUINTREG) CPUMGetHyperDR6(PVM pVM) 368 387 { 369 388 return pVM->cpum.s.Hyper.dr[6]; 370 389 } 390 371 391 372 392 CPUMDECL(RTGCUINTREG) CPUMGetHyperDR7(PVM pVM) … … 396 416 CPUMDECL(void) CPUMSetGuestCtxCore(PVM pVM, PCCPUMCTXCORE pCtxCore) 397 417 { 398 /** @todo #1410 requires selectors to be checked. */418 /** @todo #1410 requires selectors to be checked. (huh? 1410?) */ 399 419 400 420 PCPUMCTXCORE pCtxCoreDst = CPUMCTX2CORE(&pVM->cpum.s.Guest); … … 511 531 ASMSetCR0(HyperCR0); 512 532 } 513 # ifdef VBOX_STRICT533 # ifdef VBOX_STRICT 514 534 else 515 535 { … … 518 538 AssertMsg((HyperCR0 & X86_CR0_EM) == (pVM->cpum.s.Guest.cr0 & X86_CR0_EM), ("%#x\n", HyperCR0)); 519 539 } 520 # endif540 # endif 521 541 } 522 542 else … … 536 556 } 537 557 } 538 #endif 558 #endif /* IN_GC */ 539 559 540 560 /* … … 551 571 } 552 572 573 553 574 CPUMDECL(int) CPUMSetGuestCR2(PVM pVM, uint64_t cr2) 554 575 { … … 556 577 return VINF_SUCCESS; 557 578 } 579 558 580 559 581 CPUMDECL(int) CPUMSetGuestCR3(PVM pVM, uint64_t cr3) … … 563 585 return VINF_SUCCESS; 564 586 } 587 565 588 566 589 CPUMDECL(int) CPUMSetGuestCR4(PVM pVM, uint64_t cr4) … … 576 599 } 577 600 601 578 602 CPUMDECL(int) CPUMSetGuestEFlags(PVM pVM, uint32_t eflags) 579 603 { … … 582 606 } 583 607 608 584 609 CPUMDECL(int) CPUMSetGuestEIP(PVM pVM, uint32_t eip) 585 610 { … … 588 613 } 589 614 615 590 616 CPUMDECL(int) CPUMSetGuestEAX(PVM pVM, uint32_t eax) 591 617 { … … 594 620 } 595 621 622 596 623 CPUMDECL(int) CPUMSetGuestEBX(PVM pVM, uint32_t ebx) 597 624 { … … 600 627 } 601 628 629 602 630 CPUMDECL(int) CPUMSetGuestECX(PVM pVM, uint32_t ecx) 603 631 { … … 606 634 } 607 635 636 608 637 CPUMDECL(int) CPUMSetGuestEDX(PVM pVM, uint32_t edx) 609 638 { … … 612 641 } 613 642 643 614 644 CPUMDECL(int) CPUMSetGuestESP(PVM pVM, uint32_t esp) 615 645 { … … 618 648 } 619 649 650 620 651 CPUMDECL(int) CPUMSetGuestEBP(PVM pVM, uint32_t ebp) 621 652 { … … 624 655 } 625 656 657 626 658 CPUMDECL(int) CPUMSetGuestESI(PVM pVM, uint32_t esi) 627 659 { … … 630 662 } 631 663 664 632 665 CPUMDECL(int) CPUMSetGuestEDI(PVM pVM, uint32_t edi) 633 666 { … … 636 669 } 637 670 671 638 672 CPUMDECL(int) CPUMSetGuestSS(PVM pVM, uint16_t ss) 639 673 { … … 642 676 } 643 677 678 644 679 CPUMDECL(int) CPUMSetGuestCS(PVM pVM, uint16_t cs) 645 680 { … … 648 683 } 649 684 685 650 686 CPUMDECL(int) CPUMSetGuestDS(PVM pVM, uint16_t ds) 651 687 { … … 654 690 } 655 691 692 656 693 CPUMDECL(int) CPUMSetGuestES(PVM pVM, uint16_t es) 657 694 { … … 660 697 } 661 698 699 662 700 CPUMDECL(int) CPUMSetGuestFS(PVM pVM, uint16_t fs) 663 701 { … … 666 704 } 667 705 706 668 707 CPUMDECL(int) CPUMSetGuestGS(PVM pVM, uint16_t gs) 669 708 { … … 672 711 } 673 712 713 674 714 CPUMDECL(void) CPUMSetGuestEFER(PVM pVM, uint64_t val) 675 715 { … … 677 717 } 678 718 719 679 720 CPUMDECL(uint64_t) CPUMGetGuestMsr(PVM pVM, unsigned idMsr) 680 721 { 681 uint64_t val= 0;722 uint64_t u64 = 0; 682 723 683 724 switch (idMsr) 684 725 { 685 case MSR_IA32_CR_PAT:686 val= pVM->cpum.s.Guest.msrPAT;687 break;688 689 case MSR_IA32_SYSENTER_CS:690 val= pVM->cpum.s.Guest.SysEnter.cs;691 break;692 693 case MSR_IA32_SYSENTER_EIP:694 val= pVM->cpum.s.Guest.SysEnter.eip;695 break;696 697 case MSR_IA32_SYSENTER_ESP:698 val= pVM->cpum.s.Guest.SysEnter.esp;699 break;700 701 case MSR_K6_EFER:702 val= pVM->cpum.s.Guest.msrEFER;703 break;704 705 case MSR_K8_SF_MASK:706 val= pVM->cpum.s.Guest.msrSFMASK;707 break;708 709 case MSR_K6_STAR:710 val= pVM->cpum.s.Guest.msrSTAR;711 break;712 713 case MSR_K8_LSTAR:714 val= pVM->cpum.s.Guest.msrLSTAR;715 break;716 717 case MSR_K8_CSTAR:718 val= pVM->cpum.s.Guest.msrCSTAR;719 break;720 721 case MSR_K8_KERNEL_GS_BASE:722 val= pVM->cpum.s.Guest.msrKERNELGSBASE;723 break;724 725 /* fs & gs base skipped on purpose as the current context might not be up-to-date. */726 default:727 AssertFailed();728 break;726 case MSR_IA32_CR_PAT: 727 u64 = pVM->cpum.s.Guest.msrPAT; 728 break; 729 730 case MSR_IA32_SYSENTER_CS: 731 u64 = pVM->cpum.s.Guest.SysEnter.cs; 732 break; 733 734 case MSR_IA32_SYSENTER_EIP: 735 u64 = pVM->cpum.s.Guest.SysEnter.eip; 736 break; 737 738 case MSR_IA32_SYSENTER_ESP: 739 u64 = pVM->cpum.s.Guest.SysEnter.esp; 740 break; 741 742 case MSR_K6_EFER: 743 u64 = pVM->cpum.s.Guest.msrEFER; 744 break; 745 746 case MSR_K8_SF_MASK: 747 u64 = pVM->cpum.s.Guest.msrSFMASK; 748 break; 749 750 case MSR_K6_STAR: 751 u64 = pVM->cpum.s.Guest.msrSTAR; 752 break; 753 754 case MSR_K8_LSTAR: 755 u64 = pVM->cpum.s.Guest.msrLSTAR; 756 break; 757 758 case MSR_K8_CSTAR: 759 u64 = pVM->cpum.s.Guest.msrCSTAR; 760 break; 761 762 case MSR_K8_KERNEL_GS_BASE: 763 u64 = pVM->cpum.s.Guest.msrKERNELGSBASE; 764 break; 765 766 /* fs & gs base skipped on purpose as the current context might not be up-to-date. */ 767 default: 768 AssertFailed(); 769 break; 729 770 } 730 return val; 731 } 771 return u64; 772 } 773 732 774 733 775 CPUMDECL(RTGCPTR) CPUMGetGuestIDTR(PVM pVM, uint16_t *pcbLimit) … … 738 780 } 739 781 782 740 783 CPUMDECL(RTSEL) CPUMGetGuestTR(PVM pVM) 741 784 { … … 743 786 } 744 787 788 745 789 CPUMDECL(RTSEL) CPUMGetGuestCS(PVM pVM) 746 790 { … … 748 792 } 749 793 794 750 795 CPUMDECL(RTSEL) CPUMGetGuestDS(PVM pVM) 751 796 { … … 753 798 } 754 799 800 755 801 CPUMDECL(RTSEL) CPUMGetGuestES(PVM pVM) 756 802 { … … 758 804 } 759 805 806 760 807 CPUMDECL(RTSEL) CPUMGetGuestFS(PVM pVM) 761 808 { … … 763 810 } 764 811 812 765 813 CPUMDECL(RTSEL) CPUMGetGuestGS(PVM pVM) 766 814 { … … 768 816 } 769 817 818 770 819 CPUMDECL(RTSEL) CPUMGetGuestSS(PVM pVM) 771 820 { … … 773 822 } 774 823 824 775 825 CPUMDECL(RTSEL) CPUMGetGuestLDTR(PVM pVM) 776 826 { … … 778 828 } 779 829 830 780 831 CPUMDECL(uint64_t) CPUMGetGuestCR0(PVM pVM) 781 832 { … … 783 834 } 784 835 836 785 837 CPUMDECL(uint64_t) CPUMGetGuestCR2(PVM pVM) 786 838 { … … 788 840 } 789 841 842 790 843 CPUMDECL(uint64_t) CPUMGetGuestCR3(PVM pVM) 791 844 { … … 793 846 } 794 847 848 795 849 CPUMDECL(uint64_t) CPUMGetGuestCR4(PVM pVM) 796 850 { … … 798 852 } 799 853 854 800 855 CPUMDECL(void) CPUMGetGuestGDTR(PVM pVM, PVBOXGDTR pGDTR) 801 856 { … … 803 858 } 804 859 860 805 861 CPUMDECL(uint32_t) CPUMGetGuestEIP(PVM pVM) 806 862 { … … 808 864 } 809 865 866 810 867 CPUMDECL(uint64_t) CPUMGetGuestRIP(PVM pVM) 811 868 { … … 813 870 } 814 871 872 815 873 CPUMDECL(uint32_t) CPUMGetGuestEAX(PVM pVM) 816 874 { … … 818 876 } 819 877 878 820 879 CPUMDECL(uint32_t) CPUMGetGuestEBX(PVM pVM) 821 880 { … … 823 882 } 824 883 884 825 885 CPUMDECL(uint32_t) CPUMGetGuestECX(PVM pVM) 826 886 { … … 828 888 } 829 889 890 830 891 CPUMDECL(uint32_t) CPUMGetGuestEDX(PVM pVM) 831 892 { … … 833 894 } 834 895 896 835 897 CPUMDECL(uint32_t) CPUMGetGuestESI(PVM pVM) 836 898 { … … 838 900 } 839 901 902 840 903 CPUMDECL(uint32_t) CPUMGetGuestEDI(PVM pVM) 841 904 { … … 843 906 } 844 907 908 845 909 CPUMDECL(uint32_t) CPUMGetGuestESP(PVM pVM) 846 910 { … … 848 912 } 849 913 914 850 915 CPUMDECL(uint32_t) CPUMGetGuestEBP(PVM pVM) 851 916 { … … 853 918 } 854 919 920 855 921 CPUMDECL(uint32_t) CPUMGetGuestEFlags(PVM pVM) 856 922 { … … 858 924 } 859 925 926 860 927 CPUMDECL(CPUMSELREGHID *) CPUMGetGuestTRHid(PVM pVM) 861 928 { … … 863 930 } 864 931 865 //@todo: crx should be an array 932 933 ///@todo: crx should be an array 866 934 CPUMDECL(int) CPUMGetGuestCRx(PVM pVM, unsigned iReg, uint64_t *pValue) 867 935 { … … 886 954 } 887 955 956 888 957 CPUMDECL(uint64_t) CPUMGetGuestDR0(PVM pVM) 889 958 { … … 891 960 } 892 961 962 893 963 CPUMDECL(uint64_t) CPUMGetGuestDR1(PVM pVM) 894 964 { … … 896 966 } 897 967 968 898 969 CPUMDECL(uint64_t) CPUMGetGuestDR2(PVM pVM) 899 970 { … … 901 972 } 902 973 974 903 975 CPUMDECL(uint64_t) CPUMGetGuestDR3(PVM pVM) 904 976 { … … 906 978 } 907 979 980 908 981 CPUMDECL(uint64_t) CPUMGetGuestDR6(PVM pVM) 909 982 { … … 911 984 } 912 985 986 913 987 CPUMDECL(uint64_t) CPUMGetGuestDR7(PVM pVM) 914 988 { … … 916 990 } 917 991 992 918 993 CPUMDECL(int) CPUMGetGuestDRx(PVM pVM, uint32_t iReg, uint64_t *pValue) 919 994 { 920 995 AssertReturn(iReg <= USE_REG_DR7, VERR_INVALID_PARAMETER); 996 /* DR4 is an alias for DR6, and DR5 is an alias for DR7. */ 997 if (iReg == 4 || iReg == 5) 998 iReg += 2; 921 999 *pValue = pVM->cpum.s.Guest.dr[iReg]; 922 1000 return VINF_SUCCESS; 923 1001 } 924 1002 1003 925 1004 CPUMDECL(uint64_t) CPUMGetGuestEFER(PVM pVM) 926 1005 { 927 1006 return pVM->cpum.s.Guest.msrEFER; 928 1007 } 1008 929 1009 930 1010 /** … … 957 1037 } 958 1038 1039 959 1040 /** 960 1041 * Gets a pointer to the array of standard CPUID leafs. … … 971 1052 } 972 1053 1054 973 1055 /** 974 1056 * Gets a pointer to the array of extended CPUID leafs. … … 982 1064 CPUMDECL(RCPTRTYPE(PCCPUMCPUID)) CPUMGetGuestCpuIdExtGCPtr(PVM pVM) 983 1065 { 984 return RCPTRTYPE(PCCPUMCPUID)VM_GUEST_ADDR(pVM, &pVM->cpum.s.aGuestCpuIdExt[0]); 985 } 1066 return (RCPTRTYPE(PCCPUMCPUID))VM_GUEST_ADDR(pVM, &pVM->cpum.s.aGuestCpuIdExt[0]); 1067 } 1068 986 1069 987 1070 /** … … 996 1079 CPUMDECL(RCPTRTYPE(PCCPUMCPUID)) CPUMGetGuestCpuIdCentaurGCPtr(PVM pVM) 997 1080 { 998 return RCPTRTYPE(PCCPUMCPUID)VM_GUEST_ADDR(pVM, &pVM->cpum.s.aGuestCpuIdCentaur[0]); 999 } 1081 return (RCPTRTYPE(PCCPUMCPUID))VM_GUEST_ADDR(pVM, &pVM->cpum.s.aGuestCpuIdCentaur[0]); 1082 } 1083 1000 1084 1001 1085 /** … … 1008 1092 CPUMDECL(RCPTRTYPE(PCCPUMCPUID)) CPUMGetGuestCpuIdDefGCPtr(PVM pVM) 1009 1093 { 1010 return RCPTRTYPE(PCCPUMCPUID)VM_GUEST_ADDR(pVM, &pVM->cpum.s.GuestCpuIdDef); 1011 } 1094 return (RCPTRTYPE(PCCPUMCPUID))VM_GUEST_ADDR(pVM, &pVM->cpum.s.GuestCpuIdDef); 1095 } 1096 1012 1097 1013 1098 /** … … 1023 1108 } 1024 1109 1110 1025 1111 /** 1026 1112 * Gets a number of extended CPUID leafs. … … 1035 1121 } 1036 1122 1123 1037 1124 /** 1038 1125 * Gets a number of centaur CPUID leafs. … … 1046 1133 return RT_ELEMENTS(pVM->cpum.s.aGuestCpuIdCentaur); 1047 1134 } 1135 1048 1136 1049 1137 /** … … 1196 1284 } 1197 1285 1286 1198 1287 /** 1199 1288 * Queries a CPUID feature bit. … … 1220 1309 return false; 1221 1310 } 1311 1222 1312 1223 1313 /** … … 1272 1362 } 1273 1363 1364 1274 1365 /** 1275 1366 * Gets the CPU vendor … … 1290 1381 } 1291 1382 1383 1292 1384 CPUMDECL(int) CPUMSetGuestDR1(PVM pVM, uint64_t uDr1) 1293 1385 { … … 1296 1388 } 1297 1389 1390 1298 1391 CPUMDECL(int) CPUMSetGuestDR2(PVM pVM, uint64_t uDr2) 1299 1392 { … … 1302 1395 } 1303 1396 1397 1304 1398 CPUMDECL(int) CPUMSetGuestDR3(PVM pVM, uint64_t uDr3) 1305 1399 { … … 1308 1402 } 1309 1403 1404 1310 1405 CPUMDECL(int) CPUMSetGuestDR6(PVM pVM, uint64_t uDr6) 1311 1406 { … … 1314 1409 } 1315 1410 1411 1316 1412 CPUMDECL(int) CPUMSetGuestDR7(PVM pVM, uint64_t uDr7) 1317 1413 { … … 1320 1416 } 1321 1417 1418 1322 1419 CPUMDECL(int) CPUMSetGuestDRx(PVM pVM, uint32_t iReg, uint64_t Value) 1323 1420 { 1324 1421 AssertReturn(iReg <= USE_REG_DR7, VERR_INVALID_PARAMETER); 1422 /* DR4 is an alias for DR6, and DR5 is an alias for DR7. */ 1423 if (iReg == 4 || iReg == 5) 1424 iReg += 2; 1325 1425 pVM->cpum.s.Guest.dr[iReg] = Value; 1326 1426 return CPUMRecalcHyperDRx(pVM); … … 1639 1739 1640 1740 1641 1642 1643 1741 /** 1644 1742 * Gets and resets the changed flags (CPUM_CHANGED_*). … … 1661 1759 } 1662 1760 1761 1663 1762 /** 1664 1763 * Sets the specified changed flags (CPUM_CHANGED_*). … … 1670 1769 pVM->cpum.s.fChanged |= fChangedFlags; 1671 1770 } 1771 1672 1772 1673 1773 /** … … 1706 1806 } 1707 1807 1708 1709 1808 #ifndef IN_RING3 1809 1710 1810 /** 1711 1811 * Lazily sync in the FPU/XMM state … … 1731 1831 return CPUMRestoreHostFPUStateAsm(&pVM->cpum.s); 1732 1832 } 1833 1733 1834 #endif /* !IN_RING3 */ 1734 1735 1835 1736 1836 /** … … 1756 1856 1757 1857 1758 1759 1858 /** 1760 1859 * Checks if the guest debug state is active … … 1768 1867 } 1769 1868 1869 1770 1870 /** 1771 1871 * Mark the guest's debug state as inactive … … 1774 1874 * @param pVM VM handle. 1775 1875 */ 1776 CPUMDECL(void) CPUMDeactivateGuestDebug tate(PVM pVM)1876 CPUMDECL(void) CPUMDeactivateGuestDebugState(PVM pVM) 1777 1877 { 1778 1878 pVM->cpum.s.fUseFlags &= ~CPUM_USE_DEBUG_REGS; … … 1820 1920 * not affected by loading a conforming coding segment. 1821 1921 * 1822 * This only seems to apply to AMD-V; in the VT-x case we *do* need to look at SS. (ACP2 regression during install after a far call to ring 2) 1922 * This only seems to apply to AMD-V; in the VT-x case we *do* need to look 1923 * at SS. (ACP2 regression during install after a far call to ring 2) 1823 1924 */ 1824 1925 cpl = pCtxCore->ssHid.Attr.n.u2Dpl; … … 1862 1963 if (!(pVM->cpum.s.Guest.cr0 & X86_CR0_PE)) 1863 1964 enmMode = CPUMMODE_REAL; 1864 else 1865 if (!(pVM->cpum.s.Guest.msrEFER & MSR_K6_EFER_LMA)) 1965 else if (!(pVM->cpum.s.Guest.msrEFER & MSR_K6_EFER_LMA)) 1866 1966 enmMode = CPUMMODE_PROTECTED; 1867 1967 else … … 1870 1970 return enmMode; 1871 1971 } 1972 -
trunk/src/VBox/VMM/VMMAll/EMAll.cpp
r12307 r12657 298 298 if (RT_LIKELY(rc != VERR_ACCESS_DENIED)) 299 299 return rc; 300 /* 301 * The page pool cache may end up here in some cases because it 302 * flushed one of the shadow mappings used by the trapping 300 /* 301 * The page pool cache may end up here in some cases because it 302 * flushed one of the shadow mappings used by the trapping 303 303 * instruction and it either flushed the TLB or the CPU reused it. 304 304 */ … … 319 319 if (RT_LIKELY(rc != VERR_ACCESS_DENIED)) 320 320 return rc; 321 /* 322 * The page pool cache may end up here in some cases because it 323 * flushed one of the shadow mappings used by the trapping 321 /* 322 * The page pool cache may end up here in some cases because it 323 * flushed one of the shadow mappings used by the trapping 324 324 * instruction and it either flushed the TLB or the CPU reused it. 325 * We want to play safe here, verifying that we've got write 325 * We want to play safe here, verifying that we've got write 326 326 * access doesn't cost us much (see PGMPhysGCPtr2GCPhys()). 327 327 */ … … 331 331 if (RT_FAILURE(rc)) 332 332 return rc; 333 if ( !(fFlags & X86_PTE_RW) 333 if ( !(fFlags & X86_PTE_RW) 334 334 && (CPUMGetGuestCR0(pVM) & X86_CR0_WP)) 335 335 return VERR_ACCESS_DENIED; … … 351 351 352 352 #if defined(VBOX_STRICT) || defined(LOG_ENABLED) 353 /** 353 /** 354 354 * Get the mnemonic for the disassembled instruction. 355 * 356 * GC/R0 doesn't include the strings in the DIS tables because 357 * of limited space. 358 */ 355 * 356 * GC/R0 doesn't include the strings in the DIS tables because 357 * of limited space. 358 */ 359 359 static const char *emGetMnemonic(PDISCPUSTATE pCpu) 360 360 { … … 803 803 * LOCK XOR/OR/AND Emulation. 804 804 */ 805 static int emInterpretLockOrXorAnd(PVM pVM, PDISCPUSTATE pCpu, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, 805 static int emInterpretLockOrXorAnd(PVM pVM, PDISCPUSTATE pCpu, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, 806 806 uint32_t *pcbSize, PFNEMULATELOCKPARAM3 pfnEmulate) 807 807 { … … 1097 1097 * LOCK BTR/C/S Emulation. 1098 1098 */ 1099 static int emInterpretLockBitTest(PVM pVM, PDISCPUSTATE pCpu, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, 1099 static int emInterpretLockBitTest(PVM pVM, PDISCPUSTATE pCpu, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, 1100 1100 uint32_t *pcbSize, PFNEMULATELOCKPARAM2 pfnEmulate) 1101 1101 { … … 1141 1141 #ifdef IN_GC 1142 1142 Assert(TRPMHasTrap(pVM)); 1143 AssertMsgReturn((RTGCPTR)((RTGCUINTPTR)GCPtrPar1 & ~(RTGCUINTPTR)3) == pvFault, 1144 ("GCPtrPar1=%VGv pvFault=%VGv\n", GCPtrPar1, pvFault), 1143 AssertMsgReturn((RTGCPTR)((RTGCUINTPTR)GCPtrPar1 & ~(RTGCUINTPTR)3) == pvFault, 1144 ("GCPtrPar1=%VGv pvFault=%VGv\n", GCPtrPar1, pvFault), 1145 1145 VERR_EM_INTERPRETER); 1146 1146 #endif … … 1157 1157 if (RT_FAILURE(rc)) 1158 1158 { 1159 Log(("emInterpretLockBitTest %s: %VGv imm%d=%RX64 -> emulation failed due to page fault!\n", 1159 Log(("emInterpretLockBitTest %s: %VGv imm%d=%RX64 -> emulation failed due to page fault!\n", 1160 1160 emGetMnemonic(pCpu), GCPtrPar1, pCpu->param2.size*8, ValPar2)); 1161 1161 return VERR_EM_INTERPRETER; … … 1395 1395 } 1396 1396 else 1397 { 1398 if (!cTransfers) 1397 { 1398 if (!cTransfers) 1399 1399 return VINF_SUCCESS; 1400 1400 … … 1517 1517 else 1518 1518 eflags = EMEmulateCmpXchg(pvParam1, &pRegFrame->rax, valpar, pCpu->param2.size); 1519 1519 1520 1520 LogFlow(("%s %VGv rax=%RX64 %RX64 ZF=%d\n", pszInstr, GCPtrPar1, pRegFrame->rax, valpar, !!(eflags & X86_EFL_ZF))); 1521 1521 … … 2043 2043 rc = DISFetchReg64(pRegFrame, SrcRegGen, &val); 2044 2044 } 2045 else 2045 else 2046 2046 { 2047 2047 uint32_t val32; … … 2059 2059 #ifdef IN_GC 2060 2060 /* CR0.WP and CR0.AM changes require a reschedule run in ring 3. */ 2061 if ( (val & (X86_CR0_WP | X86_CR0_AM)) 2061 if ( (val & (X86_CR0_WP | X86_CR0_AM)) 2062 2062 != (oldval & (X86_CR0_WP | X86_CR0_AM))) 2063 2063 return VERR_EM_INTERPRETER; … … 2200 2200 rc = DISFetchReg64(pRegFrame, SrcRegGen, &val); 2201 2201 } 2202 else 2202 else 2203 2203 { 2204 2204 uint32_t val32; … … 2207 2207 } 2208 2208 2209 if ( VBOX_SUCCESS(rc))2210 { 2211 /* @todo:we don't fail if illegal bits are set/cleared for e.g. dr7 */2209 if (RT_SUCCESS(rc)) 2210 { 2211 /** @todo we don't fail if illegal bits are set/cleared for e.g. dr7 */ 2212 2212 rc = CPUMSetGuestDRx(pVM, DestRegDrx, val); 2213 if ( VBOX_SUCCESS(rc))2213 if (RT_SUCCESS(rc)) 2214 2214 return rc; 2215 2215 AssertMsgFailed(("CPUMSetGuestDRx %d failed\n", DestRegDrx)); -
trunk/src/VBox/VMM/VMMGC/CPUMGCA.asm
r9291 r12657 1 1 ; $Id$ 2 2 ;; @file 3 ;4 3 ; CPUM - Guest Context Assembly Routines. 4 ; 5 5 6 6 ; Copyright (C) 2006-2007 Sun Microsystems, Inc. … … 187 187 TRPM_NP_GP_HANDLER NAME(cpumGCHandleNPAndGP), CPUM_HANDLER_IRET 188 188 iret 189 190 189 ENDPROC CPUMGCCallGuestTrapHandler 190 191 191 192 192 ;; … … 195 195 ; 196 196 ; @param pRegFrame Original trap/interrupt context 197 ; 197 ; 198 198 ; This function does not return! 199 ; 199 ; 200 200 ;CPUMGCDECL(void) CPUMGCCallV86Code(PCPUMCTXCORE pRegFrame); 201 201 align 16 … … 204 204 205 205 ; construct iret stack frame 206 push dword [ebp + CPUMCTXCORE.gs] 207 push dword [ebp + CPUMCTXCORE.fs] 208 push dword [ebp + CPUMCTXCORE.ds] 209 push dword [ebp + CPUMCTXCORE.es] 210 push dword [ebp + CPUMCTXCORE.ss] 211 push dword [ebp + CPUMCTXCORE.esp] 212 push dword [ebp + CPUMCTXCORE.eflags] 213 push dword [ebp + CPUMCTXCORE.cs] 214 push dword [ebp + CPUMCTXCORE.eip] 206 push dword [ebp + CPUMCTXCORE.gs] 207 push dword [ebp + CPUMCTXCORE.fs] 208 push dword [ebp + CPUMCTXCORE.ds] 209 push dword [ebp + CPUMCTXCORE.es] 210 push dword [ebp + CPUMCTXCORE.ss] 211 push dword [ebp + CPUMCTXCORE.esp] 212 push dword [ebp + CPUMCTXCORE.eflags] 213 push dword [ebp + CPUMCTXCORE.cs] 214 push dword [ebp + CPUMCTXCORE.eip] 215 215 216 216 ; … … 235 235 iret 236 236 ENDPROC CPUMGCCallV86Code 237 237 238 238 239 ;; … … 384 385 ENDPROC CPUMGCResumeGuestV86 385 386 386 387 388 -
trunk/src/VBox/VMM/VMMR0/CPUMR0.cpp
r12600 r12657 36 36 37 37 38 39 38 /** 40 39 * Does Ring-0 CPUM initialization. … … 53 52 * Check CR0 & CR4 flags. 54 53 */ 55 uint32_t 54 uint32_t u32CR0 = ASMGetCR0(); 56 55 if ((u32CR0 & (X86_CR0_PE | X86_CR0_PG)) != (X86_CR0_PE | X86_CR0_PG)) /* a bit paranoid perhaps.. */ 57 56 { … … 99 98 * This ASSUMES that DR7.GD is not set, or that it's handled transparently! 100 99 */ 101 uint32_t 100 uint32_t u32DR7 = ASMGetDR7(); 102 101 if (u32DR7 & X86_DR7_ENABLED_MASK) 103 102 { … … 155 154 */ 156 155 157 switch(pCtx->cr0 & (X86_CR0_MP | X86_CR0_EM | X86_CR0_TS)) 158 { 159 case X86_CR0_MP | X86_CR0_TS: 160 case X86_CR0_MP | X86_CR0_EM | X86_CR0_TS: 161 return VINF_EM_RAW_GUEST_TRAP; 162 163 default: 164 break; 156 switch (pCtx->cr0 & (X86_CR0_MP | X86_CR0_EM | X86_CR0_TS)) 157 { 158 case X86_CR0_MP | X86_CR0_TS: 159 case X86_CR0_MP | X86_CR0_EM | X86_CR0_TS: 160 return VINF_EM_RAW_GUEST_TRAP; 161 default: 162 break; 165 163 } 166 164 … … 172 170 if (pVM->cpum.s.CPUFeaturesExt.edx & X86_CPUID_AMD_FEATURE_EDX_FFXSR) 173 171 { 174 /* @todo Do we really need to read this every time?? The host could change this on the fly though. */ 172 /** @todo Do we really need to read this every time?? The host could change this on the fly though. 173 * bird: what about starting by skipping the ASMWrMsr below if we didn't 174 * change anything? Ditto for the stuff in CPUMR0SaveGuestFPU. */ 175 175 oldMsrEFERHost = ASMRdMsr(MSR_K6_EFER); 176 177 176 if (oldMsrEFERHost & MSR_K6_EFER_FFXSR) 178 177 { … … 193 192 /* CPUMHandleLazyFPU could have changed CR0; restore it. */ 194 193 ASMSetCR0(oldCR0); 195 #else 196 /* Save the FPU control word and MXCSR, so we can restore the state properly afterwards. 194 195 #else /* CPUM_CAN_HANDLE_NM_TRAPS_IN_KERNEL_MODE */ 196 197 /* 198 * Save the FPU control word and MXCSR, so we can restore the state properly afterwards. 197 199 * We don't want the guest to be able to trigger floating point/SSE exceptions on the host. 198 200 */ … … 203 205 CPUMLoadFPUAsm(pCtx); 204 206 205 /* The MSR_K6_EFER_FFXSR feature is AMD only so far, but check the cpuid just in case Intel adds it in the future. 207 /* 208 * The MSR_K6_EFER_FFXSR feature is AMD only so far, but check the cpuid just in case Intel adds it in the future. 206 209 * 207 210 * MSR_K6_EFER_FFXSR changes the behaviour of fxsave and fxrstore: the XMM state isn't saved/restored … … 209 212 if (pVM->cpum.s.CPUFeaturesExt.edx & X86_CPUID_AMD_FEATURE_EDX_FFXSR) 210 213 { 211 /* @todo Do we really need to read this every time?? The host could change this on the fly though. */214 /** @todo Do we really need to read this every time?? The host could change this on the fly though. */ 212 215 uint64_t msrEFERHost = ASMRdMsr(MSR_K6_EFER); 213 216 … … 219 222 } 220 223 } 221 #endif 224 #endif /* CPUM_CAN_HANDLE_NM_TRAPS_IN_KERNEL_MODE */ 222 225 223 226 pVM->cpum.s.fUseFlags |= CPUM_USED_FPU; … … 254 257 ASMWrMsr(MSR_K6_EFER, oldMsrEFERHost | MSR_K6_EFER_FFXSR); 255 258 256 #else 259 #else /* CPUM_CAN_HANDLE_NM_TRAPS_IN_KERNEL_MODE */ 257 260 CPUMSaveFPUAsm(pCtx); 258 261 if (pVM->cpum.s.fUseFlags & CPUM_MANUAL_XMM_RESTORE) … … 261 264 CPUMSaveXMMAsm(pCtx); 262 265 } 263 /* Restore the original FPU control word and MXCSR. 266 267 /* 268 * Restore the original FPU control word and MXCSR. 264 269 * We don't want the guest to be able to trigger floating point/SSE exceptions on the host. 265 270 */ … … 267 272 if (pVM->cpum.s.CPUFeatures.edx.u1SSE) 268 273 CPUMSetMXCSR(pVM->cpum.s.Host.fpu.MXCSR); 269 #endif 270 271 pVM->cpum.s.fUseFlags &= ~(CPUM_USED_FPU |CPUM_MANUAL_XMM_RESTORE);274 #endif /* CPUM_CAN_HANDLE_NM_TRAPS_IN_KERNEL_MODE */ 275 276 pVM->cpum.s.fUseFlags &= ~(CPUM_USED_FPU | CPUM_MANUAL_XMM_RESTORE); 272 277 return VINF_SUCCESS; 273 278 } … … 294 299 pCtx->dr[6] = ASMGetDR6(); 295 300 296 /* Restore the host's debug state. DR0-3, DR6 and only then DR7! 301 /* 302 * Restore the host's debug state. DR0-3, DR6 and only then DR7! 297 303 * DR7 contains 0x400 right now. 298 304 */ … … 325 331 pVM->cpum.s.Host.dr3 = ASMGetDR3(); 326 332 pVM->cpum.s.Host.dr6 = ASMGetDR6(); 327 /* @todo dr7 might already have been changed to 0x400; don't care right now as it's harmless. */333 /** @todo dr7 might already have been changed to 0x400; don't care right now as it's harmless. */ 328 334 pVM->cpum.s.Host.dr7 = ASMGetDR7(); 329 335 /* Make sure DR7 is harmless or else we could trigger breakpoints when restoring dr0-3 (!) */ … … 341 347 return VINF_SUCCESS; 342 348 } 349 -
trunk/src/VBox/VMM/VMMR0/HWACCMR0.cpp
r12600 r12657 748 748 749 749 /* Always load the guest's debug state on-demand. */ 750 CPUMDeactivateGuestDebug tate(pVM);750 CPUMDeactivateGuestDebugState(pVM); 751 751 752 752 /* Always reload the host context and the guest's CR0 register. (!!!!) */ -
trunk/src/VBox/VMM/testcase/tstVMStructSize.cpp
r12579 r12657 160 160 } 161 161 CHECK_MEMBER_ALIGNMENT(VM, trpm.s.aIdt, 16); 162 CHECK_MEMBER_ALIGNMENT(VM, cpum.s.Host, 32); 163 CHECK_MEMBER_ALIGNMENT(VM, cpum.s.Guest, 32); 164 CHECK_MEMBER_ALIGNMENT(VM, cpum.s.Hyper, 32); 162 CHECK_MEMBER_ALIGNMENT(VM, cpum, 64); 163 CHECK_MEMBER_ALIGNMENT(VM, cpum.s.Host, 64); 164 CHECK_MEMBER_ALIGNMENT(VM, cpum.s.Guest, 64); 165 CHECK_MEMBER_ALIGNMENT(VM, cpum.s.Hyper, 64); 165 166 CHECK_MEMBER_ALIGNMENT(VM, vmm.s.CritSectVMLock, 8); 166 167 CHECK_MEMBER_ALIGNMENT(VM, vmm.s.CallHostR0JmpBuf, 8); … … 180 181 CHECK_MEMBER_ALIGNMENT(CPUMCTX, idtr, 4); 181 182 CHECK_MEMBER_ALIGNMENT(CPUMCTX, SysEnter, 8); 182 CHECK_SIZE_ALIGNMENT(CPUMCTX, 32);183 183 CHECK_CPUMCTXCORE(eax); 184 184 CHECK_CPUMCTXCORE(ebx); … … 220 220 } 221 221 #endif 222 CHECK_SIZE_ALIGNMENT(CPUMCTX, 64); 223 CHECK_SIZE_ALIGNMENT(CPUMHOSTCTX, 64); 222 224 223 225 /* pdm */
Note:
See TracChangeset
for help on using the changeset viewer.