Changeset 4680 in vbox for trunk/src/VBox
- Timestamp:
- Sep 10, 2007 4:07:34 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/TRPMAll.cpp
r4071 r4680 476 476 RTGCPTR pHandler, dummy; 477 477 GCPTRTYPE(uint32_t *) pTrapStackGC; 478 #ifndef IN_GC479 HCPTRTYPE(uint32_t *) pTrapStackHC;480 #endif481 478 482 479 pHandler = (RTGCPTR)((GuestIdte.Gen.u16OffsetHigh << 16) | GuestIdte.Gen.u16OffsetLow); … … 583 580 * Build trap stack frame on guest handler's stack 584 581 */ 582 uint32_t *pTrapStack; 585 583 #ifdef IN_GC 586 584 Assert(eflags.Bits.u1VM || (pRegFrame->ss & X86_SEL_RPL) != 0); 587 585 /* Check maximum amount we need (10 when executing in V86 mode) */ 588 586 rc = PGMVerifyAccess(pVM, (RTGCUINTPTR)pTrapStackGC - 10*sizeof(uint32_t), 10 * sizeof(uint32_t), X86_PTE_RW); 587 pTrapStack = pTrapStackGC; 589 588 #else 590 589 Assert(eflags.Bits.u1VM || (pRegFrame->ss & X86_SEL_RPL) == 0 || (pRegFrame->ss & X86_SEL_RPL) == 3); 591 590 /* Check maximum amount we need (10 when executing in V86 mode) */ 592 if ( PAGE_ADDRESS(pTrapStackGC) != PAGE_ADDRESS(pTrapStackGC - 10*sizeof(uint32_t)) /* fail if we cross a page boundary */ 593 || VBOX_FAILURE((rc = PGMPhysGCPtr2HCPtr(pVM, pTrapStackGC, (PRTHCPTR)&pTrapStackHC))) 594 ) 591 if ((pTrapStackGC >> PAGE_SHIFT) != ((pTrapStackGC - 10*sizeof(uint32_t)) >> PAGE_SHIFT)) /* fail if we cross a page boundary */ 592 goto failure; 593 594 RTGCPHYS GCPhysStack; 595 rc = PGMPhysGCPtr2GCPhys(pVM, pTrapStackGC, &GCPhysStack); 596 if (VBOX_SUCCESS(rc)) 597 rc = PGMPhysGCPhys2CCPtr(pVM, GCPhysStack, (void **)&pTrapStack); 598 if (VBOX_FAILURE(rc)) 595 599 { 596 600 AssertRC(rc); … … 604 608 { 605 609 Log(("TRAP%02X: (VM) Handler %04X:%08X Stack %04X:%08X RPL=%d CR2=%08X\n", iGate, GuestIdte.Gen.u16SegSel, pHandler, ss_r0, esp_r0, (pRegFrame->ss & X86_SEL_RPL), pVM->trpm.s.uActiveCR2)); 606 CTXSUFF(pTrapStack)[--idx] = pRegFrame->gs;607 CTXSUFF(pTrapStack)[--idx] = pRegFrame->fs;608 CTXSUFF(pTrapStack)[--idx] = pRegFrame->ds;609 CTXSUFF(pTrapStack)[--idx] = pRegFrame->es;610 pTrapStack[--idx] = pRegFrame->gs; 611 pTrapStack[--idx] = pRegFrame->fs; 612 pTrapStack[--idx] = pRegFrame->ds; 613 pTrapStack[--idx] = pRegFrame->es; 610 614 611 615 /* clear ds, es, fs & gs in current context */ … … 618 622 { 619 623 if ((pRegFrame->ss & X86_SEL_RPL) == 1 && !eflags.Bits.u1VM) 620 CTXSUFF(pTrapStack)[--idx] = pRegFrame->ss & ~1; /* Mask away traces of raw ring execution (ring 1). */624 pTrapStack[--idx] = pRegFrame->ss & ~1; /* Mask away traces of raw ring execution (ring 1). */ 621 625 else 622 CTXSUFF(pTrapStack)[--idx] = pRegFrame->ss;623 624 CTXSUFF(pTrapStack)[--idx] = pRegFrame->esp;626 pTrapStack[--idx] = pRegFrame->ss; 627 628 pTrapStack[--idx] = pRegFrame->esp; 625 629 } 626 630 627 631 /* Note: We use the eflags copy, that includes the virtualized bits! */ 628 632 /* Note: Not really necessary as we grab include those bits in the trap/irq handler trampoline */ 629 CTXSUFF(pTrapStack)[--idx] = eflags.u32;633 pTrapStack[--idx] = eflags.u32; 630 634 631 635 if ((pRegFrame->cs & X86_SEL_RPL) == 1 && !eflags.Bits.u1VM) 632 CTXSUFF(pTrapStack)[--idx] = pRegFrame->cs & ~1; /* Mask away traces of raw ring execution (ring 1). */636 pTrapStack[--idx] = pRegFrame->cs & ~1; /* Mask away traces of raw ring execution (ring 1). */ 633 637 else 634 CTXSUFF(pTrapStack)[--idx] = pRegFrame->cs;638 pTrapStack[--idx] = pRegFrame->cs; 635 639 636 640 if (enmType == TRPM_SOFTWARE_INT) 637 641 { 638 642 Assert(opsize); 639 CTXSUFF(pTrapStack)[--idx] = pRegFrame->eip + opsize; /* return address = next instruction */643 pTrapStack[--idx] = pRegFrame->eip + opsize; /* return address = next instruction */ 640 644 } 641 645 else 642 CTXSUFF(pTrapStack)[--idx] = pRegFrame->eip;646 pTrapStack[--idx] = pRegFrame->eip; 643 647 644 648 if (enmError == TRPM_TRAP_HAS_ERRORCODE) 645 649 { 646 CTXSUFF(pTrapStack)[--idx] = pVM->trpm.s.uActiveErrorCode;650 pTrapStack[--idx] = pVM->trpm.s.uActiveErrorCode; 647 651 } 648 652 … … 656 660 for (int j=idx;j<0;j++) 657 661 { 658 LogFlow(("Stack %VGv pos %02d: %08x\n", & CTXSUFF(pTrapStack)[j], j, CTXSUFF(pTrapStack)[j]));662 LogFlow(("Stack %VGv pos %02d: %08x\n", &pTrapStack[j], j, pTrapStack[j])); 659 663 } 660 664 const char *pszPrefix = ""; … … 706 710 pRegFrame->ss = ss_r0 & ~X86_SEL_RPL; /* set rpl to ring 0 */ 707 711 STAM_PROFILE_ADV_STOP(CTXSUFF(&pVM->trpm.s.StatForwardProf), a); 712 PGMPhysGCPhys2CCPtrRelease(pVM, GCPhysStack, pTrapStack); 708 713 return VINF_SUCCESS; 709 714 #endif
Note:
See TracChangeset
for help on using the changeset viewer.