VirtualBox

Changeset 6796 in vbox for trunk/src/VBox/VMM/MM.cpp


Ignore:
Timestamp:
Feb 4, 2008 6:19:58 PM (17 years ago)
Author:
vboxsync
Message:

Fixed init problems wrt. VM ownership by implementing the UVM structure (U = user mode) and moving problematic ring-3 stuff over there (emt+reqs, r3heap, stam, loader[VMMR0.r0]). Big change, but it works fine here... :-)

File:
1 edited

Legend:

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

    r6634 r6796  
    8888#include "MMInternal.h"
    8989#include <VBox/vm.h>
     90#include <VBox/uvm.h>
    9091#include <VBox/err.h>
    9192#include <VBox/param.h>
     
    107108*   Internal Functions                                                         *
    108109*******************************************************************************/
    109 static int mmR3Term(PVM pVM, bool fKeepTheHeap);
    110110static DECLCALLBACK(int) mmR3Save(PVM pVM, PSSMHANDLE pSSM);
    111111static DECLCALLBACK(int) mmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version);
    112112
     113
     114/**
     115 * Initializes the MM members of the UVM.
     116 *
     117 * This is currently only the ring-3 heap.
     118 *
     119 * @returns VBox status code.
     120 * @param   pUVM    Pointer to the user mode VM structure.
     121 */
     122MMR3DECL(int) MMR3InitUVM(PUVM pUVM)
     123{
     124    /*
     125     * Assert sizes and order.
     126     */
     127    AssertCompile(sizeof(pUVM->mm.s) <= sizeof(pUVM->mm.padding));
     128    AssertRelease(sizeof(pUVM->mm.s) <= sizeof(pUVM->mm.padding));
     129    Assert(!pUVM->mm.s.pHeap);
     130
     131    /*
     132     * Init the heap.
     133     */
     134    return mmR3HeapCreateU(pUVM, &pUVM->mm.s.pHeap);
     135}
    113136
    114137
     
    147170    pVM->mm.s.offVM = RT_OFFSETOF(VM, mm);
    148171    pVM->mm.s.offLookupHyper = NIL_OFFSET;
    149 
    150     /*
    151      * Init the heap (may already be initialized already if someone used it).
    152      */
    153     if (!pVM->mm.s.pHeap)
    154     {
    155         int rc = mmR3HeapCreate(pVM, &pVM->mm.s.pHeap);
    156         if (!VBOX_SUCCESS(rc))
    157             return rc;
    158     }
    159172
    160173    /*
     
    182195        }
    183196    }
    184     mmR3Term(pVM, true /* keep the heap */);
     197    MMR3Term(pVM);
    185198    return rc;
    186199}
     
    346359 */
    347360MMR3DECL(int) MMR3Term(PVM pVM)
    348 {
    349     return mmR3Term(pVM, false /* free the heap */);
    350 }
    351 
    352 
    353 /**
    354  * Worker for MMR3Term and MMR3Init.
    355  *
    356  * The tricky bit here is that we must not destroy the heap if we're
    357  * called from MMR3Init, otherwise we'll get into trouble when
    358  * CFGMR3Term is called later in the bailout process.
    359  *
    360  * @returns VBox status code.
    361  * @param   pVM             The VM to operate on.
    362  * @param   fKeepTheHeap    Whether or not to keep the heap.
    363  */
    364 static int mmR3Term(PVM pVM, bool fKeepTheHeap)
    365361{
    366362    /*
     
    395391
    396392    /*
    397      * Destroy the heap if requested.
    398      */
    399     if (!fKeepTheHeap)
    400     {
    401         mmR3HeapDestroy(pVM->mm.s.pHeap);
    402         pVM->mm.s.pHeap = NULL;
    403     }
    404 
    405     /*
    406393     * Zero stuff to detect after termination use of the MM interface
    407394     */
     
    413400
    414401    return 0;
     402}
     403
     404
     405/**
     406 * Terminates the UVM part of MM.
     407 *
     408 * Termination means cleaning up and freeing all resources,
     409 * the VM it self is at this point powered off or suspended.
     410 *
     411 * @returns VBox status code.
     412 * @param   pUVM        Pointer to the user mode VM structure.
     413 */
     414MMR3DECL(void) MMR3TermUVM(PUVM pUVM)
     415{
     416    /*
     417     * Destroy the heap.
     418     */
     419    mmR3HeapDestroy(pUVM->mm.s.pHeap);
     420    pUVM->mm.s.pHeap = NULL;
    415421}
    416422
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