Changeset 17426 in vbox
- Timestamp:
- Mar 6, 2009 1:55:51 AM (16 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/recompiler/VBoxREMWrapper.cpp
r17251 r17426 718 718 { REMPARMDESC_FLAGS_INT, sizeof(PRTR3PTR), NULL } 719 719 }; 720 static const REMPARMDESC g_aArgsPGMPhysGCPtr2R3PtrByGstCR3[] =721 {722 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },723 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },724 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t), NULL },725 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL },726 { REMPARMDESC_FLAGS_INT, sizeof(PRTR3PTR), NULL }727 };728 720 static const REMPARMDESC g_aArgsPGM3PhysGrowRange[] = 729 721 { … … 1113 1105 { "PGMInvalidatePage", (void *)(uintptr_t)&PGMInvalidatePage, &g_aArgsPGMInvalidatePage[0], RT_ELEMENTS(g_aArgsPGMInvalidatePage), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1114 1106 { "PGMPhysGCPhys2R3Ptr", (void *)(uintptr_t)&PGMPhysGCPhys2R3Ptr, &g_aArgsPGMPhysGCPhys2R3Ptr[0], RT_ELEMENTS(g_aArgsPGMPhysGCPhys2R3Ptr), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1115 { "PGMPhysGCPtr2R3PtrByGstCR3", (void *)(uintptr_t)&PGMPhysGCPtr2R3PtrByGstCR3, &g_aArgsPGMPhysGCPtr2R3PtrByGstCR3[0], RT_ELEMENTS(g_aArgsPGMPhysGCPtr2R3PtrByGstCR3), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },1116 1107 #ifndef VBOX_WITH_NEW_PHYS_CODE 1117 1108 { "PGM3PhysGrowRange", (void *)(uintptr_t)&PGM3PhysGrowRange, &g_aArgsPGM3PhysGrowRange[0], RT_ELEMENTS(g_aArgsPGM3PhysGrowRange), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, -
trunk/src/recompiler/VBoxRecompiler.c
r17366 r17426 3471 3471 3472 3472 /** 3473 * Disassembles n instructions and prints them to the log.3474 *3475 * @returns Success indicator.3476 * @param env Pointer to the recompiler CPU structure.3477 * @param f32BitCode Indicates that whether or not the code should3478 * be disassembled as 16 or 32 bit. If -1 the CS3479 * selector will be inspected.3480 * @param nrInstructions Nr of instructions to disassemble3481 * @param pszPrefix3482 * @remark not currently used for anything but ad-hoc debugging.3483 */3484 bool remR3DisasBlock(CPUState *env, int f32BitCode, int nrInstructions, char *pszPrefix)3485 {3486 int i;3487 3488 /*3489 * Determin 16/32 bit mode.3490 */3491 if (f32BitCode == -1)3492 f32BitCode = !!(env->segs[R_CS].flags & X86_DESC_DB); /** @todo is this right?!!?!?!?!? */3493 3494 /*3495 * Convert cs:eip to host context address.3496 * We don't care to much about cross page correctness presently.3497 */3498 RTGCPTR GCPtrPC = env->segs[R_CS].base + env->eip;3499 void *pvPC;3500 if (f32BitCode && (env->cr[0] & (X86_CR0_PE | X86_CR0_PG)) == (X86_CR0_PE | X86_CR0_PG))3501 {3502 Assert(PGMGetGuestMode(env->pVM) < PGMMODE_AMD64);3503 3504 /* convert eip to physical address. */3505 int rc = PGMPhysGCPtr2R3PtrByGstCR3(env->pVM,3506 GCPtrPC,3507 env->cr[3],3508 env->cr[4] & (X86_CR4_PSE | X86_CR4_PAE), /** @todo add longmode flag */3509 &pvPC);3510 if (RT_FAILURE(rc))3511 {3512 if (!PATMIsPatchGCAddr(env->pVM, GCPtrPC))3513 return false;3514 pvPC = (char *)PATMR3QueryPatchMemHC(env->pVM, NULL)3515 + (GCPtrPC - PATMR3QueryPatchMemGC(env->pVM, NULL));3516 }3517 }3518 else3519 {3520 /* physical address */3521 int rc = PGMPhysGCPhys2R3Ptr(env->pVM, (RTGCPHYS)GCPtrPC, nrInstructions * 16, &pvPC);3522 if (RT_FAILURE(rc))3523 return false;3524 }3525 3526 /*3527 * Disassemble.3528 */3529 RTINTPTR off = env->eip - (RTGCUINTPTR)pvPC;3530 DISCPUSTATE Cpu;3531 Cpu.mode = f32BitCode ? CPUMODE_32BIT : CPUMODE_16BIT;3532 Cpu.pfnReadBytes = NULL; /** @todo make cs:eip reader for the disassembler. */3533 //Cpu.dwUserData[0] = (uintptr_t)pVM;3534 //Cpu.dwUserData[1] = (uintptr_t)pvPC;3535 //Cpu.dwUserData[2] = GCPtrPC;3536 3537 for (i=0;i<nrInstructions;i++)3538 {3539 char szOutput[256];3540 uint32_t cbOp;3541 if (RT_FAILURE(DISInstr(&Cpu, (uintptr_t)pvPC, off, &cbOp, &szOutput[0])))3542 return false;3543 if (pszPrefix)3544 Log(("%s: %s", pszPrefix, szOutput));3545 else3546 Log(("%s", szOutput));3547 3548 pvPC += cbOp;3549 }3550 return true;3551 }3552 3553 3554 /** @todo need to test the new code, using the old code in the mean while. */3555 #define USE_OLD_DUMP_AND_DISASSEMBLY3556 3557 /**3558 3473 * Disassembles one instruction and prints it to the log. 3559 3474 * … … 3567 3482 bool remR3DisasInstr(CPUState *env, int f32BitCode, char *pszPrefix) 3568 3483 { 3569 #ifdef USE_OLD_DUMP_AND_DISASSEMBLY3570 PVM pVM = env->pVM;3571 3572 /* Doesn't work in long mode. */3573 if (env->hflags & HF_LMA_MASK)3574 return false;3575 3576 /*3577 * Determin 16/32 bit mode.3578 */3579 if (f32BitCode == -1)3580 f32BitCode = !!(env->segs[R_CS].flags & X86_DESC_DB); /** @todo is this right?!!?!?!?!? */3581 3582 /*3583 * Log registers3584 */3585 if (LogIs2Enabled())3586 {3587 remR3StateUpdate(pVM);3588 DBGFR3InfoLog(pVM, "cpumguest", pszPrefix);3589 }3590 3591 /*3592 * Convert cs:eip to host context address.3593 * We don't care to much about cross page correctness presently.3594 */3595 RTGCPTR GCPtrPC = env->segs[R_CS].base + env->eip;3596 void *pvPC;3597 if ((env->cr[0] & (X86_CR0_PE | X86_CR0_PG)) == (X86_CR0_PE | X86_CR0_PG))3598 {3599 /* convert eip to physical address. */3600 int rc = PGMPhysGCPtr2R3PtrByGstCR3(pVM,3601 GCPtrPC,3602 env->cr[3],3603 env->cr[4] & (X86_CR4_PSE | X86_CR4_PAE),3604 &pvPC);3605 if (RT_FAILURE(rc))3606 {3607 if (!PATMIsPatchGCAddr(pVM, GCPtrPC))3608 return false;3609 pvPC = (char *)PATMR3QueryPatchMemHC(pVM, NULL)3610 + (GCPtrPC - PATMR3QueryPatchMemGC(pVM, NULL));3611 }3612 }3613 else3614 {3615 3616 /* physical address */3617 int rc = PGMPhysGCPhys2R3Ptr(pVM, (RTGCPHYS)GCPtrPC, 16, &pvPC);3618 if (RT_FAILURE(rc))3619 return false;3620 }3621 3622 /*3623 * Disassemble.3624 */3625 RTINTPTR off = env->eip - (RTGCUINTPTR)pvPC;3626 DISCPUSTATE Cpu;3627 Cpu.mode = f32BitCode ? CPUMODE_32BIT : CPUMODE_16BIT;3628 Cpu.pfnReadBytes = NULL; /** @todo make cs:eip reader for the disassembler. */3629 //Cpu.dwUserData[0] = (uintptr_t)pVM;3630 //Cpu.dwUserData[1] = (uintptr_t)pvPC;3631 //Cpu.dwUserData[2] = GCPtrPC;3632 char szOutput[256];3633 uint32_t cbOp;3634 if (RT_FAILURE(DISInstr(&Cpu, (uintptr_t)pvPC, off, &cbOp, &szOutput[0])))3635 return false;3636 3637 if (!f32BitCode)3638 {3639 if (pszPrefix)3640 Log(("%s: %04X:%s", pszPrefix, env->segs[R_CS].selector, szOutput));3641 else3642 Log(("%04X:%s", env->segs[R_CS].selector, szOutput));3643 }3644 else3645 {3646 if (pszPrefix)3647 Log(("%s: %s", pszPrefix, szOutput));3648 else3649 Log(("%s", szOutput));3650 }3651 return true;3652 3653 #else /* !USE_OLD_DUMP_AND_DISASSEMBLY */3654 3484 PVM pVM = env->pVM; 3655 3485 const bool fLog = LogIsEnabled(); … … 3681 3511 3682 3512 return RT_SUCCESS(rc); 3683 #endif3684 3513 } 3685 3514 -
trunk/src/recompiler_new/VBoxREMWrapper.cpp
r17251 r17426 725 725 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL } 726 726 }; 727 static const REMPARMDESC g_aArgsPGMPhysGCPtr2R3PtrByGstCR3[] =728 {729 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },730 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },731 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t), NULL },732 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL },733 { REMPARMDESC_FLAGS_INT, sizeof(PRTR3PTR), NULL }734 };735 727 static const REMPARMDESC g_aArgsPGM3PhysGrowRange[] = 736 728 { … … 1131 1123 { "PGMInvalidatePage", (void *)(uintptr_t)&PGMInvalidatePage, &g_aArgsPGMInvalidatePage[0], RT_ELEMENTS(g_aArgsPGMInvalidatePage), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1132 1124 { "PGMPhysGCPhys2R3Ptr", (void *)(uintptr_t)&PGMPhysGCPhys2R3Ptr, &g_aArgsPGMPhysGCPhys2R3Ptr[0], RT_ELEMENTS(g_aArgsPGMPhysGCPhys2R3Ptr), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1133 { "PGMPhysGCPtr2R3PtrByGstCR3", (void *)(uintptr_t)&PGMPhysGCPtr2R3PtrByGstCR3, &g_aArgsPGMPhysGCPtr2R3PtrByGstCR3[0], RT_ELEMENTS(g_aArgsPGMPhysGCPtr2R3PtrByGstCR3), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },1134 1125 #ifndef VBOX_WITH_NEW_PHYS_CODE 1135 1126 { "PGM3PhysGrowRange", (void *)(uintptr_t)&PGM3PhysGrowRange, &g_aArgsPGM3PhysGrowRange[0], RT_ELEMENTS(g_aArgsPGM3PhysGrowRange), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, -
trunk/src/recompiler_new/VBoxRecompiler.c
r17366 r17426 3465 3465 3466 3466 /** 3467 * Disassembles n instructions and prints them to the log.3468 *3469 * @returns Success indicator.3470 * @param env Pointer to the recompiler CPU structure.3471 * @param f32BitCode Indicates that whether or not the code should3472 * be disassembled as 16 or 32 bit. If -1 the CS3473 * selector will be inspected.3474 * @param nrInstructions Nr of instructions to disassemble3475 * @param pszPrefix3476 * @remark not currently used for anything but ad-hoc debugging.3477 */3478 bool remR3DisasBlock(CPUState *env, int f32BitCode, int nrInstructions, char *pszPrefix)3479 {3480 int i, rc;3481 RTGCPTR GCPtrPC;3482 uint8_t *pvPC;3483 RTINTPTR off;3484 DISCPUSTATE Cpu;3485 3486 /*3487 * Determin 16/32 bit mode.3488 */3489 if (f32BitCode == -1)3490 f32BitCode = !!(env->segs[R_CS].flags & X86_DESC_DB); /** @todo is this right?!!?!?!?!? */3491 3492 /*3493 * Convert cs:eip to host context address.3494 * We don't care to much about cross page correctness presently.3495 */3496 GCPtrPC = env->segs[R_CS].base + env->eip;3497 if (f32BitCode && (env->cr[0] & (X86_CR0_PE | X86_CR0_PG)) == (X86_CR0_PE | X86_CR0_PG))3498 {3499 Assert(PGMGetGuestMode(env->pVM) < PGMMODE_AMD64);3500 3501 /* convert eip to physical address. */3502 rc = PGMPhysGCPtr2R3PtrByGstCR3(env->pVM,3503 GCPtrPC,3504 env->cr[3],3505 env->cr[4] & (X86_CR4_PSE | X86_CR4_PAE), /** @todo add longmode flag */3506 (void**)&pvPC);3507 if (RT_FAILURE(rc))3508 {3509 if (!PATMIsPatchGCAddr(env->pVM, GCPtrPC))3510 return false;3511 pvPC = (uint8_t *)PATMR3QueryPatchMemHC(env->pVM, NULL)3512 + (GCPtrPC - PATMR3QueryPatchMemGC(env->pVM, NULL));3513 }3514 }3515 else3516 {3517 /* physical address */3518 rc = PGMPhysGCPhys2R3Ptr(env->pVM, (RTGCPHYS)GCPtrPC, nrInstructions * 16,3519 (void**)&pvPC);3520 if (RT_FAILURE(rc))3521 return false;3522 }3523 3524 /*3525 * Disassemble.3526 */3527 off = env->eip - (RTGCUINTPTR)(uintptr_t)pvPC;3528 Cpu.mode = f32BitCode ? CPUMODE_32BIT : CPUMODE_16BIT;3529 Cpu.pfnReadBytes = NULL; /** @todo make cs:eip reader for the disassembler. */3530 //Cpu.dwUserData[0] = (uintptr_t)pVM;3531 //Cpu.dwUserData[1] = (uintptr_t)pvPC;3532 //Cpu.dwUserData[2] = GCPtrPC;3533 3534 for (i=0;i<nrInstructions;i++)3535 {3536 char szOutput[256];3537 uint32_t cbOp;3538 if (RT_FAILURE(DISInstr(&Cpu, (uintptr_t)pvPC, off, &cbOp, &szOutput[0])))3539 return false;3540 if (pszPrefix)3541 Log(("%s: %s", pszPrefix, szOutput));3542 else3543 Log(("%s", szOutput));3544 3545 pvPC += cbOp;3546 }3547 return true;3548 }3549 3550 3551 /** @todo need to test the new code, using the old code in the mean while. */3552 #define USE_OLD_DUMP_AND_DISASSEMBLY3553 3554 /**3555 3467 * Disassembles one instruction and prints it to the log. 3556 3468 * … … 3564 3476 bool remR3DisasInstr(CPUState *env, int f32BitCode, char *pszPrefix) 3565 3477 { 3566 #ifdef USE_OLD_DUMP_AND_DISASSEMBLY3567 PVM pVM = env->pVM;3568 RTGCPTR GCPtrPC;3569 uint8_t *pvPC;3570 char szOutput[256];3571 uint32_t cbOp;3572 RTINTPTR off;3573 DISCPUSTATE Cpu;3574 3575 3576 /* Doesn't work in long mode. */3577 if (env->hflags & HF_LMA_MASK)3578 return false;3579 3580 /*3581 * Determin 16/32 bit mode.3582 */3583 if (f32BitCode == -1)3584 f32BitCode = !!(env->segs[R_CS].flags & X86_DESC_DB); /** @todo is this right?!!?!?!?!? */3585 3586 /*3587 * Log registers3588 */3589 if (LogIs2Enabled())3590 {3591 remR3StateUpdate(pVM);3592 DBGFR3InfoLog(pVM, "cpumguest", pszPrefix);3593 }3594 3595 /*3596 * Convert cs:eip to host context address.3597 * We don't care to much about cross page correctness presently.3598 */3599 GCPtrPC = env->segs[R_CS].base + env->eip;3600 if ((env->cr[0] & (X86_CR0_PE | X86_CR0_PG)) == (X86_CR0_PE | X86_CR0_PG))3601 {3602 /* convert eip to physical address. */3603 int rc = PGMPhysGCPtr2R3PtrByGstCR3(pVM,3604 GCPtrPC,3605 env->cr[3],3606 env->cr[4] & (X86_CR4_PSE | X86_CR4_PAE),3607 (void**)&pvPC);3608 if (RT_FAILURE(rc))3609 {3610 if (!PATMIsPatchGCAddr(pVM, GCPtrPC))3611 return false;3612 pvPC = (uint8_t *)PATMR3QueryPatchMemHC(pVM, NULL)3613 + (GCPtrPC - PATMR3QueryPatchMemGC(pVM, NULL));3614 }3615 }3616 else3617 {3618 3619 /* physical address */3620 int rc = PGMPhysGCPhys2R3Ptr(pVM, (RTGCPHYS)GCPtrPC, 16, (void**)&pvPC);3621 if (RT_FAILURE(rc))3622 return false;3623 }3624 3625 /*3626 * Disassemble.3627 */3628 off = env->eip - (RTGCUINTPTR)(uintptr_t)pvPC;3629 Cpu.mode = f32BitCode ? CPUMODE_32BIT : CPUMODE_16BIT;3630 Cpu.pfnReadBytes = NULL; /** @todo make cs:eip reader for the disassembler. */3631 //Cpu.dwUserData[0] = (uintptr_t)pVM;3632 //Cpu.dwUserData[1] = (uintptr_t)pvPC;3633 //Cpu.dwUserData[2] = GCPtrPC;3634 if (RT_FAILURE(DISInstr(&Cpu, (uintptr_t)pvPC, off, &cbOp, &szOutput[0])))3635 return false;3636 3637 if (!f32BitCode)3638 {3639 if (pszPrefix)3640 Log(("%s: %04X:%s", pszPrefix, env->segs[R_CS].selector, szOutput));3641 else3642 Log(("%04X:%s", env->segs[R_CS].selector, szOutput));3643 }3644 else3645 {3646 if (pszPrefix)3647 Log(("%s: %s", pszPrefix, szOutput));3648 else3649 Log(("%s", szOutput));3650 }3651 return true;3652 3653 #else /* !USE_OLD_DUMP_AND_DISASSEMBLY */3654 3478 PVM pVM = env->pVM; 3655 3479 const bool fLog = LogIsEnabled(); … … 3681 3505 3682 3506 return RT_SUCCESS(rc); 3683 #endif3684 3507 } 3685 3508
Note:
See TracChangeset
for help on using the changeset viewer.