VirtualBox

Changeset 70977 in vbox for trunk/src/VBox/VMM/include


Ignore:
Timestamp:
Feb 12, 2018 8:45:31 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
120824
Message:

NEM: Working on PGM notifications. bugref:9044

Location:
trunk/src/VBox/VMM/include
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/include/NEMInternal.h

    r70954 r70977  
    116116void    nemR3NativeResetCpu(PVMCPU pVCpu);
    117117int     nemR3NativeNotifyPhysRamRegister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb);
    118 int     nemR3NativeNotifyPhysMmioExMap(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, uint32_t fFlags);
     118int     nemR3NativeNotifyPhysMmioExMap(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, uint32_t fFlags, void *pvMmio2);
    119119int     nemR3NativeNotifyPhysMmioExUnmap(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, uint32_t fFlags);
    120 int     nemR3NativeNotifyPhysRomRegisterEarly(PVM pVM, RTGCPHYS GCPhys, RTUINT cb, uint32_t fFlags);
    121 int     nemR3NativeNotifyPhysRomRegisterLate(PVM pVM, RTGCPHYS GCPhys, RTUINT cb, uint32_t fFlags);
     120int     nemR3NativeNotifyPhysRomRegisterEarly(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, uint32_t fFlags);
     121int     nemR3NativeNotifyPhysRomRegisterLate(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, uint32_t fFlags);
    122122void    nemR3NativeNotifySetA20(PVMCPU pVCpu, bool fEnabled);
     123/* NEMHCNotifyXxxx for ring-3: */
     124void    nemR3NativeNotifyHandlerPhysicalRegister(PVM pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhys, RTGCPHYS cb);
     125void    nemR3NativeNotifyHandlerPhysicalDeregister(PVM pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhys, RTGCPHYS cb,
     126                                                   int fRestoreAsRAM, bool fRestoreAsRAM2);
     127void    nemR3NativeNotifyHandlerPhysicalModify(PVM pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhysOld,
     128                                               RTGCPHYS GCPhysNew, RTGCPHYS cb, bool fRestoreAsRAM);
     129int     nemR3NativeNotifyPhysPageAllocated(PVM pVM, RTGCPHYS GCPhys, RTHCPHYS HCPhys, uint32_t fPageProt,
     130                                           PGMPAGETYPE enmType, uint8_t *pu2State);
     131void    nemR3NativeNotifyPhysPageProtChanged(PVM pVM, RTGCPHYS GCPhys, RTHCPHYS HCPhys, uint32_t fPageProt,
     132                                             PGMPAGETYPE enmType, uint8_t *pu2State);
     133void    nemR3NativeNotifyPhysPageChanged(PVM pVM, RTGCPHYS GCPhys, RTHCPHYS HCPhysPrev, RTHCPHYS HCPhysNew, uint32_t fPageProt,
     134                                         PGMPAGETYPE enmType, uint8_t *pu2State);
    123135#endif
    124136
  • trunk/src/VBox/VMM/include/PGMInline.h

    r70948 r70977  
    3333#include <VBox/vmm/gmm.h>
    3434#include <VBox/vmm/hm.h>
     35#ifndef IN_RC
     36# include <VBox/vmm/nem.h>
     37#endif
    3538#include <iprt/asm.h>
    3639#include <iprt/assert.h>
     
    514517}
    515518
     519
     520/**
     521 * Calculates NEM page protection flags.
     522 */
     523DECL_FORCE_INLINE(uint32_t) pgmPhysPageCalcNemProtection(PPGMPAGE pPage, PGMPAGETYPE enmType)
     524{
     525    /*
     526     * Deal with potentially writable pages first.
     527     */
     528    if (PGMPAGETYPE_IS_RWX(enmType))
     529    {
     530        if (!PGM_PAGE_HAS_ACTIVE_HANDLERS(pPage))
     531        {
     532            if (PGM_PAGE_IS_ALLOCATED(pPage))
     533                return NEM_PAGE_PROT_READ | NEM_PAGE_PROT_EXECUTE | NEM_PAGE_PROT_WRITE;
     534            return NEM_PAGE_PROT_READ | NEM_PAGE_PROT_EXECUTE;
     535        }
     536        if (!PGM_PAGE_HAS_ACTIVE_ALL_HANDLERS(pPage))
     537            return NEM_PAGE_PROT_READ | NEM_PAGE_PROT_EXECUTE;
     538    }
     539    /*
     540     * Potentially readable & executable pages.
     541     */
     542    else if (   PGMPAGETYPE_IS_ROX(enmType)
     543             && !PGM_PAGE_HAS_ACTIVE_ALL_HANDLERS(pPage))
     544        return NEM_PAGE_PROT_READ | NEM_PAGE_PROT_EXECUTE;
     545
     546    /*
     547     * The rest is needs special access handling.
     548     */
     549    return NEM_PAGE_PROT_NONE;
     550}
     551
    516552#endif /* !IN_RC */
    517553
     
    546582            Assert(PGM_PAGE_GET_PDE_TYPE(pFirstPage) == PGM_PAGE_PDE_TYPE_PDE_DISABLED);
    547583    }
     584
     585#ifndef IN_RC
     586    /* Tell NEM. */
     587    if (VM_IS_NEM_ENABLED(pVM))
     588    {
     589        uint8_t     u2State = PGM_PAGE_GET_NEM_STATE(pPage);
     590        PGMPAGETYPE enmType = (PGMPAGETYPE)PGM_PAGE_GET_TYPE(pPage);
     591        NEMHCNotifyPhysPageProtChanged(pVM, GCPhysPage, PGM_PAGE_GET_HCPHYS(pPage),
     592                                       pgmPhysPageCalcNemProtection(pPage, enmType), enmType, &u2State);
     593        PGM_PAGE_SET_NEM_STATE(pPage, u2State);
     594    }
     595#endif
    548596}
    549597
  • trunk/src/VBox/VMM/include/PGMInternal.h

    r70954 r70977  
    785785
    786786
    787 /** @name Page type predicates.
    788  * @{ */
    789 #define PGMPAGETYPE_IS_READABLE(type)   ( (type) <= PGMPAGETYPE_ROM )
    790 #define PGMPAGETYPE_IS_WRITEABLE(type)  ( (type) <= PGMPAGETYPE_ROM_SHADOW )
    791 #define PGMPAGETYPE_IS_RWX(type)        ( (type) <= PGMPAGETYPE_ROM_SHADOW )
    792 #define PGMPAGETYPE_IS_ROX(type)        ( (type) == PGMPAGETYPE_ROM )
    793 #define PGMPAGETYPE_IS_NP(type)         ( (type) == PGMPAGETYPE_MMIO )
    794 /** @} */
    795 
    796 
    797787/**
    798788 * A Physical Guest Page tracking structure.
     
    823813        /** 9:8   - The physical handler state (PGM_PAGE_HNDL_VIRT_STATE_*). */
    824814        uint64_t    u2HandlerVirtStateY : 2;
    825         /** 11:10 - Unused. */
    826         uint64_t    u2Unused1           : 2;
     815        /** 11:10 - NEM state bits. */
     816        uint64_t    u2NemStateY         : 2;
    827817        /** 12:48 - The host physical frame number (shift left to get the
    828818         *  address). */
     
    14261416 */
    14271417#define PGM_PAGE_INC_WRITE_LOCKS(a_pPage)       do { ++(a_pPage)->s.cWriteLocksY; } while (0)
     1418
     1419
     1420/** Gets the NEM state.
     1421 * @returns NEM state value (two bits).
     1422 * @param   a_pPage     Pointer to the physical guest page tracking structure.
     1423 */
     1424#define PGM_PAGE_GET_NEM_STATE(a_pPage)         ((a_pPage)->s.u2NemStateY)
     1425
     1426/** Sets the NEM state.
     1427 * @param   a_pPage     Pointer to the physical guest page tracking structure.
     1428 * @param   a_u2State   The NEM state value (specific to NEM impl.).
     1429 */
     1430#define PGM_PAGE_SET_NEM_STATE(a_pPage, a_u2State) \
     1431    do { Assert((a_u2State) < 4); (a_pPage)->s.u2NemStateY = (a_u2State); } while (0)
    14281432
    14291433
     
    42174221int             pgmPhysPageLoadIntoTlb(PVM pVM, RTGCPHYS GCPhys);
    42184222int             pgmPhysPageLoadIntoTlbWithPage(PVM pVM, PPGMPAGE pPage, RTGCPHYS GCPhys);
    4219 void            pgmPhysPageMakeWriteMonitoredWritable(PVM pVM, PPGMPAGE pPage);
     4223void            pgmPhysPageMakeWriteMonitoredWritable(PVM pVM, PPGMPAGE pPage, RTGCPHYS GCPhys);
    42204224int             pgmPhysPageMakeWritable(PVM pVM, PPGMPAGE pPage, RTGCPHYS GCPhys);
    42214225int             pgmPhysPageMakeWritableAndMap(PVM pVM, PPGMPAGE pPage, RTGCPHYS GCPhys, void **ppv);
     
    42354239DECLEXPORT(FNPGMRZPHYSPFHANDLER)    pgmPhysRomWritePfHandler;
    42364240#endif
    4237 int             pgmPhysFreePage(PVM pVM, PGMMFREEPAGESREQ pReq, uint32_t *pcPendingPages, PPGMPAGE pPage, RTGCPHYS GCPhys);
     4241int             pgmPhysFreePage(PVM pVM, PGMMFREEPAGESREQ pReq, uint32_t *pcPendingPages, PPGMPAGE pPage, RTGCPHYS GCPhys,
     4242                                PGMPAGETYPE enmNewType);
    42384243void            pgmPhysInvalidRamRangeTlbs(PVM pVM);
    42394244void            pgmPhysInvalidatePageMapTLB(PVM pVM);
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