VirtualBox

Changeset 52247 in vbox


Ignore:
Timestamp:
Jul 31, 2014 1:49:15 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
95328
Message:

VMM/GIM: Keep Minimal GIM provider guest agnostic.

Location:
trunk
Files:
6 edited

Legend:

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

    r52006 r52247  
    4242 * @{
    4343 */
    44 
    45 /**
    46  * GIM Guest OS type Identifiers.
    47  *
    48  * Warning!! The enum values -must- be contiguous for less-than/greater-than
    49  * range comparisons while casting from uint32_t.
    50  *
    51  * When adding OS X guest IDs, make sure to update GIMR3IsOSXGuest().
    52  */
    53 typedef enum GIMOSID
    54 {
    55     GIMOSID_UNKNOWN = 0,
    56     GIMOSID_OSX,
    57     GIMOSID_OSX_64,
    58     GIMOSID_OSX_106,
    59     GIMOSID_OSX_106_64,
    60     GIMOSID_OSX_107,
    61     GIMOSID_OSX_107_64,
    62     GIMOSID_OSX_108,
    63     GIMOSID_OSX_108_64,
    64     GIMOSID_OSX_109,
    65     GIMOSID_OSX_109_64,
    66     /** End of valid Guest IDs. */
    67     GIMOSID_END
    68 } GIMOSID;
    69 AssertCompileSize(GIMOSID, sizeof(uint32_t));
    70 
    7144
    7245/**
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r52090 r52247  
    6767#include <VBox/vmm/pdmapi.h> /* For PDMR3DriverAttach/PDMR3DriverDetach. */
    6868#include <VBox/vmm/pdmusb.h> /* For PDMR3UsbCreateEmulatedDevice. */
    69 #include <VBox/vmm/gim.h>    /* For GIMOSID. */
    7069#include <VBox/version.h>
    7170#include <VBox/HostServices/VBoxClipboardSvc.h>
     
    10031002        }
    10041003
     1004        if (fOsXGuest)
     1005        {
     1006            /* Expose extended MWAIT features to Mac OS X guests. */
     1007            LogRel(("Using MWAIT extensions\n"));
     1008            InsertConfigInteger(pCPUM, "MWaitExtensions", true);
     1009
     1010            /* Fake the CPU family/model so the guest works.  This is partly
     1011               because older mac releases really doesn't work on newer cpus,
     1012               and partly because mac os x expects more from systems with newer
     1013               cpus (MSRs, power features, whatever). */
     1014            uint32_t uMaxIntelFamilyModelStep = UINT32_MAX;
     1015            if (   osTypeId == "MacOS"
     1016                || osTypeId == "MacOS_64")
     1017                uMaxIntelFamilyModelStep = RT_MAKE_U32_FROM_U8(1, 23, 6, 7); /* Penryn / X5482. */
     1018            else if (   osTypeId == "MacOS106"
     1019                     || osTypeId == "MacOS106_64")
     1020                uMaxIntelFamilyModelStep = RT_MAKE_U32_FROM_U8(1, 23, 6, 7); /* Penryn / X5482 */
     1021            else if (   osTypeId == "MacOS107"
     1022                     || osTypeId == "MacOS107_64")
     1023                uMaxIntelFamilyModelStep = RT_MAKE_U32_FROM_U8(1, 23, 6, 7); /* Penryn / X5482 */ /** @todo figure out
     1024                                                                                what is required here. */
     1025            else if (   osTypeId == "MacOS108"
     1026                     || osTypeId == "MacOS108_64")
     1027                uMaxIntelFamilyModelStep = RT_MAKE_U32_FROM_U8(1, 23, 6, 7); /* Penryn / X5482 */ /** @todo figure out
     1028                                                                                what is required here. */
     1029            else if (   osTypeId == "MacOS109"
     1030                     || osTypeId == "MacOS109_64")
     1031                uMaxIntelFamilyModelStep = RT_MAKE_U32_FROM_U8(1, 23, 6, 7); /* Penryn / X5482 */ /** @todo figure
     1032                                                                                out what is required here. */
     1033            if (uMaxIntelFamilyModelStep != UINT32_MAX)
     1034                InsertConfigInteger(pCPUM, "MaxIntelFamilyModelStep", uMaxIntelFamilyModelStep);
     1035        }
     1036
    10051037        /* Synthetic CPU */
    10061038        BOOL fSyntheticCpu = false;
     
    11781210        }
    11791211        InsertConfigString(pParavirtNode, "Provider", pcszParavirtProvider);
    1180 
    1181         if (   !RTStrCmp(pcszParavirtProvider, "Minimal")
    1182             && fOsXGuest)
    1183         {
    1184             /* When adding new OS X types, please add corresponding types to GIMOSID and
    1185                update GIMR3IsOSXGuest().  */
    1186             GIMOSID enmOsId = GIMOSID_OSX;
    1187             if (osTypeId == "MacOS_64")
    1188                 enmOsId = GIMOSID_OSX_64;
    1189             else if (osTypeId == "MacOS106")
    1190                 enmOsId = GIMOSID_OSX_106;
    1191             else if (osTypeId == "MacOS106_64")
    1192                 enmOsId = GIMOSID_OSX_106_64;
    1193             else if (osTypeId == "MacOS107")
    1194                 enmOsId = GIMOSID_OSX_107;
    1195             else if (osTypeId == "MacOS107_64")
    1196                 enmOsId = GIMOSID_OSX_107_64;
    1197             else if (osTypeId == "MacOS108")
    1198                 enmOsId = GIMOSID_OSX_108;
    1199             else if (osTypeId == "MacOS108_64")
    1200                 enmOsId = GIMOSID_OSX_108_64;
    1201 
    1202             InsertConfigInteger(pParavirtNode, "GuestOsId", enmOsId);
    1203         }
    1204 
    12051212
    12061213        /*
  • trunk/src/VBox/VMM/VMMR3/CPUM.cpp

    r51832 r52247  
    16861686     * Mini CPU selection support for making Mac OS X happy.
    16871687     */
    1688     /** @todo This should probably be removed, as GIM Minimal provider does this
    1689      *        work. */
    16901688    if (pCPUM->GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_INTEL)
    16911689    {
  • trunk/src/VBox/VMM/VMMR3/GIM.cpp

    r52110 r52247  
    115115    AssertLogRelRCReturn(rc, rc);
    116116
    117     /** @cfgm{GIM/GuestOsId, uint32_t}
    118      * The guest OS identifier. The default is 0, implying an unknown Guest OS. */
    119     GIMOSID GuestOsId = GIMOSID_END;
    120     uint32_t uGuestOsId;
    121     rc = CFGMR3QueryU32Def(pCfgNode, "GuestOsId", &uGuestOsId, GIMOSID_UNKNOWN);
    122     AssertLogRelRCReturn(rc, rc);
    123     if (uGuestOsId < GIMOSID_END)
    124     {
    125         GuestOsId = (GIMOSID)uGuestOsId;
    126         pVM->gim.s.enmGuestOsId = GuestOsId;
    127     }
    128     else
    129     {
    130         LogRel(("GIM: GuestOsId %u invalid.", uGuestOsId));
    131         return VERR_GIM_INVALID_GUESTOS_ID;
    132     }
    133 
    134117    /*
    135118     * Setup the GIM provider for this VM.
     
    270253    rc = SSMR3PutU32(pSSM, pVM->gim.s.u32Version);
    271254    AssertRCReturn(rc, rc);
    272     rc = SSMR3PutU32(pSSM, pVM->gim.s.enmGuestOsId);
    273     AssertRCReturn(rc, rc);
    274255
    275256    /*
     
    325306    AssertRCReturn(rc, rc);
    326307    rc = SSMR3GetU32(pSSM, &pVM->gim.s.u32Version);
    327     AssertRCReturn(rc, rc);
    328     rc = SSMR3GetU32(pSSM, (uint32_t *)&pVM->gim.s.enmGuestOsId);
    329308    AssertRCReturn(rc, rc);
    330309
     
    608587#endif
    609588
    610 
    611 /**
    612  * Checks if the GIM Guest OS identifier for this VM implies an OS X family of
    613  * guests.
    614  *
    615  * @returns true if it's an OS X guest, false otherwise.
    616  * @param   pVM         Pointer to the VM.
    617  */
    618 VMMR3_INT_DECL(bool) GIMR3IsOSXGuest(PVM pVM)
    619 {
    620     switch (pVM->gim.s.enmGuestOsId)
    621     {
    622         case GIMOSID_OSX:
    623         case GIMOSID_OSX_64:
    624         case GIMOSID_OSX_106:
    625         case GIMOSID_OSX_106_64:
    626         case GIMOSID_OSX_107:
    627         case GIMOSID_OSX_107_64:
    628         case GIMOSID_OSX_108:
    629         case GIMOSID_OSX_108_64:
    630         case GIMOSID_OSX_109:
    631         case GIMOSID_OSX_109_64:
    632         {
    633             return true;
    634         }
    635 
    636         default:    /* shut up gcc */
    637             break;
    638     }
    639     return false;
    640 }
    641 
  • trunk/src/VBox/VMM/VMMR3/GIMMinimal.cpp

    r52110 r52247  
    4343    CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_HVP);
    4444
    45     if (GIMR3IsOSXGuest(pVM))
    46     {
    47         /*
    48          * Enable MWAIT Extensions for OS X Guests.
    49          */
    50         CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_MWAIT_EXTS);
    51 
    52         /*
    53          * Fake the CPU family/model so the guest works. This is partly because older
    54          * Mac releases really doesn't work on newer CPUs, and partly because OS X
    55          * expects more from systems with newer CPUs (MSRs, power features etc.)
    56          */
    57         if (CPUMGetGuestCpuVendor(pVM) == CPUMCPUVENDOR_INTEL)
    58         {
    59             uint32_t uMaxIntelFamilyModelStep = UINT32_MAX;
    60             switch (pVM->gim.s.enmGuestOsId)
    61             {
    62                 case GIMOSID_OSX:
    63                 case GIMOSID_OSX_64:
    64                     uMaxIntelFamilyModelStep = RT_MAKE_U32_FROM_U8(1, 23, 6, 7); /* Penryn / X5482. */
    65                     break;
    66 
    67                 case GIMOSID_OSX_106:
    68                 case GIMOSID_OSX_106_64:
    69                     uMaxIntelFamilyModelStep = RT_MAKE_U32_FROM_U8(1, 23, 6, 7); /* Penryn / X5482 */
    70                     break;
    71 
    72                 case GIMOSID_OSX_107:
    73                 case GIMOSID_OSX_107_64:
    74                     /** @todo Figure out what is required here. */
    75                     uMaxIntelFamilyModelStep = RT_MAKE_U32_FROM_U8(1, 23, 6, 7); /* Penryn / X5482 */
    76                     break;
    77 
    78                 case GIMOSID_OSX_108:
    79                 case GIMOSID_OSX_108_64:
    80                     /** @todo Figure out what is required here. */
    81                     uMaxIntelFamilyModelStep = RT_MAKE_U32_FROM_U8(1, 23, 6, 7); /* Penryn / X5482 */
    82                     break;
    83 
    84                 case GIMOSID_OSX_109:
    85                 case GIMOSID_OSX_109_64:
    86                     /** @todo Figure out what is required here. */
    87                     uMaxIntelFamilyModelStep = RT_MAKE_U32_FROM_U8(1, 23, 6, 7); /* Penryn / X5482 */
    88                     break;
    89 
    90                 default:    /* shut up gcc */
    91                     break;
    92             }
    93 
    94             if (uMaxIntelFamilyModelStep != UINT32_MAX)
    95             {
    96                 CPUMCPUIDLEAF Leaf;
    97                 int rc = CPUMR3CpuIdGetLeaf(pVM, &Leaf, 1, 0 /* uSubLeaf */);
    98                 if (RT_SUCCESS(rc))
    99                 {
    100                     uint32_t uCurIntelFamilyModelStep = RT_MAKE_U32_FROM_U8(ASMGetCpuStepping(Leaf.uEax),
    101                                                                             ASMGetCpuModelIntel(Leaf.uEax),
    102                                                                             ASMGetCpuFamily(Leaf.uEax),
    103                                                                             0);
    104                     if (uMaxIntelFamilyModelStep < uCurIntelFamilyModelStep)
    105                     {
    106                         uint32_t uNew = Leaf.uEax & UINT32_C(0xf0003000);
    107                         uNew |=  RT_BYTE1(uMaxIntelFamilyModelStep) & 0xf;          /* stepping */
    108                         uNew |= (RT_BYTE2(uMaxIntelFamilyModelStep) & 0xf) << 4;    /* 4 low model bits */
    109                         uNew |= (RT_BYTE2(uMaxIntelFamilyModelStep) >> 4) << 16;    /* 4 high model bits */
    110                         uNew |= (RT_BYTE3(uMaxIntelFamilyModelStep) & 0xf) << 8;    /* 4 low family bits */
    111                         /* 8 high family bits, Intel's suggested calculation. */
    112                         if (RT_BYTE3(uMaxIntelFamilyModelStep) > 0xf)
    113                         {
    114                             uNew |= (  (RT_BYTE3(uMaxIntelFamilyModelStep)
    115                                      - (RT_BYTE3(uMaxIntelFamilyModelStep) & 0xf)) & 0xff ) << 20;
    116                         }
    117 
    118                         LogRel(("GIM: Minimal: CPUID(0).EAX %#x -> %#x (uMaxIntelFamilyModelStep=%#x, uCurIntelFamilyModelStep=%#x\n",
    119                                 Leaf.uEax, uNew, uMaxIntelFamilyModelStep, uCurIntelFamilyModelStep));
    120                         Leaf.uEax = uNew;
    121                     }
    122 
    123                     rc = CPUMR3CpuIdInsert(pVM, &Leaf);
    124                     if (RT_FAILURE(rc))
    125                     {
    126                         LogRel(("GIM: Minimal: Failed to insert CPUID leaf for OS X guest. rc=%Rrc\n", rc));
    127                         return rc;
    128                     }
    129                 }
    130                 else
    131                 {
    132                     LogRel(("GIM: Minimal: Failed to retreive std. CPUID leaf. rc=%Rrc\n", rc));
    133                     return rc;
    134                 }
    135             }
    136         }
    137     }
    138 
    13945    return VINF_SUCCESS;
    14046}
  • trunk/src/VBox/VMM/include/GIMInternal.h

    r52110 r52247  
    4646    /** The interface implementation version. */
    4747    uint32_t                         u32Version;
    48     /** The Guest OS identifier. */
    49     GIMOSID                          enmGuestOsId;
    5048
    5149    /** Pointer to the GIM device - ring-3 context. */
Note: See TracChangeset for help on using the changeset viewer.

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