Changeset 40442 in vbox for trunk/src/VBox
- Timestamp:
- Mar 13, 2012 11:40:27 AM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 76794
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/EMAll.cpp
r40357 r40442 75 75 * Internal Functions * 76 76 *******************************************************************************/ 77 #ifndef VBOX_WITH_IEM 77 78 DECLINLINE(VBOXSTRICTRC) emInterpretInstructionCPU(PVM pVM, PVMCPU pVCpu, PDISCPUSTATE pDis, PCPUMCTXCORE pRegFrame, 78 79 RTGCPTR pvFault, EMCODETYPE enmCodeType, uint32_t *pcbSize); 80 #endif 79 81 80 82 … … 488 490 VMMDECL(VBOXSTRICTRC) EMInterpretInstruction(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, uint32_t *pcbSize) 489 491 { 492 LogFlow(("EMInterpretInstruction %RGv fault %RGv\n", (RTGCPTR)pRegFrame->rip, pvFault)); 493 #ifdef VBOX_WITH_IEM 494 int rc = IEMExecOneEx(pVCpu, pRegFrame, IEM_EXEC_ONE_EX_FLAGS_, pcbSize); 495 if (RT_FAILURE(rc)) 496 switch (rc) 497 { 498 case VERR_IEM_ASPECT_NOT_IMPLEMENTED: 499 case VERR_IEM_INSTR_NOT_IMPLEMENTED: 500 return VERR_EM_INTERPRETER; 501 } 502 return rc; 503 #else 490 504 RTGCPTR pbCode; 491 492 LogFlow(("EMInterpretInstruction %RGv fault %RGv\n", (RTGCPTR)pRegFrame->rip, pvFault));493 505 VBOXSTRICTRC rc = SELMToFlatEx(pVM, DIS_SELREG_CS, pRegFrame, pRegFrame->rip, 0, &pbCode); 494 506 if (RT_SUCCESS(rc)) … … 509 521 } 510 522 return VERR_EM_INTERPRETER; 523 #endif 511 524 } 512 525 … … 555 568 556 569 /** 557 * Interpret a port I/O instruction. 558 * 559 * @returns VBox status code suitable for scheduling. 570 * Interprets the current instruction using the supplied DISCPUSTATE structure. 571 * 572 * IP/EIP/RIP *IS* updated! 573 * 574 * @returns VBox strict status code. 575 * @retval VINF_* Scheduling instructions. When these are returned, it 576 * starts to get a bit tricky to know whether code was 577 * executed or not... We'll address this when it becomes a problem. 578 * @retval VERR_EM_INTERPRETER Something we can't cope with. 579 * @retval VERR_* Fatal errors. 580 * 560 581 * @param pVM The VM handle. 561 582 * @param pVCpu The VMCPU handle. 562 * @param pCtxCore The context core. This will be updated on successful return. 563 * @param pDis The instruction to interpret. 564 * @param cbOp The size of the instruction. 565 * @remark This may raise exceptions. 566 */ 567 VMMDECL(VBOXSTRICTRC) EMInterpretPortIO(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, PDISCPUSTATE pDis, uint32_t cbOp) 568 { 569 /* 570 * Hand it on to IOM. 571 */ 572 #ifdef IN_RC 573 VBOXSTRICTRC rcStrict = IOMGCIOPortHandler(pVM, pCtxCore, pDis); 574 if (IOM_SUCCESS(rcStrict)) 575 pCtxCore->rip += cbOp; 576 NOREF(pVCpu); 577 return rcStrict; 578 #else 579 NOREF(pVM); NOREF(pVCpu); NOREF(pCtxCore); NOREF(pDis); NOREF(cbOp); 580 AssertReleaseMsgFailed(("not implemented\n")); 581 return VERR_NOT_IMPLEMENTED; 582 #endif 583 } 584 583 * @param pDis The disassembler cpu state for the instruction to be 584 * interpreted. 585 * @param pRegFrame The register frame. IP/EIP/RIP *IS* changed! 586 * @param pvFault The fault address (CR2). 587 * @param pcbSize Size of the write (if applicable). 588 * @param enmCodeType Code type (user/supervisor) 589 * 590 * @remark Invalid opcode exceptions have a higher priority than GP (see Intel 591 * Architecture System Developers Manual, Vol 3, 5.5) so we don't need 592 * to worry about e.g. invalid modrm combinations (!) 593 * 594 * @todo At this time we do NOT check if the instruction overwrites vital information. 595 * Make sure this can't happen!! (will add some assertions/checks later) 596 */ 597 VMMDECL(VBOXSTRICTRC) EMInterpretInstructionCpuUpdtPC(PVM pVM, PVMCPU pVCpu, PDISCPUSTATE pDis, PCPUMCTXCORE pRegFrame, 598 RTGCPTR pvFault, EMCODETYPE enmCodeType) 599 { 600 STAM_PROFILE_START(&pVCpu->em.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,Emulate), a); 601 uint32_t cbIgnored; 602 VBOXSTRICTRC rc = emInterpretInstructionCPU(pVM, pVCpu, pDis, pRegFrame, pvFault, enmCodeType, &cbIgnored); 603 STAM_PROFILE_STOP(&pVCpu->em.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,Emulate), a); 604 if (RT_SUCCESS(rc)) 605 { 606 pRegFrame->rip += pDis->opsize; /* Move on to the next instruction. */ 607 STAM_COUNTER_INC(&pVCpu->em.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,InterpretSucceeded)); 608 } 609 else 610 STAM_COUNTER_INC(&pVCpu->em.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,InterpretFailed)); 611 return rc; 612 } 585 613 586 614 #ifndef VBOX_WITH_IEM 615 616 617 618 619 620 621 /* 622 * 623 * The old interpreter. 624 * The old interpreter. 625 * The old interpreter. 626 * The old interpreter. 627 * The old interpreter. 628 * 629 */ 587 630 588 631 DECLINLINE(int) emRamRead(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, void *pvDst, RTGCPTR GCPtrSrc, uint32_t cb) -
trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp
r39739 r40442 840 840 * Must do this in raw mode (!); XP boot will fail otherwise. 841 841 */ 842 uint32_t cbWritten; 843 VBOXSTRICTRC rc2 = EMInterpretInstructionCPU(pVM, pVCpu, pDis, pRegFrame, pvFault, EMCODETYPE_ALL, &cbWritten); 842 VBOXSTRICTRC rc2 = EMInterpretInstructionCpuUpdtPC(pVM, pVCpu, pDis, pRegFrame, pvFault, EMCODETYPE_ALL); 844 843 if (RT_SUCCESS(rc2)) 845 {846 pRegFrame->rip += pDis->opsize;847 844 AssertMsg(rc2 == VINF_SUCCESS, ("%Rrc\n", VBOXSTRICTRC_VAL(rc2))); /* ASSUMES no complicated stuff here. */ 848 }849 845 else if (rc2 == VERR_EM_INTERPRETER) 850 846 { … … 983 979 * Interpret the instruction. 984 980 */ 985 uint32_t cb; 986 VBOXSTRICTRC rc = EMInterpretInstructionCPU(pVM, pVCpu, pDis, pRegFrame, pvFault, EMCODETYPE_ALL, &cb); 981 VBOXSTRICTRC rc = EMInterpretInstructionCpuUpdtPC(pVM, pVCpu, pDis, pRegFrame, pvFault, EMCODETYPE_ALL); 987 982 if (RT_SUCCESS(rc)) 988 {989 pRegFrame->rip += pDis->opsize;990 983 AssertMsg(rc == VINF_SUCCESS, ("%Rrc\n", VBOXSTRICTRC_VAL(rc))); /* ASSUMES no complicated stuff here. */ 991 }992 984 else if (rc == VERR_EM_INTERPRETER) 993 985 { … … 1028 1020 #endif 1029 1021 1030 LogFlow(("pgmPoolAccessHandlerSimple: returns %Rrc cb=%d\n", VBOXSTRICTRC_VAL(rc), cb));1022 LogFlow(("pgmPoolAccessHandlerSimple: returns %Rrc\n", VBOXSTRICTRC_VAL(rc))); 1031 1023 return VBOXSTRICTRC_VAL(rc); 1032 1024 } -
trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp
r40424 r40442 3115 3115 { 3116 3116 uint32_t cbOp; 3117 uint32_t cbSize;3118 3117 PDISCPUSTATE pDis = &pVCpu->hwaccm.s.DisState; 3119 3118 … … 3336 3335 3337 3336 default: 3338 rc = EMInterpretInstructionCPU(pVM, pVCpu, pDis, CPUMCTX2CORE(pCtx), 0, EMCODETYPE_SUPERVISOR, &cbSize); 3337 rc = EMInterpretInstructionCpuUpdtPC(pVM, pVCpu, pDis, CPUMCTX2CORE(pCtx), 0, EMCODETYPE_SUPERVISOR); 3338 fUpdateRIP = false; 3339 3339 break; 3340 3340 } -
trunk/src/VBox/VMM/VMMR3/EMRaw.cpp
r40377 r40442 605 605 AssertRC(rc); 606 606 607 uint32_t opsize; 608 rc = VBOXSTRICTRC_TODO(EMInterpretInstructionCPU(pVM, pVCpu, &cpu, CPUMCTX2CORE(pCtx), 0, EMCODETYPE_SUPERVISOR, &opsize)); 607 rc = VBOXSTRICTRC_TODO(EMInterpretInstructionCpuUpdtPC(pVM, pVCpu, &cpu, CPUMCTX2CORE(pCtx), 0, EMCODETYPE_SUPERVISOR)); 609 608 if (RT_SUCCESS(rc)) 610 {611 pCtx->rip += cpu.opsize;612 609 return rc; 613 }614 610 return emR3ExecuteInstruction(pVM, pVCpu, "Monitor: "); 615 611 } … … 1047 1043 && SELMGetCpuModeFromSelector(pVM, pCtx->eflags, pCtx->cs, &pCtx->csHid) == CPUMODE_32BIT) 1048 1044 { 1049 uint32_t size;1050 1051 1045 STAM_PROFILE_START(&pVCpu->em.s.StatPrivEmu, a); 1052 1046 switch (Cpu.pCurInstr->opcode) … … 1100 1094 #endif 1101 1095 1102 rc = VBOXSTRICTRC_TODO(EMInterpretInstructionC PU(pVM, pVCpu, &Cpu, CPUMCTX2CORE(pCtx), 0, EMCODETYPE_SUPERVISOR, &size));1096 rc = VBOXSTRICTRC_TODO(EMInterpretInstructionCpuUpdtPC(pVM, pVCpu, &Cpu, CPUMCTX2CORE(pCtx), 0, EMCODETYPE_SUPERVISOR)); 1103 1097 if (RT_SUCCESS(rc)) 1104 1098 { 1105 pCtx->rip += Cpu.opsize;1106 1099 STAM_PROFILE_STOP(&pVCpu->em.s.StatPrivEmu, a); 1107 1100 -
trunk/src/VBox/VMM/VMMR3/IOM.cpp
r40280 r40442 33 33 * disassembler (DIS) to figure which instruction caused it (there are a number 34 34 * of instructions in addition to the I/O ones) and if it's an I/O port access 35 * it will hand it to IOM GCIOPortHandler (via EMInterpretPortIO).36 * IOM GCIOPortHandler will lookup the port in the AVL tree of registered35 * it will hand it to IOMRCIOPortHandler (via EMInterpretPortIO). 36 * IOMRCIOPortHandler will lookup the port in the AVL tree of registered 37 37 * handlers. If found, the handler will be called otherwise default action is 38 38 * taken. (Default action is to write into the void and read all set bits.) -
trunk/src/VBox/VMM/VMMRC/IOMRC.cpp
r40280 r40442 1 1 /* $Id$ */ 2 2 /** @file 3 * IOM - Input / Output Monitor - GuestContext.3 * IOM - Input / Output Monitor - Raw-Mode Context. 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 … … 46 46 * Attempts to service an IN/OUT instruction. 47 47 * 48 * The \#GP trap handler in GC will call this function if the opcode causing the 49 * trap is a in or out type instruction. (Call it indirectly via EM that is.) 48 * The \#GP trap handler in RC will call this function if the opcode causing 49 * the trap is a in or out type instruction. (Call it indirectly via EM that 50 * is.) 50 51 * 51 52 * @returns Strict VBox status code. Informational status codes other than the one documented … … 56 57 * @retval VINF_EM_RESCHEDULE_REM The exception was dispatched and cannot be executed in raw-mode. (TRPMRaiseXcptErr) 57 58 * @retval VINF_EM_RAW_EMULATE_INSTR Defer the read to the REM. 58 * @retval VINF_IOM_R3_IOPORT_READ Defer the read to ring-3. (R0/GC only)59 * @retval VINF_IOM_R3_IOPORT_READ Defer the read to ring-3. 59 60 * @retval VINF_EM_RAW_GUEST_TRAP The exception was left pending. (TRPMRaiseXcptErr) 60 61 * @retval VINF_TRPM_XCPT_DISPATCHED The exception was raised and dispatched for raw-mode execution. (TRPMRaiseXcptErr) 61 62 * 62 * @param pVM The virtual machine (GC pointer of course).63 * @param pVM The virtual machine handle. 63 64 * @param pRegFrame Pointer to CPUMCTXCORE guest registers structure. 64 65 * @param pCpu Disassembler CPU state. 65 66 */ 66 VMMRCDECL(VBOXSTRICTRC) IOM GCIOPortHandler(PVM pVM, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pCpu)67 VMMRCDECL(VBOXSTRICTRC) IOMRCIOPortHandler(PVM pVM, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pCpu) 67 68 { 68 69 switch (pCpu->pCurInstr->opcode) -
trunk/src/VBox/VMM/VMMRC/PATMRC.cpp
r39078 r40442 477 477 if (pRec->patch.flags & PATMFL_INT3_REPLACEMENT) 478 478 { 479 uint32_t size,cbOp;479 uint32_t cbOp; 480 480 DISCPUSTATE cpu; 481 481 … … 523 523 } 524 524 525 rc = EMInterpretInstructionC PU(pVM, VMMGetCpu0(pVM), &cpu, pRegFrame, 0 /* not relevant here */,526 EMCODETYPE_SUPERVISOR, &size);525 rc = EMInterpretInstructionCpuUpdtPC(pVM, VMMGetCpu0(pVM), &cpu, pRegFrame, 0 /* not relevant here */, 526 EMCODETYPE_SUPERVISOR); 527 527 if (rc != VINF_SUCCESS) 528 528 { … … 532 532 return VINF_EM_RAW_EMULATE_INSTR; 533 533 } 534 535 pRegFrame->eip += cpu.opsize;536 534 return VINF_SUCCESS; 537 535 } -
trunk/src/VBox/VMM/VMMRC/TRPMRCHandlers.cpp
r40280 r40442 556 556 { 557 557 LogFlow(("TRPMGCTrap06Handler: -> EMInterpretInstructionCPU\n")); 558 uint32_t cbIgnored; 559 rc = EMInterpretInstructionCPU(pVM, pVCpu, &Cpu, pRegFrame, PC, EMCODETYPE_SUPERVISOR, &cbIgnored); 560 if (RT_SUCCESS(rc)) 561 pRegFrame->eip += Cpu.opsize; 558 rc = EMInterpretInstructionCpuUpdtPC(pVM, pVCpu, &Cpu, pRegFrame, PC, EMCODETYPE_SUPERVISOR); 562 559 } 563 560 /* Never generate a raw trap here; it might be an instruction, that requires emulation. */ … … 801 798 case OP_WRMSR: 802 799 { 803 uint32_t cbIgnored; 804 rc = EMInterpretInstructionCPU(pVM, pVCpu, pCpu, pRegFrame, PC, EMCODETYPE_SUPERVISOR, &cbIgnored); 805 if (RT_SUCCESS(rc)) 806 pRegFrame->eip += pCpu->opsize; 807 else if (rc == VERR_EM_INTERPRETER) 800 rc = EMInterpretInstructionCpuUpdtPC(pVM, pVCpu, pCpu, pRegFrame, PC, EMCODETYPE_SUPERVISOR); 801 if (rc == VERR_EM_INTERPRETER) 808 802 rc = VINF_EM_RAW_EXCEPTION_PRIVILEGED; 809 803 return trpmGCExitTrap(pVM, pVCpu, rc, pRegFrame); … … 880 874 case OP_RDPMC: 881 875 { 882 uint32_t cbIgnored; 883 rc = EMInterpretInstructionCPU(pVM, pVCpu, pCpu, pRegFrame, PC, EMCODETYPE_SUPERVISOR, &cbIgnored); 884 if (RT_SUCCESS(rc)) 885 pRegFrame->eip += pCpu->opsize; 886 else if (rc == VERR_EM_INTERPRETER) 876 rc = EMInterpretInstructionCpuUpdtPC(pVM, pVCpu, pCpu, pRegFrame, PC, EMCODETYPE_SUPERVISOR); 877 if (rc == VERR_EM_INTERPRETER) 887 878 rc = VINF_EM_RAW_EXCEPTION_PRIVILEGED; 888 879 return trpmGCExitTrap(pVM, pVCpu, rc, pRegFrame); … … 1000 991 && (Cpu.pCurInstr->optype & OPTYPE_PORTIO)) 1001 992 { 1002 VBOXSTRICTRC rcStrict = EMInterpretPortIO(pVM, pVCpu, pRegFrame, &Cpu, cbOp); 1003 rc = VBOXSTRICTRC_TODO(rcStrict); 993 VBOXSTRICTRC rcStrict = IOMRCIOPortHandler(pVM, pRegFrame, &Cpu); 994 if (IOM_SUCCESS(rcStrict)) 995 pRegFrame->rip += cbOp; 1004 996 return trpmGCExitTrap(pVM, pVCpu, rc, pRegFrame); 1005 997 }
Note:
See TracChangeset
for help on using the changeset viewer.