VirtualBox

Changeset 4621 in vbox


Ignore:
Timestamp:
Sep 8, 2007 3:02:59 AM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
24267
Message:

pgmPhysCacheAdd doesn't look like it's SMP safe, at least I got a corruption just now, so only call it on the EMT thread.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp

    r4620 r4621  
    2121 * Since this flag is currently incorrectly kept set for ROM regions we will
    2222 * have to ignore it for now so we don't break stuff.
    23  * 
     23 *
    2424 * @todo this has been fixed now I believe, remove this hack.
    2525 */
     
    103103 * @returns VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid
    104104 *          GC physical address.
    105  * 
     105 *
    106106 * @param   pVM     The VM handle.
    107107 * @param   GCPhys  The GC physical address to convert.
     
    128128
    129129
    130 /** 
     130/**
    131131 * Replace a zero or shared page with new page that we can write to.
    132  * 
    133  * @returns VBox status. 
     132 *
     133 * @returns VBox status.
    134134 * @todo    Define the return values and propagate them up the call tree..
    135  * 
     135 *
    136136 * @param   pVM         The VM address.
    137137 * @param   pPage       The physical page tracking structure.
    138138 * @param   GCPhys      The address of the page.
    139  * 
     139 *
    140140 * @remarks Called from within the PGM critical section.
    141141 */
     
    146146
    147147
    148 /** 
     148/**
    149149 * Deal with pages that are not writable, i.e. not in the ALLOCATED state.
    150  * 
     150 *
    151151 * @returns VBox status code.
    152152 * @retval  VINF_SUCCESS on success.
    153153 * @retval  VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical backing.
    154  * 
     154 *
    155155 * @param   pVM         The VM address.
    156156 * @param   pPage       The physical page tracking structure.
    157157 * @param   GCPhys      The address of the page.
    158  * 
     158 *
    159159 * @remarks Called from within the PGM critical section.
    160160 */
     
    170170            return VINF_SUCCESS;
    171171
    172         /* 
     172        /*
    173173         * 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
    175175         * shared page replacement.
    176176         */
     
    190190/**
    191191 * 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.
    193193 */
    194194static DECLCALLBACK(int) pgmR3PhysChunkAgeingRolloverCallback(PAVLU32NODECORE pNode, void *pvUser)
     
    207207
    208208/**
    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
    211211 */
    212212static DECLCALLBACK(int) pgmR3PhysChunkAgeingCallback(PAVLU32NODECORE pNode, void *pvUser)
     
    220220        RTAvllU32Insert(&pVM->pgm.s.R3ChunkTlb.pAgeTree, &pChunk->AgeCore);
    221221    }
    222    
     222
    223223    return 0;
    224224}
     
    227227/**
    228228 * Performs ageing of the ring-3 chunk mappings.
    229  * 
     229 *
    230230 * @param   pVM         The VM handle.
    231231 */
     
    254254
    255255/**
    256  * Callback used to find the mapping that's been unused for 
     256 * Callback used to find the mapping that's been unused for
    257257 * the longest time.
    258258 */
     
    265265            &&  !pChunk->cRefs)
    266266        {
    267             /* 
    268              * Check that it's not in any of the TLBs. 
     267            /*
     268             * Check that it's not in any of the TLBs.
    269269             */
    270270            PVM pVM = ((PPGMR3PHYSCHUNKUNMAPCB)pvUser)->pVM;
     
    298298/**
    299299 * 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
    302302 * anything afterwards.
    303  * 
     303 *
    304304 * @returns Chunk id.
    305305 * @param   pVM         The VM handle.
     
    327327/**
    328328 * Maps the given chunk into the ring-3 mapping cache.
    329  * 
     329 *
    330330 * This will call ring-0.
    331  * 
     331 *
    332332 * @returns VBox status code.
    333333 * @param   pVM         The VM handle.
    334334 * @param   idChunk     The chunk in question.
    335335 * @param   ppChunk     Where to store the chunk tracking structure.
    336  * 
     336 *
    337337 * @remarks Called from within the PGM critical section.
    338338 */
     
    399399#else
    400400        MMHyperFree(pVM, pChunk);
    401 #endif 
     401#endif
    402402        pChunk = NULL;
    403403    }
     
    409409
    410410
    411 /** 
     411/**
    412412 * Maps a page into the current virtual address space so it can be accessed.
    413  * 
     413 *
    414414 * @returns VBox status code.
    415415 * @retval  VINF_SUCCESS on success.
    416416 * @retval  VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical backing.
    417  * 
     417 *
    418418 * @param   pVM         The VM address.
    419419 * @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
    423423 *                      offset is masked off!
    424  * 
     424 *
    425425 * @remarks Called from within the PGM critical section.
    426426 */
     
    438438#else /* IN_RING3 || IN_RING0 */
    439439
    440 /** 
     440/**
    441441 * Calculates the index of a guest page in the Ring-3 Chunk TLB.
    442  * @returns Chunk TLB index. 
     442 * @returns Chunk TLB index.
    443443 * @param   idChunk         The Chunk ID.
    444444 */
     
    493493
    494494
    495 /** 
     495/**
    496496 * Calculates the index of a guest page in the Physical TLB.
    497  * @returns Physical TLB index. 
     497 * @returns Physical TLB index.
    498498 * @param   GCPhys      The guest physical address.
    499499 */
     
    506506# define PGM_PHYSTLB_IDX(GCPhys)   PGM_GCPHYSTLB_IDX(GCPhys)
    507507# define PGMPHYSTLBE PGMGCPHYSTLBE
    508 #endif 
     508#endif
    509509
    510510
    511511/**
    512512 * Load a guest page into the ring-3 physical TLB.
    513  * 
     513 *
    514514 * @returns VBox status code.
    515515 * @retval  VINF_SUCCESS on success
     
    540540
    541541    /*
    542      * Map the page. 
     542     * Map the page.
    543543     * Make a special case for the zero page as it is kind of special.
    544544     */
     
    567567
    568568/**
    569  * Queries the Physical TLB entry for a physical guest page, 
     569 * Queries the Physical TLB entry for a physical guest page,
    570570 * attemting to load the TLB entry if necessary.
    571  * 
     571 *
    572572 * @returns VBox status code.
    573573 * @retval  VINF_SUCCESS on success
     
    596596
    597597
    598 /** 
     598/**
    599599 * Requests the mapping of a guest page into the current context.
    600  * 
     600 *
    601601 * 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
    603603 * with the page, call PGMPhysGCPhys2CCPtrRelease() ASAP to release it.
    604  * 
     604 *
    605605 * @returns VBox status code.
    606606 * @retval  VINF_SUCCESS on success.
    607607 * @retval  VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical backing.
    608608 * @retval  VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
    609  * 
     609 *
    610610 * @param   pVM         The VM handle.
    611611 * @param   GCPhys      The guest physical address of the page that should be mapped.
    612612 * @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
    615615 *          the PGM one) because of the deadlock risk.
    616616 */
     
    626626
    627627#else
    628     /* 
     628    /*
    629629     * Query the Physical TLB entry for the page (may fail).
    630630     */
     
    634634    {
    635635        /*
    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
    637637         * it must be converted to an page that's writable if possible.
    638638         */
     
    653653                    pMap->cRefs++; /* Extra ref to prevent it from going away. */
    654654                }
    655        
     655
    656656            *ppv = (void *)((uintptr_t)pTlbe->pv | (GCPhys & PAGE_OFFSET_MASK));
    657657        }
     
    671671# else
    672672    return PGMPhysGCPhys2HCPtr(pVM, GCPhys, 1, ppv);
    673 # endif 
    674 #endif 
    675 }
    676 
    677 
    678 /** 
     673# endif
     674#endif
     675}
     676
     677
     678/**
    679679 * Release the mapping of a guest page.
    680  * 
     680 *
    681681 * This is the counterpart to the PGMPhysGCPhys2CCPtr.
    682  * 
     682 *
    683683 * @param   pVM         The VM handle.
    684684 * @param   GCPhys      The address that was mapped using PGMPhysGCPhys2CCPtr.
     
    690690#ifdef IN_GC
    691691    /* currently nothing to do here. */
    692 /* --- postponed 
     692/* --- postponed
    693693#elif defined(IN_RING0)
    694694*/
     
    761761    NOREF(GCPhys);
    762762    NOREF(pv);
    763 #endif 
     763#endif
    764764}
    765765
     
    823823
    824824/**
    825  * Converts a HC pointer to a GC physical address. 
    826  * 
     825 * Converts a HC pointer to a GC physical address.
     826 *
    827827 * Only for the debugger.
    828828 *
     
    830830 * @retval  VINF_SUCCESS on success, *pGCPhys is set.
    831831 * @retval  VERR_INVALID_POINTER if the pointer is not within the GC physical memory.
    832  * 
     832 *
    833833 * @param   pVM     The VM handle.
    834834 * @param   HCPtr   The HC pointer to convert.
     
    884884 * @retval  VERR_PGM_PHYS_PAGE_RESERVED it it's a valid GC physical page but has no physical backing.
    885885 * @retval  VERR_INVALID_POINTER if the pointer is not within the GC physical memory.
    886  * 
     886 *
    887887 * @param   pVM     The VM handle.
    888888 * @param   HCPtr   The HC pointer to convert.
     
    945945/**
    946946 * Converts a HC physical address to a GC physical address.
    947  * 
     947 *
    948948 * Only for the debugger.
    949949 *
     
    951951 * @retval  VINF_SUCCESS on success, *pGCPhys is set.
    952952 * @retval  VERR_INVALID_POINTER if the HC physical address is not within the GC physical memory.
    953  * 
     953 *
    954954 * @param   pVM     The VM handle.
    955955 * @param   HCPhys  The HC physical address to convert.
     
    978978#ifndef PGM_IGNORE_RAM_FLAGS_RESERVED
    979979                &&  !PGM_PAGE_IS_RESERVED(&pRam->aPages[iPage])
    980 #endif 
     980#endif
    981981                )
    982982            {
     
    11531153 * @param   GCPhys          GC physical address
    11541154 * @param   pbHC            HC pointer corresponding to physical page
     1155 *
     1156 * @thread  EMT.
    11551157 */
    11561158static void pgmPhysCacheAdd(PVM pVM, PGMPHYSCACHE *pCache, RTGCPHYS GCPhys, uint8_t *pbHC)
     
    12611263                            {
    12621264#if defined(IN_RING3) && defined(PGM_PHYSMEMACCESS_CACHING)
    1263                                 if (cbRead <= 4)
     1265                                if (cbRead <= 4 && !fGrabbedLock /* i.e. EMT */)
    12641266                                    pgmPhysCacheAdd(pVM, &pVM->pgm.s.pgmphysreadcache, GCPhys, (uint8_t*)pvSrc);
    12651267#endif /* IN_RING3 && PGM_PHYSMEMACCESS_CACHING */
     
    15271529                        {
    15281530#if defined(IN_RING3) && defined(PGM_PHYSMEMACCESS_CACHING)
    1529                             if (cbWrite <= 4)
     1531                            if (cbWrite <= 4 && !fGrabbedLock /* i.e. EMT */)
    15301532                                pgmPhysCacheAdd(pVM, &pVM->pgm.s.pgmphyswritecache, GCPhys, (uint8_t*)pvDst);
    15311533#endif /* IN_RING3 && PGM_PHYSMEMACCESS_CACHING */
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