Changeset 25935 in vbox for trunk/src/VBox/VMM/PGMSavedState.cpp
- Timestamp:
- Jan 20, 2010 2:43:56 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/PGMSavedState.cpp
r25231 r25935 47 47 * Defined Constants And Macros * 48 48 *******************************************************************************/ 49 /** Saved state data unit version. */ 49 /** Saved state data unit version. 50 * @todo remove the guest mappings from the saved state at next version change! */ 50 51 #define PGM_SAVED_STATE_VERSION 11 51 52 /** Saved state data unit version used during 3.1 development, misses the RAM … … 1939 1940 * Save basic data (required / unaffected by relocation). 1940 1941 */ 1942 bool const fMappingsFixed = pVM->pgm.s.fMappingsFixed; 1943 pVM->pgm.s.fMappingsFixed |= pVM->pgm.s.fMappingsFixedRestored; 1941 1944 SSMR3PutStruct(pSSM, pPGM, &s_aPGMFields[0]); 1945 pVM->pgm.s.fMappingsFixed = fMappingsFixed; 1942 1946 1943 1947 for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++) 1944 { 1945 PVMCPU pVCpu = &pVM->aCpus[idCpu]; 1946 SSMR3PutStruct(pSSM, &pVCpu->pgm.s, &s_aPGMCpuFields[0]); 1947 } 1948 SSMR3PutStruct(pSSM, &pVM->aCpus[idCpu].pgm.s, &s_aPGMCpuFields[0]); 1948 1949 1949 1950 /* … … 2786 2787 2787 2788 uint32_t cbRamSizeIgnored; 2788 rc = SSMR3GetU32(pSSM, &cbRamSizeIgnored);2789 rc = SSMR3GetU32(pSSM, &cbRamSizeIgnored); 2789 2790 if (RT_FAILURE(rc)) 2790 2791 return rc; … … 2811 2812 2812 2813 /* 2813 * The guest mappings .2814 * The guest mappings - skipped now, see re-fixation in the caller. 2814 2815 */ 2815 2816 uint32_t i = 0; 2816 2817 for (;; i++) 2817 2818 { 2818 /* Check the seqence number / separator. */ 2819 rc = SSMR3GetU32(pSSM, &u32Sep); 2819 rc = SSMR3GetU32(pSSM, &u32Sep); /* seqence number */ 2820 2820 if (RT_FAILURE(rc)) 2821 2821 return rc; 2822 2822 if (u32Sep == ~0U) 2823 2823 break; 2824 if (u32Sep != i) 2825 { 2826 AssertMsgFailed(("u32Sep=%#x (last)\n", u32Sep)); 2827 return VERR_SSM_DATA_UNIT_FORMAT_CHANGED; 2828 } 2829 2830 /* get the mapping details. */ 2824 AssertMsgReturn(u32Sep == i, ("u32Sep=%#x i=%#x\n", u32Sep, i), VERR_SSM_DATA_UNIT_FORMAT_CHANGED); 2825 2831 2826 char szDesc[256]; 2832 szDesc[0] = '\0';2833 2827 rc = SSMR3GetStrZ(pSSM, szDesc, sizeof(szDesc)); 2834 2828 if (RT_FAILURE(rc)) 2835 2829 return rc; 2836 RTGCPTR GCPtr; 2837 SSMR3GetGCPtr(pSSM, &GCPtr); 2838 RTGCPTR cPTs; 2839 rc = SSMR3GetGCUIntPtr(pSSM, &cPTs); 2830 RTGCPTR GCPtrIgnore; 2831 SSMR3GetGCPtr(pSSM, &GCPtrIgnore); /* GCPtr */ 2832 rc = SSMR3GetGCPtr(pSSM, &GCPtrIgnore); /* cPTs */ 2840 2833 if (RT_FAILURE(rc)) 2841 2834 return rc; 2842 2843 /* find matching range. */2844 PPGMMAPPING pMapping;2845 for (pMapping = pPGM->pMappingsR3; pMapping; pMapping = pMapping->pNextR3)2846 {2847 if ( pMapping->cPTs == cPTs2848 && !strcmp(pMapping->pszDesc, szDesc))2849 break;2850 #ifdef DEBUG_sandervl2851 if ( !strcmp(szDesc, "Hypervisor Memory Area")2852 && HWACCMIsEnabled(pVM))2853 break;2854 #endif2855 }2856 if (!pMapping)2857 return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Couldn't find mapping: cPTs=%#x szDesc=%s (GCPtr=%RGv)"),2858 cPTs, szDesc, GCPtr);2859 2860 /* relocate it. */2861 if ( pMapping->GCPtr != GCPtr2862 #ifdef DEBUG_sandervl2863 && !(!strcmp(szDesc, "Hypervisor Memory Area") && HWACCMIsEnabled(pVM))2864 #endif2865 )2866 {2867 AssertMsg((GCPtr >> X86_PD_SHIFT << X86_PD_SHIFT) == GCPtr, ("GCPtr=%RGv\n", GCPtr));2868 pgmR3MapRelocate(pVM, pMapping, pMapping->GCPtr, GCPtr);2869 }2870 else2871 Log(("pgmR3Load: '%s' needed no relocation (%RGv)\n", szDesc, GCPtr));2872 2835 } 2873 2836 … … 2893 2856 } 2894 2857 2895 return pgmR3LoadMemory(pVM, pSSM, SSM_PASS_FINAL); 2896 } 2897 return pgmR3LoadMemoryOld(pVM, pSSM, uVersion); 2858 rc = pgmR3LoadMemory(pVM, pSSM, SSM_PASS_FINAL); 2859 } 2860 else 2861 rc = pgmR3LoadMemoryOld(pVM, pSSM, uVersion); 2862 return rc; 2898 2863 } 2899 2864 … … 2972 2937 VMCPU_FF_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3_NON_GLOBAL); 2973 2938 VMCPU_FF_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3); 2974 2975 2939 pVCpu->pgm.s.fSyncFlags |= PGM_SYNC_UPDATE_PAGE_BIT_VIRTUAL; 2976 2940 } … … 2978 2942 pgmR3HandlerPhysicalUpdateAll(pVM); 2979 2943 2944 /* 2945 * Change the paging mode and restore PGMCPU::GCPhysCR3. 2946 * (The latter requires the CPUM state to be restored already.) 2947 */ 2948 if (CPUMR3IsStateRestorePending(pVM)) 2949 return SSMR3SetLoadError(pSSM, VERR_WRONG_ORDER, RT_SRC_POS, 2950 N_("PGM was unexpectedly restored before CPUM")); 2951 2980 2952 for (VMCPUID i = 0; i < pVM->cCpus; i++) 2981 2953 { 2982 2954 PVMCPU pVCpu = &pVM->aCpus[i]; 2983 2955 2984 /*2985 * Change the paging mode.2986 */2987 2956 rc = PGMR3ChangeMode(pVM, pVCpu, pVCpu->pgm.s.enmGuestMode); 2957 AssertLogRelRCReturn(rc, rc); 2988 2958 2989 2959 /* Restore pVM->pgm.s.GCPhysCR3. */ … … 2999 2969 pVCpu->pgm.s.GCPhysCR3 = GCPhysCR3; 3000 2970 } 2971 2972 /* 2973 * Try re-fixate the guest mappings. 2974 */ 2975 pVM->pgm.s.fMappingsFixedRestored = false; 2976 if ( pVM->pgm.s.fMappingsFixed 2977 && pgmMapAreMappingsEnabled(&pVM->pgm.s)) 2978 { 2979 RTGCPTR GCPtrFixed = pVM->pgm.s.GCPtrMappingFixed; 2980 uint32_t cbFixed = pVM->pgm.s.cbMappingFixed; 2981 pVM->pgm.s.fMappingsFixed = false; 2982 2983 uint32_t cbRequired; 2984 int rc2 = PGMR3MappingsSize(pVM, &cbRequired); AssertRC(rc2); 2985 if ( RT_SUCCESS(rc2) 2986 && cbRequired > cbFixed) 2987 rc2 = VERR_OUT_OF_RANGE; 2988 if (RT_SUCCESS(rc2)) 2989 rc2 = pgmR3MappingsFixInternal(pVM, GCPtrFixed, cbFixed); 2990 if (RT_FAILURE(rc2)) 2991 { 2992 LogRel(("PGM: Unable to re-fixate the guest mappings at %RGv-%RGv: rc=%Rrc (cbRequired=%#x)\n", 2993 GCPtrFixed, GCPtrFixed + cbFixed, rc2, cbRequired)); 2994 pVM->pgm.s.fMappingsFixed = false; 2995 pVM->pgm.s.fMappingsFixedRestored = true; 2996 pVM->pgm.s.GCPtrMappingFixed = GCPtrFixed; 2997 pVM->pgm.s.cbMappingFixed = cbFixed; 2998 } 2999 } 3000 else 3001 { 3002 /* We used to set fixed + disabled while we only use disabled now, 3003 so wipe the state to avoid any confusion. */ 3004 pVM->pgm.s.fMappingsFixed = false; 3005 pVM->pgm.s.GCPtrMappingFixed = NIL_RTGCPTR; 3006 pVM->pgm.s.cbMappingFixed = 0; 3007 } 3008 3009 /* 3010 * If we have floating mappings, do a CR3 sync now to make sure the HMA 3011 * doesn't conflict with guest code / data and thereby cause trouble 3012 * when restoring other components like PATM. 3013 */ 3014 if (pgmMapAreMappingsFloating(&pVM->pgm.s)) 3015 { 3016 PVMCPU pVCpu = &pVM->aCpus[0]; 3017 rc = PGMSyncCR3(pVCpu, CPUMGetGuestCR0(pVCpu), CPUMGetGuestCR3(pVCpu), CPUMGetGuestCR4(pVCpu), true); 3018 if (RT_FAILURE(rc)) 3019 return SSMR3SetLoadError(pSSM, VERR_WRONG_ORDER, RT_SRC_POS, 3020 N_("PGMSyncCR3 failed unexpectedly with rc=%Rrc"), rc); 3021 3022 /* Make sure to re-sync before executing code. */ 3023 VMCPU_FF_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3_NON_GLOBAL); 3024 VMCPU_FF_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3); 3025 pVCpu->pgm.s.fSyncFlags |= PGM_SYNC_UPDATE_PAGE_BIT_VIRTUAL; 3026 } 3001 3027 } 3002 3028 }
Note:
See TracChangeset
for help on using the changeset viewer.