VirtualBox

Changeset 56055 in vbox


Ignore:
Timestamp:
May 24, 2015 3:55:01 PM (10 years ago)
Author:
vboxsync
Message:

PGMPhysRead,PGMPhysWrite: Compile the code for calling the new ring-0 and raw-mode handler callback (won't actually be called yet).

File:
1 edited

Legend:

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

    r56049 r56055  
    23142314        }
    23152315#endif
    2316 #ifdef IN_RING3 //temp
    23172316        PFNPGMPHYSHANDLER pfnHandler = PGMPHYSHANDLER_GET_TYPE(pVM, pPhys)->CTX_SUFF(pfnHandler); Assert(pfnHandler);
    23182317        void *pvUser = pPhys->CTX_SUFF(pvUser);
     
    23422341            return rcStrict;
    23432342        }
    2344 #endif //temp
    2345     }
    2346 
     2343    }
     2344
     2345#if !defined(IN_RING0) && defined(VBOX_WITH_RAW_MODE)
    23472346    /*
    23482347     * Deal with any virtual handlers.
     
    23572356        Assert(GCPhys >= pVirt->aPhysToVirt[iPage].Core.Key && GCPhys <= pVirt->aPhysToVirt[iPage].Core.KeyLast);
    23582357
    2359 #ifndef IN_RING3
     2358# ifndef IN_RING3
    23602359        //if (enmOrigin != PGMACCESSORIGIN_IOM)
    23612360        {
     
    23642363            return VERR_PGM_PHYS_WR_HIT_HANDLER;
    23652364        }
    2366 #endif
    2367 #ifdef IN_RING3 //temp
     2365# endif
    23682366        PPGMVIRTHANDLERTYPEINT pVirtType = PGMVIRTANDLER_GET_TYPE(pVM, pVirt);
    2369 #ifdef IN_RING3
    2370         if (pVirtType->CTX_SUFF(pfnHandler))
    2371 #endif
    2372         {
    2373             if (!pPhys)
    2374                 Log5(("pgmPhysReadHandler: GCPhys=%RGp cb=%#x pPage=%R[pgmpage] virt %s\n", GCPhys, cb, pPage, R3STRING(pVirt->pszDesc) ));
    2375             else
    2376                 Log(("pgmPhysReadHandler: GCPhys=%RGp cb=%#x pPage=%R[pgmpage] phys/virt %s/%s\n", GCPhys, cb, pPage, R3STRING(pVirt->pszDesc), R3STRING(pPhys->pszDesc) ));
    2377             RTGCUINTPTR GCPtr = ((RTGCUINTPTR)pVirt->Core.Key & PAGE_BASE_GC_MASK)
    2378                               + (iPage << PAGE_SHIFT)
    2379                               + (GCPhys & PAGE_OFFSET_MASK);
    2380 
    2381             STAM_PROFILE_START(&pVirt->Stat, h);
    2382             VBOXSTRICTRC rcStrict2 = pVirtType->CTX_SUFF(pfnHandler)(pVM, pVCpu, GCPtr, (void *)pvSrc, pvBuf, cb,
    2383                                                                      PGMACCESSTYPE_READ, enmOrigin, pVirt->CTX_SUFF(pvUser));
    2384             STAM_PROFILE_STOP(&pVirt->Stat, h);
    2385 
    2386             /* Merge status codes. */
    2387             if (rcStrict2 == VINF_SUCCESS)
    2388             {
    2389                 if (rcStrict == VINF_PGM_HANDLER_DO_DEFAULT)
    2390                     rcStrict = VINF_SUCCESS;
    2391             }
    2392             else if (rcStrict2 != VINF_PGM_HANDLER_DO_DEFAULT)
    2393             {
    2394                 AssertLogRelMsg(PGM_HANDLER_VIRT_IS_VALID_STATUS(rcStrict2, false),
    2395                                 ("rcStrict2=%Rrc (rcStrict=%Rrc) GCPhys=%RGp pPage=%R[pgmpage] %s\n",
    2396                                  VBOXSTRICTRC_VAL(rcStrict2), VBOXSTRICTRC_VAL(rcStrict), GCPhys, pPage, pVirt->pszDesc));
    2397                  if (!PGM_PHYS_RW_IS_SUCCESS(rcStrict2))
    2398                  {
    2399                      pgmPhysReleaseInternalPageMappingLock(pVM, &PgMpLck);
    2400                      return rcStrict2;
    2401                  }
    2402                  if (rcStrict == VINF_PGM_HANDLER_DO_DEFAULT)
    2403                      rcStrict = rcStrict2;
    2404                  else
    2405                      PGM_PHYS_RW_DO_UPDATE_STRICT_RC(rcStrict, rcStrict2);
    2406             }
    2407         }
    2408 #ifdef IN_RING3
     2367        if (!pPhys)
     2368            Log5(("pgmPhysReadHandler: GCPhys=%RGp cb=%#x pPage=%R[pgmpage] virt %s\n", GCPhys, cb, pPage, R3STRING(pVirt->pszDesc) ));
    24092369        else
    2410         {
    2411             Log5(("pgmPhysReadHandler: GCPhys=%RGp cb=%#x pPage=%R[pgmpage] virt %s [no handler]\n", GCPhys, cb, pPage, R3STRING(pVirt->pszDesc) ));
    2412             Assert(pVirtType->enmKind == PGMVIRTHANDLERKIND_HYPERVISOR);
    2413         }
    2414 #endif
    2415 #endif //temp
    2416     }
     2370            Log(("pgmPhysReadHandler: GCPhys=%RGp cb=%#x pPage=%R[pgmpage] phys/virt %s/%s\n", GCPhys, cb, pPage, R3STRING(pVirt->pszDesc), R3STRING(pPhys->pszDesc) ));
     2371        RTGCUINTPTR GCPtr = ((RTGCUINTPTR)pVirt->Core.Key & PAGE_BASE_GC_MASK)
     2372                          + (iPage << PAGE_SHIFT)
     2373                          + (GCPhys & PAGE_OFFSET_MASK);
     2374
     2375        STAM_PROFILE_START(&pVirt->Stat, h);
     2376        VBOXSTRICTRC rcStrict2 = pVirtType->CTX_SUFF(pfnHandler)(pVM, pVCpu, GCPtr, (void *)pvSrc, pvBuf, cb,
     2377                                                                 PGMACCESSTYPE_READ, enmOrigin, pVirt->CTX_SUFF(pvUser));
     2378        STAM_PROFILE_STOP(&pVirt->Stat, h);
     2379
     2380        /* Merge status codes. */
     2381        if (rcStrict2 == VINF_SUCCESS)
     2382        {
     2383            if (rcStrict == VINF_PGM_HANDLER_DO_DEFAULT)
     2384                rcStrict = VINF_SUCCESS;
     2385        }
     2386        else if (rcStrict2 != VINF_PGM_HANDLER_DO_DEFAULT)
     2387        {
     2388            AssertLogRelMsg(PGM_HANDLER_VIRT_IS_VALID_STATUS(rcStrict2, false),
     2389                            ("rcStrict2=%Rrc (rcStrict=%Rrc) GCPhys=%RGp pPage=%R[pgmpage] %s\n",
     2390                             VBOXSTRICTRC_VAL(rcStrict2), VBOXSTRICTRC_VAL(rcStrict), GCPhys, pPage, pVirt->pszDesc));
     2391             if (!PGM_PHYS_RW_IS_SUCCESS(rcStrict2))
     2392             {
     2393                 pgmPhysReleaseInternalPageMappingLock(pVM, &PgMpLck);
     2394                 return rcStrict2;
     2395             }
     2396             if (rcStrict == VINF_PGM_HANDLER_DO_DEFAULT)
     2397                 rcStrict = rcStrict2;
     2398             else
     2399                 PGM_PHYS_RW_DO_UPDATE_STRICT_RC(rcStrict, rcStrict2);
     2400        }
     2401    }
     2402#endif /* !IN_RING0 && VBOX_WITH_RAW_MODE */
    24172403
    24182404    /*
     
    26182604                return VERR_PGM_PHYS_WR_HIT_HANDLER;
    26192605#endif
    2620 #ifdef IN_RING3 //temp
    26212606            size_t cbRange = pCur->Core.KeyLast - GCPhys + 1;
    26222607            if (cbRange > cbWrite)
     
    26752660            pvBuf    = (uint8_t *)pvBuf + cbRange;
    26762661            pvDst    = (uint8_t *)pvDst + cbRange;
    2677 #endif//temp
    26782662        }
    26792663        else /* The handler is somewhere else in the page, deal with it below. */
     
    26812665        Assert(!PGM_PAGE_IS_MMIO_OR_ALIAS(pPage)); /* MMIO handlers are all PAGE_SIZEed! */
    26822666    }
     2667#if !defined(IN_RING0) && defined(VBOX_WITH_RAW_MODE)
    26832668    /*
    26842669     * A virtual handler without any interfering physical handlers.
     
    26912676        if (pVirt)
    26922677        {
    2693 #ifndef IN_RING3
     2678# ifndef IN_RING3
    26942679            //if (enmOrigin != PGMACCESSORIGIN_IOM)
    26952680                /* Cannot reliably handle informational status codes in this context */
    26962681                return VERR_PGM_PHYS_WR_HIT_HANDLER;
    2697 #endif
    2698 #ifdef IN_RING3 //temp
     2682# endif
    26992683            PPGMVIRTHANDLERTYPEINT pVirtType = PGMVIRTANDLER_GET_TYPE(pVM, pVirt);
    27002684            size_t cbRange = (PAGE_OFFSET_MASK & pVirt->Core.KeyLast) - (PAGE_OFFSET_MASK & GCPhys) + 1;
     
    27072691            if (RT_SUCCESS(rcStrict))
    27082692            {
    2709                 if (pVirtType->CTX_SUFF(pfnHandler))
    2710                 {
    2711                     RTGCUINTPTR GCPtr = ((RTGCUINTPTR)pVirt->Core.Key & PAGE_BASE_GC_MASK)
    2712                                       + (iPage << PAGE_SHIFT)
    2713                                       + (GCPhys & PAGE_OFFSET_MASK);
    2714 
    2715                     STAM_PROFILE_START(&pVirt->Stat, h);
    2716                     rcStrict = pVirtType->CTX_SUFF(pfnHandler)(pVM, pVCpu, GCPtr, pvDst, (void *)pvBuf, cbRange,
    2717                                                                PGMACCESSTYPE_WRITE, enmOrigin, pVirt->CTX_SUFF(pvUser));
    2718                     STAM_PROFILE_STOP(&pVirt->Stat, h);
    2719                 }
    2720                 else
    2721                     rcStrict = VINF_PGM_HANDLER_DO_DEFAULT;
     2693                Assert(pVirtType->CTX_SUFF(pfnHandler));
     2694                RTGCUINTPTR GCPtr = ((RTGCUINTPTR)pVirt->Core.Key & PAGE_BASE_GC_MASK)
     2695                                  + (iPage << PAGE_SHIFT)
     2696                                  + (GCPhys & PAGE_OFFSET_MASK);
     2697
     2698                STAM_PROFILE_START(&pVirt->Stat, h);
     2699                rcStrict = pVirtType->CTX_SUFF(pfnHandler)(pVM, pVCpu, GCPtr, pvDst, (void *)pvBuf, cbRange,
     2700                                                           PGMACCESSTYPE_WRITE, enmOrigin, pVirt->CTX_SUFF(pvUser));
     2701                STAM_PROFILE_STOP(&pVirt->Stat, h);
    27222702                if (rcStrict == VINF_PGM_HANDLER_DO_DEFAULT)
    27232703                {
     
    27442724            pvBuf    = (uint8_t *)pvBuf + cbRange;
    27452725            pvDst    = (uint8_t *)pvDst + cbRange;
    2746 #endif
    27472726        }
    27482727        else /* The handler is somewhere else in the page, deal with it below. */
    27492728            rcStrict = VINF_SUCCESS;
    27502729    }
     2730#endif /* !IN_RING0 && VBOX_WITH_RAW_MODE */
    27512731    else
    27522732        rcStrict = VINF_SUCCESS;
     2733
    27532734
    27542735    /*
     
    27672748
    27682749    /* The loop state (big + ugly). */
     2750#if !defined(IN_RING0) && defined(VBOX_WITH_RAW_MODE)
    27692751    unsigned        iVirtPage   = 0;
    27702752    PPGMVIRTHANDLER pVirt       = NULL;
     
    27722754    uint32_t        offVirtLast = PAGE_SIZE;
    27732755    bool            fMoreVirt   = PGM_PAGE_HAS_ACTIVE_VIRTUAL_HANDLERS(pPage);
     2756#else
     2757    uint32_t const  offVirt     = UINT32_MAX;
     2758#endif
    27742759
    27752760    PPGMPHYSHANDLER pPhys       = NULL;
     
    27812766    for (;;)
    27822767    {
     2768#if !defined(IN_RING0) && defined(VBOX_WITH_RAW_MODE)
    27832769        /*
    27842770         * Find the closest handler at or above GCPhys.
     
    28172803            }
    28182804        }
     2805#endif
    28192806
    28202807        if (fMorePhys && !pPhys)
     
    28682855                return VERR_PGM_PHYS_WR_HIT_HANDLER;
    28692856#endif
    2870 #ifdef IN_RING3 //temp
    28712857            if (cbRange > offPhysLast + 1)
    28722858                cbRange = offPhysLast + 1;
     
    28962882                            ("rcStrict2=%Rrc (rcStrict=%Rrc) GCPhys=%RGp pPage=%R[pgmpage] %s\n", VBOXSTRICTRC_VAL(rcStrict2),
    28972883                             VBOXSTRICTRC_VAL(rcStrict), GCPhys, pPage,  pPhys ? R3STRING(pPhys->pszDesc) : ""));
    2898 #endif//temp
    2899         }
     2884        }
     2885#if !defined(IN_RING0) && defined(VBOX_WITH_RAW_MODE)
    29002886        /*
    29012887         * Virtual handler.
     
    29032889        else if (offPhys && !offVirt)
    29042890        {
    2905 #ifndef IN_RING3
     2891# ifndef IN_RING3
    29062892            //if (enmOrigin != PGMACCESSORIGIN_IOM)
    29072893                /* Cannot reliably handle informational status codes in this context */
    29082894                return VERR_PGM_PHYS_WR_HIT_HANDLER;
    2909 #endif
    2910 #ifdef IN_RING3//temp
     2895# endif
    29112896            if (cbRange > offVirtLast + 1)
    29122897                cbRange = offVirtLast + 1;
     
    29162901            PPGMVIRTHANDLERTYPEINT pVirtType = PGMVIRTANDLER_GET_TYPE(pVM, pVirt);
    29172902            Log5(("pgmPhysWriteHandler: GCPhys=%RGp cbRange=%#x pPage=%R[pgmpage] phys %s\n", GCPhys, cbRange, pPage, R3STRING(pVirt->pszDesc) ));
    2918             if (pVirtType->CTX_SUFF(pfnHandler))
    2919             {
    2920                 RTGCUINTPTR GCPtr = ((RTGCUINTPTR)pVirt->Core.Key & PAGE_BASE_GC_MASK)
    2921                                   + (iVirtPage << PAGE_SHIFT)
    2922                                   + (GCPhys & PAGE_OFFSET_MASK);
    2923                 STAM_PROFILE_START(&pVirt->Stat, h);
    2924                 rcStrict2 = pVirtType->CTX_SUFF(pfnHandler)(pVM, pVCpu, GCPtr, pvDst, (void *)pvBuf, cbRange, PGMACCESSTYPE_WRITE,
    2925                                                             enmOrigin, pVirt->CTX_SUFF(pvUser));
    2926                 STAM_PROFILE_STOP(&pVirt->Stat, h);
    2927                 AssertLogRelMsg(PGM_HANDLER_VIRT_IS_VALID_STATUS(rcStrict2, true),
    2928                                 ("rcStrict2=%Rrc (rcStrict=%Rrc) GCPhys=%RGp pPage=%R[pgmpage] %s\n", VBOXSTRICTRC_VAL(rcStrict2),
    2929                                  VBOXSTRICTRC_VAL(rcStrict), GCPhys, pPage,  pPhys ? R3STRING(pPhys->pszDesc) : ""));
    2930             }
     2903            Assert(pVirtType->CTX_SUFF(pfnHandler));
     2904            RTGCUINTPTR GCPtr = ((RTGCUINTPTR)pVirt->Core.Key & PAGE_BASE_GC_MASK)
     2905                              + (iVirtPage << PAGE_SHIFT)
     2906                              + (GCPhys & PAGE_OFFSET_MASK);
     2907            STAM_PROFILE_START(&pVirt->Stat, h);
     2908            rcStrict2 = pVirtType->CTX_SUFF(pfnHandler)(pVM, pVCpu, GCPtr, pvDst, (void *)pvBuf, cbRange, PGMACCESSTYPE_WRITE,
     2909                                                        enmOrigin, pVirt->CTX_SUFF(pvUser));
     2910            STAM_PROFILE_STOP(&pVirt->Stat, h);
     2911            AssertLogRelMsg(PGM_HANDLER_VIRT_IS_VALID_STATUS(rcStrict2, true),
     2912                            ("rcStrict2=%Rrc (rcStrict=%Rrc) GCPhys=%RGp pPage=%R[pgmpage] %s\n", VBOXSTRICTRC_VAL(rcStrict2),
     2913                             VBOXSTRICTRC_VAL(rcStrict), GCPhys, pPage,  pPhys ? R3STRING(pPhys->pszDesc) : ""));
    29312914            pVirt = NULL;
    2932 #endif//temp
    29332915        }
    29342916        /*
     
    29372919        else
    29382920        {
    2939 #ifndef IN_RING3
     2921# ifndef IN_RING3
    29402922            //if (enmOrigin != PGMACCESSORIGIN_IOM)
    29412923                /* Cannot reliably handle informational status codes in this context */
    29422924                return VERR_PGM_PHYS_WR_HIT_HANDLER;
    2943 #endif
    2944 #ifdef IN_RING3//temp
     2925# endif
    29452926            Assert(!offPhys && !offVirt);
    29462927            if (cbRange > offVirtLast + 1)
     
    29642945            pgmLock(pVM);
    29652946
    2966 #ifdef VBOX_WITH_STATISTICS
     2947# ifdef VBOX_WITH_STATISTICS
    29672948            pPhys = pgmHandlerPhysicalLookup(pVM, GCPhys);
    29682949            if (pPhys)
    29692950                STAM_PROFILE_STOP(&pPhys->Stat, h);
    2970 #else
     2951# else
    29712952            pPhys = NULL; /* might not be valid anymore. */
    2972 #endif
     2953# endif
    29732954            AssertLogRelMsg(PGM_HANDLER_PHYS_IS_VALID_STATUS(rcStrict2, true),
    29742955                            ("rcStrict2=%Rrc (rcStrict=%Rrc) GCPhys=%RGp pPage=%R[pgmpage] %s\n", VBOXSTRICTRC_VAL(rcStrict2),
    29752956                             VBOXSTRICTRC_VAL(rcStrict), GCPhys, pPage,  pPhys ? R3STRING(pPhys->pszDesc) : ""));
    2976             if (   (rcStrict2 == VINF_PGM_HANDLER_DO_DEFAULT || PGM_PHYS_RW_IS_SUCCESS(rcStrict2))
    2977                 && pVirtType->CTX_SUFF(pfnHandler))
     2957            if (rcStrict2 == VINF_PGM_HANDLER_DO_DEFAULT || PGM_PHYS_RW_IS_SUCCESS(rcStrict2))
    29782958            {
     2959                Assert(pVirtType->CTX_SUFF(pfnHandler));
    29792960                RTGCUINTPTR GCPtr = ((RTGCUINTPTR)pVirt->Core.Key & PAGE_BASE_GC_MASK)
    29802961                                  + (iVirtPage << PAGE_SHIFT)
     
    30092990            pPhys = NULL;
    30102991            pVirt = NULL;
    3011 #endif
    3012         }
     2992        }
     2993#endif /* !IN_RING0 && VBOX_WITH_RAW_MODE */
     2994
    30132995
    30142996        /*
     
    30453027        offPhys         -= cbRange;
    30463028        offPhysLast     -= cbRange;
     3029#if !defined(IN_RING0) && defined(VBOX_WITH_RAW_MODE)
    30473030        offVirt         -= cbRange;
    30483031        offVirtLast     -= cbRange;
     3032#endif
    30493033    }
    30503034}
     
    35993583 * respect access handlers and set accessed bits.
    36003584 *
    3601  * @returns VBox status.
     3585 * @returns Strict VBox status, see PGMPhysRead for details.
     3586 * @retval  VERR_PAGE_TABLE_NOT_PRESENT if there is no page mapped at the
     3587 *          specified virtual address.
     3588 *
    36023589 * @param   pVCpu       Handle to the current virtual CPU.
    36033590 * @param   pvDst       The destination address.
     
    36883675 * respect access handlers and set dirty and accessed bits.
    36893676 *
    3690  * @returns VBox status.
    3691  * @retval  VINF_SUCCESS.
    3692  * @retval  VERR_PGM_PHYS_WR_HIT_HANDLER in R0 and GC, NEVER in R3.
     3677 * @returns Strict VBox status, see PGMPhysWrite for details.
     3678 * @retval  VERR_PAGE_TABLE_NOT_PRESENT if there is no page mapped at the
     3679 *          specified virtual address.
    36933680 *
    36943681 * @param   pVCpu       Handle to the current virtual CPU.
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette