VirtualBox

Changeset 11808 in vbox


Ignore:
Timestamp:
Aug 29, 2008 11:29:35 AM (16 years ago)
Author:
vboxsync
Message:

Deal with GCPtr differences between 1.6 & 2.0 saved states.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/ssm.h

    r8155 r11808  
    432432SSMR3DECL(int) SSMR3HandleSetStatus(PSSMHANDLE pSSM, int iStatus);
    433433SSMR3DECL(SSMAFTER) SSMR3HandleGetAfter(PSSMHANDLE pSSM);
     434SSMR3DECL(int) SSMR3SetGCPtrSize(PSSMHANDLE pSSM, unsigned cbGCPtr);
    434435
    435436
  • trunk/src/VBox/VMM/CPUM.cpp

    r11798 r11808  
    727727static DECLCALLBACK(int) cpumR3Save(PVM pVM, PSSMHANDLE pSSM)
    728728{
     729    /* Set the size of RTGCPTR for use of SSMR3Get/PutGCPtr. */
     730    SSMR3SetGCPtrSize(pSSM, sizeof(RTGCPTR));
     731
    729732    /*
    730733     * Save.
     
    861864        return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
    862865    }
     866
     867    /* Set the size of RTGCPTR for SSMR3GetGCPtr. */
     868    if (u32Version == CPUM_SAVED_STATE_VERSION_VER1_6)
     869        SSMR3SetGCPtrSize(pSSM, sizeof(RTGCPTR32));
     870    else
     871        SSMR3SetGCPtrSize(pSSM, sizeof(RTGCPTR));
    863872
    864873    /*
  • trunk/src/VBox/VMM/SSM.cpp

    r11803 r11808  
    132132    unsigned        uPercentDone;
    133133
     134    /** RTGCPTR size in bytes */
     135    unsigned        cbGCPtr;
    134136} SSMHANDLE;
    135137
     
    27842786SSMR3DECL(int) SSMR3GetGCUInt(PSSMHANDLE pSSM, PRTGCUINT pu)
    27852787{
     2788    Assert(pSSM->cbGCPtr == sizeof(RTGCPTR32) || pSSM->cbGCPtr == sizeof(RTGCPTR64));
     2789
    27862790    if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ)
     2791    {
     2792        if (sizeof(*pu) != pSSM->cbGCPtr)
     2793        {
     2794            uint32_t val;
     2795            Assert(sizeof(*pu) == sizeof(uint64_t) && pSSM->cbGCPtr == sizeof(uint32_t));
     2796            int rc = ssmr3Read(pSSM, &val, pSSM->cbGCPtr);
     2797            *pu = val;
     2798            return rc;
     2799        }
    27872800        return ssmr3Read(pSSM, pu, sizeof(*pu));
     2801    }
    27882802    AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp));
    27892803    return VERR_SSM_INVALID_STATE;
     
    28002814SSMR3DECL(int) SSMR3GetGCSInt(PSSMHANDLE pSSM, PRTGCINT pi)
    28012815{
     2816    Assert(pSSM->cbGCPtr == sizeof(RTGCPTR32) || pSSM->cbGCPtr == sizeof(RTGCPTR64));
     2817
    28022818    if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ)
     2819    {
     2820        if (sizeof(*pi) != pSSM->cbGCPtr)
     2821        {
     2822            int32_t val;
     2823            Assert(sizeof(*pi) == sizeof(uint64_t) && pSSM->cbGCPtr == sizeof(uint32_t));
     2824            int rc = ssmr3Read(pSSM, &val, pSSM->cbGCPtr);
     2825            *pi = val;
     2826            return rc;
     2827        }
    28032828        return ssmr3Read(pSSM, pi, sizeof(*pi));
     2829    }
    28042830    AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp));
    28052831    return VERR_SSM_INVALID_STATE;
     
    28582884 * Loads a GC virtual address item from the current data unit.
    28592885 *
     2886 * Note: only applies to:
     2887 * - SSMR3GetGCPtr
     2888 * - SSMR3GetGCUIntPtr
     2889 * - SSMR3GetGCSInt
     2890 * - SSMR3GetGCUInt
     2891 *
     2892 * Put functions are not affected.
     2893 *
     2894 * @returns VBox status.
     2895 * @param   pSSM            SSM operation handle.
     2896 * @param   cbGCPtr         Size of RTGCPTR
     2897 */
     2898SSMR3DECL(int) SSMR3SetGCPtrSize(PSSMHANDLE pSSM, unsigned cbGCPtr)
     2899{
     2900    Assert(cbGCPtr == sizeof(RTGCPTR32) || cbGCPtr == sizeof(RTGCPTR64));
     2901    pSSM->cbGCPtr = cbGCPtr;
     2902    return VINF_SUCCESS;
     2903}
     2904
     2905/**
     2906 * Loads a GC virtual address item from the current data unit.
     2907 *
    28602908 * @returns VBox status.
    28612909 * @param   pSSM            SSM operation handle.
     
    28642912SSMR3DECL(int) SSMR3GetGCPtr(PSSMHANDLE pSSM, PRTGCPTR pGCPtr)
    28652913{
     2914    Assert(pSSM->cbGCPtr == sizeof(RTGCPTR32) || pSSM->cbGCPtr == sizeof(RTGCPTR64));
     2915
    28662916    if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ)
    2867         return ssmr3Read(pSSM, pGCPtr, sizeof(*pGCPtr));
     2917    {
     2918        if (sizeof(*pGCPtr) != pSSM->cbGCPtr)
     2919        {
     2920            RTGCPTR32 val;
     2921            Assert(sizeof(*pGCPtr) == sizeof(uint64_t) && pSSM->cbGCPtr == sizeof(uint32_t));
     2922            int rc = ssmr3Read(pSSM, &val, pSSM->cbGCPtr);
     2923            *pGCPtr = val;
     2924            return rc;
     2925        }
     2926        return ssmr3Read(pSSM, pGCPtr, pSSM->cbGCPtr);
     2927    }
    28682928    AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp));
    28692929    return VERR_SSM_INVALID_STATE;
     
    28802940SSMR3DECL(int) SSMR3GetGCUIntPtr(PSSMHANDLE pSSM, PRTGCUINTPTR pGCPtr)
    28812941{
     2942    Assert(pSSM->cbGCPtr == sizeof(RTGCPTR32) || pSSM->cbGCPtr == sizeof(RTGCPTR64));
     2943
    28822944    if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ)
    2883         return ssmr3Read(pSSM, pGCPtr, sizeof(*pGCPtr));
     2945    {
     2946        if (sizeof(*pGCPtr) != pSSM->cbGCPtr)
     2947        {
     2948            RTGCUINTPTR32 val;
     2949            Assert(sizeof(*pGCPtr) == sizeof(uint64_t) && pSSM->cbGCPtr == sizeof(uint32_t));
     2950            int rc = ssmr3Read(pSSM, &val, pSSM->cbGCPtr);
     2951            *pGCPtr = val;
     2952            return rc;
     2953        }
     2954        return ssmr3Read(pSSM, pGCPtr, pSSM->cbGCPtr);
     2955    }
    28842956    AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp));
    28852957    return VERR_SSM_INVALID_STATE;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette