VirtualBox

Changeset 107650 in vbox for trunk/include/VBox/vmm/cpum.h


Ignore:
Timestamp:
Jan 10, 2025 1:42:28 PM (8 days ago)
Author:
vboxsync
Message:

VMM/CPUM,++: Made the HostFeatures match the host when targeting x86 guests on arm64 hosts. Merged and deduplicated code targeting x86 & amd64. jiraref:VBP-1470

File:
1 edited

Legend:

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

    r107389 r107650  
    354354typedef struct CPUMFEATURESCOMMON
    355355{
    356     /** The CPU vendor (CPUMCPUVENDOR). */
    357     uint8_t         enmCpuVendor;
    358     /** The CPU family. */
    359     uint8_t         uFamily;
    360     /** The CPU model. */
    361     uint8_t         uModel;
    362     /** The CPU stepping. */
    363     uint8_t         uStepping;
    364356    /** The microarchitecture. */
    365357#ifndef VBOX_FOR_DTRACE_LIB
     
    368360    uint32_t        enmMicroarch;
    369361#endif
     362    /** The CPU vendor (CPUMCPUVENDOR). */
     363    uint8_t         enmCpuVendor;
    370364    /** The maximum physical address width of the CPU. */
    371365    uint8_t         cMaxPhysAddrWidth;
     
    381375typedef struct CPUMFEATURESX86
    382376{
     377    /** The microarchitecture. */
     378#ifndef VBOX_FOR_DTRACE_LIB
     379    CPUMMICROARCH   enmMicroarch;
     380#else
     381    uint32_t        enmMicroarch;
     382#endif
    383383    /** The CPU vendor (CPUMCPUVENDOR). */
    384384    uint8_t         enmCpuVendor;
     385    /** The maximum physical address width of the CPU. */
     386    uint8_t         cMaxPhysAddrWidth;
     387    /** The maximum linear address width of the CPU. */
     388    uint8_t         cMaxLinearAddrWidth;
     389
    385390    /** The CPU family. */
    386391    uint8_t         uFamily;
     
    389394    /** The CPU stepping. */
    390395    uint8_t         uStepping;
    391     /** The microarchitecture. */
    392 #ifndef VBOX_FOR_DTRACE_LIB
    393     CPUMMICROARCH   enmMicroarch;
    394 #else
    395     uint32_t        enmMicroarch;
    396 #endif
    397     /** The maximum physical address width of the CPU. */
    398     uint8_t         cMaxPhysAddrWidth;
    399     /** The maximum linear address width of the CPU. */
    400     uint8_t         cMaxLinearAddrWidth;
    401396    /** Max size of the extended state (or FPU state if no XSAVE). */
    402397    uint16_t        cbMaxExtendedState;
     
    844839    /** VMX: Padding / reserved for future, making it a total of 128 bits.  */
    845840    uint32_t        fVmxPadding1;
     841    uint32_t        auPadding[4];
    846842} CPUMFEATURESX86;
    847843#ifndef VBOX_FOR_DTRACE_LIB
    848 AssertCompileSize(CPUMFEATURESX86, 48);
     844AssertCompileSize(CPUMFEATURESX86, 64);
    849845AssertCompileMembersAtSameOffset(CPUMFEATURESCOMMON, enmCpuVendor,          CPUMFEATURESX86, enmCpuVendor);
    850 AssertCompileMembersAtSameOffset(CPUMFEATURESCOMMON, uFamily,               CPUMFEATURESX86, uFamily);
    851 AssertCompileMembersAtSameOffset(CPUMFEATURESCOMMON, uModel,                CPUMFEATURESX86, uModel);
    852 AssertCompileMembersAtSameOffset(CPUMFEATURESCOMMON, uStepping,             CPUMFEATURESX86, uStepping);
    853846AssertCompileMembersAtSameOffset(CPUMFEATURESCOMMON, enmMicroarch,          CPUMFEATURESX86, enmMicroarch);
    854847AssertCompileMembersAtSameOffset(CPUMFEATURESCOMMON, cMaxPhysAddrWidth,     CPUMFEATURESX86, cMaxPhysAddrWidth);
     
    863856typedef struct CPUMFEATURESARMV8
    864857{
    865     /** The CPU vendor (CPUMCPUVENDOR). */
    866     uint8_t         enmCpuVendor;
    867     /** The CPU family. */
    868     uint8_t         uFamily;
    869     /** The CPU model. */
    870     uint8_t         uModel;
    871     /** The CPU stepping. */
    872     uint8_t         uStepping;
    873858    /** The microarchitecture. */
    874859#ifndef VBOX_FOR_DTRACE_LIB
     
    877862    uint32_t        enmMicroarch;
    878863#endif
     864    /** The CPU vendor (CPUMCPUVENDOR). */
     865    uint8_t         enmCpuVendor;
    879866    /** The maximum physical address width of the CPU. */
    880867    uint8_t         cMaxPhysAddrWidth;
    881868    /** The maximum linear address width of the CPU. */
    882869    uint8_t         cMaxLinearAddrWidth;
    883     uint16_t        uPadding;
     870
     871    /** The CPU implementer value (from MIDR_EL1). */
     872    uint8_t         uImplementeter;
     873    /** The CPU part number (from MIDR_EL1). */
     874    uint16_t        uPartNum;
     875    /** The CPU variant (from MIDR_EL1). */
     876    uint8_t         uVariant;
     877    /** The CPU revision (from MIDR_EL1). */
     878    uint8_t         uRevision;
    884879
    885880    /** @name Granule sizes supported.
     
    13951390    /** @} */
    13961391
    1397     /** Padding to the required size to match CPUMFEATURES for x86/amd64. */
    1398     uint8_t         abPadding[4];
     1392    /** Padding to the required size to match CPUMFEATURESX86. */
     1393    uint32_t        auPadding[5];
    13991394} CPUMFEATURESARMV8;
    14001395#ifndef VBOX_FOR_DTRACE_LIB
    1401 AssertCompileSize(CPUMFEATURESARMV8, 48);
     1396AssertCompileSize(CPUMFEATURESARMV8, 64);
     1397AssertCompileMembersAtSameOffset(CPUMFEATURESCOMMON, enmMicroarch,          CPUMFEATURESARMV8, enmMicroarch);
    14021398AssertCompileMembersAtSameOffset(CPUMFEATURESCOMMON, enmCpuVendor,          CPUMFEATURESARMV8, enmCpuVendor);
    1403 AssertCompileMembersAtSameOffset(CPUMFEATURESCOMMON, uFamily,               CPUMFEATURESARMV8, uFamily);
    1404 AssertCompileMembersAtSameOffset(CPUMFEATURESCOMMON, uModel,                CPUMFEATURESARMV8, uModel);
    1405 AssertCompileMembersAtSameOffset(CPUMFEATURESCOMMON, uStepping,             CPUMFEATURESARMV8, uStepping);
    1406 AssertCompileMembersAtSameOffset(CPUMFEATURESCOMMON, enmMicroarch,          CPUMFEATURESARMV8, enmMicroarch);
    14071399AssertCompileMembersAtSameOffset(CPUMFEATURESCOMMON, cMaxPhysAddrWidth,     CPUMFEATURESARMV8, cMaxPhysAddrWidth);
    14081400AssertCompileMembersAtSameOffset(CPUMFEATURESCOMMON, cMaxLinearAddrWidth,   CPUMFEATURESARMV8, cMaxLinearAddrWidth);
     
    14361428                    s;
    14371429} CPUHOSTFEATURES;
     1430#ifndef VBOX_FOR_DTRACE_LIB
     1431AssertCompileSize(CPUHOSTFEATURES, 64);
     1432#endif
    14381433/** Pointer to a const host CPU feature structure. */
    14391434typedef CPUHOSTFEATURES const *PCCPUHOSTFEATURES;
     
    14581453
    14591454
     1455
     1456/**
     1457 * ARMv8 CPU ID registers.
     1458 */
     1459typedef struct CPUMARMV8IDREGS
     1460{
     1461    /** Content of the ID_AA64PFR0_EL1 register. */
     1462    uint64_t        u64RegIdAa64Pfr0El1;
     1463    /** Content of the ID_AA64PFR1_EL1 register. */
     1464    uint64_t        u64RegIdAa64Pfr1El1;
     1465    /** Content of the ID_AA64DFR0_EL1 register. */
     1466    uint64_t        u64RegIdAa64Dfr0El1;
     1467    /** Content of the ID_AA64DFR1_EL1 register. */
     1468    uint64_t        u64RegIdAa64Dfr1El1;
     1469    /** Content of the ID_AA64AFR0_EL1 register. */
     1470    uint64_t        u64RegIdAa64Afr0El1;
     1471    /** Content of the ID_AA64AFR1_EL1 register. */
     1472    uint64_t        u64RegIdAa64Afr1El1;
     1473    /** Content of the ID_AA64ISAR0_EL1 register. */
     1474    uint64_t        u64RegIdAa64Isar0El1;
     1475    /** Content of the ID_AA64ISAR1_EL1 register. */
     1476    uint64_t        u64RegIdAa64Isar1El1;
     1477    /** Content of the ID_AA64ISAR2_EL1 register. */
     1478    uint64_t        u64RegIdAa64Isar2El1;
     1479    /** Content of the ID_AA64MMFR0_EL1 register. */
     1480    uint64_t        u64RegIdAa64Mmfr0El1;
     1481    /** Content of the ID_AA64MMFR1_EL1 register. */
     1482    uint64_t        u64RegIdAa64Mmfr1El1;
     1483    /** Content of the ID_AA64MMFR2_EL1 register. */
     1484    uint64_t        u64RegIdAa64Mmfr2El1;
     1485    /** Content of the CLIDR_EL1 register. */
     1486    uint64_t        u64RegClidrEl1;
     1487    /** Content of the CTR_EL0 register. */
     1488    uint64_t        u64RegCtrEl0;
     1489    /** Content of the DCZID_EL0 register. */
     1490    uint64_t        u64RegDczidEl0;
     1491    /** @todo we need MIDR_EL1 here, possibly also MPIDR_EL1 and REVIDR_EL1. */
     1492} CPUMARMV8IDREGS;
     1493/** Pointer to CPU ID registers. */
     1494typedef CPUMARMV8IDREGS *PCPUMARMV8IDREGS;
     1495/** Pointer to a const CPU ID registers structure. */
     1496typedef CPUMARMV8IDREGS const *PCCPUMARMV8IDREGS;
     1497
     1498
    14601499/*
    14611500 * Include the target specific header.
     
    14991538VMMDECL(CPUMMICROARCH)  CPUMGetHostMicroarch(PCVM pVM);
    15001539
     1540VMMDECL(const char *)   CPUMMicroarchName(CPUMMICROARCH enmMicroarch);
     1541VMMDECL(const char *)   CPUMCpuVendorName(CPUMCPUVENDOR enmVendor);
     1542
     1543VMMDECL(CPUMCPUVENDOR)  CPUMCpuIdDetectX86VendorEx(uint32_t uEAX, uint32_t uEBX, uint32_t uECX, uint32_t uEDX);
     1544#if defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)
     1545VMMDECL(int)            CPUMCpuIdCollectLeavesFromX86Host(PCPUMCPUIDLEAF *ppaLeaves, uint32_t *pcLeaves);
     1546#endif
     1547#if defined(RT_ARCH_ARM64)
     1548VMMDECL(int)            CPUMCpuIdCollectIdRegistersFromArmV8Host(PCPUMARMV8IDREGS pIdRegs);
     1549#endif
     1550
    15011551#ifdef IN_RING3
    15021552/** @defgroup grp_cpum_r3    The CPUM ring-3 API
     
    15121562VMMR3DECL(void)         CPUMR3ResetCpu(PVM pVM, PVMCPU pVCpu);
    15131563VMMDECL(bool)           CPUMR3IsStateRestorePending(PVM pVM);
    1514 VMMDECL(const char *)       CPUMMicroarchName(CPUMMICROARCH enmMicroarch);
    1515 VMMR3DECL(const char *)     CPUMCpuVendorName(CPUMCPUVENDOR enmVendor);
    15161564
    15171565VMMR3DECL(uint32_t)         CPUMR3DbGetEntries(void);
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