Changeset 44362 in vbox for trunk/src/VBox/VMM/include
- Timestamp:
- Jan 24, 2013 9:11:05 PM (12 years ago)
- Location:
- trunk/src/VBox/VMM/include
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/include/EMHandleRCTmpl.h
r43394 r44362 5 5 6 6 /* 7 * Copyright (C) 2006-20 09Oracle Corporation7 * Copyright (C) 2006-2013 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as -
trunk/src/VBox/VMM/include/PATMInternal.h
r41897 r44362 5 5 6 6 /* 7 * Copyright (C) 2006-201 2Oracle Corporation7 * Copyright (C) 2006-2013 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 30 30 31 31 32 32 /** @name Saved state version numbers. 33 * @{ */ 33 34 #define PATM_SSM_VERSION 55 34 35 #define PATM_SSM_VERSION_FIXUP_HACK 54 35 36 #define PATM_SSM_VERSION_FIXUP_HACK 54 36 37 #define PATM_SSM_VERSION_VER16 53 38 /** @} */ 37 39 38 40 /* Enable for call patching. */ … … 554 556 555 557 #ifdef IN_RING3 556 RTRCPTR patmPatchGCPtr2GuestGCPtr(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t *) pPatchGC); 557 RTRCPTR patmGuestGCPtrToPatchGCPtr(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t*) pInstrGC); 558 RTRCPTR patmGuestGCPtrToClosestPatchGCPtr(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t*) pInstrGC); 559 #endif 560 561 /* Add a patch to guest lookup record 562 * 563 * @param pVM Pointer to the VM. 564 * @param pPatch Patch structure ptr 565 * @param pPatchInstrHC Guest context pointer to patch block 566 * @param pInstrGC Guest context pointer to privileged instruction 567 * @param enmType Lookup type 568 * @param fDirty Dirty flag 569 * 570 */ 571 void patmr3AddP2GLookupRecord(PVM pVM, PPATCHINFO pPatch, uint8_t *pPatchInstrHC, RTRCPTR pInstrGC, PATM_LOOKUP_TYPE enmType, bool fDirty=false); 572 573 /** 574 * Insert page records for all guest pages that contain instructions that were recompiled for this patch 575 * 576 * @returns VBox status code. 577 * @param pVM Pointer to the VM. 578 * @param pPatch Patch record 579 */ 580 int patmInsertPatchPages(PVM pVM, PPATCHINFO pPatch); 581 582 /** 583 * Remove page records for all guest pages that contain instructions that were recompiled for this patch 584 * 585 * @returns VBox status code. 586 * @param pVM Pointer to the VM. 587 * @param pPatch Patch record 588 */ 589 int patmRemovePatchPages(PVM pVM, PPATCHINFO pPatch); 590 591 /** 592 * Returns the GC address of the corresponding patch statistics counter 593 * 594 * @returns Stat address 595 * @param pVM Pointer to the VM. 596 * @param pPatch Patch structure 597 */ 598 RTRCPTR patmPatchQueryStatAddress(PVM pVM, PPATCHINFO pPatch); 599 600 /** 601 * Remove patch for privileged instruction at specified location 602 * 603 * @returns VBox status code. 604 * @param pVM Pointer to the VM. 605 * @param pPatchRec Patch record 606 * @param fForceRemove Remove *all* patches 607 */ 608 int PATMRemovePatch(PVM pVM, PPATMPATCHREC pPatchRec, bool fForceRemove); 558 RTRCPTR patmPatchGCPtr2GuestGCPtr(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t *) pPatchGC); 559 RTRCPTR patmGuestGCPtrToPatchGCPtr(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t*) pInstrGC); 560 RTRCPTR patmGuestGCPtrToClosestPatchGCPtr(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t*) pInstrGC); 561 #endif 562 563 void patmR3AddP2GLookupRecord(PVM pVM, PPATCHINFO pPatch, uint8_t *pPatchInstrHC, RTRCPTR pInstrGC, 564 PATM_LOOKUP_TYPE enmType, bool fDirty = false); 565 int patmInsertPatchPages(PVM pVM, PPATCHINFO pPatch); 566 RTRCPTR patmPatchQueryStatAddress(PVM pVM, PPATCHINFO pPatch); 567 int patmR3RemovePatch(PVM pVM, PPATMPATCHREC pPatchRec, bool fForceRemove); 609 568 610 569 /** … … 621 580 typedef int (VBOXCALL *PFN_PATMR3ANALYSE)(PVM pVM, DISCPUSTATE *pCpu, RCPTRTYPE(uint8_t *) pInstrGC, RCPTRTYPE(uint8_t *) pCurInstrGC, PPATMP2GLOOKUPREC pCacheRec); 622 581 623 /** 624 * Install guest OS specific patch 625 * 626 * @returns VBox status code. 627 * @param pVM Pointer to the VM. 628 * @param pCpu Disassembly state of instruction. 629 * @param pInstrGC GC Instruction pointer for instruction 630 * @param pInstrHC GC Instruction pointer for instruction 631 * @param pPatchRec Patch structure 632 * 633 */ 634 int PATMInstallGuestSpecificPatch(PVM pVM, PDISCPUSTATE pCpu, RTRCPTR pInstrGC, uint8_t *pInstrHC, PPATMPATCHREC pPatchRec); 635 636 637 /** 638 * Check if the instruction is patched as a duplicated function 639 * 640 * @returns patch record 641 * @param pVM Pointer to the VM. 642 * @param pInstrGC Guest context point to the instruction 643 * 644 */ 645 VMMDECL(PPATMPATCHREC) PATMQueryFunctionPatch(PVM pVM, RTRCPTR pInstrGC); 646 647 648 /** 649 * Empty the specified tree (PV tree, MMR3 heap) 650 * 651 * @param pVM Pointer to the VM. 652 * @param ppTree Tree to empty 653 */ 654 void patmEmptyTree(PVM pVM, PPAVLPVNODECORE ppTree); 655 656 657 /** 658 * Empty the specified tree (U32 tree, MMR3 heap) 659 * 660 * @param pVM Pointer to the VM. 661 * @param ppTree Tree to empty 662 */ 663 void patmEmptyTreeU32(PVM pVM, PPAVLU32NODECORE ppTree); 664 665 666 /** 667 * Return the name of the patched instruction 668 * 669 * @returns instruction name 670 * 671 * @param opcode DIS instruction opcode 672 * @param fPatchFlags Patch flags 673 */ 674 VMMDECL(const char *) patmGetInstructionString(uint32_t opcode, uint32_t fPatchFlags); 675 676 582 int patmR3InstallGuestSpecificPatch(PVM pVM, PDISCPUSTATE pCpu, RTRCPTR pInstrGC, uint8_t *pInstrHC, PPATMPATCHREC pPatchRec); 583 PPATMPATCHREC patmQueryFunctionPatch(PVM pVM, RTRCPTR pInstrGC); 584 const char *patmGetInstructionString(uint32_t opcode, uint32_t fPatchFlags); 585 586 PPATCHINFO patmFindActivePatchByEntrypoint(PVM pVM, RTRCPTR pInstrGC, bool fIncludeHints = false); 587 int patmR3PatchInstrInt3(PVM pVM, RTRCPTR pInstrGC, R3PTRTYPE(uint8_t *) pInstrHC, DISCPUSTATE *pCpu, PPATCHINFO pPatch); 588 int patmAddBranchToLookupCache(PVM pVM, RTRCPTR pJumpTableGC, RTRCPTR pBranchTarget, RTRCUINTPTR pRelBranchPatch); 589 R3PTRTYPE(uint8_t *) patmR3GCVirtToHCVirt(PVM pVM, PPATMP2GLOOKUPREC pCacheRec, RCPTRTYPE(uint8_t *) pGCPtr); 677 590 678 591 RT_C_DECLS_BEGIN … … 691 604 VMMRCDECL(int) PATMGCMonitorPage(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPTR pvRange, uintptr_t offRange); 692 605 693 /** 694 * Find patch for privileged instruction at specified location 695 * 696 * @returns Patch structure pointer if found; else NULL 697 * @param pVM Pointer to the VM. 698 * @param pInstr Guest context point to instruction that might lie within 5 bytes of an existing patch jump 699 * @param fIncludeHints Include hinted patches or not 700 * 701 */ 702 PPATCHINFO PATMFindActivePatchByEntrypoint(PVM pVM, RTRCPTR pInstrGC, bool fIncludeHints=false); 703 704 /** 705 * Patch cli/sti pushf/popf instruction block at specified location 706 * 707 * @returns VBox status code. 708 * @param pVM Pointer to the VM. 709 * @param pInstrGC Guest context point to privileged instruction 710 * @param pInstrHC Host context point to privileged instruction 711 * @param uOpcode Instruction opcodee 712 * @param uOpSize Size of starting instruction 713 * @param pPatchRec Patch record 714 * 715 * @note returns failure if patching is not allowed or possible 716 * 717 */ 718 VMMR3DECL(int) PATMR3PatchBlock(PVM pVM, RTRCPTR pInstrGC, R3PTRTYPE(uint8_t *) pInstrHC, 719 uint32_t uOpcode, uint32_t uOpSize, PPATMPATCHREC pPatchRec); 720 721 722 /** 723 * Replace an instruction with a breakpoint (0xCC), that is handled dynamically in the guest context. 724 * 725 * @returns VBox status code. 726 * @param pVM Pointer to the VM. 727 * @param pInstrGC Guest context point to privileged instruction 728 * @param pInstrHC Host context point to privileged instruction 729 * @param pCpu Disassembly CPU structure ptr 730 * @param pPatch Patch record 731 * 732 * @note returns failure if patching is not allowed or possible 733 * 734 */ 735 VMMR3DECL(int) PATMR3PatchInstrInt3(PVM pVM, RTRCPTR pInstrGC, R3PTRTYPE(uint8_t *) pInstrHC, DISCPUSTATE *pCpu, PPATCHINFO pPatch); 736 737 /** 738 * Mark patch as dirty 739 * 740 * @returns VBox status code. 741 * @param pVM Pointer to the VM. 742 * @param pPatch Patch record 743 * 744 * @note returns failure if patching is not allowed or possible 745 * 746 */ 747 VMMR3DECL(int) PATMR3MarkDirtyPatch(PVM pVM, PPATCHINFO pPatch); 748 749 R3PTRTYPE(uint8_t *) PATMGCVirtToHCVirt(PVM pVM, PPATMP2GLOOKUPREC pCacheRec, RCPTRTYPE(uint8_t *) pGCPtr); 606 RT_C_DECLS_END 750 607 751 608 /** … … 756 613 * @param pBranchInstrGC GC pointer of branch instruction 757 614 */ 758 inline RTRCPTRPATMResolveBranch(PDISCPUSTATE pCpu, RTRCPTR pBranchInstrGC)615 DECLINLINE(RTRCPTR) PATMResolveBranch(PDISCPUSTATE pCpu, RTRCPTR pBranchInstrGC) 759 616 { 760 617 uint32_t disp; … … 785 642 } 786 643 787 RT_C_DECLS_END788 789 644 #ifdef LOG_ENABLED 790 645 int patmr3DisasmCallback(PVM pVM, DISCPUSTATE *pCpu, RCPTRTYPE(uint8_t *) pInstrGC, RCPTRTYPE(uint8_t *) pCurInstrGC, PPATMP2GLOOKUPREC pCacheRec);
Note:
See TracChangeset
for help on using the changeset viewer.