VirtualBox

Changeset 85573 in vbox for trunk


Ignore:
Timestamp:
Jul 31, 2020 12:41:14 PM (4 years ago)
Author:
vboxsync
Message:

VMM: Added method for getting at the CPU database.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/cpum.h

    r85352 r85573  
    13741374
    13751375
     1376/**
     1377 * CPU database entry.
     1378 */
     1379typedef struct CPUMDBENTRY
     1380{
     1381    /** The CPU name. */
     1382    const char     *pszName;
     1383    /** The full CPU name. */
     1384    const char     *pszFullName;
     1385    /** The CPU vendor (CPUMCPUVENDOR). */
     1386    uint8_t         enmVendor;
     1387    /** The CPU family. */
     1388    uint8_t         uFamily;
     1389    /** The CPU model. */
     1390    uint8_t         uModel;
     1391    /** The CPU stepping. */
     1392    uint8_t         uStepping;
     1393    /** The microarchitecture. */
     1394    CPUMMICROARCH   enmMicroarch;
     1395    /** Scalable bus frequency used for reporting other frequencies. */
     1396    uint64_t        uScalableBusFreq;
     1397    /** Flags - CPUMDB_F_XXX. */
     1398    uint32_t        fFlags;
     1399    /** The maximum physical address with of the CPU.  This should correspond to
     1400     * the value in CPUID leaf 0x80000008 when present. */
     1401    uint8_t         cMaxPhysAddrWidth;
     1402    /** The MXCSR mask. */
     1403    uint32_t        fMxCsrMask;
     1404    /** Pointer to an array of CPUID leaves.  */
     1405    PCCPUMCPUIDLEAF paCpuIdLeaves;
     1406    /** The number of CPUID leaves in the array paCpuIdLeaves points to. */
     1407    uint32_t        cCpuIdLeaves;
     1408    /** The method used to deal with unknown CPUID leaves. */
     1409    CPUMUNKNOWNCPUID enmUnknownCpuId;
     1410    /** The default unknown CPUID value. */
     1411    CPUMCPUID       DefUnknownCpuId;
     1412
     1413    /** MSR mask.  Several microarchitectures ignore the higher bits of ECX in
     1414     *  the RDMSR and WRMSR instructions. */
     1415    uint32_t        fMsrMask;
     1416
     1417    /** The number of ranges in the table pointed to b paMsrRanges. */
     1418    uint32_t        cMsrRanges;
     1419    /** MSR ranges for this CPU. */
     1420    PCCPUMMSRRANGE  paMsrRanges;
     1421} CPUMDBENTRY;
     1422/** Pointer to a const CPU database entry. */
     1423typedef CPUMDBENTRY const *PCCPUMDBENTRY;
     1424
     1425/** @name CPUMDB_F_XXX - CPUDBENTRY::fFlags
     1426 * @{ */
     1427/** Should execute all in IEM.
     1428 * @todo Implement this - currently done in Main...  */
     1429#define CPUMDB_F_EXECUTE_ALL_IN_IEM         RT_BIT_32(0)
     1430/** @} */
     1431
     1432
     1433
    13761434#ifndef VBOX_FOR_DTRACE_LIB
    13771435
     
    23172375    Assert(pVmcs);
    23182376
    2319     uint32_t const fGstHostMask = pVmcs->u64Cr0Mask.u;
    2320     uint32_t const fReadShadow  = pVmcs->u64Cr0ReadShadow.u;
     2377    uint32_t const fGstHostMask = (uint32_t)pVmcs->u64Cr0Mask.u;
     2378    uint32_t const fReadShadow  = (uint32_t)pVmcs->u64Cr0ReadShadow.u;
    23212379
    23222380    /*
     
    26482706VMMR3DECL(int)              CPUMR3MsrRangesInsert(PVM pVM, PCCPUMMSRRANGE pNewRange);
    26492707
     2708VMMR3DECL(uint32_t)         CPUMR3DbGetEntries(void);
     2709/** Pointer to CPUMR3DbGetEntries. */
     2710typedef DECLCALLBACKPTR(uint32_t, PFNCPUMDBGETENTRIES, (void));
     2711VMMR3DECL(PCCPUMDBENTRY)    CPUMR3DbGetEntryByIndex(uint32_t idxCpuDb);
     2712/** Pointer to CPUMR3DbGetEntryByIndex. */
     2713typedef DECLCALLBACKPTR(PCCPUMDBENTRY, PFNCPUMDBGETENTRYBYINDEX, (uint32_t idxCpuDb));
     2714VMMR3DECL(PCCPUMDBENTRY)    CPUMR3DbGetEntryByName(const char *pszName);
     2715/** Pointer to CPUMR3DbGetEntryByName. */
     2716typedef DECLCALLBACKPTR(PCCPUMDBENTRY, PFNCPUMDBGETENTRYBYNAME, (const char *pszName));
    26502717/** @} */
    26512718#endif /* IN_RING3 */
  • trunk/src/VBox/VMM/VMMR3/CPUMR3Db.cpp

    r85354 r85573  
    3333
    3434/*********************************************************************************************************************************
    35 *   Structures and Typedefs                                                                                                      *
    36 *********************************************************************************************************************************/
    37 typedef struct CPUMDBENTRY
    38 {
    39     /** The CPU name. */
    40     const char     *pszName;
    41     /** The full CPU name. */
    42     const char     *pszFullName;
    43     /** The CPU vendor (CPUMCPUVENDOR). */
    44     uint8_t         enmVendor;
    45     /** The CPU family. */
    46     uint8_t         uFamily;
    47     /** The CPU model. */
    48     uint8_t         uModel;
    49     /** The CPU stepping. */
    50     uint8_t         uStepping;
    51     /** The microarchitecture. */
    52     CPUMMICROARCH   enmMicroarch;
    53     /** Scalable bus frequency used for reporting other frequencies. */
    54     uint64_t        uScalableBusFreq;
    55     /** Flags - CPUDB_F_XXX. */
    56     uint32_t        fFlags;
    57     /** The maximum physical address with of the CPU.  This should correspond to
    58      * the value in CPUID leaf 0x80000008 when present. */
    59     uint8_t         cMaxPhysAddrWidth;
    60     /** The MXCSR mask. */
    61     uint32_t        fMxCsrMask;
    62     /** Pointer to an array of CPUID leaves.  */
    63     PCCPUMCPUIDLEAF paCpuIdLeaves;
    64     /** The number of CPUID leaves in the array paCpuIdLeaves points to. */
    65     uint32_t        cCpuIdLeaves;
    66     /** The method used to deal with unknown CPUID leaves. */
    67     CPUMUNKNOWNCPUID enmUnknownCpuId;
    68     /** The default unknown CPUID value. */
    69     CPUMCPUID       DefUnknownCpuId;
    70 
    71     /** MSR mask.  Several microarchitectures ignore the higher bits of ECX in
    72      *  the RDMSR and WRMSR instructions. */
    73     uint32_t        fMsrMask;
    74 
    75     /** The number of ranges in the table pointed to b paMsrRanges. */
    76     uint32_t        cMsrRanges;
    77     /** MSR ranges for this CPU. */
    78     PCCPUMMSRRANGE  paMsrRanges;
    79 } CPUMDBENTRY;
    80 
    81 
    82 /*********************************************************************************************************************************
    8335*   Defined Constants And Macros                                                                                                 *
    8436*********************************************************************************************************************************/
    85 /** @name CPUDB_F_XXX - CPUDBENTRY::fFlags
    86  * @{ */
    87 /** Should execute all in IEM.
    88  * @todo Implement this - currently done in Main...  */
    89 #define CPUDB_F_EXECUTE_ALL_IN_IEM          RT_BIT_32(0)
    90 /** @} */
    91 
    92 
    9337/** @def NULL_ALONE
    9438 * For eliminating an unnecessary data dependency in standalone builds (for
     
    331275
    332276
     277/**
     278 * Returns the number of entries in the CPU database.
     279 *
     280 * @returns Number of entries.
     281 * @sa      PFNCPUMDBGETENTRIES
     282 */
     283VMMR3DECL(uint32_t)         CPUMR3DbGetEntries(void)
     284{
     285    return RT_ELEMENTS(g_apCpumDbEntries);
     286}
     287
     288
     289/**
     290 * Returns CPU database entry for the given index.
     291 *
     292 * @returns Pointer the CPU database entry, NULL if index is out of bounds.
     293 * @param   idxCpuDb            The index (0..CPUMR3DbGetEntries).
     294 * @sa      PFNCPUMDBGETENTRYBYINDEX
     295 */
     296VMMR3DECL(PCCPUMDBENTRY)    CPUMR3DbGetEntryByIndex(uint32_t idxCpuDb)
     297{
     298    AssertReturn(idxCpuDb <= RT_ELEMENTS(g_apCpumDbEntries), NULL);
     299    return g_apCpumDbEntries[idxCpuDb];
     300}
     301
     302
     303/**
     304 * Returns CPU database entry with the given name.
     305 *
     306 * @returns Pointer the CPU database entry, NULL if not found.
     307 * @param   idxCpuDb            The name of the profile to return.
     308 * @sa      PFNCPUMDBGETENTRYBYNAME
     309 */
     310VMMR3DECL(PCCPUMDBENTRY)    CPUMR3DbGetEntryByName(const char *pszName)
     311{
     312    AssertPtrReturn(pszName, NULL);
     313    AssertReturn(*pszName, NULL);
     314    for (size_t i = 0; i < RT_ELEMENTS(g_apCpumDbEntries); i++)
     315        if (strcmp(g_apCpumDbEntries[i]->pszName, pszName) == 0)
     316            return g_apCpumDbEntries[i];
     317    return NULL;
     318}
     319
     320
    333321
    334322/**
  • trunk/src/VBox/VMM/VMMR3/cpus/Intel_80186.h

    r82968 r85573  
    6060    /*.enmMicroarch     = */ kCpumMicroarch_Intel_80186,
    6161    /*.uScalableBusFreq = */ CPUM_SBUSFREQ_UNKNOWN,
    62     /*.fFlags           = */ CPUDB_F_EXECUTE_ALL_IN_IEM,
     62    /*.fFlags           = */ CPUMDB_F_EXECUTE_ALL_IN_IEM,
    6363    /*.cMaxPhysAddrWidth= */ 20,
    6464    /*.fMxCsrMask       = */ 0,
  • trunk/src/VBox/VMM/VMMR3/cpus/Intel_80286.h

    r82968 r85573  
    6060    /*.enmMicroarch     = */ kCpumMicroarch_Intel_80286,
    6161    /*.uScalableBusFreq = */ CPUM_SBUSFREQ_UNKNOWN,
    62     /*.fFlags           = */ CPUDB_F_EXECUTE_ALL_IN_IEM,
     62    /*.fFlags           = */ CPUMDB_F_EXECUTE_ALL_IN_IEM,
    6363    /*.cMaxPhysAddrWidth= */ 24,
    6464    /*.fMxCsrMask       = */ 0,
  • trunk/src/VBox/VMM/VMMR3/cpus/Intel_80386.h

    r82968 r85573  
    6060    /*.enmMicroarch     = */ kCpumMicroarch_Intel_80386,
    6161    /*.uScalableBusFreq = */ CPUM_SBUSFREQ_UNKNOWN,
    62     /*.fFlags           = */ CPUDB_F_EXECUTE_ALL_IN_IEM,
     62    /*.fFlags           = */ CPUMDB_F_EXECUTE_ALL_IN_IEM,
    6363    /*.cMaxPhysAddrWidth= */ 24,
    6464    /*.fMxCsrMask       = */ 0,
  • trunk/src/VBox/VMM/VMMR3/cpus/Intel_8086.h

    r82968 r85573  
    6060    /*.enmMicroarch     = */ kCpumMicroarch_Intel_8086,
    6161    /*.uScalableBusFreq = */ CPUM_SBUSFREQ_UNKNOWN,
    62     /*.fFlags           = */ CPUDB_F_EXECUTE_ALL_IN_IEM,
     62    /*.fFlags           = */ CPUMDB_F_EXECUTE_ALL_IN_IEM,
    6363    /*.cMaxPhysAddrWidth= */ 20,
    6464    /*.fMxCsrMask       = */ 0,
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