Changeset 4621 in vbox
- Timestamp:
- Sep 8, 2007 3:02:59 AM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 24267
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp ¶
r4620 r4621 21 21 * Since this flag is currently incorrectly kept set for ROM regions we will 22 22 * have to ignore it for now so we don't break stuff. 23 * 23 * 24 24 * @todo this has been fixed now I believe, remove this hack. 25 25 */ … … 103 103 * @returns VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid 104 104 * GC physical address. 105 * 105 * 106 106 * @param pVM The VM handle. 107 107 * @param GCPhys The GC physical address to convert. … … 128 128 129 129 130 /** 130 /** 131 131 * Replace a zero or shared page with new page that we can write to. 132 * 133 * @returns VBox status. 132 * 133 * @returns VBox status. 134 134 * @todo Define the return values and propagate them up the call tree.. 135 * 135 * 136 136 * @param pVM The VM address. 137 137 * @param pPage The physical page tracking structure. 138 138 * @param GCPhys The address of the page. 139 * 139 * 140 140 * @remarks Called from within the PGM critical section. 141 141 */ … … 146 146 147 147 148 /** 148 /** 149 149 * Deal with pages that are not writable, i.e. not in the ALLOCATED state. 150 * 150 * 151 151 * @returns VBox status code. 152 152 * @retval VINF_SUCCESS on success. 153 153 * @retval VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical backing. 154 * 154 * 155 155 * @param pVM The VM address. 156 156 * @param pPage The physical page tracking structure. 157 157 * @param GCPhys The address of the page. 158 * 158 * 159 159 * @remarks Called from within the PGM critical section. 160 160 */ … … 170 170 return VINF_SUCCESS; 171 171 172 /* 172 /* 173 173 * Zero pages can be dummy pages for MMIO or reserved memory, 174 * so we need to check the flags before joining cause with 174 * so we need to check the flags before joining cause with 175 175 * shared page replacement. 176 176 */ … … 190 190 /** 191 191 * Tree enumeration callback for dealing with age rollover. 192 * It will perform a simple compression of the current age. 192 * It will perform a simple compression of the current age. 193 193 */ 194 194 static DECLCALLBACK(int) pgmR3PhysChunkAgeingRolloverCallback(PAVLU32NODECORE pNode, void *pvUser) … … 207 207 208 208 /** 209 * Tree enumeration callback that updates the chunks that have 210 * been used since the last 209 * Tree enumeration callback that updates the chunks that have 210 * been used since the last 211 211 */ 212 212 static DECLCALLBACK(int) pgmR3PhysChunkAgeingCallback(PAVLU32NODECORE pNode, void *pvUser) … … 220 220 RTAvllU32Insert(&pVM->pgm.s.R3ChunkTlb.pAgeTree, &pChunk->AgeCore); 221 221 } 222 222 223 223 return 0; 224 224 } … … 227 227 /** 228 228 * Performs ageing of the ring-3 chunk mappings. 229 * 229 * 230 230 * @param pVM The VM handle. 231 231 */ … … 254 254 255 255 /** 256 * Callback used to find the mapping that's been unused for 256 * Callback used to find the mapping that's been unused for 257 257 * the longest time. 258 258 */ … … 265 265 && !pChunk->cRefs) 266 266 { 267 /* 268 * Check that it's not in any of the TLBs. 267 /* 268 * Check that it's not in any of the TLBs. 269 269 */ 270 270 PVM pVM = ((PPGMR3PHYSCHUNKUNMAPCB)pvUser)->pVM; … … 298 298 /** 299 299 * Finds a good candidate for unmapping when the ring-3 mapping cache is full. 300 * 301 * The candidate will not be part of any TLBs, so no need to flush 300 * 301 * The candidate will not be part of any TLBs, so no need to flush 302 302 * anything afterwards. 303 * 303 * 304 304 * @returns Chunk id. 305 305 * @param pVM The VM handle. … … 327 327 /** 328 328 * Maps the given chunk into the ring-3 mapping cache. 329 * 329 * 330 330 * This will call ring-0. 331 * 331 * 332 332 * @returns VBox status code. 333 333 * @param pVM The VM handle. 334 334 * @param idChunk The chunk in question. 335 335 * @param ppChunk Where to store the chunk tracking structure. 336 * 336 * 337 337 * @remarks Called from within the PGM critical section. 338 338 */ … … 399 399 #else 400 400 MMHyperFree(pVM, pChunk); 401 #endif 401 #endif 402 402 pChunk = NULL; 403 403 } … … 409 409 410 410 411 /** 411 /** 412 412 * Maps a page into the current virtual address space so it can be accessed. 413 * 413 * 414 414 * @returns VBox status code. 415 415 * @retval VINF_SUCCESS on success. 416 416 * @retval VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical backing. 417 * 417 * 418 418 * @param pVM The VM address. 419 419 * @param pPage The physical page tracking structure. 420 * @param GCPhys The address of the page. 421 * @param ppMap Where to store the address of the mapping tracking structure. 422 * @param ppv Where to store the mapping address of the page. The page 420 * @param GCPhys The address of the page. 421 * @param ppMap Where to store the address of the mapping tracking structure. 422 * @param ppv Where to store the mapping address of the page. The page 423 423 * offset is masked off! 424 * 424 * 425 425 * @remarks Called from within the PGM critical section. 426 426 */ … … 438 438 #else /* IN_RING3 || IN_RING0 */ 439 439 440 /** 440 /** 441 441 * Calculates the index of a guest page in the Ring-3 Chunk TLB. 442 * @returns Chunk TLB index. 442 * @returns Chunk TLB index. 443 443 * @param idChunk The Chunk ID. 444 444 */ … … 493 493 494 494 495 /** 495 /** 496 496 * Calculates the index of a guest page in the Physical TLB. 497 * @returns Physical TLB index. 497 * @returns Physical TLB index. 498 498 * @param GCPhys The guest physical address. 499 499 */ … … 506 506 # define PGM_PHYSTLB_IDX(GCPhys) PGM_GCPHYSTLB_IDX(GCPhys) 507 507 # define PGMPHYSTLBE PGMGCPHYSTLBE 508 #endif 508 #endif 509 509 510 510 511 511 /** 512 512 * Load a guest page into the ring-3 physical TLB. 513 * 513 * 514 514 * @returns VBox status code. 515 515 * @retval VINF_SUCCESS on success … … 540 540 541 541 /* 542 * Map the page. 542 * Map the page. 543 543 * Make a special case for the zero page as it is kind of special. 544 544 */ … … 567 567 568 568 /** 569 * Queries the Physical TLB entry for a physical guest page, 569 * Queries the Physical TLB entry for a physical guest page, 570 570 * attemting to load the TLB entry if necessary. 571 * 571 * 572 572 * @returns VBox status code. 573 573 * @retval VINF_SUCCESS on success … … 596 596 597 597 598 /** 598 /** 599 599 * Requests the mapping of a guest page into the current context. 600 * 600 * 601 601 * This API should only be used for very short term, as it will consume 602 * scarse resources (R0 and GC) in the mapping cache. When you're done 602 * scarse resources (R0 and GC) in the mapping cache. When you're done 603 603 * with the page, call PGMPhysGCPhys2CCPtrRelease() ASAP to release it. 604 * 604 * 605 605 * @returns VBox status code. 606 606 * @retval VINF_SUCCESS on success. 607 607 * @retval VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical backing. 608 608 * @retval VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address. 609 * 609 * 610 610 * @param pVM The VM handle. 611 611 * @param GCPhys The guest physical address of the page that should be mapped. 612 612 * @param ppv Where to store the address corresponding to GCPhys. 613 * 614 * @remark Avoid calling this API from within critical sections (other than 613 * 614 * @remark Avoid calling this API from within critical sections (other than 615 615 * the PGM one) because of the deadlock risk. 616 616 */ … … 626 626 627 627 #else 628 /* 628 /* 629 629 * Query the Physical TLB entry for the page (may fail). 630 630 */ … … 634 634 { 635 635 /* 636 * If the page is shared, the zero page, or being write monitored 636 * If the page is shared, the zero page, or being write monitored 637 637 * it must be converted to an page that's writable if possible. 638 638 */ … … 653 653 pMap->cRefs++; /* Extra ref to prevent it from going away. */ 654 654 } 655 655 656 656 *ppv = (void *)((uintptr_t)pTlbe->pv | (GCPhys & PAGE_OFFSET_MASK)); 657 657 } … … 671 671 # else 672 672 return PGMPhysGCPhys2HCPtr(pVM, GCPhys, 1, ppv); 673 # endif 674 #endif 675 } 676 677 678 /** 673 # endif 674 #endif 675 } 676 677 678 /** 679 679 * Release the mapping of a guest page. 680 * 680 * 681 681 * This is the counterpart to the PGMPhysGCPhys2CCPtr. 682 * 682 * 683 683 * @param pVM The VM handle. 684 684 * @param GCPhys The address that was mapped using PGMPhysGCPhys2CCPtr. … … 690 690 #ifdef IN_GC 691 691 /* currently nothing to do here. */ 692 /* --- postponed 692 /* --- postponed 693 693 #elif defined(IN_RING0) 694 694 */ … … 761 761 NOREF(GCPhys); 762 762 NOREF(pv); 763 #endif 763 #endif 764 764 } 765 765 … … 823 823 824 824 /** 825 * Converts a HC pointer to a GC physical address. 826 * 825 * Converts a HC pointer to a GC physical address. 826 * 827 827 * Only for the debugger. 828 828 * … … 830 830 * @retval VINF_SUCCESS on success, *pGCPhys is set. 831 831 * @retval VERR_INVALID_POINTER if the pointer is not within the GC physical memory. 832 * 832 * 833 833 * @param pVM The VM handle. 834 834 * @param HCPtr The HC pointer to convert. … … 884 884 * @retval VERR_PGM_PHYS_PAGE_RESERVED it it's a valid GC physical page but has no physical backing. 885 885 * @retval VERR_INVALID_POINTER if the pointer is not within the GC physical memory. 886 * 886 * 887 887 * @param pVM The VM handle. 888 888 * @param HCPtr The HC pointer to convert. … … 945 945 /** 946 946 * Converts a HC physical address to a GC physical address. 947 * 947 * 948 948 * Only for the debugger. 949 949 * … … 951 951 * @retval VINF_SUCCESS on success, *pGCPhys is set. 952 952 * @retval VERR_INVALID_POINTER if the HC physical address is not within the GC physical memory. 953 * 953 * 954 954 * @param pVM The VM handle. 955 955 * @param HCPhys The HC physical address to convert. … … 978 978 #ifndef PGM_IGNORE_RAM_FLAGS_RESERVED 979 979 && !PGM_PAGE_IS_RESERVED(&pRam->aPages[iPage]) 980 #endif 980 #endif 981 981 ) 982 982 { … … 1153 1153 * @param GCPhys GC physical address 1154 1154 * @param pbHC HC pointer corresponding to physical page 1155 * 1156 * @thread EMT. 1155 1157 */ 1156 1158 static void pgmPhysCacheAdd(PVM pVM, PGMPHYSCACHE *pCache, RTGCPHYS GCPhys, uint8_t *pbHC) … … 1261 1263 { 1262 1264 #if defined(IN_RING3) && defined(PGM_PHYSMEMACCESS_CACHING) 1263 if (cbRead <= 4 )1265 if (cbRead <= 4 && !fGrabbedLock /* i.e. EMT */) 1264 1266 pgmPhysCacheAdd(pVM, &pVM->pgm.s.pgmphysreadcache, GCPhys, (uint8_t*)pvSrc); 1265 1267 #endif /* IN_RING3 && PGM_PHYSMEMACCESS_CACHING */ … … 1527 1529 { 1528 1530 #if defined(IN_RING3) && defined(PGM_PHYSMEMACCESS_CACHING) 1529 if (cbWrite <= 4 )1531 if (cbWrite <= 4 && !fGrabbedLock /* i.e. EMT */) 1530 1532 pgmPhysCacheAdd(pVM, &pVM->pgm.s.pgmphyswritecache, GCPhys, (uint8_t*)pvDst); 1531 1533 #endif /* IN_RING3 && PGM_PHYSMEMACCESS_CACHING */
Note:
See TracChangeset
for help on using the changeset viewer.