GMMR0Internal.h revision 9347f1987dfb760943aba5a9ef094c6066901be3
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync/* $Id$ */
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync/** @file
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync * GMM - The Global Memory Manager, Internal Header.
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync */
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync/*
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync * Copyright (C) 2007 Oracle Corporation
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync *
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync * available from http://www.virtualbox.org. This file is free software;
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync * you can redistribute it and/or modify it under the terms of the GNU
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * General Public License (GPL) as published by the Free Software
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync */
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync#ifndef ___GMMR0Internal_h
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync#define ___GMMR0Internal_h
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync#include <VBox/gmm.h>
5e31c5b77713d7c61de5f65f1c3d057dddaa27f3vboxsync#include <iprt/avl.h>
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync
1dc25926f76c463686b66fb6adec583eef0717advboxsync/**
1dc25926f76c463686b66fb6adec583eef0717advboxsync * The allocation sizes.
1dc25926f76c463686b66fb6adec583eef0717advboxsync */
1dc25926f76c463686b66fb6adec583eef0717advboxsynctypedef struct GMMVMSIZES
1dc25926f76c463686b66fb6adec583eef0717advboxsync{
1dc25926f76c463686b66fb6adec583eef0717advboxsync /** The number of pages of base memory.
1dc25926f76c463686b66fb6adec583eef0717advboxsync * This is the sum of RAM, ROMs and handy pages. */
1dc25926f76c463686b66fb6adec583eef0717advboxsync uint64_t cBasePages;
1dc25926f76c463686b66fb6adec583eef0717advboxsync /** The number of pages for the shadow pool. (Can be sequeezed for memory.) */
1dc25926f76c463686b66fb6adec583eef0717advboxsync uint32_t cShadowPages;
1dc25926f76c463686b66fb6adec583eef0717advboxsync /** The number of pages for fixed allocations like MMIO2 and the hyper heap. */
1dc25926f76c463686b66fb6adec583eef0717advboxsync uint32_t cFixedPages;
1dc25926f76c463686b66fb6adec583eef0717advboxsync} GMMVMSIZES;
209c11e4b5dbb310116c99a42d773163928e002bvboxsync/** Pointer to a GMMVMSIZES. */
1dc25926f76c463686b66fb6adec583eef0717advboxsynctypedef GMMVMSIZES *PGMMVMSIZES;
1dc25926f76c463686b66fb6adec583eef0717advboxsync
9347f1987dfb760943aba5a9ef094c6066901be3vboxsync
b2def6ea46868a11f7fd2857874e46c51932223avboxsync/**
b2def6ea46868a11f7fd2857874e46c51932223avboxsync * Shared module registration info (per VM)
b2def6ea46868a11f7fd2857874e46c51932223avboxsync */
b2def6ea46868a11f7fd2857874e46c51932223avboxsynctypedef struct GMMSHAREDMODULEPERVM
b2def6ea46868a11f7fd2857874e46c51932223avboxsync{
e4d7b580d72e968d3753363ab36e196a968c1947vboxsync /** Tree node. */
b2def6ea46868a11f7fd2857874e46c51932223avboxsync AVLGCPTRNODECORE Core;
b2def6ea46868a11f7fd2857874e46c51932223avboxsync
e4d7b580d72e968d3753363ab36e196a968c1947vboxsync /** Pointer to global shared module info. */
e4d7b580d72e968d3753363ab36e196a968c1947vboxsync PGMMSHAREDMODULE pGlobalModule;
b2def6ea46868a11f7fd2857874e46c51932223avboxsync
e4d7b580d72e968d3753363ab36e196a968c1947vboxsync /** Set if another VM registered a different shared module at the same base address. */
1084dfee3c44a35cbe9aef69158474a913a3e0d9vboxsync bool fCollision;
e4d7b580d72e968d3753363ab36e196a968c1947vboxsync /** Alignment. */
9347f1987dfb760943aba5a9ef094c6066901be3vboxsync bool bAlignment[3];
9347f1987dfb760943aba5a9ef094c6066901be3vboxsync
9347f1987dfb760943aba5a9ef094c6066901be3vboxsync /** Number of included region descriptors */
9347f1987dfb760943aba5a9ef094c6066901be3vboxsync uint32_t cRegions;
9347f1987dfb760943aba5a9ef094c6066901be3vboxsync
9347f1987dfb760943aba5a9ef094c6066901be3vboxsync /** Shared region descriptor(s). */
9347f1987dfb760943aba5a9ef094c6066901be3vboxsync GMMSHAREDREGIONDESC aRegions[1];
b2def6ea46868a11f7fd2857874e46c51932223avboxsync} GMMSHAREDMODULEPERVM;
b2def6ea46868a11f7fd2857874e46c51932223avboxsync/** Pointer to a GMMSHAREDMODULEPERVM. */
b2def6ea46868a11f7fd2857874e46c51932223avboxsynctypedef GMMSHAREDMODULEPERVM *PGMMSHAREDMODULEPERVM;
b2def6ea46868a11f7fd2857874e46c51932223avboxsync
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync/**
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync * The per-VM GMM data.
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync */
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsynctypedef struct GMMPERVM
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync{
1dc25926f76c463686b66fb6adec583eef0717advboxsync /** The reservations. */
5e31c5b77713d7c61de5f65f1c3d057dddaa27f3vboxsync GMMVMSIZES Reserved;
3cc114d9c84cf4a1e3b5225e81527614c30f1d83vboxsync /** The actual allocations.
3cc114d9c84cf4a1e3b5225e81527614c30f1d83vboxsync * This includes both private and shared page allocations. */
5e31c5b77713d7c61de5f65f1c3d057dddaa27f3vboxsync GMMVMSIZES Allocated;
3cc114d9c84cf4a1e3b5225e81527614c30f1d83vboxsync
1dc25926f76c463686b66fb6adec583eef0717advboxsync /** The current number of private pages. */
5e31c5b77713d7c61de5f65f1c3d057dddaa27f3vboxsync uint64_t cPrivatePages;
1dc25926f76c463686b66fb6adec583eef0717advboxsync /** The current number of shared pages. */
5e31c5b77713d7c61de5f65f1c3d057dddaa27f3vboxsync uint64_t cSharedPages;
3cc114d9c84cf4a1e3b5225e81527614c30f1d83vboxsync /** The current over-comitment policy. */
5e31c5b77713d7c61de5f65f1c3d057dddaa27f3vboxsync GMMOCPOLICY enmPolicy;
3cc114d9c84cf4a1e3b5225e81527614c30f1d83vboxsync /** The VM priority for arbitrating VMs in low and out of memory situation.
3cc114d9c84cf4a1e3b5225e81527614c30f1d83vboxsync * Like which VMs to start sequeezing first. */
5e31c5b77713d7c61de5f65f1c3d057dddaa27f3vboxsync GMMPRIORITY enmPriority;
3cc114d9c84cf4a1e3b5225e81527614c30f1d83vboxsync
1dc25926f76c463686b66fb6adec583eef0717advboxsync /** The current number of ballooned pages. */
5e31c5b77713d7c61de5f65f1c3d057dddaa27f3vboxsync uint64_t cBalloonedPages;
1dc25926f76c463686b66fb6adec583eef0717advboxsync /** The max number of pages that can be ballooned. */
5e31c5b77713d7c61de5f65f1c3d057dddaa27f3vboxsync uint64_t cMaxBalloonedPages;
1d5596b941d86a014c20420b73ad7be2de35cf9dvboxsync /** The number of pages we've currently requested the guest to give us.
1d5596b941d86a014c20420b73ad7be2de35cf9dvboxsync * This is 0 if no pages currently requested. */
5e31c5b77713d7c61de5f65f1c3d057dddaa27f3vboxsync uint64_t cReqBalloonedPages;
1d5596b941d86a014c20420b73ad7be2de35cf9dvboxsync /** The number of pages the guest has given us in response to the request.
1d5596b941d86a014c20420b73ad7be2de35cf9dvboxsync * This is not reset on request completed and may be used in later decisions. */
5e31c5b77713d7c61de5f65f1c3d057dddaa27f3vboxsync uint64_t cReqActuallyBalloonedPages;
1d5596b941d86a014c20420b73ad7be2de35cf9dvboxsync /** The number of pages we've currently requested the guest to take back. */
5e31c5b77713d7c61de5f65f1c3d057dddaa27f3vboxsync uint64_t cReqDeflatePages;
5e31c5b77713d7c61de5f65f1c3d057dddaa27f3vboxsync
b2def6ea46868a11f7fd2857874e46c51932223avboxsync /** Shared module tree (per-vm). */
b2def6ea46868a11f7fd2857874e46c51932223avboxsync PAVLGCPTRNODECORE pSharedModuleTree;
b2def6ea46868a11f7fd2857874e46c51932223avboxsync
3cc114d9c84cf4a1e3b5225e81527614c30f1d83vboxsync /** Whether ballooning is enabled or not. */
5e31c5b77713d7c61de5f65f1c3d057dddaa27f3vboxsync bool fBallooningEnabled;
5e31c5b77713d7c61de5f65f1c3d057dddaa27f3vboxsync
5e31c5b77713d7c61de5f65f1c3d057dddaa27f3vboxsync /** Whether shared paging is enabled or not. */
5e31c5b77713d7c61de5f65f1c3d057dddaa27f3vboxsync bool fSharedPagingEnabled;
3cc114d9c84cf4a1e3b5225e81527614c30f1d83vboxsync
1dc25926f76c463686b66fb6adec583eef0717advboxsync /** Whether the VM is allowed to allocate memory or not.
1dc25926f76c463686b66fb6adec583eef0717advboxsync * This is used when the reservation update request fails or when the VM has
1dc25926f76c463686b66fb6adec583eef0717advboxsync * been told to suspend/save/die in an out-of-memory case. */
5e31c5b77713d7c61de5f65f1c3d057dddaa27f3vboxsync bool fMayAllocate;
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync} GMMPERVM;
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync/** Pointer to the per-VM GMM data. */
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsynctypedef GMMPERVM *PGMMPERVM;
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync#endif
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync