- Timestamp:
- Feb 23, 2012 11:05:45 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/GMMR0.cpp
r40054 r40226 5 5 6 6 /* 7 * Copyright (C) 2007-201 1Oracle Corporation7 * Copyright (C) 2007-2012 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 162 162 #include <iprt/asm.h> 163 163 #include <iprt/avl.h> 164 #ifdef VBOX_STRICT 165 # include <iprt/crc.h> 166 #endif 164 167 #include <iprt/list.h> 165 168 #include <iprt/mem.h> … … 222 225 /** The reference count (64K VMs). */ 223 226 uint32_t cRefs : 16; 224 /** Reserved. Checksum or something? Two hGVMs for forking?*/225 uint32_t u14 Reserved: 14;227 /** Used for debug checksumming. */ 228 uint32_t u14Checksum : 14; 226 229 /** The page state. */ 227 230 uint32_t u2State : 2; … … 723 726 #ifdef VBOX_WITH_PAGE_SHARING 724 727 static void gmmR0SharedModuleCleanup(PGMM pGMM, PGVM pGVM); 728 # ifdef VBOX_STRICT 729 static uint32_t gmmR0StrictPageChecksum(PGMM pGMM, PGVM pGVM, uint32_t idPage); 730 # endif 725 731 #endif 726 732 … … 3282 3288 Assert(pGMM->cAllocatedPages > 0); 3283 3289 Assert(!pPage->Shared.cRefs); 3290 #ifdef VBOX_STRICT 3291 if (pPage->Shared.u14Checksum) 3292 { 3293 uint32_t uChecksum = gmmR0StrictPageChecksum(pGMM, pGVM, idPage); 3294 uChecksum &= UINT32_C(0x00003fff); 3295 AssertMsg(!uChecksum || uChecksum == pPage->Shared.u14Checksum, 3296 ("%#x vs %#x - idPage=%#\n", uChecksum, pPage->Shared.u14Checksum, idPage)); 3297 } 3298 #endif 3284 3299 3285 3300 pChunk->cShared--; … … 3978 3993 * @param ppvR3 Where to store the ring-3 address of the mapping. 3979 3994 */ 3980 static intgmmR0IsChunkMapped(PGMM pGMM, PGVM pGVM, PGMMCHUNK pChunk, PRTR3PTR ppvR3)3995 static bool gmmR0IsChunkMapped(PGMM pGMM, PGVM pGVM, PGMMCHUNK pChunk, PRTR3PTR ppvR3) 3981 3996 { 3982 3997 GMMR0CHUNKMTXSTATE MtxState; … … 4168 4183 4169 4184 #ifdef VBOX_WITH_PAGE_SHARING 4185 4186 # ifdef VBOX_STRICT 4187 /** 4188 * For checksumming shared pages in strict builds. 4189 * 4190 * The purpose is making sure that a page doesn't change. 4191 * 4192 * @returns Checksum, 0 on failure. 4193 * @param GMM The GMM instance data. 4194 * @param idPage The page ID. 4195 */ 4196 static uint32_t gmmR0StrictPageChecksum(PGMM pGMM, PGVM pGVM, uint32_t idPage) 4197 { 4198 PGMMCHUNK pChunk = gmmR0GetChunk(pGMM, idPage >> GMM_CHUNKID_SHIFT); 4199 AssertMsgReturn(pChunk, ("idPage=%#x\n", idPage), 0); 4200 4201 uint8_t *pbChunk; 4202 if (!gmmR0IsChunkMapped(pGMM, pGVM, pChunk, (PRTR3PTR)&pbChunk)) 4203 return 0; 4204 uint8_t const *pbPage = pbChunk + ((idPage & GMM_PAGEID_IDX_MASK) << PAGE_SHIFT); 4205 4206 return RTCrc32(pbPage, PAGE_SIZE); 4207 } 4208 # endif /* VBOX_STRICT */ 4209 4170 4210 4171 4211 /** … … 4682 4722 4683 4723 /* Modify the page structure. */ 4684 pPage->Shared.pfn = (uint32_t)(uint64_t)(HCPhys >> PAGE_SHIFT); 4685 pPage->Shared.cRefs = 1; 4686 pPage->Common.u2State = GMM_PAGE_STATE_SHARED; 4724 pPage->Shared.pfn = (uint32_t)(uint64_t)(HCPhys >> PAGE_SHIFT); 4725 pPage->Shared.cRefs = 1; 4726 #ifdef VBOX_STRICT 4727 pPage->Shared.u14Checksum = gmmR0StrictPageChecksum(pGMM, pGVM, idPage); 4728 #else 4729 pPage->Shared.u14Checksum = 0; 4730 #endif 4731 pPage->Shared.u2State = GMM_PAGE_STATE_SHARED; 4687 4732 } 4688 4733 … … 4828 4873 } 4829 4874 uint8_t *pbSharedPage = pbChunk + ((pGlobalRegion->paidPages[idxPage] & GMM_PAGEID_IDX_MASK) << PAGE_SHIFT); 4875 #ifdef VBOX_STRICT 4876 if (pPage->Shared.u14Checksum) 4877 { 4878 uint32_t uChecksum = RTCrc32(pbSharedPage, PAGE_SIZE) & UINT32_C(0x00003fff); 4879 AssertMsg(!uChecksum || uChecksum == pPage->Shared.u14Checksum, 4880 ("%#x vs %#x - idPage=%# - %s %s\n", uChecksum, pPage->Shared.u14Checksum, 4881 pGlobalRegion->paidPages[idxPage], pModule->szName, pModule->szVersion)); 4882 } 4883 #endif 4830 4884 4831 4885 /** @todo write ASMMemComparePage. */
Note:
See TracChangeset
for help on using the changeset viewer.