Changeset 41330 in vbox for trunk/src/VBox/VMM/VMMR0
- Timestamp:
- May 16, 2012 11:25:16 AM (13 years ago)
- Location:
- trunk/src/VBox/VMM/VMMR0
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp
r41329 r41330 5461 5461 * @param pVCpu Pointer to the VMCPU. 5462 5462 * @param idxField VMCS field index. 5463 * @param u64Val 16, 32 or 64 bits value. .5463 * @param u64Val 16, 32 or 64 bits value. 5464 5464 */ 5465 5465 VMMR0DECL(int) VMXWriteCachedVMCSEx(PVMCPU pVCpu, uint32_t idxField, uint64_t u64Val) -
trunk/src/VBox/VMM/VMMR0/HWVMXR0.h
r38685 r41330 5 5 6 6 /* 7 * Copyright (C) 2006-201 1Oracle Corporation7 * Copyright (C) 2006-2012 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 103 103 104 104 /** 105 * Enters the VT-x session 106 * 107 * @returns VBox status code. 108 * @param pVM The VM to operate on.109 * @param pVCpu The VMCPU to operate on.110 * @param pCpu CPU info struct105 * Enters the VT-x session. 106 * 107 * @returns VBox status code. 108 * @param pVM Pointer to the VM. 109 * @param pVCpu Pointer to the VM CPU. 110 * @param pCpu Pointer to the CPU info struct. 111 111 */ 112 112 VMMR0DECL(int) VMXR0Enter(PVM pVM, PVMCPU pVCpu, PHMGLOBLCPUINFO pCpu); 113 113 114 114 /** 115 * Leaves the VT-x session 116 * 117 * @returns VBox status code. 118 * @param pVM The VM to operate on.119 * @param pVCpu The VMCPU to operate on.120 * @param pCtx CPU context115 * Leaves the VT-x session. 116 * 117 * @returns VBox status code. 118 * @param pVM Pointer to the VM. 119 * @param pVCpu Pointer to the VMCPU. 120 * @param pCtx Pointer to the guest CPU context. 121 121 */ 122 122 VMMR0DECL(int) VMXR0Leave(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx); … … 124 124 125 125 /** 126 * Sets up and activates VT-x on the current CPU 127 * 128 * @returns VBox status code. 129 * @param pCpu CPU info struct130 * @param pVM The VM to operate on. (can be NULL after a resume)131 * @param pvPageCpu Pointer to the global cpu page132 * @param pPageCpuPhys Physical address of the global cpu page126 * Sets up and activates VT-x on the current CPU. 127 * 128 * @returns VBox status code. 129 * @param pCpu Pointer to the CPU info struct. 130 * @param pVM Pointer to the VM. (can be NULL after a resume) 131 * @param pvPageCpu Pointer to the global CPU page. 132 * @param pPageCpuPhys Physical address of the global CPU page. 133 133 */ 134 134 VMMR0DECL(int) VMXR0EnableCpu(PHMGLOBLCPUINFO pCpu, PVM pVM, void *pvPageCpu, RTHCPHYS pPageCpuPhys); 135 135 136 136 /** 137 * Deactivates VT-x on the current CPU 138 * 139 * @returns VBox status code. 140 * @param pCpu CPU info struct141 * @param pvPageCpu Pointer to the global cpu page142 * @param pPageCpuPhys Physical address of the global cpu page137 * Deactivates VT-x on the current CPU. 138 * 139 * @returns VBox status code. 140 * @param pCpu Pointer to the CPU info struct. 141 * @param pvPageCpu Pointer to the global CPU page. 142 * @param pPageCpuPhys Physical address of the global CPU page. 143 143 */ 144 144 VMMR0DECL(int) VMXR0DisableCpu(PHMGLOBLCPUINFO pCpu, void *pvPageCpu, RTHCPHYS pPageCpuPhys); 145 145 146 146 /** 147 * Does Ring-0 per VM VT-x init .148 * 149 * @returns VBox status code. 150 * @param pVM The VM to operate on.147 * Does Ring-0 per VM VT-x initialization. 148 * 149 * @returns VBox status code. 150 * @param pVM Pointer to the VM. 151 151 */ 152 152 VMMR0DECL(int) VMXR0InitVM(PVM pVM); … … 156 156 * 157 157 * @returns VBox status code. 158 * @param pVM The VM to operate on.158 * @param pVM Pointer to the VM. 159 159 */ 160 160 VMMR0DECL(int) VMXR0TermVM(PVM pVM); 161 161 162 162 /** 163 * Sets up VT-x for the specified VM 164 * 165 * @returns VBox status code. 166 * @param pVM The VM to operate on.163 * Sets up VT-x for the specified VM. 164 * 165 * @returns VBox status code. 166 * @param pVM Pointer to the VM. 167 167 */ 168 168 VMMR0DECL(int) VMXR0SetupVM(PVM pVM); … … 170 170 171 171 /** 172 * Save the host state 173 * 174 * @returns VBox status code. 175 * @param pVM The VM to operate on.176 * @param pVCpu The VMCPU to operate on.172 * Save the host state. 173 * 174 * @returns VBox status code. 175 * @param pVM Pointer to the VM. 176 * @param pVCpu Pointer to the VMCPU. 177 177 */ 178 178 VMMR0DECL(int) VMXR0SaveHostState(PVM pVM, PVMCPU pVCpu); 179 179 180 180 /** 181 * Loads the guest state 182 * 183 * @returns VBox status code. 184 * @param pVM The VM to operate on.185 * @param pVCpu The VMCPU to operate on.186 * @param pCtx Guest context181 * Loads the guest state. 182 * 183 * @returns VBox status code. 184 * @param pVM Pointer to the VM. 185 * @param pVCpu Pointer to the VMCPU. 186 * @param pCtx Pointer to the guest CPU context. 187 187 */ 188 188 VMMR0DECL(int) VMXR0LoadGuestState(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx); … … 193 193 * 194 194 * @returns VBox status code. 195 * @param pVM The VM to operate on.196 * @param pVCpu The VMCPU to operate on.197 * @param pCtx Guest context195 * @param pVM Pointer to the VM. 196 * @param pVCpu Pointer to the VMCPU. 197 * @param pCtx Pointer to the guest CPU context. 198 198 */ 199 199 VMMR0DECL(int) VMXR0RunGuestCode(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx); … … 202 202 # if HC_ARCH_BITS == 32 && defined(VBOX_WITH_64_BITS_GUESTS) && !defined(VBOX_WITH_HYBRID_32BIT_KERNEL) 203 203 /** 204 * Executes the specified handler in 64 mode 205 * 206 * @returns VBox status code. 207 * @param pVM The VM to operate on. 208 * @param pVCpu The VMCPU to operate on. 209 * @param pCtx Guest context 210 * @param pfnHandler RC handler 211 * @param cbParam Number of parameters 212 * @param paParam Array of 32 bits parameters 213 */ 214 VMMR0DECL(int) VMXR0Execute64BitsHandler(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx, RTRCPTR pfnHandler, uint32_t cbParam, uint32_t *paParam); 204 * Executes the specified handler in 64-bit mode. 205 * 206 * @returns VBox status code. 207 * @param pVM Pointer to the VM. 208 * @param pVCpu Pointer to the VMCPU. 209 * @param pCtx Pointer to the guest CPU context. 210 * @param pfnHandler Pointer to the RC handler function. 211 * @param cbParam Number of parameters. 212 * @param paParam Array of 32-bit parameters. 213 */ 214 VMMR0DECL(int) VMXR0Execute64BitsHandler(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx, RTRCPTR pfnHandler, uint32_t cbParam, 215 uint32_t *paParam); 215 216 # endif 216 217 … … 235 236 } \ 236 237 else \ 237 if ( (pCtx->reg || !CPUMIsGuestInPagedProtectedModeEx(pCtx) || (!pCtx->csHid.Attr.n.u1DefBig && !CPUMIsGuestIn64BitCodeEx(pCtx))) \ 238 if ( ( pCtx->reg \ 239 || !CPUMIsGuestInPagedProtectedModeEx(pCtx) \ 240 || (!pCtx->csHid.Attr.n.u1DefBig && !CPUMIsGuestIn64BitCodeEx(pCtx)) \ 241 ) \ 238 242 && pCtx->reg##Hid.Attr.n.u1Present == 1) \ 243 { \ 239 244 val = pCtx->reg##Hid.Attr.u | X86_SEL_TYPE_ACCESSED; \ 245 } \ 240 246 else \ 241 247 val = 0x10000; /* Invalid guest state error otherwise. (BIT(16) = Unusable) */ \ … … 245 251 246 252 # define VMX_READ_SELREG(REG, reg) \ 247 { \253 { \ 248 254 VMXReadCachedVMCS(VMX_VMCS16_GUEST_FIELD_##REG, &val); \ 249 pCtx->reg = val; \255 pCtx->reg = val; \ 250 256 VMXReadCachedVMCS(VMX_VMCS32_GUEST_##REG##_LIMIT, &val); \ 251 pCtx->reg##Hid.u32Limit = val; \257 pCtx->reg##Hid.u32Limit = val; \ 252 258 VMXReadCachedVMCS(VMX_VMCS64_GUEST_##REG##_BASE, &val); \ 253 pCtx->reg##Hid.u64Base = val; \259 pCtx->reg##Hid.u64Base = val; \ 254 260 VMXReadCachedVMCS(VMX_VMCS32_GUEST_##REG##_ACCESS_RIGHTS, &val); \ 255 pCtx->reg##Hid.Attr.u = val; \261 pCtx->reg##Hid.Attr.u = val; \ 256 262 } 257 263 258 264 /* Don't read from the cache in this macro; used only in case of failure where the cache is out of sync. */ 259 265 # define VMX_LOG_SELREG(REG, szSelReg, val) \ 260 { \ 261 VMXReadVMCS(VMX_VMCS16_GUEST_FIELD_##REG, &(val)); \ 262 Log(("%s Selector %x\n", szSelReg, (val))); \ 263 VMXReadVMCS(VMX_VMCS32_GUEST_##REG##_LIMIT, &(val)); \ 264 Log(("%s Limit %x\n", szSelReg, (val))); \ 265 VMXReadVMCS(VMX_VMCS64_GUEST_##REG##_BASE, &(val)); \ 266 Log(("%s Base %RX64\n", szSelReg, (uint64_t)(val))); \ 267 VMXReadVMCS(VMX_VMCS32_GUEST_##REG##_ACCESS_RIGHTS, &(val)); \ 268 Log(("%s Attributes %x\n", szSelReg, (val))); \ 269 } 270 271 /** 272 * Cache VMCS writes for performance reasons (Darwin) and for running 64 bits guests on 32 bits hosts. 273 * 274 * @param pVCpu The VMCPU to operate on. 275 * @param idxField VMCS field 276 * @param u64Val Value 266 { \ 267 VMXReadVMCS(VMX_VMCS16_GUEST_FIELD_##REG, &(val)); \ 268 Log(("%s Selector %x\n", szSelReg, (val))); \ 269 VMXReadVMCS(VMX_VMCS32_GUEST_##REG##_LIMIT, &(val)); \ 270 Log(("%s Limit %x\n", szSelReg, (val))); \ 271 VMXReadVMCS(VMX_VMCS64_GUEST_##REG##_BASE, &(val)); \ 272 Log(("%s Base %RX64\n", szSelReg, (uint64_t)(val))); \ 273 VMXReadVMCS(VMX_VMCS32_GUEST_##REG##_ACCESS_RIGHTS, &(val)); \ 274 Log(("%s Attributes %x\n", szSelReg, (val))); \ 275 } 276 277 /** 278 * Cache VMCS writes for performance reasons (Darwin) and for running 64 bits 279 * guests on 32-bit hosts. 280 * 281 * @param pVCpu Pointer to the VMCPU. 282 * @param idxField VMCS field index. 283 * @param u64Val 16, 32 or 64 bits value. 277 284 */ 278 285 VMMR0DECL(int) VMXWriteCachedVMCSEx(PVMCPU pVCpu, uint32_t idxField, uint64_t u64Val); … … 282 289 * Return value of cached VMCS read for performance reasons (Darwin) and for running 64 bits guests on 32 bits hosts. 283 290 * 284 * @param pVCpu The VMCPU to operate on.291 * @param pVCpu Pointer to the VMCPU. 285 292 * @param idxField VMCS cache index (not VMCS field index!) 286 * @param pVal Value293 * @param pVal 16, 32 or 64 bits value. 287 294 */ 288 295 DECLINLINE(int) VMXReadCachedVMCSEx(PVMCPU pVCpu, uint32_t idxCache, RTGCUINTREG *pVal) … … 295 302 296 303 /** 297 * Return value of cached VMCS read for performance reasons (Darwin) and for running 64 bits guests on 32 bits hosts. 298 * 299 * @param idxField VMCS field 300 * @param pVal Value pointer (out) 304 * Return value of cached VMCS read for performance reasons (Darwin) and for 305 * running 64 bits guests on 32-bit hosts. 306 * 307 * @param idxField VMCS field index. 308 * @param pVal Value pointer (out). 301 309 */ 302 310 #ifdef VMX_USE_CACHED_VMCS_ACCESSES … … 307 315 308 316 /** 309 * Setup cached VMCS for performance reasons (Darwin) and for running 64 bits guests on 32 bits hosts. 317 * Setup cached VMCS for performance reasons (Darwin) and for running 64-bit 318 * guests on 32-bit hosts. 310 319 * 311 320 * @param pCache The cache. 312 * @param idxField VMCS field 313 */ 314 #define VMXSetupCachedReadVMCS(pCache, idxField) \315 { \316 Assert(pCache->Read.aField[idxField##_CACHE_IDX] == 0); \317 pCache->Read.aField[idxField##_CACHE_IDX] = idxField; \318 pCache->Read.aFieldVal[idxField##_CACHE_IDX] = 0; \321 * @param idxField VMCS field index. 322 */ 323 #define VMXSetupCachedReadVMCS(pCache, idxField) \ 324 { \ 325 Assert(pCache->Read.aField[idxField##_CACHE_IDX] == 0); \ 326 pCache->Read.aField[idxField##_CACHE_IDX] = idxField; \ 327 pCache->Read.aFieldVal[idxField##_CACHE_IDX] = 0; \ 319 328 } 320 329 … … 328 337 329 338 /** 330 * Prepares for and executes VMLAUNCH (32 bits guest mode) 339 * Prepares for and executes VMLAUNCH (32-bit guest mode). 340 * 341 * @returns VBox status code. 342 * @param fResume Whether to vmlauch/vmresume. 343 * @param pCtx Pointer to the guest CPU context. 344 * @param pCache Pointer to the VMCS cache. 345 * @param pVM Pointer to the VM. 346 * @param pVCpu Pointer to the VMCPU. 347 */ 348 DECLASM(int) VMXR0StartVM32(RTHCUINT fResume, PCPUMCTX pCtx, PVMCSCACHE pCache, PVM pVM, PVMCPU pVCpu); 349 350 /** 351 * Prepares for and executes VMLAUNCH (64-bit guest mode). 352 * 353 * @returns VBox status code. 354 * @param fResume Whether to vmlauch/vmresume. 355 * @param pCtx Pointer to the guest CPU context. 356 * @param pCache Pointer to the VMCS cache. 357 * @param pVM Pointer to the VM. 358 * @param pVCpu Pointer to the VMCPU. 359 */ 360 DECLASM(int) VMXR0StartVM64(RTHCUINT fResume, PCPUMCTX pCtx, PVMCSCACHE pCache, PVM pVM, PVMCPU pVCpu); 361 362 # if HC_ARCH_BITS == 32 && defined(VBOX_WITH_64_BITS_GUESTS) && !defined(VBOX_WITH_HYBRID_32BIT_KERNEL) 363 /** 364 * Prepares for and executes VMLAUNCH (64-bit guest mode). 331 365 * 332 366 * @returns VBox status code 333 * @param fResume vmlauch/vmresume 334 * @param pCtx Guest context 335 * @param pCache VMCS cache 336 * @param pVM The VM to operate on. 337 * @param pVCpu The VMCPU to operate on. 338 */ 339 DECLASM(int) VMXR0StartVM32(RTHCUINT fResume, PCPUMCTX pCtx, PVMCSCACHE pCache, PVM pVM, PVMCPU pVCpu); 340 341 /** 342 * Prepares for and executes VMLAUNCH (64 bits guest mode) 343 * 344 * @returns VBox status code 345 * @param fResume vmlauch/vmresume 346 * @param pCtx Guest context 347 * @param pCache VMCS cache 348 * @param pVM The VM to operate on. 349 * @param pVCpu The VMCPU to operate on. 350 */ 351 DECLASM(int) VMXR0StartVM64(RTHCUINT fResume, PCPUMCTX pCtx, PVMCSCACHE pCache, PVM pVM, PVMCPU pVCpu); 352 353 # if HC_ARCH_BITS == 32 && defined(VBOX_WITH_64_BITS_GUESTS) && !defined(VBOX_WITH_HYBRID_32BIT_KERNEL) 354 /** 355 * Prepares for and executes VMLAUNCH (64 bits guest mode) 356 * 357 * @returns VBox status code 358 * @param fResume vmlauch/vmresume 359 * @param pCtx Guest context 360 * @param pCache VMCS cache 361 * @param pVM The VM to operate on. 362 * @param pVCpu The VMCPU to operate on. 367 * @param fResume Whether to vmlauch/vmresume. 368 * @param pCtx Pointer to the guest CPU context. 369 * @param pCache Pointer to the VMCS cache. 370 * @param pVM Pointer to the VM. 371 * @param pVCpu Pointer to the VMCPU. 363 372 */ 364 373 DECLASM(int) VMXR0SwitcherStartVM64(RTHCUINT fResume, PCPUMCTX pCtx, PVMCSCACHE pCache, PVM pVM, PVMCPU pVCpu); … … 371 380 RT_C_DECLS_END 372 381 373 #endif 374 382 #endif /* ___HWVMXR0_h */ 383
Note:
See TracChangeset
for help on using the changeset viewer.