Changeset 41943 in vbox
- Timestamp:
- Jun 28, 2012 2:33:43 AM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 78811
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/cpum.h
r41940 r41943 357 357 VMMDECL(PCPUMCTX) CPUMQueryGuestCtxPtr(PVMCPU pVCpu); 358 358 VMMDECL(PCCPUMCTXCORE) CPUMGetGuestCtxCore(PVMCPU pVCpu); 359 VMMDECL(void) CPUMSetGuestCtxCore(PVMCPU pVCpu, PCCPUMCTXCORE pCtxCore);360 359 VMMR3DECL(int) CPUMR3RawEnter(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore); 361 360 VMMR3DECL(int) CPUMR3RawLeave(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, int rc); -
trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp
r41940 r41943 380 380 { 381 381 return CPUMCTX2CORE(&pVCpu->cpum.s.Guest); 382 }383 384 385 /**386 * Sets the guest context core registers.387 *388 * @param pVCpu Handle to the virtual cpu.389 * @param pCtxCore The new context core values.390 */391 VMMDECL(void) CPUMSetGuestCtxCore(PVMCPU pVCpu, PCCPUMCTXCORE pCtxCore)392 {393 /** @todo #1410 requires selectors to be checked. (huh? 1410?) */394 395 PCPUMCTXCORE pCtxCoreDst = CPUMCTX2CORE(&pVCpu->cpum.s.Guest);396 *pCtxCoreDst = *pCtxCore;397 398 /* Mask away invalid parts of the cpu context. */399 if (!CPUMIsGuestInLongMode(pVCpu))400 {401 uint64_t u64Mask = UINT64_C(0xffffffff);402 403 pCtxCoreDst->rip &= u64Mask;404 pCtxCoreDst->rax &= u64Mask;405 pCtxCoreDst->rbx &= u64Mask;406 pCtxCoreDst->rcx &= u64Mask;407 pCtxCoreDst->rdx &= u64Mask;408 pCtxCoreDst->rsi &= u64Mask;409 pCtxCoreDst->rdi &= u64Mask;410 pCtxCoreDst->rbp &= u64Mask;411 pCtxCoreDst->rsp &= u64Mask;412 pCtxCoreDst->rflags.u &= u64Mask;413 414 pCtxCoreDst->r8 = 0;415 pCtxCoreDst->r9 = 0;416 pCtxCoreDst->r10 = 0;417 pCtxCoreDst->r11 = 0;418 pCtxCoreDst->r12 = 0;419 pCtxCoreDst->r13 = 0;420 pCtxCoreDst->r14 = 0;421 pCtxCoreDst->r15 = 0;422 }423 382 } 424 383 -
trunk/src/VBox/VMM/VMMRC/CPUMRC.cpp
r41906 r41943 1 1 /* $Id$ */ 2 2 /** @file 3 * CPUM - GuestContext Code.3 * CPUM - Raw-mode Context Code. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2006-20 07Oracle Corporation7 * Copyright (C) 2006-2012 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 35 35 *******************************************************************************/ 36 36 RT_C_DECLS_BEGIN /* addressed from asm (not called so no DECLASM). */ 37 DECLCALLBACK(int) cpum GCHandleNPAndGP(PVM pVM, PCPUMCTXCORE pRegFrame, uintptr_t uUser);37 DECLCALLBACK(int) cpumRCHandleNPAndGP(PVM pVM, PCPUMCTXCORE pRegFrame, uintptr_t uUser); 38 38 RT_C_DECLS_END 39 39 40 40 41 41 /** 42 * Deal with traps occurring during segment loading and IRET 43 * when resuming guest context.42 * Deal with traps occurring during segment loading and IRET when resuming guest 43 * context execution. 44 44 * 45 45 * @returns VBox status code. … … 49 49 * CPUM_HANDLER_* \#defines. 50 50 */ 51 DECLCALLBACK(int) cpum GCHandleNPAndGP(PVM pVM, PCPUMCTXCORE pRegFrame, uintptr_t uUser)51 DECLCALLBACK(int) cpumRCHandleNPAndGP(PVM pVM, PCPUMCTXCORE pRegFrame, uintptr_t uUser) 52 52 { 53 53 Log(("********************************************************\n")); 54 Log(("cpum GCHandleNPAndGP: eip=%RX32 uUser=%#x\n", pRegFrame->eip, uUser));54 Log(("cpumRCHandleNPAndGP: eip=%RX32 uUser=%#x\n", pRegFrame->eip, uUser)); 55 55 Log(("********************************************************\n")); 56 57 PVMCPU pVCpu = VMMGetCpu0(pVM);58 59 /*60 * Update the guest cpu state.61 */62 if (uUser & CPUM_HANDLER_CTXCORE_IN_EBP)63 {64 PCPUMCTXCORE pGstCtxCore = (PCPUMCTXCORE)CPUMGetGuestCtxCore(pVCpu);65 PCCPUMCTXCORE pGstCtxCoreSrc = (PCPUMCTXCORE)pRegFrame->ebp;66 *pGstCtxCore = *pGstCtxCoreSrc;67 }68 56 69 57 /* … … 73 61 { 74 62 case CPUM_HANDLER_GS: 75 // if (!pVM->cpum.s.Guest.ldtr)76 // {77 // pRegFrame->gs = 0;78 // pRegFrame->eip += 6; /* mov gs, [edx + CPUM.Guest.gs] */79 // return VINF_SUCCESS;80 // }81 63 case CPUM_HANDLER_DS: 82 64 case CPUM_HANDLER_ES: … … 85 67 break; 86 68 87 /* Make sure we restore the guest context from the interrupt stack frame. */88 69 case CPUM_HANDLER_IRET: 89 {90 PCPUMCTXCORE pGstCtxCore = (PCPUMCTXCORE)CPUMGetGuestCtxCore(pVCpu);91 uint32_t *pEsp = (uint32_t *)pRegFrame->esp;92 93 /* Sync general purpose registers */94 *pGstCtxCore = *pRegFrame;95 96 pGstCtxCore->eip = *pEsp++;97 pGstCtxCore->cs.Sel = (RTSEL)*pEsp++;98 pGstCtxCore->eflags.u32 = *pEsp++;99 pGstCtxCore->esp = *pEsp++;100 pGstCtxCore->ss.Sel = (RTSEL)*pEsp++;101 if (pGstCtxCore->eflags.Bits.u1VM)102 {103 pGstCtxCore->es.Sel = (RTSEL)*pEsp++;104 pGstCtxCore->ds.Sel = (RTSEL)*pEsp++;105 pGstCtxCore->fs.Sel = (RTSEL)*pEsp++;106 pGstCtxCore->gs.Sel = (RTSEL)*pEsp++;107 }108 109 70 TRPMGCHyperReturnToHost(pVM, VINF_EM_RAW_IRET_TRAP); 110 71 break; 111 }112 72 } 73 74 AssertMsgFailed(("uUser=%#x eip=%#x\n", uUser, pRegFrame->eip)); 113 75 return VERR_TRPM_DONT_PANIC; 114 76 } -
trunk/src/VBox/VMM/VMMRC/CPUMRCA.asm
r41931 r41943 1 1 ; $Id$ 2 2 ;; @file 3 ; CPUM - GuestContext Assembly Routines.4 ; 5 6 ; Copyright (C) 2006-20 07Oracle Corporation3 ; CPUM - Raw-mode Context Assembly Routines. 4 ; 5 6 ; Copyright (C) 2006-2012 Oracle Corporation 7 7 ; 8 8 ; This file is part of VirtualBox Open Source Edition (OSE), as … … 32 32 extern IMPNAME(g_CPUM) ; VMM GC Builtin import 33 33 extern IMPNAME(g_VM) ; VMM GC Builtin import 34 extern NAME(cpum GCHandleNPAndGP) ; CPUMGC.cpp34 extern NAME(cpumRCHandleNPAndGP) ; CPUMGC.cpp 35 35 36 36 ; … … 86 86 87 87 ;; @todo load segment registers *before* enabling WP. 88 TRPM_NP_GP_HANDLER NAME(cpum GCHandleNPAndGP), CPUM_HANDLER_GS | CPUM_HANDLER_CTXCORE_IN_EBP88 TRPM_NP_GP_HANDLER NAME(cpumRCHandleNPAndGP), CPUM_HANDLER_GS | CPUM_HANDLER_CTXCORE_IN_EBP 89 89 mov gs, [ebp + CPUMCTXCORE.gs.Sel] 90 TRPM_NP_GP_HANDLER NAME(cpum GCHandleNPAndGP), CPUM_HANDLER_FS | CPUM_HANDLER_CTXCORE_IN_EBP90 TRPM_NP_GP_HANDLER NAME(cpumRCHandleNPAndGP), CPUM_HANDLER_FS | CPUM_HANDLER_CTXCORE_IN_EBP 91 91 mov fs, [ebp + CPUMCTXCORE.fs.Sel] 92 TRPM_NP_GP_HANDLER NAME(cpum GCHandleNPAndGP), CPUM_HANDLER_ES | CPUM_HANDLER_CTXCORE_IN_EBP92 TRPM_NP_GP_HANDLER NAME(cpumRCHandleNPAndGP), CPUM_HANDLER_ES | CPUM_HANDLER_CTXCORE_IN_EBP 93 93 mov es, [ebp + CPUMCTXCORE.es.Sel] 94 TRPM_NP_GP_HANDLER NAME(cpum GCHandleNPAndGP), CPUM_HANDLER_DS | CPUM_HANDLER_CTXCORE_IN_EBP94 TRPM_NP_GP_HANDLER NAME(cpumRCHandleNPAndGP), CPUM_HANDLER_DS | CPUM_HANDLER_CTXCORE_IN_EBP 95 95 mov ds, [ebp + CPUMCTXCORE.ds.Sel] 96 96 … … 98 98 mov ebp, [ebp + CPUMCTXCORE.ebp] 99 99 100 TRPM_NP_GP_HANDLER NAME(cpum GCHandleNPAndGP), CPUM_HANDLER_IRET100 TRPM_NP_GP_HANDLER NAME(cpumRCHandleNPAndGP), CPUM_HANDLER_IRET 101 101 iret 102 102 ENDPROC CPUMGCCallGuestTrapHandler … … 145 145 mov ebp, [ebp + CPUMCTXCORE.ebp] 146 146 147 TRPM_NP_GP_HANDLER NAME(cpum GCHandleNPAndGP), CPUM_HANDLER_IRET147 TRPM_NP_GP_HANDLER NAME(cpumRCHandleNPAndGP), CPUM_HANDLER_IRET 148 148 iret 149 149 ENDPROC CPUMGCCallV86Code … … 177 177 ; Restore registers. 178 178 ; 179 TRPM_NP_GP_HANDLER NAME(cpum GCHandleNPAndGP), CPUM_HANDLER_ES179 TRPM_NP_GP_HANDLER NAME(cpumRCHandleNPAndGP), CPUM_HANDLER_ES 180 180 mov es, [edx + CPUMCPU.Guest.es.Sel] 181 TRPM_NP_GP_HANDLER NAME(cpum GCHandleNPAndGP), CPUM_HANDLER_FS181 TRPM_NP_GP_HANDLER NAME(cpumRCHandleNPAndGP), CPUM_HANDLER_FS 182 182 mov fs, [edx + CPUMCPU.Guest.fs.Sel] 183 TRPM_NP_GP_HANDLER NAME(cpum GCHandleNPAndGP), CPUM_HANDLER_GS183 TRPM_NP_GP_HANDLER NAME(cpumRCHandleNPAndGP), CPUM_HANDLER_GS 184 184 mov gs, [edx + CPUMCPU.Guest.gs.Sel] 185 185 … … 219 219 push dword [edx + CPUMCPU.Guest.ds.Sel] 220 220 mov edx, [edx + CPUMCPU.Guest.edx] 221 TRPM_NP_GP_HANDLER NAME(cpum GCHandleNPAndGP), CPUM_HANDLER_DS221 TRPM_NP_GP_HANDLER NAME(cpumRCHandleNPAndGP), CPUM_HANDLER_DS 222 222 pop ds 223 223 224 224 ; restart execution. 225 TRPM_NP_GP_HANDLER NAME(cpum GCHandleNPAndGP), CPUM_HANDLER_IRET225 TRPM_NP_GP_HANDLER NAME(cpumRCHandleNPAndGP), CPUM_HANDLER_IRET 226 226 iretd 227 227 ENDPROC CPUMGCResumeGuest … … 298 298 299 299 ; restart execution. 300 TRPM_NP_GP_HANDLER NAME(cpum GCHandleNPAndGP), CPUM_HANDLER_IRET300 TRPM_NP_GP_HANDLER NAME(cpumRCHandleNPAndGP), CPUM_HANDLER_IRET 301 301 iretd 302 302 ENDPROC CPUMGCResumeGuestV86 -
trunk/src/VBox/VMM/VMMRC/TRPMRCHandlers.cpp
r41940 r41943 1 1 /* $Id$ */ 2 2 /** @file 3 * TRPM - GuestContext Trap Handlers, CPP part3 * TRPM - Raw-mode Context Trap Handlers, CPP part 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2006-20 07Oracle Corporation7 * Copyright (C) 2006-2012 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 114 114 *******************************************************************************/ 115 115 RT_C_DECLS_BEGIN /* addressed from asm (not called so no DECLASM). */ 116 DECLCALLBACK(int) trpm GCTrapInGeneric(PVM pVM, PCPUMCTXCORE pRegFrame, uintptr_t uUser);116 DECLCALLBACK(int) trpmRCTrapInGeneric(PVM pVM, PCPUMCTXCORE pRegFrame, uintptr_t uUser); 117 117 RT_C_DECLS_END 118 118 … … 1271 1271 * Deal with hypervisor traps occurring when resuming execution on a trap. 1272 1272 * 1273 * @returns VBox status code. 1273 * There is a little problem with recursive RC (hypervisor) traps. We deal with 1274 * this by not allowing recursion without it being the subject of a guru 1275 * meditation. (We used to / tried to handle this but there isn't any reason 1276 * for it.) 1277 * 1278 * So, do NOT use this for handling RC traps! 1279 * 1280 * @returns VBox status code. (Anything but VINF_SUCCESS will cause guru.) 1274 1281 * @param pVM Pointer to the VM. 1275 1282 * @param pRegFrame Register frame. 1276 1283 * @param uUser User arg. 1277 1284 */ 1278 DECLCALLBACK(int) trpm GCTrapInGeneric(PVM pVM, PCPUMCTXCORE pRegFrame, uintptr_t uUser)1285 DECLCALLBACK(int) trpmRCTrapInGeneric(PVM pVM, PCPUMCTXCORE pRegFrame, uintptr_t uUser) 1279 1286 { 1280 1287 Log(("********************************************************\n")); 1281 Log(("trpm GCTrapInGeneric: eip=%RX32 uUser=%#x\n", pRegFrame->eip, uUser));1288 Log(("trpmRCTrapInGeneric: eip=%RX32 uUser=%#x\n", pRegFrame->eip, uUser)); 1282 1289 Log(("********************************************************\n")); 1283 1290 1284 if (uUser & TRPM_TRAP_IN_HYPER) 1285 { 1286 /* 1287 * Check that there is still some stack left, if not we'll flag 1288 * a guru meditation (the alternative is a triple fault). 1289 */ 1290 RTRCUINTPTR cbStackUsed = (RTRCUINTPTR)VMMGetStackRC(VMMGetCpu(pVM)) - pRegFrame->esp; 1291 if (cbStackUsed > VMM_STACK_SIZE - _1K) 1292 { 1293 LogRel(("trpmGCTrapInGeneric: ran out of stack: esp=#x cbStackUsed=%#x\n", pRegFrame->esp, cbStackUsed)); 1294 return VERR_TRPM_DONT_PANIC; 1295 } 1296 1297 /* 1298 * Just zero the register containing the selector in question. 1299 * We'll deal with the actual stale or troublesome selector value in 1300 * the outermost trap frame. 1301 */ 1302 switch (uUser & TRPM_TRAP_IN_OP_MASK) 1303 { 1304 case TRPM_TRAP_IN_MOV_GS: 1305 pRegFrame->eax = 0; 1306 pRegFrame->gs.Sel = 0; /* prevent recursive trouble. */ 1307 break; 1308 case TRPM_TRAP_IN_MOV_FS: 1309 pRegFrame->eax = 0; 1310 pRegFrame->fs.Sel = 0; /* prevent recursive trouble. */ 1311 return VINF_SUCCESS; 1312 1313 default: 1314 AssertMsgFailed(("Invalid uUser=%#x\n", uUser)); 1315 return VERR_TRPM_BAD_TRAP_IN_OP; 1316 } 1317 } 1318 else 1319 { 1320 /* 1321 * Reconstruct the guest context and switch to the recompiler. 1322 * We ASSUME we're only at 1323 */ 1324 CPUMCTXCORE CtxCore = *pRegFrame; 1325 uint32_t *pEsp = (uint32_t *)pRegFrame->esp; 1326 int rc; 1327 1328 switch (uUser) 1329 { 1330 /* 1331 * This will only occur when resuming guest code in a trap handler! 1332 */ 1333 /* @note ASSUMES esp points to the temporary guest CPUMCTXCORE!!! */ 1334 case TRPM_TRAP_IN_MOV_GS: 1335 case TRPM_TRAP_IN_MOV_FS: 1336 case TRPM_TRAP_IN_MOV_ES: 1337 case TRPM_TRAP_IN_MOV_DS: 1338 { 1339 PCPUMCTXCORE pTempGuestCtx = (PCPUMCTXCORE)pEsp; 1340 1341 /* Just copy the whole thing; several selector registers, eip (etc) and eax are not yet in pRegFrame. */ 1342 CtxCore = *pTempGuestCtx; 1343 rc = VINF_EM_RAW_STALE_SELECTOR; 1344 break; 1345 } 1346 1347 /* 1348 * This will only occur when resuming guest code! 1349 */ 1350 case TRPM_TRAP_IN_IRET: 1351 CtxCore.eip = *pEsp++; 1352 CtxCore.cs.Sel = (RTSEL)*pEsp++; 1353 CtxCore.eflags.u32 = *pEsp++; 1354 CtxCore.esp = *pEsp++; 1355 CtxCore.ss.Sel = (RTSEL)*pEsp++; 1356 rc = VINF_EM_RAW_IRET_TRAP; 1357 break; 1358 1359 /* 1360 * This will only occur when resuming V86 guest code! 1361 */ 1362 case TRPM_TRAP_IN_IRET | TRPM_TRAP_IN_V86: 1363 CtxCore.eip = *pEsp++; 1364 CtxCore.cs.Sel = (RTSEL)*pEsp++; 1365 CtxCore.eflags.u32 = *pEsp++; 1366 CtxCore.esp = *pEsp++; 1367 CtxCore.ss.Sel = (RTSEL)*pEsp++; 1368 CtxCore.es.Sel = (RTSEL)*pEsp++; 1369 CtxCore.ds.Sel = (RTSEL)*pEsp++; 1370 CtxCore.fs.Sel = (RTSEL)*pEsp++; 1371 CtxCore.gs.Sel = (RTSEL)*pEsp++; 1372 rc = VINF_EM_RAW_IRET_TRAP; 1373 break; 1374 1375 default: 1376 AssertMsgFailed(("Invalid uUser=%#x\n", uUser)); 1377 return VERR_TRPM_BAD_TRAP_IN_OP; 1378 } 1379 1380 1381 CPUMSetGuestCtxCore(VMMGetCpu0(pVM), &CtxCore); 1382 TRPMGCHyperReturnToHost(pVM, rc); 1291 /* 1292 * This used to be kind of complicated, but since we stopped storing 1293 * the register frame on the stack and instead storing it directly 1294 * in the CPUMCPU::Guest structure, we just have to figure out which 1295 * status to hand on to the host and let the recompiler/IEM do its 1296 * job. 1297 */ 1298 switch (uUser) 1299 { 1300 case TRPM_TRAP_IN_MOV_GS: 1301 case TRPM_TRAP_IN_MOV_FS: 1302 case TRPM_TRAP_IN_MOV_ES: 1303 case TRPM_TRAP_IN_MOV_DS: 1304 TRPMGCHyperReturnToHost(pVM, VINF_EM_RAW_STALE_SELECTOR); 1305 break; 1306 1307 case TRPM_TRAP_IN_IRET: 1308 case TRPM_TRAP_IN_IRET | TRPM_TRAP_IN_V86: 1309 TRPMGCHyperReturnToHost(pVM, VINF_EM_RAW_IRET_TRAP); 1310 break; 1311 1312 default: 1313 AssertMsgFailed(("Invalid uUser=%#x\n", uUser)); 1314 return VERR_TRPM_BAD_TRAP_IN_OP; 1383 1315 } 1384 1316 -
trunk/src/VBox/VMM/VMMRC/TRPMRCHandlersA.asm
r41931 r41943 1 1 ; $Id$ 2 2 ;; @file 3 ; TRPM - Guest Context Trap Handlers 4 ; 5 6 ; Copyright (C) 2006-2010 Oracle Corporation 3 ; TRPM - Raw-mode Context Trap Handlers 4 ; 5 6 ; 7 ; Copyright (C) 2006-2012 Oracle Corporation 7 8 ; 8 9 ; This file is part of VirtualBox Open Source Edition (OSE), as … … 36 37 extern IMPNAME(g_trpmGuestCtxCore) 37 38 extern IMPNAME(g_trpmHyperCtxCore) 38 extern NAME(trpm GCTrapInGeneric)39 extern NAME(trpmRCTrapInGeneric) 39 40 extern NAME(TRPMGCTrap01Handler) 40 41 extern NAME(TRPMGCHyperTrap01Handler) … … 247 248 248 249 ; 249 ; Save ds, es, eax and ebx so we have a context pointer (ebx) and250 ; Save ds, es, fs, gs, eax and ebx so we have a context pointer (ebx) and 250 251 ; scratch (eax) register to work with. A sideeffect of using ebx is that 251 252 ; it's preserved accross cdecl calls. 252 253 ; 253 254 ; In order to safely access data, we need to load our flat DS & ES selector, 254 ; and clear make sure CR0.WP is cleared. 255 ; 256 push ds ; +0ch 257 push es ; +08h 255 ; clear FS and GS (stale guest selector prevention), and clear make sure 256 ; that CR0.WP is cleared. 257 ; 258 push ds ; +14h 259 push es ; +10h 260 push fs ; +0ch 261 push gs ; +08h 258 262 push eax ; +04h 259 263 push ebx ; +00h 260 %push foobar264 %push StackFrame 261 265 %define %$STK_SAVED_EBX esp 262 266 %define %$STK_SAVED_EAX esp + 04h 263 %define %$STK_SAVED_ES esp + 08h 264 %define %$STK_SAVED_DS esp + 0ch 265 %define %$ESPOFF 10h 267 %define %$STK_SAVED_GS esp + 08h 268 %define %$STK_SAVED_FS esp + 0ch 269 %define %$STK_SAVED_ES esp + 10h 270 %define %$STK_SAVED_DS esp + 14h 271 %define %$ESPOFF 18h 266 272 %define %$STK_VECTOR esp + 00h + %$ESPOFF 267 273 %define %$STK_ERRCD esp + 04h + %$ESPOFF … … 276 282 %define %$STK_V86_GS esp + 28h + %$ESPOFF 277 283 278 push ss 279 pop ds 280 push ss 281 pop es 284 mov bx, ss ; load 285 mov ds, bx 286 mov es, bx 287 288 xor bx, bx ; load 0 into gs and fs. 289 mov gs, bx 290 mov fs, bx 282 291 283 292 mov eax, cr0 ;; @todo elimitate this read? … … 286 295 287 296 mov ebx, IMP(g_trpmGuestCtxCore) ; Assume GC as the most common. 288 test byte [%$STK_CS], 3h 297 test byte [%$STK_CS], 3h ; check RPL of the cs selector 289 298 ;; @todo check this for conforming segments. 290 299 jnz .save_state 291 test dword [%$STK_EFLAGS], X86_EFL_VM 300 test dword [%$STK_EFLAGS], X86_EFL_VM; If in V86, then guest. 292 301 jnz .save_state 293 302 mov ebx, IMP(g_trpmHyperCtxCore) ; It's raw-mode context, actually. … … 341 350 mov cx, [%$STK_SAVED_DS] 342 351 mov [ebx + CPUMCTXCORE.ds.Sel], cx 343 mov cx, fs352 mov cx, [%$STK_SAVED_FS] 344 353 mov [ebx + CPUMCTXCORE.fs.Sel], cx 345 mov cx, gs354 mov cx, [%$STK_SAVED_GS] 346 355 mov [ebx + CPUMCTXCORE.gs.Sel], cx 347 356 jmp .done_saving … … 496 505 497 506 mov ax, [ebx + CPUMCTXCORE.gs.Sel] 498 TRPM_NP_GP_HANDLER NAME(trpm GCTrapInGeneric), TRPM_TRAP_IN_MOV_GS507 TRPM_NP_GP_HANDLER NAME(trpmRCTrapInGeneric), TRPM_TRAP_IN_MOV_GS 499 508 mov gs, ax 500 509 501 510 mov ax, [ebx + CPUMCTXCORE.fs.Sel] 502 TRPM_NP_GP_HANDLER NAME(trpm GCTrapInGeneric), TRPM_TRAP_IN_MOV_FS511 TRPM_NP_GP_HANDLER NAME(trpmRCTrapInGeneric), TRPM_TRAP_IN_MOV_FS 503 512 mov fs, ax 504 513 505 514 mov ax, [ebx + CPUMCTXCORE.es.Sel] 506 TRPM_NP_GP_HANDLER NAME(trpm GCTrapInGeneric), TRPM_TRAP_IN_MOV_ES515 TRPM_NP_GP_HANDLER NAME(trpmRCTrapInGeneric), TRPM_TRAP_IN_MOV_ES 507 516 mov es, ax 508 517 509 518 mov ax, [ebx + CPUMCTXCORE.ds.Sel] 510 TRPM_NP_GP_HANDLER NAME(trpm GCTrapInGeneric), TRPM_TRAP_IN_MOV_DS519 TRPM_NP_GP_HANDLER NAME(trpmRCTrapInGeneric), TRPM_TRAP_IN_MOV_DS 511 520 mov ds, ax 512 521 … … 514 523 pop ebx 515 524 pop eax 516 517 add esp, 8 + 8 ; skip ds, es, the error code, and vector number. 518 519 TRPM_NP_GP_HANDLER NAME(trpmGCTrapInGeneric), TRPM_TRAP_IN_IRET 525 add esp, 16 + 8 ; skip segregs, error code, and vector number. 526 527 TRPM_NP_GP_HANDLER NAME(trpmRCTrapInGeneric), TRPM_TRAP_IN_IRET 520 528 iret 521 529 … … 534 542 pop ebx 535 543 pop eax 536 537 add esp, 8 + 8 ; skip ds, es, the error code, and vector number. 538 539 TRPM_NP_GP_HANDLER NAME(trpmGCTrapInGeneric), TRPM_TRAP_IN_IRET | TRPM_TRAP_IN_V86 544 add esp, 16 + 8 ; skip segregs, error code, and vector number. 545 546 TRPM_NP_GP_HANDLER NAME(trpmRCTrapInGeneric), TRPM_TRAP_IN_IRET | TRPM_TRAP_IN_V86 540 547 iret 541 548 … … 651 658 652 659 mov ax, [ebx + CPUMCTXCORE.gs.Sel] 653 TRPM_NP_GP_HANDLER NAME(trpmGCTrapInGeneric), TRPM_TRAP_IN_MOV_GS | TRPM_TRAP_IN_HYPER654 660 mov gs, ax 655 661 656 662 mov ax, [ebx + CPUMCTXCORE.fs.Sel] 657 TRPM_NP_GP_HANDLER NAME(trpmGCTrapInGeneric), TRPM_TRAP_IN_MOV_FS | TRPM_TRAP_IN_HYPER658 663 mov fs, ax 659 664 660 665 mov ax, [ebx + CPUMCTXCORE.es.Sel] 661 TRPM_NP_GP_HANDLER NAME(trpmGCTrapInGeneric), TRPM_TRAP_IN_MOV_ES | TRPM_TRAP_IN_HYPER662 666 mov es, ax 663 667 664 668 mov ax, [ebx + CPUMCTXCORE.ds.Sel] 665 TRPM_NP_GP_HANDLER NAME(trpmGCTrapInGeneric), TRPM_TRAP_IN_MOV_DS | TRPM_TRAP_IN_HYPER666 669 mov ds, ax 667 670 … … 669 672 pop ebx 670 673 pop eax 671 672 add esp, 8 + 8 ; skip ds, es, the error code, and vector number. 674 add esp, 16 + 8 ; skip segregs, error code, and vector number. 673 675 674 676 iret … … 735 737 736 738 ; 737 ; Save ds, es, eax and ebx so we have a context pointer (ebx) and739 ; Save ds, es, fs, gs, eax and ebx so we have a context pointer (ebx) and 738 740 ; scratch (eax) register to work with. A sideeffect of using ebx is that 739 741 ; it's preserved accross cdecl calls. 740 742 ; 741 743 ; In order to safely access data, we need to load our flat DS & ES selector, 742 ; and clear make sure CR0.WP is cleared. 743 ; 744 push ds ; +0ch 745 push es ; +08h 744 ; clear FS and GS (stale guest selector prevention), and clear make sure 745 ; that CR0.WP is cleared. 746 ; 747 push ds ; +14h 748 push es ; +10h 749 push fs ; +0ch 750 push gs ; +08h 746 751 push eax ; +04h 747 752 push ebx ; +00h 748 %push foobar753 %push StackFrame 749 754 %define %$STK_SAVED_EBX esp 750 755 %define %$STK_SAVED_EAX esp + 04h 751 %define %$STK_SAVED_ES esp + 08h 752 %define %$STK_SAVED_DS esp + 0ch 753 %define %$ESPOFF 10h 756 %define %$STK_SAVED_GS esp + 08h 757 %define %$STK_SAVED_FS esp + 0ch 758 %define %$STK_SAVED_ES esp + 10h 759 %define %$STK_SAVED_DS esp + 14h 760 %define %$ESPOFF 18h 754 761 %define %$STK_VECTOR esp + 00h + %$ESPOFF 755 762 %define %$STK_EIP esp + 04h + %$ESPOFF … … 763 770 %define %$STK_V86_GS esp + 24h + %$ESPOFF 764 771 765 push ss 766 pop ds 767 push ss 768 pop es 772 mov bx, ss ; load 773 mov ds, bx 774 mov es, bx 775 776 xor bx, bx ; load 0 into gs and fs. 777 mov gs, bx 778 mov fs, bx 769 779 770 780 mov eax, cr0 ;; @todo elimitate this read? … … 828 838 mov cx, [%$STK_SAVED_DS] 829 839 mov [ebx + CPUMCTXCORE.ds.Sel], cx 830 mov cx, fs840 mov cx, [%$STK_SAVED_FS] 831 841 mov [ebx + CPUMCTXCORE.fs.Sel], cx 832 mov cx, gs842 mov cx, [%$STK_SAVED_GS] 833 843 mov [ebx + CPUMCTXCORE.gs.Sel], cx 834 844 jmp .done_saving … … 945 955 946 956 mov ax, [ebx + CPUMCTXCORE.gs.Sel] 947 TRPM_NP_GP_HANDLER NAME(trpm GCTrapInGeneric), TRPM_TRAP_IN_MOV_GS957 TRPM_NP_GP_HANDLER NAME(trpmRCTrapInGeneric), TRPM_TRAP_IN_MOV_GS 948 958 mov gs, ax 949 959 950 960 mov ax, [ebx + CPUMCTXCORE.fs.Sel] 951 TRPM_NP_GP_HANDLER NAME(trpm GCTrapInGeneric), TRPM_TRAP_IN_MOV_FS961 TRPM_NP_GP_HANDLER NAME(trpmRCTrapInGeneric), TRPM_TRAP_IN_MOV_FS 952 962 mov fs, ax 953 963 954 964 mov ax, [ebx + CPUMCTXCORE.es.Sel] 955 TRPM_NP_GP_HANDLER NAME(trpm GCTrapInGeneric), TRPM_TRAP_IN_MOV_ES965 TRPM_NP_GP_HANDLER NAME(trpmRCTrapInGeneric), TRPM_TRAP_IN_MOV_ES 956 966 mov es, ax 957 967 958 968 mov ax, [ebx + CPUMCTXCORE.ds.Sel] 959 TRPM_NP_GP_HANDLER NAME(trpm GCTrapInGeneric), TRPM_TRAP_IN_MOV_DS969 TRPM_NP_GP_HANDLER NAME(trpmRCTrapInGeneric), TRPM_TRAP_IN_MOV_DS 960 970 mov ds, ax 961 971 … … 963 973 pop ebx 964 974 pop eax 965 966 add esp, 8 + 4 ; skip ds, es, and vector number. 967 968 TRPM_NP_GP_HANDLER NAME(trpmGCTrapInGeneric), TRPM_TRAP_IN_IRET 975 add esp, 16 + 4 ; skip segregs, and vector number. 976 977 TRPM_NP_GP_HANDLER NAME(trpmRCTrapInGeneric), TRPM_TRAP_IN_IRET 969 978 iret 970 979 … … 983 992 pop ebx 984 993 pop eax 985 986 add esp, 8 + 4 ; skip ds, es, and vector number. 987 988 TRPM_NP_GP_HANDLER NAME(trpmGCTrapInGeneric), TRPM_TRAP_IN_IRET | TRPM_TRAP_IN_V86 994 add esp, 16 + 4 ; skip segregs, and vector number. 995 996 TRPM_NP_GP_HANDLER NAME(trpmRCTrapInGeneric), TRPM_TRAP_IN_IRET | TRPM_TRAP_IN_V86 989 997 iret 990 998 … … 1041 1049 mov edi, [ebx + CPUMCTXCORE.edi] 1042 1050 1043 1051 ; skipping esp & ss. 1044 1052 1045 1053 mov eax, [ebx + CPUMCTXCORE.eflags] … … 1051 1059 1052 1060 mov ax, [ebx + CPUMCTXCORE.gs.Sel] 1053 TRPM_NP_GP_HANDLER NAME(trpmGCTrapInGeneric), TRPM_TRAP_IN_MOV_GS | TRPM_TRAP_IN_HYPER1054 1061 mov gs, ax 1055 1062 1056 1063 mov ax, [ebx + CPUMCTXCORE.fs.Sel] 1057 TRPM_NP_GP_HANDLER NAME(trpmGCTrapInGeneric), TRPM_TRAP_IN_MOV_FS | TRPM_TRAP_IN_HYPER1058 1064 mov fs, ax 1059 1065 1060 1066 mov ax, [ebx + CPUMCTXCORE.es.Sel] 1061 TRPM_NP_GP_HANDLER NAME(trpmGCTrapInGeneric), TRPM_TRAP_IN_MOV_ES | TRPM_TRAP_IN_HYPER1062 1067 mov es, ax 1063 1068 1064 1069 mov ax, [ebx + CPUMCTXCORE.ds.Sel] 1065 TRPM_NP_GP_HANDLER NAME(trpmGCTrapInGeneric), TRPM_TRAP_IN_MOV_DS | TRPM_TRAP_IN_HYPER1066 1070 mov ds, ax 1067 1071 … … 1069 1073 pop ebx 1070 1074 pop eax 1071 1072 add esp, 8 + 4 ; skip ds, es, and vector number. 1075 add esp, 16 + 4 ; skip segregs, and vector number. 1076 1073 1077 iret 1074 1078 %pop -
trunk/src/VBox/VMM/include/TRPMInternal.h
r41801 r41943 5 5 6 6 /* 7 * Copyright (C) 2006-20 07Oracle Corporation7 * Copyright (C) 2006-2012 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 58 58 /** Set if this is a V86 resume. */ 59 59 #define TRPM_TRAP_IN_V86 RT_BIT(30) 60 /** If set this is a hypervisor register set. If cleared it's a guest set. */61 #define TRPM_TRAP_IN_HYPER RT_BIT(31)62 60 /** @} */ 63 61 -
trunk/src/VBox/VMM/include/TRPMInternal.mac
r38867 r41943 5 5 6 6 ; 7 ; Copyright (C) 2006-20 07Oracle Corporation7 ; Copyright (C) 2006-2012 Oracle Corporation 8 8 ; 9 9 ; This file is part of VirtualBox Open Source Edition (OSE), as … … 26 26 %define TRPM_TRAP_IN_IRET 5 27 27 %define TRPM_TRAP_IN_V86 RT_BIT(30) 28 %define TRPM_TRAP_IN_HYPER RT_BIT(31)29 28 30 29 struc TRPM
Note:
See TracChangeset
for help on using the changeset viewer.