Changeset 13533 in vbox
- Timestamp:
- Oct 23, 2008 1:00:28 PM (16 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/HWACCMInternal.h
r13347 r13533 143 143 typedef struct 144 144 { 145 RTCPUID idCpu;146 147 RTR0MEMOBJ pMemObj;145 RTCPUID idCpu; 146 147 RTR0MEMOBJ pMemObj; 148 148 /* Current ASID (AMD-V)/VPID (Intel) */ 149 uint32_t uCurrentASID;149 uint32_t uCurrentASID; 150 150 /* TLB flush count */ 151 uint32_t cTLBFlushes;151 uint32_t cTLBFlushes; 152 152 153 153 /* Set the first time a cpu is used to make sure we start with a clean TLB. */ 154 bool fFlushTLB; 155 156 bool fConfigured; 154 bool fFlushTLB; 155 156 /** Configured for VT-x or AMD-V. */ 157 bool fConfigured; 158 159 /** In use by our code. (for power suspend) */ 160 volatile bool fInUse; 157 161 } HWACCM_CPUINFO; 158 162 typedef HWACCM_CPUINFO *PHWACCM_CPUINFO; -
trunk/src/VBox/VMM/VMMR0/HWACCMR0.cpp
r13532 r13533 603 603 Assert(idCpu < RT_ELEMENTS(HWACCMR0Globals.aCpuInfo)); 604 604 Assert(!pCpu->fConfigured); 605 Assert(ASMAtomicReadBool(&pCpu->fInUse) == false); 605 606 606 607 pCpu->idCpu = idCpu; … … 648 649 Assert(idCpu == (RTCPUID)RTMpCpuIdToSetIndex(idCpu)); /// @todo fix idCpu == index assumption (rainy day) 649 650 Assert(idCpu < RT_ELEMENTS(HWACCMR0Globals.aCpuInfo)); 651 Assert(ASMAtomicReadBool(&pCpu->fInUse) == false); 650 652 651 653 if (!pCpu->pMemObj) … … 735 737 VMMR0DECL(int) HWACCMR0InitVM(PVM pVM) 736 738 { 739 int rc; 740 RTCPUID idCpu = RTMpCpuId(); 741 PHWACCM_CPUINFO pCpu = &HWACCMR0Globals.aCpuInfo[idCpu]; 742 737 743 AssertReturn(pVM, VERR_INVALID_PARAMETER); 738 744 … … 780 786 pVM->hwaccm.s.uCurrentASID = 0; 781 787 788 ASMAtomicWriteBool(&pCpu->fInUse, true); 789 782 790 /* Init a VT-x or AMD-V VM. */ 783 return HWACCMR0Globals.pfnInitVM(pVM); 791 rc = HWACCMR0Globals.pfnInitVM(pVM); 792 793 ASMAtomicWriteBool(&pCpu->fInUse, false); 794 795 return rc; 784 796 } 785 797 … … 793 805 VMMR0DECL(int) HWACCMR0TermVM(PVM pVM) 794 806 { 807 int rc; 808 RTCPUID idCpu = RTMpCpuId(); 809 PHWACCM_CPUINFO pCpu = &HWACCMR0Globals.aCpuInfo[idCpu]; 810 795 811 AssertReturn(pVM, VERR_INVALID_PARAMETER); 796 812 … … 802 818 AssertReturn(!ASMAtomicReadBool(&HWACCMR0Globals.fSuspended), VERR_HWACCM_SUSPEND_PENDING); 803 819 820 ASMAtomicWriteBool(&pCpu->fInUse, true); 821 804 822 /* Terminate a VT-x or AMD-V VM. */ 805 return HWACCMR0Globals.pfnTermVM(pVM); 823 rc = HWACCMR0Globals.pfnTermVM(pVM); 824 825 ASMAtomicWriteBool(&pCpu->fInUse, false); 826 return rc; 806 827 } 807 828 … … 815 836 VMMR0DECL(int) HWACCMR0SetupVM(PVM pVM) 816 837 { 838 int rc; 839 RTCPUID idCpu = RTMpCpuId(); 840 PHWACCM_CPUINFO pCpu = &HWACCMR0Globals.aCpuInfo[idCpu]; 841 817 842 AssertReturn(pVM, VERR_INVALID_PARAMETER); 818 843 … … 824 849 #endif 825 850 851 ASMAtomicWriteBool(&pCpu->fInUse, true); 852 826 853 /* Setup VT-x or AMD-V. */ 827 return HWACCMR0Globals.pfnSetupVM(pVM); 854 rc = HWACCMR0Globals.pfnSetupVM(pVM); 855 856 ASMAtomicWriteBool(&pCpu->fInUse, false); 857 858 return rc; 828 859 } 829 860 … … 837 868 VMMR0DECL(int) HWACCMR0Enter(PVM pVM) 838 869 { 839 CPUMCTX *pCtx; 840 int rc; 841 RTCPUID idCpu = RTMpCpuId(); 870 PCPUMCTX pCtx; 871 int rc; 872 RTCPUID idCpu = RTMpCpuId(); 873 PHWACCM_CPUINFO pCpu = &HWACCMR0Globals.aCpuInfo[idCpu]; 842 874 843 875 /* Make sure we can't enter a session after we've disabled hwaccm in preparation of a suspend. */ 844 876 AssertReturn(!ASMAtomicReadBool(&HWACCMR0Globals.fSuspended), VERR_HWACCM_SUSPEND_PENDING); 877 ASMAtomicWriteBool(&pCpu->fInUse, true); 845 878 846 879 pCtx = CPUMQueryGuestCtxPtr(pVM); … … 861 894 pVM->hwaccm.s.u64RegisterMask = UINT64_C(0xFFFFFFFF); 862 895 863 rc = HWACCMR0Globals.pfnEnterSession(pVM, &HWACCMR0Globals.aCpuInfo[idCpu]);896 rc = HWACCMR0Globals.pfnEnterSession(pVM, pCpu); 864 897 AssertRC(rc); 865 898 /* We must save the host context here (VT-x) as we might be rescheduled on a different cpu after a long jump back to ring 3. */ … … 889 922 VMMR0DECL(int) HWACCMR0Leave(PVM pVM) 890 923 { 891 CPUMCTX *pCtx; 892 int rc; 924 PCPUMCTX pCtx; 925 int rc; 926 RTCPUID idCpu = RTMpCpuId(); 927 PHWACCM_CPUINFO pCpu = &HWACCMR0Globals.aCpuInfo[idCpu]; 893 928 894 929 AssertReturn(!ASMAtomicReadBool(&HWACCMR0Globals.fSuspended), VERR_HWACCM_SUSPEND_PENDING); … … 913 948 #ifdef VBOX_STRICT 914 949 /* keep track of the CPU owning the VMCS for debugging scheduling weirdness and ring-3 calls. */ 915 RTCPUID idCpu = RTMpCpuId();916 950 AssertMsg(pVM->hwaccm.s.idEnteredCpu == idCpu, ("owner is %d, I'm %d", (int)pVM->hwaccm.s.idEnteredCpu, (int)idCpu)); 917 951 pVM->hwaccm.s.idEnteredCpu = NIL_RTCPUID; 918 952 #endif 919 953 954 ASMAtomicWriteBool(&pCpu->fInUse, false); 920 955 return rc; 921 956 } … … 932 967 int rc; 933 968 RTCPUID idCpu = RTMpCpuId(); NOREF(idCpu); 969 #ifdef VBOX_STRICT 970 PHWACCM_CPUINFO pCpu = &HWACCMR0Globals.aCpuInfo[idCpu]; 971 #endif 934 972 935 973 Assert(!VM_FF_ISPENDING(pVM, VM_FF_PGM_SYNC_CR3 | VM_FF_PGM_SYNC_CR3_NON_GLOBAL)); 936 974 Assert(HWACCMR0Globals.aCpuInfo[idCpu].fConfigured); 937 975 AssertReturn(!ASMAtomicReadBool(&HWACCMR0Globals.fSuspended), VERR_HWACCM_SUSPEND_PENDING); 976 Assert(ASMAtomicReadBool(&pCpu->fInUse) == true); 938 977 939 978 pCtx = CPUMQueryGuestCtxPtr(pVM);
Note:
See TracChangeset
for help on using the changeset viewer.