Changeset 20530 in vbox for trunk/src/VBox/VMM/VMMR0
- Timestamp:
- Jun 13, 2009 8:53:44 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 48532
- Location:
- trunk/src/VBox/VMM/VMMR0
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp
r20516 r20530 1023 1023 * 1024 1024 * Interrupts are disabled before the call to make sure we don't miss any interrupt 1025 * that would flag preemption (IPI, timer tick, ++). 1025 * that would flag preemption (IPI, timer tick, ++). 1026 1026 * 1027 1027 * Note! Interrupts must be disabled done *before* we check for TLB flushes; TLB … … 2062 2062 { 2063 2063 /* ins/outs */ 2064 DISCPUSTATE Cpu;2064 PDISCPUSTATE pDis = &pVCpu->hwaccm.s.DisState; 2065 2065 2066 2066 /* Disassemble manually to deal with segment prefixes. */ 2067 rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), &Cpu, NULL);2067 rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), pDis, NULL); 2068 2068 if (rc == VINF_SUCCESS) 2069 2069 { … … 2072 2072 Log2(("IOMInterpretOUTSEx %RGv %x size=%d\n", (RTGCPTR)pCtx->rip, IoExitInfo.n.u16Port, uIOSize)); 2073 2073 STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatExitIOStringWrite); 2074 rc = IOMInterpretOUTSEx(pVM, CPUMCTX2CORE(pCtx), IoExitInfo.n.u16Port, Cpu.prefix, uIOSize);2074 rc = IOMInterpretOUTSEx(pVM, CPUMCTX2CORE(pCtx), IoExitInfo.n.u16Port, pDis->prefix, uIOSize); 2075 2075 } 2076 2076 else … … 2078 2078 Log2(("IOMInterpretINSEx %RGv %x size=%d\n", (RTGCPTR)pCtx->rip, IoExitInfo.n.u16Port, uIOSize)); 2079 2079 STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatExitIOStringRead); 2080 rc = IOMInterpretINSEx(pVM, CPUMCTX2CORE(pCtx), IoExitInfo.n.u16Port, Cpu.prefix, uIOSize);2080 rc = IOMInterpretINSEx(pVM, CPUMCTX2CORE(pCtx), IoExitInfo.n.u16Port, pDis->prefix, uIOSize); 2081 2081 } 2082 2082 } … … 2337 2337 * @returns VBox status code. 2338 2338 * @param pVCpu The VM CPU to operate on. 2339 * @param pDis StateDisassembly state2339 * @param pDis Disassembly state 2340 2340 * @param pCtx CPU context 2341 2341 * @param cbOp Opcode size 2342 2342 */ 2343 static int svmR0EmulateTprMov(PVMCPU pVCpu, DISCPUSTATE *pDisState, PCPUMCTX pCtx, unsigned cbOp)2343 static int svmR0EmulateTprMov(PVMCPU pVCpu, PDISCPUSTATE pDis, PCPUMCTX pCtx, unsigned cbOp) 2344 2344 { 2345 2345 int rc; 2346 2346 2347 if (pDis State->param1.flags == USE_DISPLACEMENT32)2347 if (pDis->param1.flags == USE_DISPLACEMENT32) 2348 2348 { 2349 2349 /* write */ … … 2351 2351 2352 2352 /* Fetch the new TPR value */ 2353 if (pDis State->param2.flags == USE_REG_GEN32)2353 if (pDis->param2.flags == USE_REG_GEN32) 2354 2354 { 2355 2355 uint32_t val; 2356 2356 2357 rc = DISFetchReg32(CPUMCTX2CORE(pCtx), pDis State->param2.base.reg_gen, &val);2357 rc = DISFetchReg32(CPUMCTX2CORE(pCtx), pDis->param2.base.reg_gen, &val); 2358 2358 AssertRC(rc); 2359 2359 u8Tpr = val >> 4; 2360 2360 } 2361 2361 else 2362 if (pDis State->param2.flags == USE_IMMEDIATE32)2363 { 2364 u8Tpr = (uint8_t)pDis State->param2.parval >> 4;2362 if (pDis->param2.flags == USE_IMMEDIATE32) 2363 { 2364 u8Tpr = (uint8_t)pDis->param2.parval >> 4; 2365 2365 } 2366 2366 else … … 2375 2375 } 2376 2376 else 2377 if (pDis State->param2.flags == USE_DISPLACEMENT32)2377 if (pDis->param2.flags == USE_DISPLACEMENT32) 2378 2378 { 2379 2379 /* read */ … … 2385 2385 AssertRC(rc); 2386 2386 2387 rc = DISWriteReg32(CPUMCTX2CORE(pCtx), pDis State->param1.base.reg_gen, u8Tpr << 4);2387 rc = DISWriteReg32(CPUMCTX2CORE(pCtx), pDis->param1.base.reg_gen, u8Tpr << 4); 2388 2388 AssertRC(rc); 2389 2389 … … 2405 2405 static int svmR0ReplaceTprInstr(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx) 2406 2406 { 2407 RTGCPTR oldrip = pCtx->rip;2408 DISCPUSTATE Cpu;2409 unsigned cbOp;2407 RTGCPTR oldrip = pCtx->rip; 2408 PDISCPUSTATE pDis = &pVCpu->hwaccm.s.DisState; 2409 unsigned cbOp; 2410 2410 2411 2411 Log(("Replace TPR access at %RGv\n", pCtx->rip)); 2412 2412 2413 int rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), &Cpu, &cbOp);2413 int rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), pDis, &cbOp); 2414 2414 AssertRC(rc); 2415 2415 if ( rc == VINF_SUCCESS 2416 && Cpu.pCurInstr->opcode == OP_MOV)2416 && pDis->pCurInstr->opcode == OP_MOV) 2417 2417 { 2418 2418 #if 0 2419 2419 uint8_t szInstr[15]; 2420 2420 if ( cbOp == 10 2421 && Cpu.param1.flags == USE_DISPLACEMENT322422 && Cpu.param2.flags == USE_IMMEDIATE32)2421 && pDis->param1.flags == USE_DISPLACEMENT32 2422 && pDis->param2.flags == USE_IMMEDIATE32) 2423 2423 { 2424 2424 /* Found: … … 2431 2431 * 2432 2432 */ 2433 uint32_t u32tpr = (uint32_t) Cpu.param2.parval;2433 uint32_t u32tpr = (uint32_t)pDis->param2.parval; 2434 2434 2435 2435 u32tpr = (u32tpr >> 4) & 0xf; 2436 2436 2437 /* Check if the next instruction overwrites a general purpose register. If 2437 /* Check if the next instruction overwrites a general purpose register. If 2438 2438 * it does, then we can safely use it ourselves. 2439 2439 */ 2440 2440 pCtx->rip += cbOp; 2441 rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), &Cpu, &cbOp);2441 rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), pDis, &cbOp); 2442 2442 pCtx->rip = oldrip; 2443 2443 if ( rc == VINF_SUCCESS 2444 && Cpu.pCurInstr->opcode == OP_MOV2445 && Cpu.param1.flags == USE_REG_GEN32)2444 && pDis->pCurInstr->opcode == OP_MOV 2445 && pDis->param1.flags == USE_REG_GEN32) 2446 2446 { 2447 2447 /* 0xB8, dword immediate = mov eax, dword immediate */ 2448 szInstr[0] = 0xB8 + Cpu.param1.base.reg_gen;2448 szInstr[0] = 0xB8 + pDis->param1.base.reg_gen; 2449 2449 szInstr[1] = (uint8_t)u32tpr; 2450 2450 szInstr[2] = 0; … … 2456 2456 szInstr[6] = 0x0F; 2457 2457 szInstr[7] = 0x22; 2458 szInstr[8] = 0xC0 | Cpu.param1.base.reg_gen;2458 szInstr[8] = 0xC0 | pDis->param1.base.reg_gen; 2459 2459 szInstr[9] = 0x90; /* nop */ 2460 2460 … … 2468 2468 else 2469 2469 { 2470 if ( Cpu.param2.flags == USE_REG_GEN322470 if ( pDis->param2.flags == USE_REG_GEN32 2471 2471 && cbOp == 6) 2472 2472 { 2473 RTGCPTR GCPtrTpr = (uint32_t) Cpu.param1.disp32;2474 uint32_t uMmioReg = Cpu.param2.base.reg_gen;2473 RTGCPTR GCPtrTpr = (uint32_t)pDis->param1.disp32; 2474 uint32_t uMmioReg = pDis->param2.base.reg_gen; 2475 2475 2476 2476 /* Found: … … 2480 2480 */ 2481 2481 pCtx->rip += cbOp; 2482 rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), &Cpu, &cbOp);2482 rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), pDis, &cbOp); 2483 2483 pCtx->rip = oldrip; 2484 2484 if ( rc == VINF_SUCCESS 2485 && Cpu.pCurInstr->opcode == OP_MOV2486 && Cpu.param1.flags == USE_REG_GEN322487 && Cpu.param2.flags == USE_DISPLACEMENT322488 && Cpu.param2.disp32 == (uint32_t)GCPtrTpr2485 && pDis->pCurInstr->opcode == OP_MOV 2486 && pDis->param1.flags == USE_REG_GEN32 2487 && pDis->param2.flags == USE_DISPLACEMENT32 2488 && pDis->param2.disp32 == (uint32_t)GCPtrTpr 2489 2489 && cbOp == 5) 2490 2490 { 2491 2491 /* mov new_reg, uMmioReg */ 2492 2492 szInstr[0] = 0x89; 2493 szInstr[1] = MAKE_MODRM(3, uMmioReg, Cpu.param1.base.reg_gen);2493 szInstr[1] = MAKE_MODRM(3, uMmioReg, pDis->param1.base.reg_gen); 2494 2494 2495 2495 /* Let's hope the guest won't mind us trashing the source register... … … 2518 2518 } 2519 2519 else 2520 if ( Cpu.param1.flags == USE_REG_GEN322520 if ( pDis->param1.flags == USE_REG_GEN32 2521 2521 && cbOp == 5) 2522 2522 { 2523 uint32_t uMmioReg = Cpu.param1.base.reg_gen;2523 uint32_t uMmioReg = pDis->param1.base.reg_gen; 2524 2524 2525 2525 /* Found: … … 2529 2529 */ 2530 2530 pCtx->rip += cbOp; 2531 rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), &Cpu, &cbOp);2531 rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), pDis, &cbOp); 2532 2532 pCtx->rip = oldrip; 2533 2533 if ( rc == VINF_SUCCESS 2534 && Cpu.pCurInstr->opcode == OP_SHR2535 && Cpu.param1.flags == USE_REG_GEN322536 && Cpu.param1.base.reg_gen == uMmioReg2537 && Cpu.param2.flags == USE_IMMEDIATE82538 && Cpu.param2.parval == 4)2534 && pDis->pCurInstr->opcode == OP_SHR 2535 && pDis->param1.flags == USE_REG_GEN32 2536 && pDis->param1.base.reg_gen == uMmioReg 2537 && pDis->param2.flags == USE_IMMEDIATE8 2538 && pDis->param2.parval == 4) 2539 2539 { 2540 2540 /* 0xF0, 0x0F, 0x20, 0xC0 = mov eax, cr8 */ … … 2542 2542 szInstr[1] = 0x0F; 2543 2543 szInstr[2] = 0x20; 2544 szInstr[3] = 0xC0 | Cpu.param1.base.reg_gen;2544 szInstr[3] = 0xC0 | pDis->param1.base.reg_gen; 2545 2545 for (unsigned i = 4; i < 5+cbOp; i++) 2546 2546 szInstr[i] = 0x90; /* nop */ … … 2555 2555 } 2556 2556 #endif 2557 rc = svmR0EmulateTprMov(pVCpu, &Cpu, pCtx, cbOp);2557 rc = svmR0EmulateTprMov(pVCpu, pDis, pCtx, cbOp); 2558 2558 if (rc != VINF_SUCCESS) 2559 2559 return rc; … … 2683 2683 if (RT_SUCCESS(rc)) 2684 2684 { 2685 uint32_t cbOp;2686 DISCPUSTATE Cpu;2687 2688 Cpu.mode = enmMode;2689 rc = EMInterpretDisasOneEx(pVM, pVCpu, pbCode, pRegFrame, &Cpu, &cbOp);2690 Assert(RT_FAILURE(rc) || Cpu.pCurInstr->opcode == OP_INVLPG);2691 if (RT_SUCCESS(rc) && Cpu.pCurInstr->opcode == OP_INVLPG)2685 uint32_t cbOp; 2686 PDISCPUSTATE pDis = &pVCpu->hwaccm.s.DisState; 2687 2688 pDis->mode = enmMode; 2689 rc = EMInterpretDisasOneEx(pVM, pVCpu, pbCode, pRegFrame, pDis, &cbOp); 2690 Assert(RT_FAILURE(rc) || pDis->pCurInstr->opcode == OP_INVLPG); 2691 if (RT_SUCCESS(rc) && pDis->pCurInstr->opcode == OP_INVLPG) 2692 2692 { 2693 Assert(cbOp == Cpu.opsize);2694 rc = svmR0InterpretInvlPg(pVCpu, &Cpu, pRegFrame, uASID);2693 Assert(cbOp == pDis->opsize); 2694 rc = svmR0InterpretInvlPg(pVCpu, pDis, pRegFrame, uASID); 2695 2695 if (RT_SUCCESS(rc)) 2696 2696 { -
trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp
r20517 r20530 2315 2315 /* All done! Let's start VM execution. */ 2316 2316 STAM_PROFILE_ADV_START(&pVCpu->hwaccm.s.StatInGC, z); 2317 #ifdef VBOX_STRICT2318 2317 Assert(idCpuCheck == RTMpCpuId()); 2319 #endif2320 2318 2321 2319 #ifdef VBOX_WITH_CRASHDUMP_MAGIC … … 2328 2326 TMNotifyEndOfExecution(pVCpu); 2329 2327 VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED); 2328 Assert(!(ASMGetFlags() & X86_EFL_IF)); 2330 2329 ASMSetFlags(uOldEFlags); 2331 2330 #ifndef VBOX_WITH_VMMR0_DISABLE_PREEMPTION … … 2676 2675 case X86_XCPT_GP: /* General protection failure exception.*/ 2677 2676 { 2678 uint32_t cbOp;2679 uint32_t cbSize;2680 DISCPUSTATE Cpu;2677 uint32_t cbOp; 2678 uint32_t cbSize; 2679 PDISCPUSTATE pDis = &pVCpu->hwaccm.s.DisState; 2681 2680 2682 2681 STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatExitGuestGP); … … 2695 2694 LogFlow(("Real mode X86_XCPT_GP instruction emulation at %RGv\n", (RTGCPTR)pCtx->rip)); 2696 2695 2697 rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), &Cpu, &cbOp);2696 rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), pDis, &cbOp); 2698 2697 if (RT_SUCCESS(rc)) 2699 2698 { 2700 2699 bool fUpdateRIP = true; 2701 2700 2702 Assert(cbOp == Cpu.opsize);2703 switch ( Cpu.pCurInstr->opcode)2701 Assert(cbOp == pDis->opsize); 2702 switch (pDis->pCurInstr->opcode) 2704 2703 { 2705 2704 case OP_CLI: … … 2716 2715 fUpdateRIP = false; 2717 2716 rc = VINF_EM_HALT; 2718 pCtx->rip += Cpu.opsize;2717 pCtx->rip += pDis->opsize; 2719 2718 STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatExitHlt); 2720 2719 break; … … 2727 2726 X86EFLAGS eflags; 2728 2727 2729 if ( Cpu.prefix & PREFIX_OPSIZE)2728 if (pDis->prefix & PREFIX_OPSIZE) 2730 2729 { 2731 2730 cbParm = 4; … … 2769 2768 X86EFLAGS eflags; 2770 2769 2771 if ( Cpu.prefix & PREFIX_OPSIZE)2770 if (pDis->prefix & PREFIX_OPSIZE) 2772 2771 { 2773 2772 cbParm = 4; … … 2810 2809 uint16_t aIretFrame[3]; 2811 2810 2812 if ( Cpu.prefix & (PREFIX_OPSIZE | PREFIX_ADDRSIZE))2811 if (pDis->prefix & (PREFIX_OPSIZE | PREFIX_ADDRSIZE)) 2813 2812 { 2814 2813 rc = VERR_EM_INTERPRETER; … … 2844 2843 RTGCUINTPTR intInfo; 2845 2844 2846 LogFlow(("Realmode: INT %x\n", Cpu.param1.parval & 0xff));2847 intInfo = Cpu.param1.parval & 0xff;2845 LogFlow(("Realmode: INT %x\n", pDis->param1.parval & 0xff)); 2846 intInfo = pDis->param1.parval & 0xff; 2848 2847 intInfo |= (1 << VMX_EXIT_INTERRUPTION_INFO_VALID_SHIFT); 2849 2848 intInfo |= (VMX_EXIT_INTERRUPTION_INFO_TYPE_SW << VMX_EXIT_INTERRUPTION_INFO_TYPE_SHIFT); … … 2892 2891 2893 2892 default: 2894 rc = EMInterpretInstructionCPU(pVM, pVCpu, &Cpu, CPUMCTX2CORE(pCtx), 0, &cbSize);2893 rc = EMInterpretInstructionCPU(pVM, pVCpu, pDis, CPUMCTX2CORE(pCtx), 0, &cbSize); 2895 2894 break; 2896 2895 } … … 3341 3340 { 3342 3341 /* ins/outs */ 3343 DISCPUSTATE Cpu;3342 PDISCPUSTATE pDis = &pVCpu->hwaccm.s.DisState; 3344 3343 3345 3344 /* Disassemble manually to deal with segment prefixes. */ 3346 3345 /** @todo VMX_VMCS_EXIT_GUEST_LINEAR_ADDR contains the flat pointer operand of the instruction. */ 3347 3346 /** @todo VMX_VMCS32_RO_EXIT_INSTR_INFO also contains segment prefix info. */ 3348 rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), &Cpu, NULL);3347 rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), pDis, NULL); 3349 3348 if (rc == VINF_SUCCESS) 3350 3349 { … … 3353 3352 Log2(("IOMInterpretOUTSEx %RGv %x size=%d\n", (RTGCPTR)pCtx->rip, uPort, cbSize)); 3354 3353 STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatExitIOStringWrite); 3355 rc = IOMInterpretOUTSEx(pVM, CPUMCTX2CORE(pCtx), uPort, Cpu.prefix, cbSize);3354 rc = IOMInterpretOUTSEx(pVM, CPUMCTX2CORE(pCtx), uPort, pDis->prefix, cbSize); 3356 3355 } 3357 3356 else … … 3359 3358 Log2(("IOMInterpretINSEx %RGv %x size=%d\n", (RTGCPTR)pCtx->rip, uPort, cbSize)); 3360 3359 STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatExitIOStringRead); 3361 rc = IOMInterpretINSEx(pVM, CPUMCTX2CORE(pCtx), uPort, Cpu.prefix, cbSize);3360 rc = IOMInterpretINSEx(pVM, CPUMCTX2CORE(pCtx), uPort, pDis->prefix, cbSize); 3362 3361 } 3363 3362 }
Note:
See TracChangeset
for help on using the changeset viewer.