Changeset 1480 in vbox
- Timestamp:
- Mar 14, 2007 6:27:47 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 23 edited
-
include/VBox/mm.h (modified) (2 diffs)
-
include/VBox/sup.h (modified) (4 diffs)
-
include/VBox/vm.h (modified) (3 diffs)
-
include/VBox/vm.mac (modified) (1 diff)
-
include/VBox/vmapi.h (modified) (2 diffs)
-
src/VBox/HostDrivers/Support/SUPDRV.h (modified) (2 diffs)
-
src/VBox/HostDrivers/Support/SUPDRVIOC.h (modified) (6 diffs)
-
src/VBox/HostDrivers/Support/SUPDRVShared.c (modified) (54 diffs)
-
src/VBox/HostDrivers/Support/SUPLib.cpp (modified) (6 diffs)
-
src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c (modified) (8 diffs)
-
src/VBox/HostDrivers/Support/testcase/tstInt.cpp (modified) (1 diff)
-
src/VBox/HostDrivers/Support/testcase/tstLow.cpp (modified) (2 diffs)
-
src/VBox/HostDrivers/Support/win32/SUPDrv-win32.cpp (modified) (6 diffs)
-
src/VBox/VMM/MM.cpp (modified) (3 diffs)
-
src/VBox/VMM/MMHyper.cpp (modified) (3 diffs)
-
src/VBox/VMM/MMInternal.h (modified) (3 diffs)
-
src/VBox/VMM/MMPagePool.cpp (modified) (1 diff)
-
src/VBox/VMM/SELM.cpp (modified) (1 diff)
-
src/VBox/VMM/SELMInternal.h (modified) (1 diff)
-
src/VBox/VMM/VM.cpp (modified) (6 diffs)
-
src/VBox/VMM/VMMAll/MMAll.cpp (modified) (1 diff)
-
src/VBox/VMM/testcase/tstVMStructGC.cpp (modified) (2 diffs)
-
src/VBox/VMM/testcase/tstVMStructSize.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/mm.h
r834 r1480 25 25 #include <VBox/types.h> 26 26 #include <VBox/x86.h> 27 #include <VBox/sup.h> 27 28 28 29 … … 767 768 768 769 /** 770 * Maps locked R3 virtual memory into the hypervisor region in the GC. 771 * 772 * @return VBox status code. 773 * 774 * @param pVM VM handle. 775 * @param pvR3 The ring-3 address of the memory, must be page aligned. 776 * @param pvR0 The ring-0 address of the memory, must be page aligned. (optional) 777 * @param cPages The number of pages. 778 * @param paPages The page descriptors. 779 * @param pszDesc Mapping description. 780 * @param pGCPtr Where to store the GC address corresponding to pvHC. 781 */ 782 MMR3DECL(int) MMR3HyperMapPages(PVM pVM, void *pvR3, RTR0PTR pvR0, size_t cPages, PCSUPPAGE paPages, const char *pszDesc, PRTGCPTR pGCPtr); 783 784 /** 769 785 * Reserves a hypervisor memory area. 770 786 * Most frequent usage is fence pages and dynamically mappings like the guest PD and PDPTR. -
trunk/include/VBox/sup.h
r1027 r1480 33 33 */ 34 34 35 /** Physical page. 35 /** 36 * Physical page descriptor. 36 37 */ 37 38 #pragma pack(4) /* space is more important. */ … … 42 43 /** Reserved entry for internal use by the caller. */ 43 44 RTHCUINTPTR uReserved; 44 } SUPPAGE , *PSUPPAGE;45 } SUPPAGE; 45 46 #pragma pack() 47 /** Pointer to a page descriptor. */ 48 typedef SUPPAGE *PSUPPAGE; 49 /** Pointer to a const page descriptor. */ 50 typedef const SUPPAGE *PCSUPPAGE; 46 51 47 52 /** … … 428 433 * The pointer stored here on success must be passed to SUPLowFree when 429 434 * the memory should be released. 435 * @param ppvPagesR0 Where to store the ring-0 pointer to the allocated memory. optional. 430 436 * @param paPages Where to store the physical addresses of the individual pages. 431 437 */ 432 SUPR3DECL(int) SUPLowAlloc(unsigned cPages, void **ppvPages, P SUPPAGE paPages);438 SUPR3DECL(int) SUPLowAlloc(unsigned cPages, void **ppvPages, PRTR0PTR ppvPagesR0, PSUPPAGE paPages); 433 439 434 440 /** … … 537 543 SUPR0DECL(int) SUPR0ObjVerifyAccess(void *pvObj, PSUPDRVSESSION pSession, const char *pszObjName); 538 544 539 SUPR0DECL(int) SUPR0LockMem(PSUPDRVSESSION pSession, void *pvR3, unsignedcb, PSUPPAGE paPages);540 SUPR0DECL(int) SUPR0UnlockMem(PSUPDRVSESSION pSession, void *pvR3);541 SUPR0DECL(int) SUPR0ContAlloc(PSUPDRVSESSION pSession, u nsigned cb, void **ppvR0, PRTR3PTR ppvR3, PRTHCPHYS pHCPhys);542 SUPR0DECL(int) SUPR0ContFree(PSUPDRVSESSION pSession, void *pv);543 SUPR0DECL(int) SUPR0LowAlloc(PSUPDRVSESSION pSession, u nsigned cPages, void **ppvR3, PSUPPAGE paPages);544 SUPR0DECL(int) SUPR0LowFree(PSUPDRVSESSION pSession, void *pv);545 SUPR0DECL(int) SUPR0MemAlloc(PSUPDRVSESSION pSession, u nsigned cb, void **ppvR0, void **ppvR3);546 SUPR0DECL(int) SUPR0MemGetPhys(PSUPDRVSESSION pSession, void *pv, PSUPPAGE paPages);547 SUPR0DECL(int) SUPR0MemFree(PSUPDRVSESSION pSession, void *pv);548 SUPR0DECL(int) SUPR0GipMap(PSUPDRVSESSION pSession, PCSUPGLOBALINFOPAGE *ppGip, RTHCPHYS *pHCPhysGid);545 SUPR0DECL(int) SUPR0LockMem(PSUPDRVSESSION pSession, RTR3PTR pvR3, uint32_t cb, PSUPPAGE paPages); 546 SUPR0DECL(int) SUPR0UnlockMem(PSUPDRVSESSION pSession, RTR3PTR pvR3); 547 SUPR0DECL(int) SUPR0ContAlloc(PSUPDRVSESSION pSession, uint32_t cb, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PRTHCPHYS pHCPhys); 548 SUPR0DECL(int) SUPR0ContFree(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr); 549 SUPR0DECL(int) SUPR0LowAlloc(PSUPDRVSESSION pSession, uint32_t cPages, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PSUPPAGE paPages); 550 SUPR0DECL(int) SUPR0LowFree(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr); 551 SUPR0DECL(int) SUPR0MemAlloc(PSUPDRVSESSION pSession, uint32_t cb, PRTR0PTR ppvR0, PRTR3PTR ppvR3); 552 SUPR0DECL(int) SUPR0MemGetPhys(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr, PSUPPAGE paPages); 553 SUPR0DECL(int) SUPR0MemFree(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr); 554 SUPR0DECL(int) SUPR0GipMap(PSUPDRVSESSION pSession, PCSUPGLOBALINFOPAGE *ppGip, PRTHCPHYS pHCPhysGid); 549 555 SUPR0DECL(int) SUPR0GipUnmap(PSUPDRVSESSION pSession); 550 556 SUPR0DECL(int) SUPR0Printf(const char *pszFormat, ...); -
trunk/include/VBox/vm.h
r1283 r1480 28 28 #include <VBox/stam.h> 29 29 #include <VBox/vmapi.h> 30 #include <VBox/sup.h> 30 31 31 32 … … 227 228 */ 228 229 volatile uint32_t fForcedActions; 229 /** P hysical address (real) of this structure. */230 R THCPHYS HCPhysVM;230 /** Pointer to the array of page descriptors for the VM structure allocation. */ 231 R3PTRTYPE(PSUPPAGE) paVMPagesR3; 231 232 /** Session handle. For use when calling SUPR0 APIs. */ 232 233 HCPTRTYPE(PSUPDRVSESSION) pSession; … … 318 319 319 320 /* padding to make gnuc put the StatQemuToGC where msc does. */ 320 #if HC_ARCH_BITS == 32321 /*#if HC_ARCH_BITS == 32 321 322 uint32_t padding0; 322 #endif 323 #endif*/ 323 324 324 325 /** Profiling the total time from Qemu to GC. */ -
trunk/include/VBox/vm.mac
r1283 r1480 40 40 .enmVMState resd 1 41 41 .fForcedActions resd 1 42 . HCPhysVM resq142 .paVMPagesR3 RTR3PTR_RES 1 43 43 .pSession RTR3PTR_RES 1 44 44 .pNext RTHCPTR_RES 1 -
trunk/include/VBox/vmapi.h
r869 r1480 36 36 * @{ */ 37 37 38 /** @def VM_PHYS_ADDR39 * Converts address of data within the VM structure to the equivalent40 * physical address.41 *42 * @returns physical address.43 * @param pVM Pointer to the VM.44 * @param pvInVM Pointer within the VM.45 */46 #define VM_PHYS_ADDR(pVM, pvInVM) ( pVM->PhysVM + (uint32_t)((uintptr_t)pvInVM - (uintptr_t)pVM) )47 48 38 /** @def VM_GUEST_ADDR 49 * Converts host address of data within the VM structure to the equivalent39 * Converts a current context address of data within the VM structure to the equivalent 50 40 * guest address. 51 41 * 52 42 * @returns guest virtual address. 53 43 * @param pVM Pointer to the VM. 54 * @param pvInVM HC Pointer within the VM. 55 */ 56 #define VM_GUEST_ADDR(pVM, pvInVM) ( (RTGCPTR)((RTGCUINTPTR)pVM->pVMGC + (uint32_t)((uintptr_t)(pvInVM) - (uintptr_t)pVM->pVMHC)) ) 44 * @param pvInVM CC Pointer within the VM. 45 */ 46 #ifdef IN_RING3 47 # define VM_GUEST_ADDR(pVM, pvInVM) ( (RTGCPTR)((RTGCUINTPTR)pVM->pVMGC + (uint32_t)((uintptr_t)(pvInVM) - (uintptr_t)pVM->pVMR3)) ) 48 #elif defined(IN_RING0) 49 # define VM_GUEST_ADDR(pVM, pvInVM) ( (RTGCPTR)((RTGCUINTPTR)pVM->pVMGC + (uint32_t)((uintptr_t)(pvInVM) - (uintptr_t)pVM->pVMR0)) ) 50 #else 51 # define VM_GUEST_ADDR(pVM, pvInVM) ( (RTGCPTR)(pvInVM) ) 52 #endif 53 54 /** @def VM_R3_ADDR 55 * Converts a current context address of data within the VM structure to the equivalent 56 * ring-3 host address. 57 * 58 * @returns host virtual address. 59 * @param pVM Pointer to the VM. 60 * @param pvInVM CC pointer within the VM. 61 */ 62 #ifdef IN_GC 63 # define VM_R3_ADDR(pVM, pvInVM) ( (RTR3PTR)((RTR3UINTPTR)pVM->pVMR3 + (uint32_t)((uintptr_t)(pvInVM) - (uintptr_t)pVM->pVMGC)) ) 64 #elif defined(IN_RING0) 65 # define VM_R3_ADDR(pVM, pvInVM) ( (RTR3PTR)((RTR3UINTPTR)pVM->pVMR3 + (uint32_t)((uintptr_t)(pvInVM) - (uintptr_t)pVM->pVMR0)) ) 66 #else 67 # define VM_R3_ADDR(pVM, pvInVM) ( (RTR3PTR)(pvInVM) ) 68 #endif 69 70 71 /** @def VM_R0_ADDR 72 * Converts a current context address of data within the VM structure to the equivalent 73 * ring-0 host address. 74 * 75 * @returns host virtual address. 76 * @param pVM Pointer to the VM. 77 * @param pvInVM CC pointer within the VM. 78 */ 79 #ifdef IN_GC 80 # define VM_R0_ADDR(pVM, pvInVM) ( (RTR0PTR)((RTR0UINTPTR)pVM->pVMR0 + (uint32_t)((uintptr_t)(pvInVM) - (uintptr_t)pVM->pVMGC)) ) 81 #elif defined(IN_RING3) 82 # define VM_R0_ADDR(pVM, pvInVM) ( (RTR0PTR)((RTR0UINTPTR)pVM->pVMR0 + (uint32_t)((uintptr_t)(pvInVM) - (uintptr_t)pVM->pVMR3)) ) 83 #else 84 # define VM_R0_ADDR(pVM, pvInVM) ( (RTR0PTR)(pvInVM) ) 85 #endif 57 86 58 87 /** @def VM_HOST_ADDR … … 63 92 * @param pVM Pointer to the VM. 64 93 * @param pvInVM GC Pointer within the VM. 94 * @deprecated 65 95 */ 66 96 #define VM_HOST_ADDR(pVM, pvInVM) ( (RTHCPTR)((RTHCUINTPTR)pVM->pVMHC + (uint32_t)((uintptr_t)(pvInVM) - (uintptr_t)pVM->pVMGC)) ) 97 67 98 68 99 -
trunk/src/VBox/HostDrivers/Support/SUPDRV.h
r1193 r1480 357 357 /** Pointer to the R3 mapping of the memory. 358 358 * Set to NULL if N/A. */ 359 void *pvR3;359 RTR3PTR pvR3; 360 360 /** Size of the locked memory. */ 361 361 unsigned cb; … … 662 662 int VBOXCALL supdrvOSLockMemOne(PSUPDRVMEMREF pMem, PSUPPAGE paPages); 663 663 void VBOXCALL supdrvOSUnlockMemOne(PSUPDRVMEMREF pMem); 664 int VBOXCALL supdrvOSContAllocOne(PSUPDRVMEMREF pMem, void **ppvR0, void **ppvR3, PRTHCPHYS pHCPhys);664 int VBOXCALL supdrvOSContAllocOne(PSUPDRVMEMREF pMem, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PRTHCPHYS pHCPhys); 665 665 void VBOXCALL supdrvOSContFreeOne(PSUPDRVMEMREF pMem); 666 int VBOXCALL supdrvOSLowAllocOne(PSUPDRVMEMREF pMem, void **ppvR3, PSUPPAGE paPages);666 int VBOXCALL supdrvOSLowAllocOne(PSUPDRVMEMREF pMem, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PSUPPAGE paPages); 667 667 void VBOXCALL supdrvOSLowFreeOne(PSUPDRVMEMREF pMem); 668 int VBOXCALL supdrvOSMemAllocOne(PSUPDRVMEMREF pMem, void **ppvR0, void **ppvR3);668 int VBOXCALL supdrvOSMemAllocOne(PSUPDRVMEMREF pMem, PRTR0PTR ppvR0, PRTR3PTR ppvR3); 669 669 void VBOXCALL supdrvOSMemGetPages(PSUPDRVMEMREF pMem, PSUPPAGE paPages); 670 670 void VBOXCALL supdrvOSMemFreeOne(PSUPDRVMEMREF pMem); -
trunk/src/VBox/HostDrivers/Support/SUPDRVIOC.h
r1193 r1480 181 181 #define SUPCOOKIE_MAGIC "The Magic Word!" 182 182 /** Current interface version. */ 183 #define SUPDRVIOC_VERSION 0x0004000 0183 #define SUPDRVIOC_VERSION 0x00040001 184 184 185 185 /** SUP_IOCTL_COOKIE Output. */ … … 263 263 uint32_t u32SessionCookie; 264 264 /** Start of page range. Must be PAGE aligned. */ 265 void *pv;265 RTR3PTR pvR3; 266 266 /** Size of the range. Must be PAGE aligned. */ 267 267 uint32_t cb; … … 285 285 uint32_t u32SessionCookie; 286 286 /** Start of page range of a range previuosly pinned. */ 287 void *pv;287 RTR3PTR pvR3; 288 288 } SUPUNPINPAGES_IN, *PSUPUNPINPAGES_IN; 289 289 … … 320 320 /** Session cookie. */ 321 321 uint32_t u32SessionCookie; 322 /** The address (virtual, not physical address)of the memory to free. */323 void *pv;322 /** The ring-3 address of the memory to free. */ 323 RTR3PTR pvR3; 324 324 } SUPCONTFREE_IN, *PSUPCONTFREE_IN; 325 325 … … 511 511 typedef struct SUPLOWALLOC_OUT 512 512 { 513 /** The address (virtual & linear) of the allocated memory. */ 514 void *pvVirt; 513 /** The ring-3 address of the allocated memory. */ 514 RTR3PTR pvR3; 515 /** The ring-0 address of the allocated memory. */ 516 RTR0PTR pvR0; 515 517 /** Array of pages. */ 516 518 SUPPAGE aPages[1]; … … 525 527 /** Session cookie. */ 526 528 uint32_t u32SessionCookie; 527 /** The address (virtual, not physical address)of the memory to free. */528 void *pv;529 /** The ring-3 address of the memory to free. */ 530 RTR3PTR pvR3; 529 531 } SUPLOWFREE_IN, *PSUPLOWFREE_IN; 530 532 -
trunk/src/VBox/HostDrivers/Support/SUPDRVShared.c
r1193 r1480 146 146 __BEGIN_DECLS 147 147 static int supdrvMemAdd(PSUPDRVMEMREF pMem, PSUPDRVSESSION pSession); 148 static int supdrvMemRelease(PSUPDRVSESSION pSession, void *pv, SUPDRVMEMREFTYPE eType);148 static int supdrvMemRelease(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr, SUPDRVMEMREFTYPE eType); 149 149 #ifndef VBOX_WITHOUT_IDT_PATCHING 150 150 static int supdrvIOCtl_IdtInstall(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPIDTINSTALL_IN pIn, PSUPIDTINSTALL_OUT pOut); … … 644 644 || cbOut != sizeof(*pOut)) 645 645 { 646 dprintf(("SUP_IOCTL_COOKIE: Invalid input/output sizes. cbIn=% d expected %d. cbOut=%d expected %d.\n",647 cbIn, sizeof(*pIn), cbOut,sizeof(*pOut)));646 dprintf(("SUP_IOCTL_COOKIE: Invalid input/output sizes. cbIn=%ld expected %ld. cbOut=%ld expected %ld.\n", 647 (long)cbIn, (long)sizeof(*pIn), (long)cbOut, (long)sizeof(*pOut))); 648 648 return SUPDRV_ERR_INVALID_PARAM; 649 649 } … … 685 685 || cbOut < sizeof(*pOut)) 686 686 { 687 dprintf(("SUP_IOCTL_QUERY_FUNCS: Invalid input/output sizes. cbIn=% d expected %d. cbOut=%d expected %d.\n",688 cbIn, sizeof(*pIn), cbOut,sizeof(*pOut)));687 dprintf(("SUP_IOCTL_QUERY_FUNCS: Invalid input/output sizes. cbIn=%ld expected %ld. cbOut=%ld expected %ld.\n", 688 (long)cbIn, (long)sizeof(*pIn), (long)cbOut, (long)sizeof(*pOut))); 689 689 return SUPDRV_ERR_INVALID_PARAM; 690 690 } … … 723 723 || cbOut != sizeof(*pOut)) 724 724 { 725 dprintf(("SUP_IOCTL_INSTALL: Invalid input/output sizes. cbIn=% d expected %d. cbOut=%d expected %d.\n",726 cbIn, sizeof(*pIn), cbOut,sizeof(*pOut)));725 dprintf(("SUP_IOCTL_INSTALL: Invalid input/output sizes. cbIn=%ld expected %ld. cbOut=%ld expected %ld.\n", 726 (long)cbIn, (long)sizeof(*pIn), (long)cbOut, (long)sizeof(*pOut))); 727 727 return SUPDRV_ERR_INVALID_PARAM; 728 728 } … … 756 756 || cbOut != 0) 757 757 { 758 dprintf(("SUP_IOCTL_REMOVE: Invalid input/output sizes. cbIn=% d expected %d. cbOut=%d expected %d.\n",759 cbIn, sizeof(*pIn), cbOut,0));758 dprintf(("SUP_IOCTL_REMOVE: Invalid input/output sizes. cbIn=%ld expected %ld. cbOut=%ld expected %ld.\n", 759 (long)cbIn, (long)sizeof(*pIn), (long)cbOut, (long)0)); 760 760 return SUPDRV_ERR_INVALID_PARAM; 761 761 } … … 788 788 || cbOut < sizeof(*pOut)) 789 789 { 790 dprintf(("SUP_IOCTL_PINPAGES: Invalid input/output sizes. cbIn=% d expected %d. cbOut=%d expected %d.\n",791 cbIn, sizeof(*pIn), cbOut,sizeof(*pOut)));790 dprintf(("SUP_IOCTL_PINPAGES: Invalid input/output sizes. cbIn=%ld expected %ld. cbOut=%ld expected %ld.\n", 791 (long)cbIn, (long)sizeof(*pIn), (long)cbOut, (long)sizeof(*pOut))); 792 792 return SUPDRV_ERR_INVALID_PARAM; 793 793 } … … 799 799 return SUPDRV_ERR_INVALID_MAGIC; 800 800 } 801 if (pIn->cb <= 0 || !pIn->pv )802 { 803 dprintf(("SUP_IOCTL_PINPAGES: Illegal request %p %d\n", pIn->pv, pIn->cb));801 if (pIn->cb <= 0 || !pIn->pvR3) 802 { 803 dprintf(("SUP_IOCTL_PINPAGES: Illegal request %p %d\n", (void *)pIn->pvR3, pIn->cb)); 804 804 return SUPDRV_ERR_INVALID_PARAM; 805 805 } … … 815 815 */ 816 816 *pcbReturned = RT_OFFSETOF(SUPPINPAGES_OUT, aPages[pIn->cb >> PAGE_SHIFT]); 817 rc = SUPR0LockMem(pSession, pIn->pv , pIn->cb, &pOut->aPages[0]);817 rc = SUPR0LockMem(pSession, pIn->pvR3, pIn->cb, &pOut->aPages[0]); 818 818 if (rc) 819 819 *pcbReturned = 0; … … 832 832 || cbOut != 0) 833 833 { 834 dprintf(("SUP_IOCTL_UNPINPAGES: Invalid input/output sizes. cbIn=% d expected %d. cbOut=%d expected %d.\n",835 cbIn, sizeof(*pIn), cbOut,0));834 dprintf(("SUP_IOCTL_UNPINPAGES: Invalid input/output sizes. cbIn=%ld expected %ld. cbOut=%ld expected %ld.\n", 835 (long)cbIn, (long)sizeof(*pIn), (long)cbOut, (long)0)); 836 836 return SUPDRV_ERR_INVALID_PARAM; 837 837 } … … 847 847 * Execute. 848 848 */ 849 return SUPR0UnlockMem(pSession, pIn->pv );849 return SUPR0UnlockMem(pSession, pIn->pvR3); 850 850 } 851 851 … … 862 862 || cbOut < sizeof(*pOut)) 863 863 { 864 dprintf(("SUP_IOCTL_CONT_ALLOC: Invalid input/output sizes. cbIn=% d expected %d. cbOut=%d expected %d.\n",865 cbIn, sizeof(*pIn), cbOut,sizeof(*pOut)));864 dprintf(("SUP_IOCTL_CONT_ALLOC: Invalid input/output sizes. cbIn=%ld expected %ld. cbOut=%ld expected %ld.\n", 865 (long)cbIn, (long)sizeof(*pIn), (long)cbOut, (long)sizeof(*pOut))); 866 866 return SUPDRV_ERR_INVALID_PARAM; 867 867 } … … 894 894 || cbOut != 0) 895 895 { 896 dprintf(("SUP_IOCTL_CONT_FREE: Invalid input/output sizes. cbIn=% d expected %d. cbOut=%d expected %d.\n",897 cbIn, sizeof(*pIn), cbOut,0));896 dprintf(("SUP_IOCTL_CONT_FREE: Invalid input/output sizes. cbIn=%ld expected %ld. cbOut=%ld expected %ld.\n", 897 (long)cbIn, (long)sizeof(*pIn), (long)cbOut, (long)0)); 898 898 return SUPDRV_ERR_INVALID_PARAM; 899 899 } … … 909 909 * Execute. 910 910 */ 911 return SUPR0ContFree(pSession, pIn->pv);911 return SUPR0ContFree(pSession, (RTHCUINTPTR)pIn->pvR3); 912 912 } 913 913 … … 924 924 || cbOut != sizeof(*pOut)) 925 925 { 926 dprintf(("SUP_IOCTL_LDR_OPEN: Invalid input/output sizes. cbIn=% d expected %d. cbOut=%d expected %d.\n",927 cbIn, sizeof(*pIn), cbOut,sizeof(*pOut)));926 dprintf(("SUP_IOCTL_LDR_OPEN: Invalid input/output sizes. cbIn=%ld expected %ld. cbOut=%ld expected %ld.\n", 927 (long)cbIn, (long)sizeof(*pIn), (long)cbOut, (long)sizeof(*pOut))); 928 928 return SUPDRV_ERR_INVALID_PARAM; 929 929 } … … 972 972 || cbOut != 0) 973 973 { 974 dprintf(("SUP_IOCTL_LDR_LOAD: Invalid input/output sizes. cbIn=% d expected greater than %d. cbOut=%d expected %d.\n",975 cbIn, sizeof(*pIn), cbOut,0));974 dprintf(("SUP_IOCTL_LDR_LOAD: Invalid input/output sizes. cbIn=%ld expected greater than %ld. cbOut=%ld expected %ld.\n", 975 (long)cbIn, (long)sizeof(*pIn), (long)cbOut, (long)0)); 976 976 return SUPDRV_ERR_INVALID_PARAM; 977 977 } … … 1055 1055 || cbOut != 0) 1056 1056 { 1057 dprintf(("SUP_IOCTL_LDR_FREE: Invalid input/output sizes. cbIn=% d expected %d. cbOut=%d expected %d.\n",1058 cbIn, sizeof(*pIn), cbOut,0));1057 dprintf(("SUP_IOCTL_LDR_FREE: Invalid input/output sizes. cbIn=%ld expected %ld. cbOut=%ld expected %ld.\n", 1058 (long)cbIn, (long)sizeof(*pIn), (long)cbOut, (long)0)); 1059 1059 return SUPDRV_ERR_INVALID_PARAM; 1060 1060 } … … 1102 1102 if (pszEnd - &pIn->szSymbol[0] >= 1024) 1103 1103 { 1104 dprintf(("SUP_IOCTL_LDR_GET_SYMBOL: The symbol name too long (% d chars, max is %d)!\n",1105 pszEnd - &pIn->szSymbol[0], 1024));1104 dprintf(("SUP_IOCTL_LDR_GET_SYMBOL: The symbol name too long (%ld chars, max is %d)!\n", 1105 (long)(pszEnd - &pIn->szSymbol[0]), 1024)); 1106 1106 return SUPDRV_ERR_INVALID_PARAM; 1107 1107 } … … 1125 1125 || cbOut != sizeof(*pOut)) 1126 1126 { 1127 dprintf(("SUP_IOCTL_CALL_VMMR0: Invalid input/output sizes. cbIn=% d expected %d. cbOut=%d expected %d.\n",1128 cbIn, sizeof(*pIn), cbOut,sizeof(*pOut)));1127 dprintf(("SUP_IOCTL_CALL_VMMR0: Invalid input/output sizes. cbIn=%ld expected %ld. cbOut=%ld expected %ld.\n", 1128 (long)cbIn, (long)sizeof(*pIn), (long)cbOut, (long)sizeof(*pOut))); 1129 1129 return SUPDRV_ERR_INVALID_PARAM; 1130 1130 } … … 1164 1164 || cbOut != sizeof(*pOut)) 1165 1165 { 1166 dprintf(("SUP_IOCTL_GET_PAGING_MODE: Invalid input/output sizes. cbIn=% d expected %d. cbOut=%d expected %d.\n",1167 cbIn, sizeof(*pIn), cbOut,sizeof(*pOut)));1166 dprintf(("SUP_IOCTL_GET_PAGING_MODE: Invalid input/output sizes. cbIn=%ld expected %ld. cbOut=%ld expected %ld.\n", 1167 (long)cbIn, (long)sizeof(*pIn), (long)cbOut, (long)sizeof(*pOut))); 1168 1168 return SUPDRV_ERR_INVALID_PARAM; 1169 1169 } … … 1199 1199 || cbOut < sizeof(*pOut)) 1200 1200 { 1201 dprintf(("SUP_IOCTL_LOW_ALLOC: Invalid input/output sizes. cbIn=% d expected %d. cbOut=%d expected %d.\n",1202 cbIn, sizeof(*pIn), cbOut,sizeof(*pOut)));1201 dprintf(("SUP_IOCTL_LOW_ALLOC: Invalid input/output sizes. cbIn=%ld expected %ld. cbOut=%ld expected %ld.\n", 1202 (long)cbIn, (long)sizeof(*pIn), (long)cbOut, (long)sizeof(*pOut))); 1203 1203 return SUPDRV_ERR_INVALID_PARAM; 1204 1204 } … … 1221 1221 */ 1222 1222 *pcbReturned = RT_OFFSETOF(SUPLOWALLOC_OUT, aPages[pIn->cPages]); 1223 rc = SUPR0LowAlloc(pSession, pIn->cPages, &pOut->pv Virt, &pOut->aPages[0]);1223 rc = SUPR0LowAlloc(pSession, pIn->cPages, &pOut->pvR0, &pOut->pvR3, &pOut->aPages[0]); 1224 1224 if (rc) 1225 1225 *pcbReturned = 0; … … 1238 1238 || cbOut != 0) 1239 1239 { 1240 dprintf(("SUP_IOCTL_LOW_FREE: Invalid input/output sizes. cbIn=% d expected %d. cbOut=%d expected %d.\n",1241 cbIn, sizeof(*pIn), cbOut,0));1240 dprintf(("SUP_IOCTL_LOW_FREE: Invalid input/output sizes. cbIn=%ld expected %ld. cbOut=%ld expected %ld.\n", 1241 (long)cbIn, (long)sizeof(*pIn), (long)cbOut, (long)0)); 1242 1242 return SUPDRV_ERR_INVALID_PARAM; 1243 1243 } … … 1253 1253 * Execute. 1254 1254 */ 1255 return SUPR0LowFree(pSession, pIn->pv);1255 return SUPR0LowFree(pSession, (RTHCUINTPTR)pIn->pvR3); 1256 1256 } 1257 1257 … … 1269 1269 || cbOut != sizeof(*pOut)) 1270 1270 { 1271 dprintf(("SUP_IOCTL_GIP_MAP: Invalid input/output sizes. cbIn=% d expected %d. cbOut=%d expected %d.\n",1272 cbIn, sizeof(*pIn), cbOut,0));1271 dprintf(("SUP_IOCTL_GIP_MAP: Invalid input/output sizes. cbIn=%ld expected %ld. cbOut=%ld expected %ld.\n", 1272 (long)cbIn, (long)sizeof(*pIn), (long)cbOut, (long)0)); 1273 1273 return SUPDRV_ERR_INVALID_PARAM; 1274 1274 } … … 1304 1304 || cbOut != 0) 1305 1305 { 1306 dprintf(("SUP_IOCTL_GIP_UNMAP: Invalid input/output sizes. cbIn=% d expected %d. cbOut=%d expected %d.\n",1307 cbIn, sizeof(*pIn), cbOut,0));1306 dprintf(("SUP_IOCTL_GIP_UNMAP: Invalid input/output sizes. cbIn=%ld expected %ld. cbOut=%ld expected %ld.\n", 1307 (long)cbIn, (long)sizeof(*pIn), (long)cbOut, (long)0)); 1308 1308 return SUPDRV_ERR_INVALID_PARAM; 1309 1309 } … … 1333 1333 || cbOut != 0) 1334 1334 { 1335 dprintf(("SUP_IOCTL_SET_VM_FOR_FAST: Invalid input/output sizes. cbIn=% d expected %d. cbOut=%d expected %d.\n",1336 cbIn, sizeof(*pIn), cbOut,0));1335 dprintf(("SUP_IOCTL_SET_VM_FOR_FAST: Invalid input/output sizes. cbIn=%ld expected %ld. cbOut=%ld expected %ld.\n", 1336 (long)cbIn, (long)sizeof(*pIn), (long)cbOut, (long)0)); 1337 1337 return SUPDRV_ERR_INVALID_PARAM; 1338 1338 } … … 1732 1732 * This must be page aligned. 1733 1733 */ 1734 SUPR0DECL(int) SUPR0LockMem(PSUPDRVSESSION pSession, void *pvR3, unsignedcb, PSUPPAGE paPages)1734 SUPR0DECL(int) SUPR0LockMem(PSUPDRVSESSION pSession, RTR3PTR pvR3, uint32_t cb, PSUPPAGE paPages) 1735 1735 { 1736 1736 int rc; 1737 1737 SUPDRVMEMREF Mem = {0}; 1738 1738 dprintf(("SUPR0LockMem: pSession=%p pvR3=%p cb=%d paPages=%p\n", 1739 pSession, pvR3, cb, paPages));1739 pSession, (void *)pvR3, cb, paPages)); 1740 1740 1741 1741 /* 1742 1742 * Verify input. 1743 1743 */ 1744 if (RT_ALIGN_R3PT(pvR3, PAGE_SIZE, void *) != pvR3 || !pvR3)1745 { 1746 dprintf(("pvR3 (%p) must be page aligned and not NULL!\n", pvR3));1744 if (RT_ALIGN_R3PT(pvR3, PAGE_SIZE, RTR3PTR) != pvR3 || !pvR3) 1745 { 1746 dprintf(("pvR3 (%p) must be page aligned and not NULL!\n", (void *)pvR3)); 1747 1747 return SUPDRV_ERR_INVALID_PARAM; 1748 1748 } 1749 if (RT_ALIGN (cb, PAGE_SIZE) != cb)1749 if (RT_ALIGN_Z(cb, PAGE_SIZE) != cb) 1750 1750 { 1751 1751 dprintf(("cb (%u) must be page aligned!\n", cb)); … … 1822 1822 * @param pvR3 Memory to unlock. 1823 1823 */ 1824 SUPR0DECL(int) SUPR0UnlockMem(PSUPDRVSESSION pSession, void *pvR3)1825 { 1826 dprintf(("SUPR0UnlockMem: pSession=%p pvR3=%p\n", pSession, pvR3));1827 return supdrvMemRelease(pSession, pvR3, MEMREF_TYPE_LOCKED);1824 SUPR0DECL(int) SUPR0UnlockMem(PSUPDRVSESSION pSession, RTR3PTR pvR3) 1825 { 1826 dprintf(("SUPR0UnlockMem: pSession=%p pvR3=%p\n", pSession, (void *)pvR3)); 1827 return supdrvMemRelease(pSession, (RTHCUINTPTR)pvR3, MEMREF_TYPE_LOCKED); 1828 1828 } 1829 1829 … … 1837 1837 * @param pSession Session data. 1838 1838 * @param cb Number of bytes to allocate. 1839 * @param ppvR0 Where to put the address of Ring-0 mapping the allocated memory. optional1839 * @param ppvR0 Where to put the address of Ring-0 mapping the allocated memory. 1840 1840 * @param ppvR3 Where to put the address of Ring-3 mapping the allocated memory. 1841 1841 * @param pHCPhys Where to put the physical address of allocated memory. 1842 1842 */ 1843 SUPR0DECL(int) SUPR0ContAlloc(PSUPDRVSESSION pSession, u nsigned cb, void **ppvR0, PRTR3PTR ppvR3, PRTHCPHYS pHCPhys)1843 SUPR0DECL(int) SUPR0ContAlloc(PSUPDRVSESSION pSession, uint32_t cb, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PRTHCPHYS pHCPhys) 1844 1844 { 1845 1845 int rc; … … 1850 1850 * Validate input. 1851 1851 */ 1852 if (!pSession || !ppvR3 || !p HCPhys)1853 { 1854 dprintf(("Null pointer. All of these should be set: pSession=%p ppvR 3=%p pHCPhys=%p\n",1855 pSession, ppvR 3, pHCPhys));1852 if (!pSession || !ppvR3 || !ppvR0 || !pHCPhys) 1853 { 1854 dprintf(("Null pointer. All of these should be set: pSession=%p ppvR0=%p ppvR3=%p pHCPhys=%p\n", 1855 pSession, ppvR0, ppvR3, pHCPhys)); 1856 1856 return SUPDRV_ERR_INVALID_PARAM; 1857 1857 … … 1879 1879 if (!rc) 1880 1880 { 1881 if (ppvR0) 1882 *ppvR0 = RTR0MemObjAddress(Mem.MemObj); 1883 *ppvR3 = RTR0MemObjAddress(Mem.MapObjR3); 1881 *ppvR0 = RTR0MemObjAddress(Mem.MemObj); 1882 *ppvR3 = (RTR3PTR)RTR0MemObjAddress(Mem.MapObjR3); 1884 1883 *pHCPhys = RTR0MemObjGetPagePhysAddr(Mem.MemObj, 0); 1885 1884 return 0; … … 1899 1898 */ 1900 1899 Mem.pvR0 = NULL; 1901 Mem.pvR3 = N ULL;1900 Mem.pvR3 = NIL_RTR3PTR; 1902 1901 Mem.eType = MEMREF_TYPE_CONT; 1903 1902 Mem.cb = cb; … … 1926 1925 * @returns SUPDRV_ERR_* on failure. 1927 1926 * @param pSession The session to which the memory was allocated. 1928 * @param pv Pointer to the memory.1929 */ 1930 SUPR0DECL(int) SUPR0ContFree(PSUPDRVSESSION pSession, void *pv)1931 { 1932 dprintf(("SUPR0ContFree: pSession=%p pv=%p\n", pSession, pv));1933 return supdrvMemRelease(pSession, pv, MEMREF_TYPE_CONT);1927 * @param uPtr Pointer to the memory (ring-3 or ring-0). 1928 */ 1929 SUPR0DECL(int) SUPR0ContFree(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr) 1930 { 1931 dprintf(("SUPR0ContFree: pSession=%p uPtr=%p\n", pSession, (void *)uPtr)); 1932 return supdrvMemRelease(pSession, uPtr, MEMREF_TYPE_CONT); 1934 1933 } 1935 1934 … … 1942 1941 * @param pSession Session data. 1943 1942 * @param cPages Number of pages to allocate. 1943 * @param ppvR0 Where to put the address of Ring-0 mapping of the allocated memory. 1944 1944 * @param ppvR3 Where to put the address of Ring-3 mapping of the allocated memory. 1945 1945 * @param paPages Where to put the physical addresses of allocated memory. 1946 1946 */ 1947 SUPR0DECL(int) SUPR0LowAlloc(PSUPDRVSESSION pSession, u nsigned cPages, void **ppvR3, PSUPPAGE paPages)1947 SUPR0DECL(int) SUPR0LowAlloc(PSUPDRVSESSION pSession, uint32_t cPages, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PSUPPAGE paPages) 1948 1948 { 1949 1949 unsigned iPage; 1950 1950 int rc; 1951 1951 SUPDRVMEMREF Mem = {0}; 1952 dprintf(("SUPR0LowAlloc: pSession=%p cPages=%d ppvR3=%p p aPages=%p\n", pSession, cPages, ppvR3, paPages));1952 dprintf(("SUPR0LowAlloc: pSession=%p cPages=%d ppvR3=%p ppvR0=%p paPages=%p\n", pSession, cPages, ppvR3, ppvR0, paPages)); 1953 1953 1954 1954 /* 1955 1955 * Validate input. 1956 1956 */ 1957 if (!pSession || !ppvR3 || !p aPages)1958 { 1959 dprintf(("Null pointer. All of these should be set: pSession=%p ppvR3=%p p aPages=%p\n",1960 pSession, ppvR3, p aPages));1957 if (!pSession || !ppvR3 || !ppvR0 || !paPages) 1958 { 1959 dprintf(("Null pointer. All of these should be set: pSession=%p ppvR3=%p ppvR0=%p paPages=%p\n", 1960 pSession, ppvR3, ppvR0, paPages)); 1961 1961 return SUPDRV_ERR_INVALID_PARAM; 1962 1962 … … 1990 1990 AssertMsg(!(paPages[iPage].Phys & (PAGE_SIZE - 1)), ("iPage=%d Phys=%VHp\n", paPages[iPage].Phys)); 1991 1991 } 1992 /*if (ppvR0) 1993 *ppvR0 = RTR0MemObjAddress(Mem.MemObj); */ 1992 *ppvR0 = RTR0MemObjAddress(Mem.MemObj); 1994 1993 *ppvR3 = RTR0MemObjAddress(Mem.MapObjR3); 1995 1994 return 0; … … 2010 2009 */ 2011 2010 Mem.pvR0 = NULL; 2012 Mem.pvR3 = N ULL;2011 Mem.pvR3 = NIL_RTR3PTR; 2013 2012 Mem.eType = MEMREF_TYPE_LOW; 2014 2013 Mem.cb = cPages << PAGE_SHIFT; 2015 rc = supdrvOSLowAllocOne(&Mem, ppvR 3, paPages);2014 rc = supdrvOSLowAllocOne(&Mem, ppvR0, ppvR3, paPages); 2016 2015 if (rc) 2017 2016 return rc; 2018 2017 AssertMsg(!((uintptr_t)*ppvR3 & (PAGE_SIZE - 1)), ("Memory is not page aligned! virt=%p\n", *ppvR3)); 2018 AssertMsg(!((uintptr_t)*ppvR0 & (PAGE_SIZE - 1)), ("Memory is not page aligned! virt=%p\n", *ppvR0)); 2019 2019 for (iPage = 0; iPage < cPages; iPage++) 2020 2020 AssertMsg(!(paPages[iPage].Phys & (PAGE_SIZE - 1)), ("iPage=%d Phys=%VHp\n", paPages[iPage].Phys)); … … 2037 2037 * @returns SUPDRV_ERR_* on failure. 2038 2038 * @param pSession The session to which the memory was allocated. 2039 * @param pv Pointer to the memory.2040 */ 2041 SUPR0DECL(int) SUPR0LowFree(PSUPDRVSESSION pSession, void *pv)2042 { 2043 dprintf(("SUPR0LowFree: pSession=%p pv=%p\n", pSession, pv));2044 return supdrvMemRelease(pSession, pv, MEMREF_TYPE_LOW);2039 * @param uPtr Pointer to the memory (ring-3 or ring-0). 2040 */ 2041 SUPR0DECL(int) SUPR0LowFree(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr) 2042 { 2043 dprintf(("SUPR0LowFree: pSession=%p uPtr=%p\n", pSession, (void *)uPtr)); 2044 return supdrvMemRelease(pSession, uPtr, MEMREF_TYPE_LOW); 2045 2045 } 2046 2046 … … 2057 2057 * @param ppvR3 Where to store the address of the Ring-3 mapping. 2058 2058 */ 2059 SUPR0DECL(int) SUPR0MemAlloc(PSUPDRVSESSION pSession, u nsigned cb, void **ppvR0, void **ppvR3)2059 SUPR0DECL(int) SUPR0MemAlloc(PSUPDRVSESSION pSession, uint32_t cb, PRTR0PTR ppvR0, PRTR3PTR ppvR3) 2060 2060 { 2061 2061 int rc; … … 2096 2096 { 2097 2097 *ppvR0 = RTR0MemObjAddress(Mem.MemObj); 2098 *ppvR3 = RTR0MemObjAddress(Mem.MapObjR3);2098 *ppvR3 = (RTR3PTR)RTR0MemObjAddress(Mem.MapObjR3); 2099 2099 return 0; 2100 2100 } … … 2113 2113 */ 2114 2114 Mem.pvR0 = NULL; 2115 Mem.pvR3 = N ULL;2115 Mem.pvR3 = NIL_RTR3PTR; 2116 2116 Mem.eType = MEMREF_TYPE_MEM; 2117 2117 Mem.cb = cb; … … 2139 2139 * @returns SUPDRV_ERR_* on failure. 2140 2140 * @param pSession The session to which the memory was allocated. 2141 * @param pv The Ring-0 or Ring-3 address returned by SUPR0MemAlloc(). 2142 */ 2143 SUPR0DECL(int) SUPR0MemGetPhys(PSUPDRVSESSION pSession, void *pv, PSUPPAGE paPages) 2141 * @param uPtr The Ring-0 or Ring-3 address returned by SUPR0MemAlloc(). 2142 * @param paPages Where to store the physical addresses. 2143 */ 2144 SUPR0DECL(int) SUPR0MemGetPhys(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr, PSUPPAGE paPages) 2144 2145 { 2145 2146 PSUPDRVBUNDLE pBundle; 2146 2147 RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER; 2147 dprintf(("SUPR0MemGetPhys: pSession=%p pv=%p paPages=%p\n", pSession, pv, paPages));2148 dprintf(("SUPR0MemGetPhys: pSession=%p uPtr=%p paPages=%p\n", pSession, (void *)uPtr, paPages)); 2148 2149 2149 2150 /* … … 2155 2156 return SUPDRV_ERR_INVALID_PARAM; 2156 2157 } 2157 if (! pv|| !paPages)2158 { 2159 dprintf(("Illegal address pv=%p or/and paPages=%p\n", pv, paPages));2158 if (!uPtr || !paPages) 2159 { 2160 dprintf(("Illegal address uPtr=%p or/and paPages=%p\n", (void *)uPtr, paPages)); 2160 2161 return SUPDRV_ERR_INVALID_PARAM; 2161 2162 } … … 2175 2176 if ( pBundle->aMem[i].eType == MEMREF_TYPE_MEM 2176 2177 && pBundle->aMem[i].MemObj != NIL_RTR0MEMOBJ 2177 && ( RTR0MemObjAddress(pBundle->aMem[i].MemObj) == pv2178 && ( (RTHCUINTPTR)RTR0MemObjAddress(pBundle->aMem[i].MemObj) == uPtr 2178 2179 || ( pBundle->aMem[i].MapObjR3 != NIL_RTR0MEMOBJ 2179 && RTR0MemObjAddress(pBundle->aMem[i].MapObjR3) == pv)2180 && (RTHCUINTPTR)RTR0MemObjAddress(pBundle->aMem[i].MapObjR3) == uPtr) 2180 2181 ) 2181 2182 ) … … 2193 2194 #else /* !USE_NEW_OS_INTERFACE */ 2194 2195 if ( pBundle->aMem[i].eType == MEMREF_TYPE_MEM 2195 && ( pBundle->aMem[i].pvR0 == pv2196 || pBundle->aMem[i].pvR3 == pv))2196 && ( (RTHCUINTPTR)pBundle->aMem[i].pvR0 == uPtr 2197 || (RTHCUINTPTR)pBundle->aMem[i].pvR3 == uPtr)) 2197 2198 { 2198 2199 supdrvOSMemGetPages(&pBundle->aMem[i], paPages); … … 2205 2206 } 2206 2207 RTSpinlockRelease(pSession->Spinlock, &SpinlockTmp); 2207 dprintf(("Failed to find %p!!!\n", pv));2208 dprintf(("Failed to find %p!!!\n", (void *)uPtr)); 2208 2209 return SUPDRV_ERR_INVALID_PARAM; 2209 2210 } … … 2216 2217 * @returns SUPDRV_ERR_* on failure. 2217 2218 * @param pSession The session owning the allocation. 2218 * @param pvThe Ring-0 or Ring-3 address returned by SUPR0MemAlloc().2219 */ 2220 SUPR0DECL(int) SUPR0MemFree(PSUPDRVSESSION pSession, void *pv)2221 { 2222 dprintf(("SUPR0MemFree: pSession=%p pv=%p\n", pSession, pv));2223 return supdrvMemRelease(pSession, pv, MEMREF_TYPE_MEM);2219 * @param uPtr The Ring-0 or Ring-3 address returned by SUPR0MemAlloc(). 2220 */ 2221 SUPR0DECL(int) SUPR0MemFree(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr) 2222 { 2223 dprintf(("SUPR0MemFree: pSession=%p uPtr=%p\n", pSession, (void *)uPtr)); 2224 return supdrvMemRelease(pSession, uPtr, MEMREF_TYPE_MEM); 2224 2225 } 2225 2226 … … 2238 2239 * and remove the session as a GIP user. 2239 2240 */ 2240 SUPR0DECL(int) SUPR0GipMap(PSUPDRVSESSION pSession, PCSUPGLOBALINFOPAGE *ppGip, RTHCPHYS *pHCPhysGid)2241 SUPR0DECL(int) SUPR0GipMap(PSUPDRVSESSION pSession, PCSUPGLOBALINFOPAGE *ppGip, PRTHCPHYS pHCPhysGid) 2241 2242 { 2242 2243 int rc = 0; … … 2461 2462 * @returns SUPDRV_ERR_INVALID_PARAM on failure. 2462 2463 * @param pSession Session data. 2463 * @param pvPointer to memory. This is matched against both the R0 and R3 addresses.2464 * @param uPtr Pointer to memory. This is matched against both the R0 and R3 addresses. 2464 2465 * @param eType Memory type. 2465 2466 */ 2466 static int supdrvMemRelease(PSUPDRVSESSION pSession, void *pv, SUPDRVMEMREFTYPE eType)2467 static int supdrvMemRelease(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr, SUPDRVMEMREFTYPE eType) 2467 2468 { 2468 2469 PSUPDRVBUNDLE pBundle; … … 2477 2478 return SUPDRV_ERR_INVALID_PARAM; 2478 2479 } 2479 if (! pv)2480 { 2481 dprintf(("Illegal address %p\n", pv));2480 if (!uPtr) 2481 { 2482 dprintf(("Illegal address %p\n", (void *)uPtr)); 2482 2483 return SUPDRV_ERR_INVALID_PARAM; 2483 2484 } … … 2497 2498 if ( pBundle->aMem[i].eType == eType 2498 2499 && pBundle->aMem[i].MemObj != NIL_RTR0MEMOBJ 2499 && ( RTR0MemObjAddress(pBundle->aMem[i].MemObj) == pv2500 && ( (RTHCUINTPTR)RTR0MemObjAddress(pBundle->aMem[i].MemObj) == uPtr 2500 2501 || ( pBundle->aMem[i].MapObjR3 != NIL_RTR0MEMOBJ 2501 && RTR0MemObjAddress(pBundle->aMem[i].MapObjR3) == pv))2502 && (RTHCUINTPTR)RTR0MemObjAddress(pBundle->aMem[i].MapObjR3) == uPtr)) 2502 2503 ) 2503 2504 { … … 2523 2524 #else /* !USE_NEW_OS_INTERFACE */ 2524 2525 if ( pBundle->aMem[i].eType == eType 2525 && ( pBundle->aMem[i].pvR0 == pv2526 || pBundle->aMem[i].pvR3 == pv))2526 && ( (RTHCUINTPTR)pBundle->aMem[i].pvR0 == uPtr 2527 || (RTHCUINTPTR)pBundle->aMem[i].pvR3 == uPtr)) 2527 2528 { 2528 2529 /* Make a copy of it and release it outside the spinlock. */ … … 2530 2531 pBundle->aMem[i].eType = MEMREF_TYPE_UNUSED; 2531 2532 pBundle->aMem[i].pvR0 = NULL; 2532 pBundle->aMem[i].pvR3 = N ULL;2533 pBundle->aMem[i].pvR3 = NIL_RTR3PTR; 2533 2534 pBundle->aMem[i].cb = 0; 2534 2535 RTSpinlockRelease(pSession->Spinlock, &SpinlockTmp); … … 2560 2561 } 2561 2562 RTSpinlockRelease(pSession->Spinlock, &SpinlockTmp); 2562 dprintf(("Failed to find %p!!! (eType=%d)\n", pv, eType));2563 dprintf(("Failed to find %p!!! (eType=%d)\n", (void *)uPtr, eType)); 2563 2564 return SUPDRV_ERR_INVALID_PARAM; 2564 2565 } … … 3833 3834 * @param pMem Memory reference record of the memory to be allocated. 3834 3835 * (This is not linked in anywhere.) 3836 * @param ppvR3 Where to store the Ring-0 mapping of the allocated memory. 3835 3837 * @param ppvR3 Where to store the Ring-3 mapping of the allocated memory. 3836 3838 * @param paPagesOut Where to store the physical addresss. 3837 3839 */ 3838 int VBOXCALL supdrvOSLowAllocOne(PSUPDRVMEMREF pMem, void **ppvR3, PSUPPAGE paPagesOut)3840 int VBOXCALL supdrvOSLowAllocOne(PSUPDRVMEMREF pMem, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PSUPPAGE paPagesOut) 3839 3841 { 3840 3842 RTHCPHYS HCPhys; 3841 int rc = supdrvOSContAllocOne(pMem, NULL, ppvR3, &HCPhys);3843 int rc = supdrvOSContAllocOne(pMem, ppvR0, ppvR3, &HCPhys); 3842 3844 if (!rc) 3843 3845 { -
trunk/src/VBox/HostDrivers/Support/SUPLib.cpp
r1199 r1480 474 474 In.u32Cookie = g_u32Cookie; 475 475 In.u32SessionCookie = g_u32SessionCookie; 476 In.pv = pvStart;476 In.pvR3 = pvStart; 477 477 In.cb = (uint32_t)cbMemory; AssertRelease(In.cb == cbMemory); 478 478 int rc; … … 529 529 In.u32Cookie = g_u32Cookie; 530 530 In.u32SessionCookie = g_u32SessionCookie; 531 In.pv = pvStart;531 In.pvR3 = pvStart; 532 532 int rc; 533 533 if (!g_u32FakeMode) … … 602 602 In.u32Cookie = g_u32Cookie; 603 603 In.u32SessionCookie = g_u32SessionCookie; 604 In.pv = pv;604 In.pvR3 = pv; 605 605 int rc; 606 606 if (!g_u32FakeMode) … … 613 613 614 614 615 SUPR3DECL(int) SUPLowAlloc(unsigned cPages, void **ppvPages, P SUPPAGE paPages)615 SUPR3DECL(int) SUPLowAlloc(unsigned cPages, void **ppvPages, PRTR0PTR ppvPagesR0, PSUPPAGE paPages) 616 616 { 617 617 /* … … 640 640 if (VBOX_SUCCESS(rc)) 641 641 { 642 *ppvPages = pOut->pvVirt; 642 *ppvPages = pOut->pvR3; 643 if (ppvPagesR0) 644 *ppvPagesR0 = pOut->pvR0; 643 645 AssertCompile(sizeof(paPages[0]) == sizeof(pOut->aPages[0])); 644 646 memcpy(paPages, &pOut->aPages[0], sizeof(paPages[0]) * cPages); … … 688 690 In.u32Cookie = g_u32Cookie; 689 691 In.u32SessionCookie = g_u32SessionCookie; 690 In.pv = pv;692 In.pvR3 = pv; 691 693 int rc; 692 694 if (!g_u32FakeMode) -
trunk/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c
r1355 r1480 246 246 static int VBoxSupDrvDeviceControl(struct inode *pInode, struct file *pFilp, 247 247 unsigned int IOCmd, unsigned long IOArg); 248 static void *VBoxSupDrvMapUser(struct page **papPages, unsigned cPages, unsigned fProt, pgprot_t pgFlags);248 static RTR3PTR VBoxSupDrvMapUser(struct page **papPages, unsigned cPages, unsigned fProt, pgprot_t pgFlags); 249 249 static int VBoxSupDrvInitGip(PSUPDRVDEVEXT pDevExt); 250 250 static int VBoxSupDrvTermGip(PSUPDRVDEVEXT pDevExt); 251 251 static void VBoxSupGipTimer(unsigned long ulUser); 252 #ifdef CONFIG_SMP 252 253 static void VBoxSupDrvGipPerCpu(void *pvUser); 254 #endif 253 255 static int VBoxSupDrvOrder(unsigned long size); 254 256 static int VBoxSupDrvErr2LinuxErr(int); … … 827 829 * @param pHCPhys Where to store the physical address. 828 830 */ 829 int VBOXCALL supdrvOSContAllocOne(PSUPDRVMEMREF pMem, void **ppvR0, void **ppvR3, PRTHCPHYS pHCPhys)831 int VBOXCALL supdrvOSContAllocOne(PSUPDRVMEMREF pMem, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PRTHCPHYS pHCPhys) 830 832 { 831 833 struct page *paPages; … … 916 918 { 917 919 *pHCPhys = HCPhys; 918 *ppvR3 = (void *)ulAddr;920 *ppvR3 = ulAddr; 919 921 if (ppvR0) 920 922 *ppvR0 = (void *)ulAddr; 921 pMem->pvR3 = (void *)ulAddr;923 pMem->pvR3 = ulAddr; 922 924 pMem->pvR0 = NULL; 923 925 pMem->u.cont.paPages = paPages; … … 1000 1002 * @param ppvR3 Where to store the address of the Ring-3 mapping. 1001 1003 */ 1002 int VBOXCALL supdrvOSMemAllocOne(PSUPDRVMEMREF pMem, void **ppvR0, void **ppvR3)1004 int VBOXCALL supdrvOSMemAllocOne(PSUPDRVMEMREF pMem, PRTR0PTR ppvR0, PRTR3PTR ppvR3) 1003 1005 { 1004 1006 const unsigned cbAligned = RT_ALIGN(pMem->cb, PAGE_SIZE); … … 1132 1134 up_write(¤t->mm->mmap_sem); /* check when we can leave this. */ 1133 1135 } 1134 pMem->pvR3 = N ULL;1136 pMem->pvR3 = NIL_RTR3PTR; 1135 1137 1136 1138 /* … … 1190 1192 * @param pgFlags The page level protection. 1191 1193 */ 1192 static void *VBoxSupDrvMapUser(struct page **papPages, unsigned cPages, unsigned fProt, pgprot_t pgFlags)1194 static RTR3PTR VBoxSupDrvMapUser(struct page **papPages, unsigned cPages, unsigned fProt, pgprot_t pgFlags) 1193 1195 { 1194 1196 int rc = SUPDRV_ERR_NO_MEMORY; … … 1234 1236 { 1235 1237 up_write(¤t->mm->mmap_sem); 1236 return (void *)ulAddr;1238 return ulAddr; 1237 1239 } 1238 1240 … … 1252 1254 up_write(¤t->mm->mmap_sem); 1253 1255 1254 return N ULL;1256 return NIL_RTR3PTR; 1255 1257 } 1256 1258 -
trunk/src/VBox/HostDrivers/Support/testcase/tstInt.cpp
r914 r1480 87 87 * Create a fake 'VM'. 88 88 */ 89 PVMR0 pVMR0; 90 RTHCPHYS HCPhysVM; 91 PVM pVM = (PVM)SUPContAlloc2(sizeof(*pVM), &pVMR0, &HCPhysVM); 92 if (pVM) 89 PVMR0 pVMR0 = NIL_RTR0PTR; 90 PVM pVM = NULL; 91 const unsigned cPages = RT_ALIGN_Z(sizeof(*pVM), PAGE_SIZE) >> PAGE_SHIFT; 92 PSUPPAGE paPages = (PSUPPAGE)RTMemAllocZ(cPages * sizeof(SUPPAGE)); 93 if (paPages) 94 rc = SUPLowAlloc(cPages, (void **)&pVM, &pVMR0, &paPages[0]); 95 else 96 rc = VERR_NO_MEMORY; 97 if (VBOX_SUCCESS(rc)) 93 98 { 94 99 pVM->pVMGC = 0; 95 100 pVM->pVMR3 = pVM; 96 101 pVM->pVMR0 = pVMR0; 102 #ifdef VBOX_USE_LOW_MEM_FOR_VM 103 pVM->paVMPagesR3 = paPages; 104 #else 97 105 pVM->HCPhysVM = HCPhysVM; 106 #endif 98 107 pVM->pSession = pSession; 99 108 -
trunk/src/VBox/HostDrivers/Support/testcase/tstLow.cpp
r1 r1480 50 50 void *pvPages0 = (void *)0x77777777; 51 51 memset(&aPages0[0], 0x8f, sizeof(aPages0)); 52 rc = SUPLowAlloc(ELEMENTS(aPages0), &pvPages0, aPages0);52 rc = SUPLowAlloc(ELEMENTS(aPages0), &pvPages0, NULL, aPages0); 53 53 if (VBOX_SUCCESS(rc)) 54 54 { … … 98 98 void *pvPages1 = (void *)0x77777777; 99 99 memset(&aPages1[0], 0x8f, sizeof(aPages1)); 100 rc = SUPLowAlloc(cPages, &pvPages1, aPages1);100 rc = SUPLowAlloc(cPages, &pvPages1, NULL, aPages1); 101 101 if (VBOX_SUCCESS(rc)) 102 102 { -
trunk/src/VBox/HostDrivers/Support/win32/SUPDrv-win32.cpp
r1355 r1480 521 521 * @param pHCPhys Where to store the physical address. 522 522 */ 523 int VBOXCALL supdrvOSContAllocOne(PSUPDRVMEMREF pMem, void **ppvR0, void **ppvR3, PRTHCPHYS pHCPhys)523 int VBOXCALL supdrvOSContAllocOne(PSUPDRVMEMREF pMem, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PRTHCPHYS pHCPhys) 524 524 { 525 525 Assert(ppvR3); … … 547 547 __try 548 548 { 549 pMem->pvR3 = MmMapLockedPages(pMem->u.cont.pMdl, UserMode);549 pMem->pvR3 = (RTR3PTR)MmMapLockedPages(pMem->u.cont.pMdl, UserMode); 550 550 if (pMem->pvR3) 551 551 { … … 593 593 if (pMem->pvR3) 594 594 { 595 MmUnmapLockedPages( pMem->pvR3, pMem->u.cont.pMdl);595 MmUnmapLockedPages((void *)pMem->pvR3, pMem->u.cont.pMdl); 596 596 dprintf2(("MmUnmapLockedPages ok!\n")); 597 597 pMem->pvR3 = NULL; … … 625 625 * @param ppvR3 Where to store the address of the Ring-3 mapping. 626 626 */ 627 int VBOXCALL supdrvOSMemAllocOne(PSUPDRVMEMREF pMem, void **ppvR0, void **ppvR3)627 int VBOXCALL supdrvOSMemAllocOne(PSUPDRVMEMREF pMem, PRTR0PTR ppvR0, PRTR3PTR ppvR3) 628 628 { 629 629 Assert(ppvR0); … … 648 648 __try 649 649 { 650 pMem->pvR3 = MmMapLockedPages(pMem->u.mem.pMdl, UserMode);650 pMem->pvR3 = (RTR3PTR)MmMapLockedPages(pMem->u.mem.pMdl, UserMode); 651 651 if (pMem->pvR3) 652 652 { … … 711 711 if (pMem->pvR3) 712 712 { 713 MmUnmapLockedPages( pMem->pvR3, pMem->u.mem.pMdl);713 MmUnmapLockedPages((void *)pMem->pvR3, pMem->u.mem.pMdl); 714 714 pMem->pvR3 = NULL; 715 715 dprintf2(("MmUnmapLockedPages ok!\n")); -
trunk/src/VBox/VMM/MM.cpp
r247 r1480 291 291 * (Associated record are released by the heap.) 292 292 */ 293 PMMLOCKEDMEM pLockedMem = pVM->mm.s.pLockedMem;293 PMMLOCKEDMEM pLockedMem = pVM->mm.s.pLockedMem; 294 294 while (pLockedMem) 295 295 { … … 298 298 switch (pLockedMem->eType) 299 299 { 300 case MM_LOCKED_TYPE_PHYS:301 case MM_LOCKED_TYPE_HYPER_NOFREE:302 break;303 300 case MM_LOCKED_TYPE_HYPER: 304 301 rc = SUPPageFree(pLockedMem->pv); 305 302 AssertMsgRC(rc, ("SUPPageFree(%p) -> rc=%d\n", pLockedMem->pv, rc)); 303 break; 304 case MM_LOCKED_TYPE_HYPER_NOFREE: 305 case MM_LOCKED_TYPE_HYPER_PAGES: 306 case MM_LOCKED_TYPE_PHYS: 307 /* nothing to do. */ 306 308 break; 307 309 } … … 543 545 544 546 /* 545 * The VM structure?546 */547 uint32_t off = (uint32_t)(HCPhys - pVM->HCPhysVM);548 if (off < RT_ALIGN_32(sizeof(*pVM), PAGE_SIZE))549 {550 *ppv = (char *)pVM + off;551 return VINF_SUCCESS;552 }553 554 /*555 547 * Iterate the locked memory - very slow. 556 548 */ 557 off = HCPhys & PAGE_OFFSET_MASK;549 uint32_t off = HCPhys & PAGE_OFFSET_MASK; 558 550 HCPhys &= X86_PTE_PAE_PG_MASK; 559 551 for (PMMLOCKEDMEM pCur = pVM->mm.s.pLockedMem; pCur; pCur = pCur->pNext) -
trunk/src/VBox/VMM/MMHyper.cpp
r323 r1480 100 100 * Map the VM structure into the hypervisor space. 101 101 */ 102 rc = MMR3HyperMap HCPhys(pVM, pVM, pVM->HCPhysVM, sizeof(VM), "VM", &pVM->pVMGC);102 rc = MMR3HyperMapPages(pVM, pVM, pVM->pVMR0, RT_ALIGN_Z(sizeof(VM), PAGE_SIZE) >> PAGE_SHIFT, pVM->paVMPagesR3, "VM", &pVM->pVMGC); 103 103 if (VBOX_SUCCESS(rc)) 104 104 { … … 446 446 pLookup->enmType = MMLOOKUPHYPERTYPE_LOCKED; 447 447 pLookup->u.Locked.pvHC = pvHC; 448 pLookup->u.Locked.pvR0 = NIL_RTR0PTR; 448 449 pLookup->u.Locked.pLockedMem = pLockedMem; 449 450 450 451 /* done. */ 451 452 GCPtr |= (uintptr_t)pvHC & PAGE_OFFSET_MASK; 453 *pGCPtr = GCPtr; 454 return rc; 455 } 456 /* Don't care about failure clean, we're screwed if this fails anyway. */ 457 } 458 } 459 460 return rc; 461 } 462 463 464 /** 465 * Maps locked R3 virtual memory into the hypervisor region in the GC. 466 * 467 * @return VBox status code. 468 * 469 * @param pVM VM handle. 470 * @param pvR3 The ring-3 address of the memory, must be page aligned. 471 * @param pvR0 The ring-0 address of the memory, must be page aligned. (optional) 472 * @param cPages The number of pages. 473 * @param paPages The page descriptors. 474 * @param pszDesc Mapping description. 475 * @param pGCPtr Where to store the GC address corresponding to pvHC. 476 */ 477 MMR3DECL(int) MMR3HyperMapPages(PVM pVM, void *pvR3, RTR0PTR pvR0, size_t cPages, PCSUPPAGE paPages, const char *pszDesc, PRTGCPTR pGCPtr) 478 { 479 LogFlow(("MMR3HyperMapPages: pvR3=%p pvR0=%p cPages=%zu paPages=%p pszDesc=%p:{%s} pGCPtr=%p\n", 480 pvR3, pvR0, cPages, paPages, pszDesc, pszDesc, pGCPtr)); 481 482 /* 483 * Validate input. 484 */ 485 AssertPtrReturn(pvR3, VERR_INVALID_POINTER); 486 AssertPtrReturn(paPages, VERR_INVALID_POINTER); 487 AssertReturn(cPages > 0, VERR_INVALID_PARAMETER); 488 AssertReturn(cPages < 1024, VERR_INVALID_PARAMETER); 489 AssertPtrReturn(pszDesc, VERR_INVALID_POINTER); 490 AssertReturn(*pszDesc, VERR_INVALID_PARAMETER); 491 AssertPtrReturn(pGCPtr, VERR_INVALID_PARAMETER); 492 493 /* 494 * Add the memory to the hypervisor area. 495 */ 496 RTGCPTR GCPtr; 497 PMMLOOKUPHYPER pLookup; 498 int rc = mmR3HyperMap(pVM, cPages << PAGE_SHIFT, pszDesc, &GCPtr, &pLookup); 499 if (VBOX_SUCCESS(rc)) 500 { 501 /* 502 * Create a locked memory record and tell PGM about this. 503 */ 504 PMMLOCKEDMEM pLockedMem = (PMMLOCKEDMEM)MMR3HeapAlloc(pVM, MM_TAG_MM, RT_OFFSETOF(MMLOCKEDMEM, aPhysPages[cPages])); 505 if (pLockedMem) 506 { 507 pLockedMem->pv = pvR3; 508 pLockedMem->cb = cPages << PAGE_SHIFT; 509 pLockedMem->eType = MM_LOCKED_TYPE_HYPER_PAGES; 510 memset(&pLockedMem->u, 0, sizeof(pLockedMem->u)); 511 for (size_t i = 0; i < cPages; i++) 512 { 513 AssertReleaseReturn(paPages[i].Phys != 0 && paPages[i].Phys != NIL_RTHCPHYS && !(paPages[i].Phys & PAGE_OFFSET_MASK), VERR_INTERNAL_ERROR); 514 pLockedMem->aPhysPages[i].Phys = paPages[i].Phys; 515 pLockedMem->aPhysPages[i].uReserved = (RTHCUINTPTR)pLockedMem; 516 } 517 518 /* map the stuff into guest address space. */ 519 if (pVM->mm.s.fPGMInitialized) 520 rc = mmr3MapLocked(pVM, pLockedMem, GCPtr, 0, ~(size_t)0, 0); 521 if (VBOX_SUCCESS(rc)) 522 { 523 pLookup->enmType = MMLOOKUPHYPERTYPE_LOCKED; 524 pLookup->u.Locked.pvHC = pvR3; 525 pLookup->u.Locked.pvR0 = pvR0; 526 pLookup->u.Locked.pLockedMem = pLockedMem; 527 528 /* done. */ 452 529 *pGCPtr = GCPtr; 453 530 return rc; … … 864 941 pLookup->u.Locked.pvHC, 865 942 sizeof(RTHCPTR) * 2, 866 pLookup->u.Locked.pLockedMem->eType == MM_LOCKED_TYPE_HYPER_NOFREE 867 ? "nofree" : "autofree", 943 pLookup->u.Locked.pLockedMem->eType == MM_LOCKED_TYPE_HYPER_NOFREE ? "nofree" 944 : pLookup->u.Locked.pLockedMem->eType == MM_LOCKED_TYPE_HYPER ? "autofree" 945 : pLookup->u.Locked.pLockedMem->eType == MM_LOCKED_TYPE_HYPER_PAGES ? "pages" 946 : pLookup->u.Locked.pLockedMem->eType == MM_LOCKED_TYPE_PHYS ? "gstphys" 947 : "??", 868 948 pLookup->pszDesc); 869 949 break; -
trunk/src/VBox/VMM/MMInternal.h
r323 r1480 440 440 typedef enum MMLOCKEDTYPE 441 441 { 442 /** Hypervisor memory (VMM GC). */442 /** Hypervisor: Ring-3 memory locked by MM. */ 443 443 MM_LOCKED_TYPE_HYPER, 444 /** Hypervisor memory to be mapped from HC. */444 /** Hypervisor: Ring-3 memory locked by MM that shouldn't be freed up. */ 445 445 MM_LOCKED_TYPE_HYPER_NOFREE, 446 /** Physical VM memory (RAM & MMIO2). */ 446 /** Hypervisor: Pre-locked ring-3 pages. */ 447 MM_LOCKED_TYPE_HYPER_PAGES, 448 /** Guest: Physical VM memory (RAM & MMIO2). */ 447 449 MM_LOCKED_TYPE_PHYS 448 450 } MMLOCKEDTYPE; … … 475 477 union 476 478 { 477 /** Data for MM_LOCKED_TYPE_HYPER . */479 /** Data for MM_LOCKED_TYPE_HYPER, MM_LOCKED_TYPE_HYPER_NOFREE and MM_LOCKED_TYPE_HYPER_PAGES. */ 478 480 struct 479 481 { … … 544 546 /** Host context pointer. */ 545 547 HCPTRTYPE(void *) pvHC; 548 /** Host context ring-0 pointer. */ 549 RTR0PTR pvR0; 546 550 /** Pointer to the locked mem record. */ 547 551 HCPTRTYPE(PMMLOCKEDMEM) pLockedMem; -
trunk/src/VBox/VMM/MMPagePool.cpp
r1468 r1480 252 252 } 253 253 else 254 rc = SUPLowAlloc(cPages, &pSub->pvPages, paPhysPages);254 rc = SUPLowAlloc(cPages, &pSub->pvPages, NULL, paPhysPages); 255 255 if (VBOX_SUCCESS(rc)) 256 256 { -
trunk/src/VBox/VMM/SELM.cpp
r1450 r1480 98 98 /* 99 99 * Assert alignment and sizes. 100 */ 100 * (The TSS block requires contiguous back.) 101 */ 102 AssertCompile(sizeof(pVM->selm.s) <= sizeof(pVM->selm.padding)); AssertRelease(sizeof(pVM->selm.s) <= sizeof(pVM->selm.padding)); 101 103 AssertCompileMemberAlignment(VM, selm.s, 32); AssertRelease(!(RT_OFFSETOF(VM, selm.s) & 31)); 102 AssertCompileMemberAlignment(VM, selm.s.Tss, 16); AssertRelease(!(RT_OFFSETOF(VM, selm.s.Tss) & 15)); 103 AssertCompile(sizeof(pVM->selm.s) <= sizeof(pVM->selm.padding)); AssertRelease(sizeof(pVM->selm.s) <= sizeof(pVM->selm.padding)); 104 #ifndef __AMD64__ /* gcc 4.1.1 doesn't deal correctly with this :/ */ 105 AssertCompile((RT_OFFSETOF(VM, selm.s.Tss) & PAGE_OFFSET_MASK) <= PAGE_SIZE - sizeof(pVM->selm.s.Tss)); 106 AssertCompile((RT_OFFSETOF(VM, selm.s.TssTrap08) & PAGE_OFFSET_MASK) <= PAGE_SIZE - sizeof(pVM->selm.s.TssTrap08)); 107 #endif 108 AssertRelease((RT_OFFSETOF(VM, selm.s.Tss) & PAGE_OFFSET_MASK) <= PAGE_SIZE - sizeof(pVM->selm.s.Tss)); 109 AssertRelease((RT_OFFSETOF(VM, selm.s.TssTrap08) & PAGE_OFFSET_MASK) <= PAGE_SIZE - sizeof(pVM->selm.s.TssTrap08)); 104 110 105 111 /* -
trunk/src/VBox/VMM/SELMInternal.h
r1449 r1480 114 114 RTUINT auPadding[2]; 115 115 #endif 116 /** TSS. (This is 16 byte aligned!) */ 116 /** TSS. (This is 16 byte aligned!) 117 * @todo I/O bitmap & interrupt redirection table? */ 117 118 VBOXTSS Tss; 118 /** @todo I/O bitmap & interrupt redirection table. */119 119 120 120 /** TSS for trap 08 (\#DF). */ 121 121 VBOXTSS TssTrap08; 122 /** TSS for trap 0a (\#TS). */123 VBOXTSS TssTrap0a;124 122 125 123 /** GC Pointer to the TSS shadow area (Tss) placed in Hypervisor memory arena. */ -
trunk/src/VBox/VMM/VM.cpp
r1468 r1480 187 187 * Allocate memory for the VM structure. 188 188 */ 189 RTHCPHYS HCPhysVM; 190 PVMR0 pVMR0; 191 PVM pVM = (PVM)SUPContAlloc2(RT_ALIGN_Z(sizeof(*pVM), PAGE_SIZE), &pVMR0, &HCPhysVM); 192 if (pVM) 189 PVMR0 pVMR0 = NIL_RTR0PTR; 190 PVM pVM = NULL; 191 const unsigned cPages = RT_ALIGN_Z(sizeof(*pVM), PAGE_SIZE) >> PAGE_SHIFT; 192 PSUPPAGE paPages = (PSUPPAGE)RTMemAllocZ(cPages * sizeof(SUPPAGE)); 193 AssertReturn(paPages, VERR_NO_MEMORY); 194 rc = SUPLowAlloc(cPages, (void **)&pVM, &pVMR0, &paPages[0]); 195 if (VBOX_SUCCESS(rc)) 193 196 { 194 Log(("VMR3Create: Allocated pVM=%p HCPhysVM=%VHp\n", pVM, HCPhysVM));197 Log(("VMR3Create: Allocated pVM=%p pVMR0=%p\n", pVM, pVMR0)); 195 198 196 199 /* … … 201 204 pVM->pVMR0 = pVMR0; 202 205 pVM->pVMR3 = pVM; 203 pVM-> HCPhysVM = HCPhysVM;206 pVM->paVMPagesR3 = paPages; 204 207 pVM->pSession = pSession; 205 208 pVM->vm.s.offVM = RT_OFFSETOF(VM, vm.s); … … 209 212 pVM->vm.s.ppAtRuntimeErrorNext = &pVM->vm.s.pAtRuntimeError; 210 213 rc = RTSemEventCreate(&pVM->vm.s.EventSemWait); 211 if (VBOX_FAILURE(rc)) 212 { 213 AssertMsgFailed(("RTSemEventCreate -> rc=%Vrc\n", rc)); 214 return rc; 215 } 214 AssertRCReturn(rc, rc); 216 215 217 216 /* … … 265 264 AssertRC(rc2); 266 265 267 /* free VM memory */268 rc2 = SUP ContFree(pVM);266 /* free the VM memory */ 267 rc2 = SUPLowFree(pVM); 269 268 AssertRC(rc2); 270 269 } … … 277 276 AssertMsgFailed(("Failed to allocate %d bytes of contiguous memory for the VM structure!\n", RT_ALIGN(sizeof(*pVM), PAGE_SIZE))); 278 277 } 278 RTMemFree(paPages); 279 279 280 280 /* terminate SUPLib */ … … 1519 1519 * Free the VM structure. 1520 1520 */ 1521 rc = SUP ContFree(pVM);1521 rc = SUPLowFree(pVM); 1522 1522 AssertRC(rc); 1523 1523 rc = SUPTerm(); -
trunk/src/VBox/VMM/VMMAll/MMAll.cpp
r1309 r1480 213 213 DECLINLINE(RTR0PTR) mmHyperLookupCalcR0(PMMLOOKUPHYPER pLookup, uint32_t off) 214 214 { 215 return (RTR0PTR)mmHyperLookupCalcR3(pLookup, off); 215 switch (pLookup->enmType) 216 { 217 case MMLOOKUPHYPERTYPE_LOCKED: 218 if (pLookup->u.Locked.pvR0) 219 return (RTR0PTR)((RTR0UINTPTR)pLookup->u.Locked.pvR0 + off); 220 return (RTR0PTR)((RTR3UINTPTR)pLookup->u.Locked.pvHC + off); 221 case MMLOOKUPHYPERTYPE_HCPHYS: 222 return (RTR0PTR)((RTR3UINTPTR)pLookup->u.HCPhys.pvHC + off); 223 default: 224 AssertMsgFailed(("enmType=%d\n", pLookup->enmType)); 225 return NIL_RTR0PTR; 226 } 216 227 } 217 228 -
trunk/src/VBox/VMM/testcase/tstVMStructGC.cpp
r1408 r1480 165 165 GEN_CHECK_OFF(MMLOOKUPHYPER, enmType); 166 166 GEN_CHECK_OFF(MMLOOKUPHYPER, u.Locked.pvHC); 167 GEN_CHECK_OFF(MMLOOKUPHYPER, u.Locked.pvR0); 167 168 GEN_CHECK_OFF(MMLOOKUPHYPER, u.Locked.pLockedMem); 168 169 GEN_CHECK_OFF(MMLOOKUPHYPER, u.HCPhys.pvHC); … … 565 566 GEN_CHECK_OFF(SELM, Tss); 566 567 GEN_CHECK_OFF(SELM, TssTrap08); 567 GEN_CHECK_OFF(SELM, TssTrap0a);568 568 GEN_CHECK_OFF(SELM, GCPtrTss); 569 569 GEN_CHECK_OFF(SELM, GCPtrGuestTss); -
trunk/src/VBox/VMM/testcase/tstVMStructSize.cpp
r1283 r1480 90 90 do \ 91 91 { \ 92 printf("%s::%s offset % d sizeof %d\n", #strct, #member, (int)RT_OFFSETOF(strct, member), (int)RT_SIZEOFMEMB(strct, member)); \92 printf("%s::%s offset %#x (%d) sizeof %d\n", #strct, #member, (int)RT_OFFSETOF(strct, member), (int)RT_OFFSETOF(strct, member), (int)RT_SIZEOFMEMB(strct, member)); \ 93 93 } while (0) 94 94 … … 148 148 CHECK_PADDING_VM(csam); 149 149 CHECK_MEMBER_ALIGNMENT(VM, selm.s.Tss, 16); 150 PRINT_OFFSET(VM, selm.s.Tss); 151 PVM pVM; 152 if ((RT_OFFSETOF(VM, selm.s.Tss) & PAGE_OFFSET_MASK) > PAGE_SIZE - sizeof(pVM->selm.s.Tss)) 153 { 154 printf("SELM:Tss is crossing a page!\n"); 155 rc++; 156 } 157 PRINT_OFFSET(VM, selm.s.TssTrap08); 158 if ((RT_OFFSETOF(VM, selm.s.TssTrap08) & PAGE_OFFSET_MASK) > PAGE_SIZE - sizeof(pVM->selm.s.TssTrap08)) 159 { 160 printf("SELM:TssTrap08 is crossing a page!\n"); 161 rc++; 162 } 150 163 CHECK_MEMBER_ALIGNMENT(VM, trpm.s.aIdt, 16); 151 164 CHECK_MEMBER_ALIGNMENT(VM, cpum.s.Host, 32);
Note:
See TracChangeset
for help on using the changeset viewer.

