VirtualBox

Changeset 13789 in vbox


Ignore:
Timestamp:
Nov 4, 2008 3:42:49 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
38775
Message:

VMM: Ring-0 initializes VM::cCPUs, VMR3CreateVM validates i'ts input before doing anything, and use AssertLogRel.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VM.cpp

    r13785 r13789  
    207207        fGlobalInitDone = true;
    208208    }
     209
     210    /*
     211     * Validate input.
     212     */
     213#ifdef VBOX_WITH_SMP_GUESTS
     214    AssertLogRelMsgReturn(cCPUs > 0 && cCPUs <= VMCPU_MAX_CPU_COUNT, ("%RU32\n", cCPUs), VERR_INVALID_PARAMETER);
     215#else
     216    AssertLogRelMsgReturn(cCPUs == 1, ("%RU32\n", cCPUs), VERR_INVALID_PARAMETER);
     217#endif
    209218
    210219    /*
     
    483492        AssertRelease(pVM->pVMR0 == CreateVMReq.pVMR0);
    484493        AssertRelease(pVM->pSession == pUVM->vm.s.pSession);
    485 
    486         Log(("VMR3Create: Created pUVM=%p pVM=%p pVMR0=%p hSelf=%#x \n", pUVM, pVM, pVM->pVMR0, pVM->hSelf));
     494        AssertRelease(pVM->cCPUs == cCPUs);
     495
     496        Log(("VMR3Create: Created pUVM=%p pVM=%p pVMR0=%p hSelf=%#x cCPUs=%RU32\n",
     497             pUVM, pVM, pVM->pVMR0, pVM->hSelf, pVM->cCPUs));
    487498
    488499        /*
     
    491502        pVM->pUVM = pUVM;
    492503        pVM->NativeThreadEMT = pUVM->aCpu[0].vm.s.NativeThreadEMT;
    493 
    494         for (unsigned i=0;i<pVM->cCPUs;i++)
     504        pVM->offVMCPU = RT_OFFSETOF(VM, aCpu);
     505
     506        for (uint32_t i = 0; i < pVM->cCPUs; i++)
    495507        {
    496508            pVM->aCpu[i].hNativeThread = pUVM->aCpu[i].vm.s.NativeThreadEMT;
    497             Assert(pVM->aCpu[i].hNativeThread!= NIL_RTNATIVETHREAD);
     509            Assert(pVM->aCpu[i].hNativeThread != NIL_RTNATIVETHREAD);
    498510        }
     511
    499512
    500513        /*
     
    516529            }
    517530
    518             /* Calculate the offset to the VMCPU array. */
    519             pVM->offVMCPU = RT_OFFSETOF(VM, aCpu);
    520 
    521             /* Make sure the CPU count in the config data matches. */
    522             rc = CFGMR3QueryU32Def(CFGMR3GetRoot(pVM), "NumCPUs", &pVM->cCPUs, 1);
    523             AssertMsgRC(rc, ("Configuration error: Querying \"NumCPUs\" as integer failed, rc=%Vrc\n", rc));
    524             Assert(pVM->cCPUs == cCPUs);
    525 
    526 #ifdef VBOX_WITH_SMP_GUESTS
    527             AssertMsg(pVM->cCPUs > 0 && pVM->cCPUs <= VMCPU_MAX_CPU_COUNT,
    528                       ("Configuration error: \"NumCPUs\"=%RU32 is out of range [1..255]\n", pVM->cCPUs));
    529 #else
    530             AssertMsg(pVM->cCPUs != 0,
    531                       ("Configuration error: \"NumCPUs\"=%RU32, expected 1\n", pVM->cCPUs));
    532 #endif
    533             if (pVM->cCPUs != cCPUs)
     531            /*
     532             * Make sure the CPU count in the config data matches.
     533             */
     534            uint32_t cCPUsCfg;
     535            rc = CFGMR3QueryU32Def(CFGMR3GetRoot(pVM), "NumCPUs", &cCPUsCfg, 1);
     536            AssertLogRelMsgRC(rc, ("Configuration error: Querying \"NumCPUs\" as integer failed, rc=%Rrc\n", rc));
     537            if (RT_SUCCESS(rc) && cCPUsCfg != cCPUs)
     538            {
     539                AssertLogRelMsgFailed(("Configuration error: \"NumCPUs\"=%RU32 and VMR3CreateVM::cCPUs=%RU32 does not match!\n",
     540                                       cCPUsCfg, cCPUs));
    534541                rc = VERR_INVALID_PARAMETER;
    535             else
    536 #ifdef VBOX_WITH_SMP_GUESTS
    537             if (pVM->cCPUs == 0 || pVM->cCPUs > VMCPU_MAX_CPU_COUNT)
    538                 rc = VERR_INVALID_PARAMETER;
    539 #else
    540             if (pVM->cCPUs != 1)
    541                 rc = VERR_INVALID_PARAMETER;
    542 #endif
     542            }
    543543            if (VBOX_SUCCESS(rc))
    544544            {
  • trunk/src/VBox/VMM/VMMR0/GVMMR0.cpp

    r13751 r13789  
    587587                            pVM->hSelf      = iHandle;
    588588                            pVM->cbSelf     = cbVM;
     589                            pVM->cCPUs      = cCPUs;
    589590
    590591                            rc = RTR0MemObjAllocPage(&pGVM->gvmm.s.VMPagesMemObj, cPages * sizeof(SUPPAGE), false /* fExecutable */);
     
    609610                                    AssertPtr((void *)pVM->pVMR3);
    610611
    611                                     /** Initialize all the VM pointers. */
    612                                     for (unsigned i=0;i<cCPUs;i++)
     612                                    /* Initialize all the VM pointers. */
     613                                    for (uint32_t i = 0; i < cCPUs; i++)
    613614                                    {
    614615                                        pVM->aCpu[i].pVMR0 = pVM;
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