Changeset 56055 in vbox
- Timestamp:
- May 24, 2015 3:55:01 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp
r56049 r56055 2314 2314 } 2315 2315 #endif 2316 #ifdef IN_RING3 //temp2317 2316 PFNPGMPHYSHANDLER pfnHandler = PGMPHYSHANDLER_GET_TYPE(pVM, pPhys)->CTX_SUFF(pfnHandler); Assert(pfnHandler); 2318 2317 void *pvUser = pPhys->CTX_SUFF(pvUser); … … 2342 2341 return rcStrict; 2343 2342 } 2344 #endif //temp 2345 } 2346 2343 } 2344 2345 #if !defined(IN_RING0) && defined(VBOX_WITH_RAW_MODE) 2347 2346 /* 2348 2347 * Deal with any virtual handlers. … … 2357 2356 Assert(GCPhys >= pVirt->aPhysToVirt[iPage].Core.Key && GCPhys <= pVirt->aPhysToVirt[iPage].Core.KeyLast); 2358 2357 2359 # ifndef IN_RING32358 # ifndef IN_RING3 2360 2359 //if (enmOrigin != PGMACCESSORIGIN_IOM) 2361 2360 { … … 2364 2363 return VERR_PGM_PHYS_WR_HIT_HANDLER; 2365 2364 } 2366 #endif 2367 #ifdef IN_RING3 //temp 2365 # endif 2368 2366 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) )); 2409 2369 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 */ 2417 2403 2418 2404 /* … … 2618 2604 return VERR_PGM_PHYS_WR_HIT_HANDLER; 2619 2605 #endif 2620 #ifdef IN_RING3 //temp2621 2606 size_t cbRange = pCur->Core.KeyLast - GCPhys + 1; 2622 2607 if (cbRange > cbWrite) … … 2675 2660 pvBuf = (uint8_t *)pvBuf + cbRange; 2676 2661 pvDst = (uint8_t *)pvDst + cbRange; 2677 #endif//temp2678 2662 } 2679 2663 else /* The handler is somewhere else in the page, deal with it below. */ … … 2681 2665 Assert(!PGM_PAGE_IS_MMIO_OR_ALIAS(pPage)); /* MMIO handlers are all PAGE_SIZEed! */ 2682 2666 } 2667 #if !defined(IN_RING0) && defined(VBOX_WITH_RAW_MODE) 2683 2668 /* 2684 2669 * A virtual handler without any interfering physical handlers. … … 2691 2676 if (pVirt) 2692 2677 { 2693 # ifndef IN_RING32678 # ifndef IN_RING3 2694 2679 //if (enmOrigin != PGMACCESSORIGIN_IOM) 2695 2680 /* Cannot reliably handle informational status codes in this context */ 2696 2681 return VERR_PGM_PHYS_WR_HIT_HANDLER; 2697 #endif 2698 #ifdef IN_RING3 //temp 2682 # endif 2699 2683 PPGMVIRTHANDLERTYPEINT pVirtType = PGMVIRTANDLER_GET_TYPE(pVM, pVirt); 2700 2684 size_t cbRange = (PAGE_OFFSET_MASK & pVirt->Core.KeyLast) - (PAGE_OFFSET_MASK & GCPhys) + 1; … … 2707 2691 if (RT_SUCCESS(rcStrict)) 2708 2692 { 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); 2722 2702 if (rcStrict == VINF_PGM_HANDLER_DO_DEFAULT) 2723 2703 { … … 2744 2724 pvBuf = (uint8_t *)pvBuf + cbRange; 2745 2725 pvDst = (uint8_t *)pvDst + cbRange; 2746 #endif2747 2726 } 2748 2727 else /* The handler is somewhere else in the page, deal with it below. */ 2749 2728 rcStrict = VINF_SUCCESS; 2750 2729 } 2730 #endif /* !IN_RING0 && VBOX_WITH_RAW_MODE */ 2751 2731 else 2752 2732 rcStrict = VINF_SUCCESS; 2733 2753 2734 2754 2735 /* … … 2767 2748 2768 2749 /* The loop state (big + ugly). */ 2750 #if !defined(IN_RING0) && defined(VBOX_WITH_RAW_MODE) 2769 2751 unsigned iVirtPage = 0; 2770 2752 PPGMVIRTHANDLER pVirt = NULL; … … 2772 2754 uint32_t offVirtLast = PAGE_SIZE; 2773 2755 bool fMoreVirt = PGM_PAGE_HAS_ACTIVE_VIRTUAL_HANDLERS(pPage); 2756 #else 2757 uint32_t const offVirt = UINT32_MAX; 2758 #endif 2774 2759 2775 2760 PPGMPHYSHANDLER pPhys = NULL; … … 2781 2766 for (;;) 2782 2767 { 2768 #if !defined(IN_RING0) && defined(VBOX_WITH_RAW_MODE) 2783 2769 /* 2784 2770 * Find the closest handler at or above GCPhys. … … 2817 2803 } 2818 2804 } 2805 #endif 2819 2806 2820 2807 if (fMorePhys && !pPhys) … … 2868 2855 return VERR_PGM_PHYS_WR_HIT_HANDLER; 2869 2856 #endif 2870 #ifdef IN_RING3 //temp2871 2857 if (cbRange > offPhysLast + 1) 2872 2858 cbRange = offPhysLast + 1; … … 2896 2882 ("rcStrict2=%Rrc (rcStrict=%Rrc) GCPhys=%RGp pPage=%R[pgmpage] %s\n", VBOXSTRICTRC_VAL(rcStrict2), 2897 2883 VBOXSTRICTRC_VAL(rcStrict), GCPhys, pPage, pPhys ? R3STRING(pPhys->pszDesc) : "")); 2898 #endif//temp 2899 } 2884 } 2885 #if !defined(IN_RING0) && defined(VBOX_WITH_RAW_MODE) 2900 2886 /* 2901 2887 * Virtual handler. … … 2903 2889 else if (offPhys && !offVirt) 2904 2890 { 2905 # ifndef IN_RING32891 # ifndef IN_RING3 2906 2892 //if (enmOrigin != PGMACCESSORIGIN_IOM) 2907 2893 /* Cannot reliably handle informational status codes in this context */ 2908 2894 return VERR_PGM_PHYS_WR_HIT_HANDLER; 2909 #endif 2910 #ifdef IN_RING3//temp 2895 # endif 2911 2896 if (cbRange > offVirtLast + 1) 2912 2897 cbRange = offVirtLast + 1; … … 2916 2901 PPGMVIRTHANDLERTYPEINT pVirtType = PGMVIRTANDLER_GET_TYPE(pVM, pVirt); 2917 2902 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) : "")); 2931 2914 pVirt = NULL; 2932 #endif//temp2933 2915 } 2934 2916 /* … … 2937 2919 else 2938 2920 { 2939 # ifndef IN_RING32921 # ifndef IN_RING3 2940 2922 //if (enmOrigin != PGMACCESSORIGIN_IOM) 2941 2923 /* Cannot reliably handle informational status codes in this context */ 2942 2924 return VERR_PGM_PHYS_WR_HIT_HANDLER; 2943 #endif 2944 #ifdef IN_RING3//temp 2925 # endif 2945 2926 Assert(!offPhys && !offVirt); 2946 2927 if (cbRange > offVirtLast + 1) … … 2964 2945 pgmLock(pVM); 2965 2946 2966 # ifdef VBOX_WITH_STATISTICS2947 # ifdef VBOX_WITH_STATISTICS 2967 2948 pPhys = pgmHandlerPhysicalLookup(pVM, GCPhys); 2968 2949 if (pPhys) 2969 2950 STAM_PROFILE_STOP(&pPhys->Stat, h); 2970 # else2951 # else 2971 2952 pPhys = NULL; /* might not be valid anymore. */ 2972 # endif2953 # endif 2973 2954 AssertLogRelMsg(PGM_HANDLER_PHYS_IS_VALID_STATUS(rcStrict2, true), 2974 2955 ("rcStrict2=%Rrc (rcStrict=%Rrc) GCPhys=%RGp pPage=%R[pgmpage] %s\n", VBOXSTRICTRC_VAL(rcStrict2), 2975 2956 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)) 2978 2958 { 2959 Assert(pVirtType->CTX_SUFF(pfnHandler)); 2979 2960 RTGCUINTPTR GCPtr = ((RTGCUINTPTR)pVirt->Core.Key & PAGE_BASE_GC_MASK) 2980 2961 + (iVirtPage << PAGE_SHIFT) … … 3009 2990 pPhys = NULL; 3010 2991 pVirt = NULL; 3011 #endif 3012 } 2992 } 2993 #endif /* !IN_RING0 && VBOX_WITH_RAW_MODE */ 2994 3013 2995 3014 2996 /* … … 3045 3027 offPhys -= cbRange; 3046 3028 offPhysLast -= cbRange; 3029 #if !defined(IN_RING0) && defined(VBOX_WITH_RAW_MODE) 3047 3030 offVirt -= cbRange; 3048 3031 offVirtLast -= cbRange; 3032 #endif 3049 3033 } 3050 3034 } … … 3599 3583 * respect access handlers and set accessed bits. 3600 3584 * 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 * 3602 3589 * @param pVCpu Handle to the current virtual CPU. 3603 3590 * @param pvDst The destination address. … … 3688 3675 * respect access handlers and set dirty and accessed bits. 3689 3676 * 3690 * @returns VBox status.3691 * @retval V INF_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. 3693 3680 * 3694 3681 * @param pVCpu Handle to the current virtual CPU.
Note:
See TracChangeset
for help on using the changeset viewer.