- Timestamp:
- Dec 15, 2008 1:26:31 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/err.h
r15366 r15503 449 449 */ 450 450 /** The specified data unit already exist. */ 451 #define VERR_SSM_UNIT_EXISTS (-1800)451 #define VERR_SSM_UNIT_EXISTS (-1800) 452 452 /** The specified data unit wasn't found. */ 453 #define VERR_SSM_UNIT_NOT_FOUND (-1801)453 #define VERR_SSM_UNIT_NOT_FOUND (-1801) 454 454 /** The specified data unit wasn't owned by caller. */ 455 #define VERR_SSM_UNIT_NOT_OWNER (-1802)455 #define VERR_SSM_UNIT_NOT_OWNER (-1802) 456 456 /** General saved state file integrity error. */ 457 #define VERR_SSM_INTEGRITY (-1810)457 #define VERR_SSM_INTEGRITY (-1810) 458 458 /** The saved state file magic was not recognized. */ 459 #define VERR_SSM_INTEGRITY_MAGIC (-1811)459 #define VERR_SSM_INTEGRITY_MAGIC (-1811) 460 460 /** The saved state file version is not supported. */ 461 #define VERR_SSM_INTEGRITY_VERSION (-1812)461 #define VERR_SSM_INTEGRITY_VERSION (-1812) 462 462 /** The saved state file size didn't match the one in the header. */ 463 #define VERR_SSM_INTEGRITY_SIZE (-1813)463 #define VERR_SSM_INTEGRITY_SIZE (-1813) 464 464 /** The CRC of the saved state file did match. */ 465 #define VERR_SSM_INTEGRITY_CRC (-1814)465 #define VERR_SSM_INTEGRITY_CRC (-1814) 466 466 /** The current virtual machine id didn't match the virtual machine id. */ 467 #define VERR_SMM_INTEGRITY_MACHINE (-1815)467 #define VERR_SMM_INTEGRITY_MACHINE (-1815) 468 468 /** Invalid unit magic (internal data tag). */ 469 #define VERR_SSM_INTEGRITY_UNIT_MAGIC (-1816)469 #define VERR_SSM_INTEGRITY_UNIT_MAGIC (-1816) 470 470 /** The file contained a data unit which no-one wants. */ 471 #define VERR_SSM_INTEGRITY_UNIT_NOT_FOUND (-1817) 471 #define VERR_SSM_INTEGRITY_UNIT_NOT_FOUND (-1817) 472 /** Incorrect type sizes in the header. */ 473 #define VERR_SSM_INTEGRITY_SIZES (-1818) 474 /** Incorrect version numbers in the header. */ 475 #define VERR_SSM_INTEGRITY_VBOX_VERSION (-1819) 472 476 /** A data unit in the saved state file was defined but didn't any 473 477 * routine for processing it. */ 474 #define VERR_SSM_NO_LOAD_EXEC (-1818)478 #define VERR_SSM_NO_LOAD_EXEC (-1820) 475 479 /** A restore routine attempted to load more data then the unit contained. */ 476 #define VERR_SSM_LOADED_TOO_MUCH (-1819)480 #define VERR_SSM_LOADED_TOO_MUCH (-1821) 477 481 /** Not in the correct state for the attempted operation. */ 478 #define VERR_SSM_INVALID_STATE (-1820)482 #define VERR_SSM_INVALID_STATE (-1822) 479 483 480 484 /** Unsupported data unit version. 481 485 * A SSM user returns this if it doesn't know the u32Version. */ 482 #define VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION (-182 1)486 #define VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION (-1823) 483 487 /** The format of a data unit has changed. 484 488 * A SSM user returns this if it's not able to read the format for 485 489 * other reasons than u32Version. */ 486 #define VERR_SSM_DATA_UNIT_FORMAT_CHANGED (-182 2)490 #define VERR_SSM_DATA_UNIT_FORMAT_CHANGED (-1824) 487 491 /** The CPUID instruction returns different information when loading than when saved. 488 492 * Normally caused by hardware changes on the host, but could also be caused by 489 493 * changes in the BIOS setup. */ 490 #define VERR_SSM_LOAD_CPUID_MISMATCH (-182 3)494 #define VERR_SSM_LOAD_CPUID_MISMATCH (-1825) 491 495 /** The RAM size differes between the saved state and the VM config. */ 492 #define VERR_SSM_LOAD_MEMORY_SIZE_MISMATCH (-182 4)496 #define VERR_SSM_LOAD_MEMORY_SIZE_MISMATCH (-1826) 493 497 /** The state doesn't match the VM configuration in one or another way. 494 498 * (There are certain PCI reconfiguration which the OS could potentially 495 499 * do which can cause this problem. Check this out when it happens.) */ 496 #define VERR_SSM_LOAD_CONFIG_MISMATCH (-182 5)500 #define VERR_SSM_LOAD_CONFIG_MISMATCH (-1827) 497 501 /** The virtual clock freqency differs too much. 498 502 * The clock source for the virtual time isn't reliable or the code have changed. */ 499 #define VERR_SSM_VIRTUAL_CLOCK_HZ (-182 6)503 #define VERR_SSM_VIRTUAL_CLOCK_HZ (-1828) 500 504 /** A timeout occured while waiting for async IDE operations to finish. */ 501 #define VERR_SSM_IDE_ASYNC_TIMEOUT (-182 7)505 #define VERR_SSM_IDE_ASYNC_TIMEOUT (-1829) 502 506 /** One of the structure magics was wrong. */ 503 #define VERR_SSM_STRUCTURE_MAGIC (-18 28)507 #define VERR_SSM_STRUCTURE_MAGIC (-1830) 504 508 /** The data in the saved state doesn't confirm to expectations. */ 505 #define VERR_SSM_UNEXPECTED_DATA (-1829) 509 #define VERR_SSM_UNEXPECTED_DATA (-1831) 510 /** Trying to read a 64-bit guest physical address into a 32-bit variable. */ 511 #define VERR_SSM_GCPHYS_OVERFLOW (-1832) 512 /** Trying to read a 64-bit guest virtual address into a 32-bit variable. */ 513 #define VERR_SSM_GCPTR_OVERFLOW (-1833) 506 514 /** @} */ 507 515 -
trunk/src/VBox/VMM/CPUM.cpp
r15414 r15503 773 773 static DECLCALLBACK(int) cpumR3Save(PVM pVM, PSSMHANDLE pSSM) 774 774 { 775 /* Set the size of RTGCPTR for use of SSMR3Get/PutGCPtr. */776 SSMR3SetGCPtrSize(pSSM, sizeof(RTGCPTR));777 778 775 /* 779 776 * Save. … … 929 926 if (u32Version == CPUM_SAVED_STATE_VERSION_VER1_6) 930 927 SSMR3SetGCPtrSize(pSSM, sizeof(RTGCPTR32)); 931 else 932 SSMR3SetGCPtrSize(pSSM, sizeof(RTGCPTR));928 else if (u32Version <= CPUM_SAVED_STATE_VERSION) 929 SSMR3SetGCPtrSize(pSSM, HC_ARCH_BITS == 32 ? sizeof(RTGCPTR32) : sizeof(RTGCPTR)); 933 930 934 931 /* -
trunk/src/VBox/VMM/SSM.cpp
r14075 r15503 84 84 /** Saved state file v1.1 magic. */ 85 85 #define SSMFILEHDR_MAGIC_V1_1 "\177VirtualBox SavedState V1.1\n" 86 /** Saved state file v1.2 magic. */ 87 #define SSMFILEHDR_MAGIC_V1_2 "\177VirtualBox SavedState V1.2\n\0\0\0" 86 88 87 89 /** Data unit magic. */ … … 102 104 typedef enum SSMSTATE 103 105 { 104 SSMSTATE_SAVE_PREP = 1, 106 SSMSTATE_INVALID = 0, 107 SSMSTATE_SAVE_PREP, 105 108 SSMSTATE_SAVE_EXEC, 106 109 SSMSTATE_SAVE_DONE, … … 158 161 unsigned uPercentDone; 159 162 160 /** RTGCPTR size in bytes */ 163 /** RTGCPHYS size in bytes. (Only applicable when loading/reading.) */ 164 unsigned cbGCPhys; 165 /** RTGCPTR size in bytes. (Only applicable when loading/reading.) */ 161 166 unsigned cbGCPtr; 167 /** Whether cbGCPtr is fixed or settable. */ 168 bool fFixedGCPtrSize; 162 169 } SSMHANDLE; 163 170 … … 165 172 /** 166 173 * Header of the saved state file. 174 * 175 * @remarks This is a superset of SSMFILEHDRV11. 167 176 */ 168 177 typedef struct SSMFILEHDR 178 { 179 /** Magic string which identifies this file as a version of VBox saved state 180 * file format (SSMFILEHDR_MAGIC_V1_2). */ 181 char achMagic[32]; 182 /** The size of this file. Used to check 183 * whether the save completed and that things are fine otherwise. */ 184 uint64_t cbFile; 185 /** File checksum. The actual calculation skips past the u32CRC field. */ 186 uint32_t u32CRC; 187 /** Padding. */ 188 uint32_t u32Reserved; 189 /** The machine UUID. (Ignored if NIL.) */ 190 RTUUID MachineUuid; 191 192 /** The major version number. */ 193 uint16_t u16VerMajor; 194 /** The minor version number. */ 195 uint16_t u16VerMinor; 196 /** The build number. */ 197 uint32_t u32VerBuild; 198 /** The SVN revision. */ 199 uint32_t u32SvnRev; 200 201 /** 32 or 64 depending on the host. */ 202 uint8_t cHostBits; 203 /** The size of RTGCPHYS. */ 204 uint8_t cbGCPhys; 205 /** The size of RTGCPTR. */ 206 uint8_t cbGCPtr; 207 /** Padding. */ 208 uint8_t au8Reserved; 209 } SSMFILEHDR; 210 AssertCompileSize(SSMFILEHDR, 64+16); 211 AssertCompileMemberSize(SSMFILEHDR, achMagic, sizeof(SSMFILEHDR_MAGIC_V1_2)); 212 /** Pointer to a saved state file header. */ 213 typedef SSMFILEHDR *PSSMFILEHDR; 214 215 216 /** 217 * Header of the saved state file, version 1.1. 218 */ 219 typedef struct SSMFILEHDRV11 169 220 { 170 221 /** Magic string which identifies this file as a version of VBox saved state … … 180 231 /** The machine UUID. (Ignored if NIL.) */ 181 232 RTUUID MachineUuid; 182 } SSMFILEHDR ;183 AssertCompileSize(SSMFILEHDR , 64);233 } SSMFILEHDRV11; 234 AssertCompileSize(SSMFILEHDRV11, 64); 184 235 /** Pointer to a saved state file header. */ 185 typedef SSMFILEHDR *PSSMFILEHDR;236 typedef SSMFILEHDRV11 *PSSMFILEHDRV11; 186 237 187 238 … … 278 329 279 330 /** 280 * For saving the version + revision and stuff. 331 * For saving usful things without having to go thru the tedious process of 332 * adding it to the header. 281 333 * 282 334 * @returns VBox status code. … … 292 344 * Terminated by two empty strings. 293 345 */ 294 SSMR3PutStrZ(pSSM, "VBox Version");295 SSMR3PutStrZ(pSSM, VBOX_VERSION_STRING);296 SSMR3PutStrZ(pSSM, "VBox Revision");297 RTStrPrintf(szTmp, sizeof(szTmp), "%d", VMMGetSvnRev());298 SSMR3PutStrZ(pSSM, szTmp);299 346 #ifdef VBOX_OSE 300 347 SSMR3PutStrZ(pSSM, "OSE"); … … 324 371 * Terminated by two empty strings. 325 372 */ 326 LogRel(("SSM: Saved state info:\n")); 327 for (;;) 373 for (unsigned i = 0; ; i++) 328 374 { 329 375 char szVar[128]; … … 335 381 if (!szVar[0] && !szValue[0]) 336 382 break; 383 if (i == 0) 384 LogRel(("SSM: Saved state info:\n")); 337 385 LogRel(("SSM: %s: %s\n", szVar, szValue)); 338 386 } … … 925 973 */ 926 974 SSMHANDLE Handle = {0}; 927 Handle.enmAfter = enmAfter; 928 Handle.pVM = pVM; 929 Handle.cbFileHdr = sizeof(SSMFILEHDR); 930 Handle.pfnProgress = pfnProgress; 931 Handle.pvUser = pvUser; 932 Handle.uPercentPrepare = 2; 933 Handle.uPercentDone = 20; 975 Handle.File = NIL_RTFILE; 976 Handle.pVM = pVM; 977 Handle.cbFileHdr = sizeof(SSMFILEHDR); 978 Handle.enmOp = SSMSTATE_INVALID; 979 Handle.enmAfter = enmAfter; 980 Handle.rc = VINF_SUCCESS; 981 Handle.pZipComp = NULL; 982 Handle.pZipDecomp = NULL; 983 Handle.pfnProgress = pfnProgress; 984 Handle.pvUser = pvUser; 985 Handle.uPercent = 0; 986 Handle.offEstProgress = 0; 987 Handle.cbEstTotal = 0; 988 Handle.offEst = 0; 989 Handle.offEstUnitEnd = 0; 990 Handle.uPercentPrepare = 20; 991 Handle.uPercentDone = 2; 992 Handle.cbGCPhys = sizeof(RTGCPHYS); 993 Handle.cbGCPtr = sizeof(RTGCPTR); 994 Handle.fFixedGCPtrSize = true; 934 995 935 996 int rc = RTFileOpen(&Handle.File, pszFilename, RTFILE_O_READWRITE | RTFILE_O_CREATE_REPLACE | RTFILE_O_DENY_WRITE); … … 945 1006 * Write header. 946 1007 */ 947 SSMFILEHDR Hdr = { SSMFILEHDR_MAGIC_V1_1, 0, 0, 0 }; 1008 SSMFILEHDR Hdr = 1009 { 1010 /* .achMagic[32] = */ SSMFILEHDR_MAGIC_V1_2, 1011 /* .cbFile = */ 0, 1012 /* .u32CRC = */ 0, 1013 /* .u32Reserved = */ 0, 1014 /* .MachineUuid = */ {{0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0}}, 1015 /* .u16VerMajor = */ VBOX_VERSION_MAJOR, 1016 /* .u16VerMinor = */ VBOX_VERSION_MINOR, 1017 /* .u32VerBuild = */ VBOX_VERSION_BUILD, 1018 /* .u32SvnRev = */ VMMGetSvnRev(), 1019 /* .cHostBits = */ HC_ARCH_BITS, 1020 /* .cbGCPhys = */ sizeof(RTGCPHYS), 1021 /* .cbGCPtr = */ sizeof(RTGCPTR), 1022 /* .au8Reserved = */ 0 1023 }; 948 1024 rc = RTFileWrite(Handle.File, &Hdr, sizeof(Hdr), NULL); 949 1025 if (RT_SUCCESS(rc)) … … 1276 1352 pHdr->u32Reserved = 0; 1277 1353 pHdr->MachineUuid = OldHdr.MachineUuid; 1354 pHdr->cHostBits = 32; 1278 1355 1279 1356 offCrc32 = RT_OFFSETOF(SSMFILEHDRV10X86, u32CRC) + sizeof(pHdr->u32CRC); … … 1282 1359 else 1283 1360 { 1284 /* (It's identical to the current, but this doesn't harm us and will1285 continue working after future changes.) */1286 1361 SSMFILEHDRV10AMD64 OldHdr; 1287 1362 memcpy(&OldHdr, pHdr, sizeof(OldHdr)); … … 1290 1365 pHdr->u32Reserved = 0; 1291 1366 pHdr->MachineUuid = OldHdr.MachineUuid; 1367 pHdr->cHostBits = 64; 1292 1368 1293 1369 offCrc32 = RT_OFFSETOF(SSMFILEHDRV10AMD64, u32CRC) + sizeof(pHdr->u32CRC); 1294 1370 *pcbFileHdr = sizeof(OldHdr); 1295 1371 } 1296 } 1297 else if (memcmp(pHdr->achMagic, SSMFILEHDR_MAGIC_V1_1, sizeof(SSMFILEHDR_MAGIC_V1_1))) 1372 pHdr->u16VerMajor = 0; 1373 pHdr->u16VerMinor = 0; 1374 pHdr->u32VerBuild = 0; 1375 pHdr->u32SvnRev = 0; 1376 pHdr->cbGCPhys = sizeof(uint32_t); 1377 pHdr->cbGCPtr = sizeof(uint32_t); 1378 pHdr->au8Reserved = 0; 1379 } 1380 else if (!memcmp(pHdr->achMagic, SSMFILEHDR_MAGIC_V1_1, sizeof(SSMFILEHDR_MAGIC_V1_1))) 1381 { 1382 *pcbFileHdr = sizeof(SSMFILEHDRV11); 1383 pHdr->u16VerMajor = 0; 1384 pHdr->u16VerMinor = 0; 1385 pHdr->u32VerBuild = 0; 1386 pHdr->u32SvnRev = 0; 1387 pHdr->cHostBits = 0; /* unknown */ 1388 pHdr->cbGCPhys = sizeof(RTGCPHYS); 1389 pHdr->cbGCPtr = 0; /* settable. */ 1390 pHdr->au8Reserved = 0; 1391 } 1392 else if (!memcmp(pHdr->achMagic, SSMFILEHDR_MAGIC_V1_2, sizeof(pHdr->achMagic))) 1393 { 1394 if ( pHdr->u16VerMajor == 0 1395 || pHdr->u16VerMajor > 1000 1396 || pHdr->u32SvnRev == 0 1397 || pHdr->u32SvnRev > 10000000 /*100M*/) 1398 { 1399 LogRel(("SSM: Incorrect version values: %d.%d.%d.r%d\n", 1400 pHdr->u16VerMajor, pHdr->u16VerMinor, pHdr->u32VerBuild, pHdr->u32SvnRev)); 1401 return VERR_SSM_INTEGRITY_VBOX_VERSION; 1402 } 1403 if ( pHdr->cHostBits != 32 1404 && pHdr->cHostBits != 64) 1405 { 1406 LogRel(("SSM: Incorrect cHostBits value: %d\n", pHdr->cHostBits)); 1407 return VERR_SSM_INTEGRITY_SIZES; 1408 } 1409 if ( pHdr->cbGCPhys != sizeof(uint32_t) 1410 && pHdr->cbGCPhys != sizeof(uint64_t)) 1411 { 1412 LogRel(("SSM: Incorrect cbGCPhys value: %d\n", pHdr->cbGCPhys)); 1413 return VERR_SSM_INTEGRITY_SIZES; 1414 } 1415 if ( pHdr->cbGCPtr != sizeof(uint32_t) 1416 && pHdr->cbGCPtr != sizeof(uint64_t)) 1417 { 1418 LogRel(("SSM: Incorrect cbGCPtr value: %d\n", pHdr->cbGCPtr)); 1419 return VERR_SSM_INTEGRITY_SIZES; 1420 } 1421 } 1422 else 1298 1423 { 1299 1424 Log(("SSM: Unknown file format version. magic=%.*s\n", sizeof(pHdr->achMagic) - 1, pHdr->achMagic)); … … 1410 1535 * take a long time. 1411 1536 */ 1412 SSMHANDLE Handle = {0}; 1413 Handle.enmAfter = enmAfter; 1414 Handle.pVM = pVM; 1415 Handle.cbFileHdr = sizeof(SSMFILEHDR); 1416 Handle.pfnProgress = pfnProgress; 1417 Handle.pvUser = pvUser; 1418 Handle.uPercentPrepare = 20; 1419 Handle.uPercentDone = 2; 1537 SSMHANDLE Handle = {0}; 1538 Handle.File = NIL_RTFILE; 1539 Handle.pVM = pVM; 1540 Handle.cbFileHdr = sizeof(SSMFILEHDR); 1541 Handle.enmOp = SSMSTATE_INVALID; 1542 Handle.enmAfter = enmAfter; 1543 Handle.rc = VINF_SUCCESS; 1544 Handle.pZipComp = NULL; 1545 Handle.pZipDecomp = NULL; 1546 Handle.pfnProgress = pfnProgress; 1547 Handle.pvUser = pvUser; 1548 Handle.uPercent = 0; 1549 Handle.offEstProgress = 0; 1550 Handle.cbEstTotal = 0; 1551 Handle.offEst = 0; 1552 Handle.offEstUnitEnd = 0; 1553 Handle.uPercentPrepare = 20; 1554 Handle.uPercentDone = 2; 1555 Handle.cbGCPhys = sizeof(RTGCPHYS); 1556 Handle.cbGCPtr = sizeof(RTGCPTR); 1557 Handle.fFixedGCPtrSize = false; 1420 1558 1421 1559 int rc = RTFileOpen(&Handle.File, pszFilename, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE); … … 1433 1571 if (RT_SUCCESS(rc)) 1434 1572 { 1573 if (Hdr.cbGCPhys) 1574 Handle.cbGCPhys = Hdr.cbGCPhys; 1575 if (Hdr.cbGCPtr) 1576 { 1577 Handle.cbGCPtr = Hdr.cbGCPtr; 1578 Handle.fFixedGCPtrSize = true; 1579 } 1580 1581 if (Handle.cbFileHdr == sizeof(Hdr)) 1582 LogRel(("SSM: File header: Format %.4s, VirtualBox Version %u.%u.%u r%u, %u-bit host, cbGCPhys=%u, cbGCPtr=%u\n", 1583 &Hdr.achMagic[sizeof(SSMFILEHDR_MAGIC_BASE) - 1], 1584 Hdr.u16VerMajor, Hdr.u16VerMinor, Hdr.u32VerBuild, Hdr.u32SvnRev, 1585 Hdr.cHostBits, Hdr.cbGCPhys, Hdr.cbGCPtr)); 1586 else 1587 LogRel(("SSM: File header: Format %.4s, %u-bit host, cbGCPhys=%u, cbGCPtr=%u\n" , 1588 &Hdr.achMagic[sizeof(SSMFILEHDR_MAGIC_BASE)-1], Hdr.cHostBits, Hdr.cbGCPhys, Hdr.cbGCPtr)); 1589 1590 1435 1591 /* 1436 1592 * Clear the per unit flags. … … 1851 2007 pSSM->enmOp = SSMSTATE_OPEN_READ; 1852 2008 pSSM->enmAfter = SSMAFTER_OPENED; 1853 pSSM->uPercentPrepare = 20;1854 pSSM->uPercentDone = 2;1855 2009 //pSSM->rc = VINF_SUCCESS; 1856 2010 //pSSM->pZipComp = NULL; … … 1864 2018 //pSSM->offEst = 0; 1865 2019 //pSSM->offEstUnitEnd = 0; 2020 pSSM->uPercentPrepare = 20; 2021 pSSM->uPercentDone = 2; 2022 pSSM->cbGCPhys = Hdr.cbGCPhys ? Hdr.cbGCPhys : sizeof(RTGCPHYS); 2023 pSSM->cbGCPtr = sizeof(RTGCPTR); 2024 pSSM->fFixedGCPtrSize = false; 2025 if (Hdr.cbGCPtr) 2026 { 2027 pSSM->cbGCPtr = Hdr.cbGCPtr; 2028 pSSM->fFixedGCPtrSize = true; 2029 } 2030 1866 2031 *ppSSM = pSSM; 1867 2032 LogFlow(("SSMR3Open: returns VINF_SUCCESS *ppSSM=%p\n", *ppSSM)); 1868 2033 return VINF_SUCCESS; 1869 2034 } 2035 1870 2036 Log(("SSMR3Open: Validation of '%s' failed, rc=%Rrc.\n", pszFilename, rc)); 1871 2037 RTFileClose(pSSM->File); … … 2940 3106 * @param pu Where to store the integer. 2941 3107 * 2942 * @deprecated Silly type , don't use it.3108 * @deprecated Silly type with an incorrect size, don't use it. 2943 3109 */ 2944 3110 VMMR3DECL(int) SSMR3GetGCUInt(PSSMHANDLE pSSM, PRTGCUINT pu) 2945 3111 { 2946 Assert(pSSM->cbGCPtr == sizeof(RTGCPTR32) || pSSM->cbGCPtr == sizeof(RTGCPTR64)); 2947 2948 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ) 2949 { 2950 if (sizeof(*pu) != pSSM->cbGCPtr) 2951 { 2952 uint32_t val; 2953 Assert(sizeof(*pu) == sizeof(uint64_t) && pSSM->cbGCPtr == sizeof(uint32_t)); 2954 int rc = ssmR3Read(pSSM, &val, pSSM->cbGCPtr); 2955 *pu = val; 2956 return rc; 2957 } 2958 return ssmR3Read(pSSM, pu, sizeof(*pu)); 2959 } 2960 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 2961 return VERR_SSM_INVALID_STATE; 3112 AssertCompile(sizeof(RTGCPTR) == sizeof(*pu)); 3113 return SSMR3GetGCPtr(pSSM, (PRTGCPTR)pu); 2962 3114 } 2963 3115 … … 2972 3124 VMMR3DECL(int) SSMR3GetGCUIntReg(PSSMHANDLE pSSM, PRTGCUINTREG pu) 2973 3125 { 2974 Assert(pSSM->cbGCPtr == sizeof(RTGCPTR32) || pSSM->cbGCPtr == sizeof(RTGCPTR64)); 2975 2976 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ) 2977 { 2978 if (sizeof(*pu) != pSSM->cbGCPtr) 2979 { 2980 uint32_t val; 2981 Assert(sizeof(*pu) == sizeof(uint64_t) && pSSM->cbGCPtr == sizeof(uint32_t)); 2982 int rc = ssmR3Read(pSSM, &val, pSSM->cbGCPtr); 2983 *pu = val; 2984 return rc; 2985 } 2986 return ssmR3Read(pSSM, pu, sizeof(*pu)); 2987 } 2988 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 2989 return VERR_SSM_INVALID_STATE; 3126 AssertCompile(sizeof(RTGCPTR) == sizeof(*pu)); 3127 return SSMR3GetGCPtr(pSSM, (PRTGCPTR)pu); 2990 3128 } 2991 3129 … … 3033 3171 { 3034 3172 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ) 3035 return ssmR3Read(pSSM, pGCPhys, sizeof(*pGCPhys)); 3173 { 3174 if (sizeof(*pGCPhys) != pSSM->cbGCPhys) 3175 { 3176 Assert(sizeof(*pGCPhys) == sizeof(uint64_t) || sizeof(*pGCPhys) == sizeof(uint32_t)); 3177 Assert(pSSM->cbGCPhys == sizeof(uint64_t) || pSSM->cbGCPhys == sizeof(uint32_t)); 3178 if (pSSM->cbGCPhys == sizeof(uint64_t)) 3179 { 3180 /* 64-bit saved, 32-bit load: try truncate it. */ 3181 uint64_t u64; 3182 int rc = ssmR3Read(pSSM, &u64, pSSM->cbGCPhys); 3183 if (RT_FAILURE(rc)) 3184 return rc; 3185 if (u64 >= _4G) 3186 return VERR_SSM_GCPHYS_OVERFLOW; 3187 *pGCPhys = (RTGCPHYS)u64; 3188 return rc; 3189 } 3190 /* 32-bit saved, 64-bit load: clear the high part. */ 3191 *pGCPhys = 0; 3192 } 3193 return ssmR3Read(pSSM, pGCPhys, pSSM->cbGCPhys); 3194 } 3036 3195 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 3037 3196 return VERR_SSM_INVALID_STATE; … … 3042 3201 * Loads a GC virtual address item from the current data unit. 3043 3202 * 3044 * Only applies to :3203 * Only applies to in the 1.1 format: 3045 3204 * - SSMR3GetGCPtr 3046 3205 * - SSMR3GetGCUIntPtr … … 3053 3212 * @param pSSM SSM operation handle. 3054 3213 * @param cbGCPtr Size of RTGCPTR 3214 * 3215 * @remarks This interface only works with saved state version 1.1, if the 3216 * format isn't 1.1 the call will be ignored. 3055 3217 */ 3056 3218 VMMR3DECL(int) SSMR3SetGCPtrSize(PSSMHANDLE pSSM, unsigned cbGCPtr) 3057 3219 { 3058 3220 Assert(cbGCPtr == sizeof(RTGCPTR32) || cbGCPtr == sizeof(RTGCPTR64)); 3059 Log(("SSMR3SetGCPtrSize %d bytes\n", cbGCPtr)); 3060 pSSM->cbGCPtr = cbGCPtr; 3221 if (!pSSM->fFixedGCPtrSize) 3222 { 3223 Log(("SSMR3SetGCPtrSize: %d -> %d bytes\n", pSSM->cbGCPtr, cbGCPtr)); 3224 pSSM->cbGCPtr = cbGCPtr; 3225 pSSM->fFixedGCPtrSize = true; 3226 } 3227 else if ( pSSM->cbGCPtr != cbGCPtr 3228 && pSSM->cbFileHdr == sizeof(SSMFILEHDRV11)) 3229 AssertMsgFailed(("SSMR3SetGCPtrSize: already fixed at %d bytes; requested %d bytes\n", pSSM->cbGCPtr, cbGCPtr)); 3230 3061 3231 return VINF_SUCCESS; 3062 3232 } … … 3072 3242 VMMR3DECL(int) SSMR3GetGCPtr(PSSMHANDLE pSSM, PRTGCPTR pGCPtr) 3073 3243 { 3074 Assert(pSSM->cbGCPtr == sizeof(RTGCPTR32) || pSSM->cbGCPtr == sizeof(RTGCPTR64));3075 3076 3244 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ) 3077 3245 { 3078 3246 if (sizeof(*pGCPtr) != pSSM->cbGCPtr) 3079 3247 { 3080 RTGCPTR32 val; 3081 Assert(sizeof(*pGCPtr) == sizeof(uint64_t) && pSSM->cbGCPtr == sizeof(uint32_t)); 3082 int rc = ssmR3Read(pSSM, &val, pSSM->cbGCPtr); 3083 *pGCPtr = val; 3084 return rc; 3248 Assert(sizeof(*pGCPtr) == sizeof(uint64_t) || sizeof(*pGCPtr) == sizeof(uint32_t)); 3249 Assert(pSSM->cbGCPtr == sizeof(uint64_t) || pSSM->cbGCPtr == sizeof(uint32_t)); 3250 if (pSSM->cbGCPtr == sizeof(uint64_t)) 3251 { 3252 /* 64-bit saved, 32-bit load: try truncate it. */ 3253 uint64_t u64; 3254 int rc = ssmR3Read(pSSM, &u64, pSSM->cbGCPhys); 3255 if (RT_FAILURE(rc)) 3256 return rc; 3257 if (u64 >= _4G) 3258 return VERR_SSM_GCPTR_OVERFLOW; 3259 *pGCPtr = (RTGCPTR)u64; 3260 return rc; 3261 } 3262 /* 32-bit saved, 64-bit load: clear the high part. */ 3263 *pGCPtr = 0; 3085 3264 } 3086 3265 return ssmR3Read(pSSM, pGCPtr, pSSM->cbGCPtr); … … 3092 3271 3093 3272 /** 3273 * Loads a GC virtual address (represented as unsigned integer) item from the current data unit. 3274 * 3275 * @returns VBox status. 3276 * @param pSSM SSM operation handle. 3277 * @param pGCPtr Where to store the GC virtual address. 3278 */ 3279 VMMR3DECL(int) SSMR3GetGCUIntPtr(PSSMHANDLE pSSM, PRTGCUINTPTR pGCPtr) 3280 { 3281 AssertCompile(sizeof(RTGCPTR) == sizeof(*pGCPtr)); 3282 return SSMR3GetGCPtr(pSSM, (PRTGCPTR)pGCPtr); 3283 } 3284 3285 3286 /** 3094 3287 * Loads an RC virtual address item from the current data unit. 3095 3288 * … … 3103 3296 return ssmR3Read(pSSM, pRCPtr, sizeof(*pRCPtr)); 3104 3297 3105 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp));3106 return VERR_SSM_INVALID_STATE;3107 }3108 3109 3110 /**3111 * Loads a GC virtual address (represented as unsigned integer) item from the current data unit.3112 *3113 * @returns VBox status.3114 * @param pSSM SSM operation handle.3115 * @param pGCPtr Where to store the GC virtual address.3116 */3117 VMMR3DECL(int) SSMR3GetGCUIntPtr(PSSMHANDLE pSSM, PRTGCUINTPTR pGCPtr)3118 {3119 Assert(pSSM->cbGCPtr == sizeof(RTGCPTR32) || pSSM->cbGCPtr == sizeof(RTGCPTR64));3120 3121 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ)3122 {3123 if (sizeof(*pGCPtr) != pSSM->cbGCPtr)3124 {3125 RTGCUINTPTR32 val;3126 Assert(sizeof(*pGCPtr) == sizeof(uint64_t) && pSSM->cbGCPtr == sizeof(uint32_t));3127 int rc = ssmR3Read(pSSM, &val, pSSM->cbGCPtr);3128 *pGCPtr = val;3129 return rc;3130 }3131 return ssmR3Read(pSSM, pGCPtr, pSSM->cbGCPtr);3132 }3133 3298 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 3134 3299 return VERR_SSM_INVALID_STATE;
Note:
See TracChangeset
for help on using the changeset viewer.