VirtualBox

Changeset 104507 in vbox for trunk/src/VBox/VMM/VMMR3


Ignore:
Timestamp:
May 3, 2024 1:58:16 PM (9 months ago)
Author:
vboxsync
Message:

VMM,Main: Some GCM adjustments. bugref:9735 bugref:10683

Location:
trunk/src/VBox/VMM/VMMR3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/GCM.cpp

    r99739 r104507  
    108108
    109109    /*
    110      * Read configuration.
    111      */
     110     * Read & validate configuration.
     111     */
     112    static struct { const char *pszName; uint32_t cchName; uint32_t fFlag; } const s_aFixerIds[] =
     113    {
     114        { RT_STR_TUPLE("DivByZeroDOS"),       GCMFIXER_DBZ_DOS },
     115        { RT_STR_TUPLE("DivByZeroOS2"),       GCMFIXER_DBZ_OS2 },
     116        { RT_STR_TUPLE("DivByZeroWin9x"),     GCMFIXER_DBZ_WIN9X },
     117    };
     118
     119    /* Assemble valid value names for CFMGR3ValidateConfig. */
     120    char   szValidValues[1024];
     121    size_t offValidValues = 0;
     122    for (unsigned i = 0; i < RT_ELEMENTS(s_aFixerIds); i++)
     123    {
     124        AssertReturn(offValidValues + s_aFixerIds[i].cchName + 2 <= sizeof(szValidValues), VERR_INTERNAL_ERROR_2);
     125        if (offValidValues)
     126            szValidValues[offValidValues++] = '|';
     127        memcpy(&szValidValues[offValidValues], s_aFixerIds[i].pszName, s_aFixerIds[i].cchName);
     128        offValidValues += s_aFixerIds[i].cchName;
     129    }
     130    szValidValues[offValidValues] = '\0';
     131
     132    /* Validate the configuration. */
    112133    PCFGMNODE pCfgNode = CFGMR3GetChild(CFGMR3GetRoot(pVM), "GCM/");
    113 
    114     /*
    115      * Validate the GCM settings.
    116      */
    117     rc = CFGMR3ValidateConfig(pCfgNode, "/GCM/",    /* pszNode */
    118                               "FixerSet",           /* pszValidValues */
     134    rc = CFGMR3ValidateConfig(pCfgNode,
     135                              "/GCM/",              /* pszNode (for error msgs) */
     136                              szValidValues,
    119137                              "",                   /* pszValidNodes */
    120138                              "GCM",                /* pszWho */
     
    123141        return rc;
    124142
    125 #if 1
    126     /** @cfgm{/GCM/FixerSet, uint32_t, 0}
    127      * The set (bit mask) of enabled fixers. See GCMFIXERID.
    128      */
    129     uint32_t    u32FixerIds;
    130     rc = CFGMR3QueryU32Def(pCfgNode, "FixerSet", &u32FixerIds, 0);
    131     AssertRCReturn(rc, rc);
    132 
    133     /* Check for unknown bits. */
    134     uint32_t    u32BadBits = u32FixerIds & ~(GCMFIXER_DBZ_DOS | GCMFIXER_DBZ_OS2 | GCMFIXER_DBZ_WIN9X);
    135 
    136     if (u32BadBits)
     143    /* Read the configuration. */
     144    pVM->gcm.s.fFixerSet = 0;
     145    for (unsigned i = 0; i < RT_ELEMENTS(s_aFixerIds); i++)
    137146    {
    138         rc = VMR3SetError(pVM->pUVM, VERR_CFGM_CONFIG_UNKNOWN_VALUE, RT_SRC_POS, "Unsupported GCM fixer bits (%#x) set.", u32BadBits);
     147        bool fEnabled = false;
     148        rc = CFGMR3QueryBoolDef(pCfgNode, s_aFixerIds[i].pszName, &fEnabled, false);
     149        if (RT_FAILURE(rc))
     150            return VMR3SetError(pVM->pUVM, rc, RT_SRC_POS, "Error reading /GCM/%s as boolean: %Rrc", s_aFixerIds[i].pszName, rc);
     151        if (fEnabled)
     152            pVM->gcm.s.fFixerSet = s_aFixerIds[i].fFlag;
    139153    }
    140     else
    141     {
    142         pVM->gcm.s.enmFixerIds = u32FixerIds;
    143     }
    144 #else
     154
     155#if 0 /* development override */
    145156    pVM->gcm.s.enmFixerIds = GCMFIXER_DBZ_OS2 | GCMFIXER_DBZ_DOS | GCMFIXER_DBZ_WIN9X;
    146157#endif
    147     LogRel(("GCM: Initialized (fixer bits: %#x)\n", u32FixerIds));
    148 
    149     return rc;
    150 }
    151 
    152 
    153 /**
    154  * Finalize the GCM initialization.
    155  *
    156  * This is called after initializing HM and most other VMM components.
    157  *
    158  * @returns VBox status code.
    159  * @param   pVM                 The cross context VM structure.
    160  * @thread  EMT(0)
    161  */
    162 VMMR3_INT_DECL(int) GCMR3InitCompleted(PVM pVM)
    163 {
    164     RT_NOREF(pVM);
     158
     159    /*
     160     * Log what's enabled.
     161     */
     162    offValidValues = 0;
     163    for (unsigned i = 0; i < RT_ELEMENTS(s_aFixerIds); i++)
     164        if (pVM->gcm.s.fFixerSet & s_aFixerIds[i].fFlag)
     165        {
     166            AssertReturn(offValidValues + s_aFixerIds[i].cchName + 4 <= sizeof(szValidValues), VERR_INTERNAL_ERROR_2);
     167            if (!offValidValues)
     168            {
     169                szValidValues[offValidValues++] = ' ';
     170                szValidValues[offValidValues++] = '(';
     171            }
     172            else
     173            {
     174                szValidValues[offValidValues++] = ',';
     175                szValidValues[offValidValues++] = ' ';
     176            }
     177            memcpy(&szValidValues[offValidValues], s_aFixerIds[i].pszName, s_aFixerIds[i].cchName);
     178            offValidValues += s_aFixerIds[i].cchName;
     179        }
     180    if (offValidValues)
     181        szValidValues[offValidValues++] = ')';
     182    szValidValues[offValidValues] = '\0';
     183    LogRel(("GCM: Initialized - Fixer bits: %#x%s\n", pVM->gcm.s.fFixerSet, szValidValues));
     184
    165185    return VINF_SUCCESS;
    166186}
     
    175195    AssertReturn(pSSM, VERR_SSM_INVALID_STATE);
    176196
    177     int rc = VINF_SUCCESS;
    178 
    179     /*
    180      * Save per-VM data.
    181      */
    182     SSMR3PutU32(pSSM, pVM->gcm.s.enmFixerIds);
    183 
    184     return rc;
     197    /*
     198     * At present there is only configuration to save.
     199     */
     200    return SSMR3PutU32(pSSM, pVM->gcm.s.fFixerSet);
    185201}
    186202
     
    196212        return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
    197213
    198     int rc;
    199 
    200     /*
    201      * Load per-VM data.
    202      */
    203     uint32_t uFixerIds;
    204 
    205     rc = SSMR3GetU32(pSSM, &uFixerIds);
     214    /*
     215     * Load configuration and check it aginst the current (live migration,
     216     * general paranoia).
     217     */
     218    uint32_t fFixerSet = 0;
     219    int rc = SSMR3GetU32(pSSM, &fFixerSet);
    206220    AssertRCReturn(rc, rc);
    207221
    208     if ((GCMFIXERID)uFixerIds != pVM->gcm.s.enmFixerIds)
     222    if (fFixerSet != pVM->gcm.s.fFixerSet)
    209223        return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Saved GCM fixer set %#X differs from the configured one (%#X)."),
    210                                 uFixerIds, pVM->gcm.s.enmFixerIds);
     224                                fFixerSet, pVM->gcm.s.fFixerSet);
    211225
    212226    return VINF_SUCCESS;
     
    231245
    232246/**
    233  * Applies relocations to data and code managed by this
    234  * component. This function will be called at init and
    235  * whenever the VMM need to relocate itself inside the GC.
    236  *
    237  * @param   pVM         The cross context VM structure.
    238  * @param   offDelta    Relocation delta relative to old location.
    239  */
    240 VMMR3_INT_DECL(void) GCMR3Relocate(PVM pVM, RTGCINTPTR offDelta)
     247 * The VM is being reset.
     248 *
     249 * Do whatever fixer-specific resetting that needs to be done.
     250 *
     251 * @param   pVM     The cross context VM structure.
     252 */
     253VMMR3_INT_DECL(void) GCMR3Reset(PVM pVM)
    241254{
    242255    RT_NOREF(pVM);
    243     RT_NOREF(offDelta);
    244 }
    245 
    246 
    247 /**
    248  * The VM is being reset.
    249  *
    250  * Do whatever fixer-specific resetting that needs to be done.
    251  *
    252  * @param   pVM     The cross context VM structure.
    253  */
    254 VMMR3_INT_DECL(void) GCMR3Reset(PVM pVM)
    255 {
    256     RT_NOREF(pVM);
    257 }
    258 
     256}
     257
  • trunk/src/VBox/VMM/VMMR3/VM.cpp

    r100927 r104507  
    10941094    PDMR3Relocate(pVM, offDelta);
    10951095    GIMR3Relocate(pVM, offDelta);
    1096 #if !defined(VBOX_VMM_TARGET_ARMV8)
    1097     GCMR3Relocate(pVM, offDelta);
    1098 #endif
    10991096}
    11001097
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