Changeset 17537 in vbox
- Timestamp:
- Mar 8, 2009 5:22:28 AM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 43971
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/rem.h
r17251 r17537 62 62 */ 63 63 REMR3DECL(int) REMR3Init(PVM pVM); 64 REMR3DECL(int) REMR3InitFinalize(PVM pVM); 64 65 REMR3DECL(int) REMR3Term(PVM pVM); 65 66 REMR3DECL(void) REMR3Reset(PVM pVM); … … 77 78 REMR3DECL(void) REMR3ReplayHandlerNotifications(PVM pVM); 78 79 REMR3DECL(int) REMR3NotifyCodePageChanged(PVM pVM, RTGCPTR pvCodePage); 79 REMR3DECL(void) REMR3NotifyPhysRamRegister(PVM pVM, RTGCPHYS GCPhys, RT UINTcb, unsigned fFlags);80 REMR3DECL(void) REMR3NotifyPhysRamRegister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, unsigned fFlags); 80 81 #ifndef VBOX_WITH_NEW_PHYS_CODE 81 82 REMR3DECL(void) REMR3NotifyPhysRamChunkRegister(PVM pVM, RTGCPHYS GCPhys, RTUINT cb, RTHCUINTPTR pvRam, unsigned fFlags); -
trunk/src/VBox/VMM/REMInternal.h
r17429 r17537 110 110 111 111 /** 112 * Dynamically allocated guest RAM chunk information113 * HC virt to GC Phys114 *115 * A RAM chunk can spawn two chunk regions as we don't align them on chunk boundaries.116 */117 typedef struct REMCHUNKINFO118 {119 RTHCUINTPTR pChunk1;120 RTHCUINTPTR pChunk2;121 RTGCPHYS GCPhys1;122 RTGCPHYS GCPhys2;123 } REMCHUNKINFO, *PREMCHUNKINFO;124 125 /** Maximum number of external guest RAM/ROM registrations. */126 #define REM_MAX_PHYS_REGISTRATIONS 16127 128 /**129 * Registration record for external guest RAM & ROM130 */131 typedef struct REMPHYSREGISTRATION132 {133 RTGCPHYS GCPhys;134 RTHCUINTPTR HCVirt;135 RTUINT cb;136 #if HC_ARCH_BITS == 64137 uint32_t u32Padding;138 #endif139 } REMPHYSREGISTRATION, *PREMPHYSREGISTRATION;140 141 /**142 112 * Converts a REM pointer into a VM pointer. 143 113 * @returns Pointer to the VM structure the REM is part of. … … 182 152 /** Number of times REMR3CanExecuteRaw has been called. 183 153 * It is used to prevent rescheduling on the first call. */ 184 RTUINTcCanExecuteRaw;154 uint32_t cCanExecuteRaw; 185 155 186 156 /** Pending interrupt (~0 -> nothing). */ 187 RTUINTu32PendingInterrupt;157 uint32_t u32PendingInterrupt; 188 158 189 159 #if HC_ARCH_BITS == 64 … … 192 162 #endif 193 163 /** Number of recorded invlpg instructions. */ 194 RTUINTcInvalidatedPages;164 uint32_t cInvalidatedPages; 195 165 /** Array of recorded invlpg instruction. 196 166 * These instructions are replayed when entering REM. */ … … 203 173 REMHANDLERNOTIFICATION aHandlerNotifications[32]; 204 174 205 /** Pointer to an array of hc virt to gc phys records. */206 R3PTRTYPE(PREMCHUNKINFO) paHCVirtToGCPhys;207 /** Pointer to a GC Phys to HC Virt lookup table. */208 R3PTRTYPE(PRTHCUINTPTR) paGCPhysToHCVirt;209 210 /** Array of external RAM and ROM registrations (excluding guest RAM). */211 REMPHYSREGISTRATION aPhysReg[REM_MAX_PHYS_REGISTRATIONS];212 /** Number of external RAM and ROM registrations (excluding guest RAM). */213 RTUINT cPhysRegistrations;214 215 175 /** MMIO memory type. 216 176 * This is used to register MMIO physical access handlers. */ 217 RTINTiMMIOMemType;177 int32_t iMMIOMemType; 218 178 /** Handler memory type. 219 179 * This is used to register non-MMIO physical access handlers which are executed in HC. */ 220 RTINTiHandlerMemType;180 int32_t iHandlerMemType; 221 181 222 182 /** Pending exception */ 223 183 uint32_t uPendingException; 184 /** Nr of pending exceptions */ 185 uint32_t cPendingExceptions; 224 186 /** Pending exception's EIP */ 225 187 uint32_t uPendingExcptEIP; 188 uint32_t reserved_for_future_uPendingExcptRIP; 226 189 /** Pending exception's CR2 */ 227 190 uint32_t uPendingExcptCR2; 228 /** Nr of pending exceptions */ 229 uint32_t cPendingExceptions; 191 uint32_t reserved_for_future_64bit_uPendingExcptCR2; 192 193 /** The highest known RAM address. */ 194 RTGCPHYS GCPhysLastRam; 195 /** Whether GCPhysLastRam has been fixed (see REMR3Init()). */ 196 bool fGCPhysLastRamFixed; 230 197 231 198 /** Pending rc. */ 232 RTINTrc;199 int32_t rc; 233 200 234 201 /** Time spent in QEMU. */ … … 241 208 STAMPROFILE StatsStateBack; 242 209 243 #if HC_ARCH_BITS != 32244 210 /** Padding the CPUX86State structure to 32 byte. */ 245 uint32_t abPadding[HC_ARCH_BITS == 32 ? 0 : 4]; 246 #endif 211 uint32_t abPadding[HC_ARCH_BITS == 32 ? 6 : 4]; 247 212 248 213 #ifdef VBOX_WITH_NEW_RECOMPILER -
trunk/src/VBox/VMM/VM.cpp
r16584 r17537 749 749 rc = VMMR3InitFinalize(pVM); 750 750 if (RT_SUCCESS(rc)) 751 rc = REMR3InitFinalize(pVM); 752 if (RT_SUCCESS(rc)) 751 753 rc = vmR3InitDoCompleted(pVM, VMINITCOMPLETED_RING3); 752 754 if (RT_SUCCESS(rc)) -
trunk/src/VBox/VMM/testcase/tstVMStructGC.cpp
r17513 r17537 746 746 GEN_CHECK_OFF(REM, cHandlerNotifications); 747 747 GEN_CHECK_OFF(REM, aHandlerNotifications); 748 GEN_CHECK_OFF(REM, paHCVirtToGCPhys);749 GEN_CHECK_OFF(REM, cPhysRegistrations);750 GEN_CHECK_OFF(REM, aPhysReg);751 748 GEN_CHECK_OFF(REM, rc); 752 749 GEN_CHECK_OFF(REM, StatsInQEMU); -
trunk/src/VBox/VMM/testcase/tstVMStructSize.cpp
r14411 r17537 175 175 CHECK_MEMBER_ALIGNMENT(VM, vmm.s.StatRunRC, 8); 176 176 CHECK_MEMBER_ALIGNMENT(VM, StatTotalQemuToGC, 8); 177 CHECK_MEMBER_ALIGNMENT(VM, rem.s.uPendingExcptCR2, 8); 177 178 CHECK_MEMBER_ALIGNMENT(VM, rem.s.StatsInQEMU, 8); 178 179 CHECK_MEMBER_ALIGNMENT(VM, rem.s.Env, 32); -
trunk/src/recompiler/VBoxREM.def
r17251 r17537 24 24 EXPORTS 25 25 REMR3Init 26 REMR3InitFinalize 26 27 REMR3Term 27 28 REMR3Reset -
trunk/src/recompiler/VBoxREMWrapper.cpp
r17530 r17537 333 333 * @{ */ 334 334 static DECLCALLBACKPTR(int, pfnREMR3Init)(PVM); 335 static DECLCALLBACKPTR(int, pfnREMR3InitFinalize)(PVM); 335 336 static DECLCALLBACKPTR(int, pfnREMR3Term)(PVM); 336 337 static DECLCALLBACKPTR(void, pfnREMR3Reset)(PVM); … … 346 347 static DECLCALLBACKPTR(void, pfnREMR3ReplayInvalidatedPages)(PVM); 347 348 static DECLCALLBACKPTR(void, pfnREMR3ReplayHandlerNotifications)(PVM pVM); 348 static DECLCALLBACKPTR(void, pfnREMR3NotifyPhysRamRegister)(PVM, RTGCPHYS, RT UINT, unsigned);349 static DECLCALLBACKPTR(void, pfnREMR3NotifyPhysRamRegister)(PVM, RTGCPHYS, RTGCPHYS, unsigned); 349 350 #ifndef VBOX_WITH_NEW_PHYS_CODE 350 351 static DECLCALLBACKPTR(void, pfnREMR3NotifyPhysRamChunkRegister)(PVM, RTGCPHYS, RTUINT, RTHCUINTPTR, unsigned); … … 400 401 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL }, 401 402 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL }, 402 { REMPARMDESC_FLAGS_ INT, sizeof(RTUINT), NULL },403 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL }, 403 404 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL }, 404 405 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL } … … 413 414 }; 414 415 static const REMPARMDESC g_aArgsNotifyPhysReserve[] = 416 { 417 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL }, 418 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL }, 419 { REMPARMDESC_FLAGS_INT, sizeof(RTUINT), NULL } 420 }; 421 static const REMPARMDESC g_aArgsNotifyPhysRamDeregister[] = 415 422 { 416 423 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL }, … … 552 559 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL }, 553 560 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t *), NULL } 561 }; 562 static const REMPARMDESC g_aArgsDBGFR3DisasInstrCurrentLogInternal[] = 563 { 564 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL }, 565 { REMPARMDESC_FLAGS_INT, sizeof(char *), NULL } 554 566 }; 555 567 static const REMPARMDESC g_aArgsDBGFR3Info[] = … … 1000 1012 */ 1001 1013 static const REMFNDESC g_aExports[] = 1002 { /* pszName, (void *)pv, pParams, cParams, fFlags, cb, pvWrapper. */1014 { /* pszName, (void *)pv, pParams, cParams, fFlags, cb, pvWrapper. */ 1003 1015 { "REMR3Init", (void *)&pfnREMR3Init, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1016 { "REMR3InitFinalize", (void *)&pfnREMR3InitFinalize, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1004 1017 { "REMR3Term", (void *)&pfnREMR3Term, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1005 1018 { "REMR3Reset", (void *)&pfnREMR3Reset, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL }, … … 1069 1082 #endif 1070 1083 { "DBGFR3DisasInstrEx", (void *)(uintptr_t)&DBGFR3DisasInstrEx, &g_aArgsDBGFR3DisasInstrEx[0], RT_ELEMENTS(g_aArgsDBGFR3DisasInstrEx), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1084 { "DBGFR3DisasInstrCurrentLogInternal", (void *)(uintptr_t)&DBGFR3DisasInstrCurrentLogInternal, &g_aArgsDBGFR3DisasInstrCurrentLogInternal[0], RT_ELEMENTS(g_aArgsDBGFR3DisasInstrCurrentLogInternal),REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1071 1085 { "DBGFR3Info", (void *)(uintptr_t)&DBGFR3Info, &g_aArgsDBGFR3Info[0], RT_ELEMENTS(g_aArgsDBGFR3Info), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1072 1086 { "DBGFR3InfoLogRelHlp", (void *)(uintptr_t)&DBGFR3InfoLogRelHlp, NULL, 0, REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL }, … … 1992 2006 } 1993 2007 2008 REMR3DECL(int) REMR3InitFinalize(PVM pVM) 2009 { 2010 #ifndef USE_REM_STUBS 2011 Assert(VALID_PTR(pfnREMR3InitFinalize)); 2012 return pfnREMR3InitFinalize(pVM); 2013 #endif 2014 } 2015 1994 2016 REMR3DECL(int) REMR3Term(PVM pVM) 1995 2017 { … … 2133 2155 } 2134 2156 2135 REMR3DECL(void) REMR3NotifyPhysRamRegister(PVM pVM, RTGCPHYS GCPhys, RT UINTcb, unsigned fFlags)2157 REMR3DECL(void) REMR3NotifyPhysRamRegister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, unsigned fFlags) 2136 2158 { 2137 2159 #ifndef USE_REM_STUBS -
trunk/src/recompiler/VBoxRecompiler.c
r17426 r17537 86 86 static DECLCALLBACK(int) remR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version); 87 87 static void remR3StateUpdate(PVM pVM); 88 static int remR3InitPhysRamSizeAndDirtyMap(PVM pVM, bool fGuarded); 88 89 89 90 static uint32_t remR3MMIOReadU8(void *pvVM, target_phys_addr_t GCPhys); … … 401 402 #endif 402 403 404 return rc; 405 } 406 407 408 /** 409 * Finalizes the REM initialization. 410 * 411 * This is called after all components, devices and drivers has 412 * been initialized. Its main purpose it to finish the RAM related 413 * initialization. 414 * 415 * @returns VBox status code. 416 * 417 * @param pVM The VM handle. 418 */ 419 REMR3DECL(int) REMR3InitFinalize(PVM pVM) 420 { 421 int rc; 422 423 /* 424 * Ram size & dirty bit map. 425 */ 426 Assert(!pVM->rem.s.fGCPhysLastRamFixed); 427 pVM->rem.s.fGCPhysLastRamFixed = true; 428 #ifdef RT_STRICT 429 rc = remR3InitPhysRamSizeAndDirtyMap(pVM, true /* fGuarded */); 430 #else 431 rc = remR3InitPhysRamSizeAndDirtyMap(pVM, false /* fGuarded */); 432 #endif 433 return rc; 434 } 435 436 437 /** 438 * Initializes phys_ram_size, phys_ram_dirty and phys_ram_dirty_size. 439 * 440 * @returns VBox status code. 441 * @param pVM The VM handle. 442 * @param fGuarded Whether to guard the map. 443 */ 444 static int remR3InitPhysRamSizeAndDirtyMap(PVM pVM, bool fGuarded) 445 { 446 int rc = VINF_SUCCESS; 447 RTGCPHYS cb; 448 449 cb = pVM->rem.s.GCPhysLastRam + 1; 450 AssertLogRelMsgReturn(cb > pVM->rem.s.GCPhysLastRam, 451 ("GCPhysLastRam=%RGp - out of range\n", pVM->rem.s.GCPhysLastRam), 452 VERR_OUT_OF_RANGE); 453 phys_ram_size = cb; 454 phys_ram_dirty_size = cb >> PAGE_SHIFT; 455 AssertMsg(((RTGCPHYS)phys_ram_dirty_size << PAGE_SHIFT) == cb, ("%RGp\n", cb)); 456 457 if (!fGuarded) 458 { 459 phys_ram_dirty = MMR3HeapAlloc(pVM, MM_TAG_REM, phys_ram_dirty_size); 460 AssertLogRelMsgReturn(phys_ram_dirty, ("Failed to allocate %u bytes of dirty page map bytes\n", phys_ram_dirty_size), VERR_NO_MEMORY); 461 } 462 else 463 { 464 /* 465 * Fill it up the nearest 4GB RAM and leave at least _64KB of guard after it. 466 */ 467 uint32_t cbBitmapAligned = RT_ALIGN_32(phys_ram_dirty_size, PAGE_SIZE); 468 uint32_t cbBitmapFull = RT_ALIGN_32(phys_ram_dirty_size, (_4G >> PAGE_SHIFT)); 469 if (cbBitmapFull == cbBitmapAligned) 470 cbBitmapFull += _4G >> PAGE_SHIFT; 471 else if (cbBitmapFull - cbBitmapAligned < _64K) 472 cbBitmapFull += _64K; 473 474 phys_ram_dirty = RTMemPageAlloc(cbBitmapFull); 475 AssertLogRelMsgReturn(phys_ram_dirty, ("Failed to allocate %u bytes of dirty page map bytes\n", cbBitmapFull), VERR_NO_MEMORY); 476 477 rc = RTMemProtect(phys_ram_dirty + cbBitmapAligned, cbBitmapFull - cbBitmapAligned, RTMEM_PROT_NONE); 478 if (RT_FAILURE(rc)) 479 { 480 RTMemPageFree(phys_ram_dirty); 481 AssertLogRelRCReturn(rc, rc); 482 } 483 484 phys_ram_dirty += cbBitmapAligned - phys_ram_dirty_size; 485 } 486 487 /* initialize it. */ 488 memset(phys_ram_dirty, 0xff, phys_ram_dirty_size); 403 489 return rc; 404 490 } … … 1419 1505 } 1420 1506 1507 1421 1508 /** 1422 1509 * Called from tlb_unprotect_code in order to clear write monitoring for a code page. … … 1863 1950 } 1864 1951 1865 /* Sync FPU state after CR4 and CPUID. */1952 /* Sync FPU state after CR4, CPUID and EFER (!). */ 1866 1953 if (fFlags & CPUM_CHANGED_FPU_REM) 1867 1954 save_raw_fp_state(&pVM->rem.s.Env, (uint8_t *)&pCtx->fpu); /* 'save' is an excellent name. */ … … 2698 2785 * @param fFlags Flags of the MM_RAM_FLAGS_* defines. 2699 2786 */ 2700 REMR3DECL(void) REMR3NotifyPhysRamRegister(PVM pVM, RTGCPHYS GCPhys, RT UINTcb, unsigned fFlags)2701 { 2702 Log(("REMR3NotifyPhysRamRegister: GCPhys=%RGp cb=% dfFlags=%d\n", GCPhys, cb, fFlags));2787 REMR3DECL(void) REMR3NotifyPhysRamRegister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, unsigned fFlags) 2788 { 2789 Log(("REMR3NotifyPhysRamRegister: GCPhys=%RGp cb=%RGp fFlags=%d\n", GCPhys, cb, fFlags)); 2703 2790 VM_ASSERT_EMT(pVM); 2704 2791 … … 2713 2800 * Base ram? 2714 2801 */ 2715 if (!GCPhys) 2716 { 2717 phys_ram_size = cb; 2718 phys_ram_dirty_size = cb >> PAGE_SHIFT; 2719 #ifndef VBOX_STRICT 2720 phys_ram_dirty = MMR3HeapAlloc(pVM, MM_TAG_REM, phys_ram_dirty_size); 2721 AssertReleaseMsg(phys_ram_dirty, ("failed to allocate %d bytes of dirty bytes\n", phys_ram_dirty_size)); 2722 #else /* VBOX_STRICT: allocate a full map and make the out of bounds pages invalid. */ 2723 phys_ram_dirty = RTMemPageAlloc(_4G >> PAGE_SHIFT); 2724 AssertReleaseMsg(phys_ram_dirty, ("failed to allocate %d bytes of dirty bytes\n", _4G >> PAGE_SHIFT)); 2725 uint32_t cbBitmap = RT_ALIGN_32(phys_ram_dirty_size, PAGE_SIZE); 2726 int rc = RTMemProtect(phys_ram_dirty + cbBitmap, (_4G >> PAGE_SHIFT) - cbBitmap, RTMEM_PROT_NONE); 2727 AssertRC(rc); 2728 phys_ram_dirty += cbBitmap - phys_ram_dirty_size; 2729 #endif 2730 memset(phys_ram_dirty, 0xff, phys_ram_dirty_size); 2802 if (!GCPhys) /** @todo add a flag for identifying MMIO2 memory here (new phys code)*/ 2803 { 2804 if (GCPhys + (cb - 1) > pVM->rem.s.GCPhysLastRam) 2805 { 2806 AssertReleaseMsg(!pVM->rem.s.fGCPhysLastRamFixed, ("GCPhys=%RGp cb=%RGp\n", GCPhys, cb)); 2807 pVM->rem.s.GCPhysLastRam = GCPhys + (cb - 1); 2808 } 2731 2809 } 2732 2810 … … 2738 2816 2739 2817 #ifdef VBOX_WITH_NEW_PHYS_CODE 2740 if (fFlags & MM_RAM_FLAGS_RESERVED) 2741 cpu_register_physical_memory(GCPhys, cb, IO_MEM_UNASSIGNED); 2742 else 2743 cpu_register_physical_memory(GCPhys, cb, GCPhys); 2818 cpu_register_physical_memory(GCPhys, cb, GCPhys); 2744 2819 #else 2745 2820 if (!GCPhys) -
trunk/src/recompiler_new/VBoxREM.def
r17251 r17537 24 24 EXPORTS 25 25 REMR3Init 26 REMR3InitFinalize 26 27 REMR3Term 27 28 REMR3Reset -
trunk/src/recompiler_new/VBoxREMWrapper.cpp
r17530 r17537 333 333 * @{ */ 334 334 static DECLCALLBACKPTR(int, pfnREMR3Init)(PVM); 335 static DECLCALLBACKPTR(int, pfnREMR3InitFinalize)(PVM); 335 336 static DECLCALLBACKPTR(int, pfnREMR3Term)(PVM); 336 337 static DECLCALLBACKPTR(void, pfnREMR3Reset)(PVM); … … 346 347 static DECLCALLBACKPTR(void, pfnREMR3ReplayInvalidatedPages)(PVM); 347 348 static DECLCALLBACKPTR(void, pfnREMR3ReplayHandlerNotifications)(PVM pVM); 348 static DECLCALLBACKPTR(void, pfnREMR3NotifyPhysRamRegister)(PVM, RTGCPHYS, RT UINT, unsigned);349 static DECLCALLBACKPTR(void, pfnREMR3NotifyPhysRamRegister)(PVM, RTGCPHYS, RTGCPHYS, unsigned); 349 350 #ifndef VBOX_WITH_NEW_PHYS_CODE 350 351 static DECLCALLBACKPTR(void, pfnREMR3NotifyPhysRamChunkRegister)(PVM, RTGCPHYS, RTUINT, RTHCUINTPTR, unsigned); … … 400 401 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL }, 401 402 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL }, 402 { REMPARMDESC_FLAGS_ INT, sizeof(RTUINT), NULL },403 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL }, 403 404 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL }, 404 405 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL } … … 558 559 { REMPARMDESC_FLAGS_INT, sizeof(char *), NULL } 559 560 }; 560 561 561 static const REMPARMDESC g_aArgsDBGFR3Info[] = 562 562 { … … 798 798 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL }, 799 799 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t), NULL } 800 };801 static const REMPARMDESC g_aArgsPGMR3DbgR3Ptr2GCPhys[] =802 {803 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },804 { REMPARMDESC_FLAGS_INT, sizeof(void*), NULL },805 { REMPARMDESC_FLAGS_INT, sizeof(PRTGCPHYS), NULL }806 800 }; 807 801 static const REMPARMDESC g_aArgsRTMemRealloc[] = … … 1024 1018 */ 1025 1019 static const REMFNDESC g_aExports[] = 1026 { /* pszName, (void *)pv, pParams, cParams, fFlags, cb, pvWrapper. */1020 { /* pszName, (void *)pv, pParams, cParams, fFlags, cb, pvWrapper. */ 1027 1021 { "REMR3Init", (void *)&pfnREMR3Init, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1022 { "REMR3InitFinalize", (void *)&pfnREMR3InitFinalize, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1028 1023 { "REMR3Term", (void *)&pfnREMR3Term, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1029 1024 { "REMR3Reset", (void *)&pfnREMR3Reset, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL }, … … 1144 1139 { "PGMR3PhysWriteU32", (void *)(uintptr_t)&PGMR3PhysWriteU32, &g_aArgsPGMR3PhysWriteU32[0], RT_ELEMENTS(g_aArgsPGMR3PhysWriteU32), REMFNDESC_FLAGS_RET_VOID, 0, NULL }, 1145 1140 { "PGMR3PhysWriteU64", (void *)(uintptr_t)&PGMR3PhysWriteU64, &g_aArgsPGMR3PhysWriteU64[0], RT_ELEMENTS(g_aArgsPGMR3PhysWriteU32), REMFNDESC_FLAGS_RET_VOID, 0, NULL }, 1146 { "PGMR3DbgR3Ptr2GCPhys", (void *)(uintptr_t)&PGMR3DbgR3Ptr2GCPhys, &g_aArgsPGMR3DbgR3Ptr2GCPhys[0], RT_ELEMENTS(g_aArgsPGMR3DbgR3Ptr2GCPhys), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },1147 1141 { "PGMR3PhysTlbGCPhys2Ptr", (void *)(uintptr_t)&PGMR3PhysTlbGCPhys2Ptr, &g_aArgsPGMR3PhysTlbGCPhys2Ptr[0], RT_ELEMENTS(g_aArgsPGMR3PhysTlbGCPhys2Ptr), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1148 1142 { "SSMR3GetGCPtr", (void *)(uintptr_t)&SSMR3GetGCPtr, &g_aArgsSSMR3GetGCPtr[0], RT_ELEMENTS(g_aArgsSSMR3GetGCPtr), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, … … 1198 1192 { "RTLogPrintf", (void *)(uintptr_t)&RTLogPrintf, &g_aArgsRTLogPrintf[0], RT_ELEMENTS(g_aArgsRTLogPrintf), REMFNDESC_FLAGS_RET_VOID, 0, NULL }, 1199 1193 { "RTMemAlloc", (void *)(uintptr_t)&RTMemAlloc, &g_aArgsSIZE_T[0], RT_ELEMENTS(g_aArgsSIZE_T), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL }, 1200 { "RTMemAllocZ", (void *)(uintptr_t)&RTMemAllocZ, 1201 { "RTMemRealloc", (void *)(uintptr_t)&RTMemRealloc, &g_aArgsRTMemRealloc[0], RT_ELEMENTS(g_aArgsRTMemRealloc),REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL },1194 { "RTMemAllocZ", (void *)(uintptr_t)&RTMemAllocZ, &g_aArgsSIZE_T[0], RT_ELEMENTS(g_aArgsSIZE_T), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL }, 1195 { "RTMemRealloc", (void *)(uintptr_t)&RTMemRealloc, &g_aArgsRTMemRealloc[0], RT_ELEMENTS(g_aArgsRTMemRealloc), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL }, 1202 1196 { "RTMemExecAlloc", (void *)(uintptr_t)&RTMemExecAlloc, &g_aArgsSIZE_T[0], RT_ELEMENTS(g_aArgsSIZE_T), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL }, 1203 1204 1197 { "RTMemExecFree", (void *)(uintptr_t)&RTMemExecFree, &g_aArgsPTR[0], RT_ELEMENTS(g_aArgsPTR), REMFNDESC_FLAGS_RET_VOID, 0, NULL }, 1205 1198 { "RTMemFree", (void *)(uintptr_t)&RTMemFree, &g_aArgsPTR[0], RT_ELEMENTS(g_aArgsPTR), REMFNDESC_FLAGS_RET_VOID, 0, NULL }, … … 2025 2018 } 2026 2019 2020 REMR3DECL(int) REMR3InitFinalize(PVM pVM) 2021 { 2022 #ifndef USE_REM_STUBS 2023 Assert(VALID_PTR(pfnREMR3InitFinalize)); 2024 return pfnREMR3InitFinalize(pVM); 2025 #endif 2026 } 2027 2027 2028 REMR3DECL(int) REMR3Term(PVM pVM) 2028 2029 { … … 2166 2167 } 2167 2168 2168 REMR3DECL(void) REMR3NotifyPhysRamRegister(PVM pVM, RTGCPHYS GCPhys, RT UINTcb, unsigned fFlags)2169 REMR3DECL(void) REMR3NotifyPhysRamRegister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, unsigned fFlags) 2169 2170 { 2170 2171 #ifndef USE_REM_STUBS -
trunk/src/recompiler_new/VBoxRecompiler.c
r17459 r17537 90 90 static DECLCALLBACK(int) remR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version); 91 91 static void remR3StateUpdate(PVM pVM); 92 static int remR3InitPhysRamSizeAndDirtyMap(PVM pVM, bool fGuarded); 92 93 93 94 static uint32_t remR3MMIOReadU8(void *pvVM, target_phys_addr_t GCPhys); … … 258 259 Assert(!testmath()); 259 260 #endif 261 260 262 /* 261 263 * Init some internal data members. … … 396 398 #endif 397 399 400 return rc; 401 } 402 403 404 /** 405 * Finalizes the REM initialization. 406 * 407 * This is called after all components, devices and drivers has 408 * been initialized. Its main purpose it to finish the RAM related 409 * initialization. 410 * 411 * @returns VBox status code. 412 * 413 * @param pVM The VM handle. 414 */ 415 REMR3DECL(int) REMR3InitFinalize(PVM pVM) 416 { 417 int rc; 418 419 /* 420 * Ram size & dirty bit map. 421 */ 422 Assert(!pVM->rem.s.fGCPhysLastRamFixed); 423 pVM->rem.s.fGCPhysLastRamFixed = true; 424 #ifdef RT_STRICT 425 rc = remR3InitPhysRamSizeAndDirtyMap(pVM, true /* fGuarded */); 426 #else 427 rc = remR3InitPhysRamSizeAndDirtyMap(pVM, false /* fGuarded */); 428 #endif 429 return rc; 430 } 431 432 433 /** 434 * Initializes phys_ram_size, phys_ram_dirty and phys_ram_dirty_size. 435 * 436 * @returns VBox status code. 437 * @param pVM The VM handle. 438 * @param fGuarded Whether to guard the map. 439 */ 440 static int remR3InitPhysRamSizeAndDirtyMap(PVM pVM, bool fGuarded) 441 { 442 int rc = VINF_SUCCESS; 443 RTGCPHYS cb; 444 445 cb = pVM->rem.s.GCPhysLastRam + 1; 446 AssertLogRelMsgReturn(cb > pVM->rem.s.GCPhysLastRam, 447 ("GCPhysLastRam=%RGp - out of range\n", pVM->rem.s.GCPhysLastRam), 448 VERR_OUT_OF_RANGE); 449 phys_ram_size = cb; 450 phys_ram_dirty_size = cb >> PAGE_SHIFT; 451 AssertMsg(((RTGCPHYS)phys_ram_dirty_size << PAGE_SHIFT) == cb, ("%RGp\n", cb)); 452 453 if (!fGuarded) 454 { 455 phys_ram_dirty = MMR3HeapAlloc(pVM, MM_TAG_REM, phys_ram_dirty_size); 456 AssertLogRelMsgReturn(phys_ram_dirty, ("Failed to allocate %u bytes of dirty page map bytes\n", phys_ram_dirty_size), VERR_NO_MEMORY); 457 } 458 else 459 { 460 /* 461 * Fill it up the nearest 4GB RAM and leave at least _64KB of guard after it. 462 */ 463 uint32_t cbBitmapAligned = RT_ALIGN_32(phys_ram_dirty_size, PAGE_SIZE); 464 uint32_t cbBitmapFull = RT_ALIGN_32(phys_ram_dirty_size, (_4G >> PAGE_SHIFT)); 465 if (cbBitmapFull == cbBitmapAligned) 466 cbBitmapFull += _4G >> PAGE_SHIFT; 467 else if (cbBitmapFull - cbBitmapAligned < _64K) 468 cbBitmapFull += _64K; 469 470 phys_ram_dirty = RTMemPageAlloc(cbBitmapFull); 471 AssertLogRelMsgReturn(phys_ram_dirty, ("Failed to allocate %u bytes of dirty page map bytes\n", cbBitmapFull), VERR_NO_MEMORY); 472 473 rc = RTMemProtect(phys_ram_dirty + cbBitmapAligned, cbBitmapFull - cbBitmapAligned, RTMEM_PROT_NONE); 474 if (RT_FAILURE(rc)) 475 { 476 RTMemPageFree(phys_ram_dirty); 477 AssertLogRelRCReturn(rc, rc); 478 } 479 480 phys_ram_dirty += cbBitmapAligned - phys_ram_dirty_size; 481 } 482 483 /* initialize it. */ 484 memset(phys_ram_dirty, 0xff, phys_ram_dirty_size); 398 485 return rc; 399 486 } … … 1573 1660 * 1574 1661 * @param pVM VM Handle. 1575 * @param fFlushTBs Flush all translation blocks before executing code1576 1662 * 1577 1663 * @remark The caller has to check for important FFs before calling REMR3Run. REMR3State will … … 1712 1798 pVM->rem.s.Env.hflags &= ~(HF_LMA_MASK | HF_CS64_MASK); 1713 1799 #endif 1714 1715 1800 1716 1801 /* … … 2637 2722 * @param fFlags Flags of the MM_RAM_FLAGS_* defines. 2638 2723 */ 2639 REMR3DECL(void) REMR3NotifyPhysRamRegister(PVM pVM, RTGCPHYS GCPhys, RTUINT cb, unsigned fFlags) 2640 { 2641 uint32_t cbBitmap; 2642 int rc; 2643 Log(("REMR3NotifyPhysRamRegister: GCPhys=%RGp cb=%d fFlags=%d\n", GCPhys, cb, fFlags)); 2724 REMR3DECL(void) REMR3NotifyPhysRamRegister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, unsigned fFlags) 2725 { 2726 Log(("REMR3NotifyPhysRamRegister: GCPhys=%RGp cb=%RGp fFlags=%d\n", GCPhys, cb, fFlags)); 2644 2727 VM_ASSERT_EMT(pVM); 2645 2728 … … 2652 2735 2653 2736 /* 2654 * Base ram? 2655 */ 2656 if (!GCPhys) 2657 { 2658 phys_ram_size = cb; 2659 phys_ram_dirty_size = cb >> PAGE_SHIFT; 2660 #ifndef VBOX_STRICT 2661 phys_ram_dirty = MMR3HeapAlloc(pVM, MM_TAG_REM, phys_ram_dirty_size); 2662 AssertReleaseMsg(phys_ram_dirty, ("failed to allocate %d bytes of dirty bytes\n", phys_ram_dirty_size)); 2663 #else /* VBOX_STRICT: allocate a full map and make the out of bounds pages invalid. */ 2664 phys_ram_dirty = RTMemPageAlloc(_4G >> PAGE_SHIFT); 2665 AssertReleaseMsg(phys_ram_dirty, ("failed to allocate %d bytes of dirty bytes\n", _4G >> PAGE_SHIFT)); 2666 cbBitmap = RT_ALIGN_32(phys_ram_dirty_size, PAGE_SIZE); 2667 rc = RTMemProtect(phys_ram_dirty + cbBitmap, (_4G >> PAGE_SHIFT) - cbBitmap, RTMEM_PROT_NONE); 2668 AssertRC(rc); 2669 phys_ram_dirty += cbBitmap - phys_ram_dirty_size; 2670 #endif 2671 memset(phys_ram_dirty, 0xff, phys_ram_dirty_size); 2737 * Base ram? Update GCPhysLastRam. 2738 */ 2739 if (!GCPhys) /** @todo add a flag for identifying MMIO2 memory here (new phys code)*/ 2740 { 2741 if (GCPhys + (cb - 1) > pVM->rem.s.GCPhysLastRam) 2742 { 2743 AssertReleaseMsg(!pVM->rem.s.fGCPhysLastRamFixed, ("GCPhys=%RGp cb=%RGp\n", GCPhys, cb)); 2744 pVM->rem.s.GCPhysLastRam = GCPhys + (cb - 1); 2745 } 2672 2746 } 2673 2747
Note:
See TracChangeset
for help on using the changeset viewer.