VirtualBox

Changeset 22042 in vbox


Ignore:
Timestamp:
Aug 6, 2009 4:58:57 PM (16 years ago)
Author:
vboxsync
Message:

VMM: refactor CPUID limitation, passed OSType

Location:
trunk
Files:
5 edited

Legend:

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

    r22037 r22042  
    692692    uint32_t                    offVMCPU;
    693693
    694     /** Maximum CPUID leaf, exposed to this VM. */
    695     uint32_t                    cCpuidLeafs;
    696 
    697694    /** Reserved; alignment. */
    698     uint32_t                    u32Reserved[5];
     695    uint32_t                    u32Reserved[6];
    699696
    700697    /** @name Public VMM Switcher APIs
  • trunk/include/VBox/vm.mac

    r22037 r22042  
    5959    .cbSelf                 resd 1
    6060    .offVMCPU               resd 1
    61     .cCpuidLeafs            resd 1
    62     .u32Reserved            resd 5
     61    .u32Reserved            resd 6
    6362
    6463    .pfnVMMGCGuestToHostAsmGuestCtx RTRCPTR_RES 1
  • trunk/src/VBox/Main/ConsoleImpl2.cpp

    r22037 r22042  
    212212    hrc = pMachine->COMGETTER(CPUCount)(&cCpus);                                    H();
    213213
    214     ULONG cCpuidLeafs = 5;
    215214    Bstr osTypeId;
    216215    hrc = pMachine->COMGETTER(OSTypeId)(osTypeId.asOutParam());                     H();
    217     if (osTypeId == "WindowsNT4")
    218     {
    219         /*
    220          * We must limit CPUID count for Windows NT 4 manually,
    221          * as otherwise it stops with 0x3e error
    222          * (MULTIPROCESSOR_CONFIGURATION_NOT_SUPPORTED).
    223          */
    224         LogRel(("Limiting CPUID leaf count for NT4 guests\n"));
    225         cCpuidLeafs = 2;
    226     }
    227216
    228217    /*
     
    244233    rc = CFGMR3InsertInteger(pRoot, "RamHoleSize",          cbRamHole);             RC_CHECK();
    245234    rc = CFGMR3InsertInteger(pRoot, "NumCPUs",              cCpus);                 RC_CHECK();
    246     rc = CFGMR3InsertInteger(pRoot, "CpuidLeafs",           cCpuidLeafs);           RC_CHECK();
     235    rc = CFGMR3InsertString (pRoot, "OSType",               Utf8Str(osTypeId));     RC_CHECK();
    247236    rc = CFGMR3InsertInteger(pRoot, "TimerMillies",         10);                    RC_CHECK();
    248237    rc = CFGMR3InsertInteger(pRoot, "RawR3Enabled",         1);     /* boolean */   RC_CHECK();
     
    251240    rc = CFGMR3InsertInteger(pRoot, "PATMEnabled",          1);     /* boolean */   RC_CHECK();
    252241    rc = CFGMR3InsertInteger(pRoot, "CSAMEnabled",          1);     /* boolean */   RC_CHECK();
     242
     243    if (osTypeId == "WindowsNT4")
     244    {
     245        /*
     246         * We must limit CPUID count for Windows NT 4,
     247         * as otherwise it stops with 0x3e error
     248         * (MULTIPROCESSOR_CONFIGURATION_NOT_SUPPORTED).
     249         */
     250        LogRel(("Limiting CPUID leaf count for NT4 guests\n"));
     251        rc = CFGMR3InsertInteger(pRoot, "NT4LeafLimit", true);                          RC_CHECK();
     252    }
    253253
    254254    /* hardware virtualization extensions */
  • trunk/src/VBox/VMM/CPUM.cpp

    r22037 r22042  
    534534     * info too in these leaves (like words about having a constant TSC).
    535535     */
    536     if (pCPUM->aGuestCpuIdStd[0].eax > pVM->cCpuidLeafs)
    537         pCPUM->aGuestCpuIdStd[0].eax = pVM->cCpuidLeafs;
     536    {
     537        bool fNt4LeafLimit;
     538        PCFGMNODE pNode = CFGMR3GetRoot(pVM);
     539        int rc = CFGMR3QueryBoolDef(pNode, "NT4LeafLimit", &fNt4LeafLimit, false);
     540        if (RT_SUCCESS(rc) && fNt4LeafLimit)
     541            pCPUM->aGuestCpuIdStd[0].eax = 2;
     542    }
     543    if (pCPUM->aGuestCpuIdStd[0].eax > 5)
     544        pCPUM->aGuestCpuIdStd[0].eax = 5;
    538545
    539546    for (i = pCPUM->aGuestCpuIdStd[0].eax + 1; i < RT_ELEMENTS(pCPUM->aGuestCpuIdStd); i++)
     
    11211128                              );
    11221129
    1123         /* Make sure we don't forget to update the masks when enabling 
    1124          * features in the future. 
     1130        /* Make sure we don't forget to update the masks when enabling
     1131         * features in the future.
    11251132         */
    1126         AssertRelease(!(pVM->cpum.s.aGuestCpuIdStd[1].ecx & 
     1133        AssertRelease(!(pVM->cpum.s.aGuestCpuIdStd[1].ecx &
    11271134                              (   X86_CPUID_FEATURE_ECX_DTES64
    11281135                               |  X86_CPUID_FEATURE_ECX_VMX
  • trunk/src/VBox/VMM/VM.cpp

    r22037 r22042  
    594594                    rc = VERR_INVALID_PARAMETER;
    595595                }
    596             }
    597             /*
    598              * Set correct CPUID leafs limit, some guests types,
    599              * notably Win NT 4.0 may wish to override this value.
    600              */
    601             if (RT_SUCCESS(rc))
    602             {
    603                  uint32_t cCpuidLeafs;
    604                  rc = CFGMR3QueryU32Def(CFGMR3GetRoot(pVM), "CpuidLeafs", &cCpuidLeafs, 5);
    605                  pVM->cCpuidLeafs = cCpuidLeafs;
    606596            }
    607597            if (RT_SUCCESS(rc))
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