Changeset 15284 in vbox for trunk/src/recompiler_new
- Timestamp:
- Dec 11, 2008 3:23:40 AM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 40703
- Location:
- trunk/src/recompiler_new
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/recompiler_new/VBoxREMWrapper.cpp
r14969 r15284 718 718 { REMPARMDESC_FLAGS_INT, sizeof(PRTR3PTR), NULL } 719 719 }; 720 static const REMPARMDESC g_aArgsPGM PhysGCPhys2R3PtrEx[] =720 static const REMPARMDESC g_aArgsPGMR3PhysTlbGCPhys2Ptr[] = 721 721 { 722 722 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL }, 723 723 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL }, 724 { REMPARMDESC_FLAGS_GCPTR, sizeof(RTGCPHYS), NULL }, 725 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL }, 726 { REMPARMDESC_FLAGS_INT, sizeof(PRTR3PTR), NULL } 724 { REMPARMDESC_FLAGS_INT, sizeof(bool), NULL }, 725 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL } 727 726 }; 728 727 static const REMPARMDESC g_aArgsPGMPhysGCPtr2R3PtrByGstCR3[] = … … 1151 1150 { "PGMR3PhysWriteU32", (void *)(uintptr_t)&PGMR3PhysWriteU32, &g_aArgsPGMR3PhysWriteU32[0], RT_ELEMENTS(g_aArgsPGMR3PhysWriteU32), REMFNDESC_FLAGS_RET_VOID, 0, NULL }, 1152 1151 { "PGMR3PhysWriteU64", (void *)(uintptr_t)&PGMR3PhysWriteU64, &g_aArgsPGMR3PhysWriteU64[0], RT_ELEMENTS(g_aArgsPGMR3PhysWriteU32), REMFNDESC_FLAGS_RET_VOID, 0, NULL }, 1153 { "PGMR3DbgR3Ptr2GCPhys", (void *)(uintptr_t)&PGMR3DbgR3Ptr2GCPhys, &g_aArgsPGMR3DbgR3Ptr2GCPhys[0], RT_ELEMENTS(g_aArgsPGMR3DbgR3Ptr2GCPhys), REMFNDESC_FLAGS_RET_INT, sizeof(uint64_t),NULL },1154 { "PGM PhysGCPhys2R3PtrEx", (void *)(uintptr_t)&PGMPhysGCPhys2R3PtrEx, &g_aArgsPGMPhysGCPhys2R3PtrEx[0], RT_ELEMENTS(g_aArgsPGMPhysGCPhys2R3PtrEx), REMFNDESC_FLAGS_RET_INT, sizeof(int),NULL },1152 { "PGMR3DbgR3Ptr2GCPhys", (void *)(uintptr_t)&PGMR3DbgR3Ptr2GCPhys, &g_aArgsPGMR3DbgR3Ptr2GCPhys[0], RT_ELEMENTS(g_aArgsPGMR3DbgR3Ptr2GCPhys), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1153 { "PGMR3PhysGCPhys2Ptr", (void *)(uintptr_t)&PGMR3PhysTlbGCPhys2Ptr, &g_aArgsPGMR3PhysTlbGCPhys2Ptr[0], RT_ELEMENTS(g_aArgsPGMR3PhysTlbGCPhys2Ptr), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1155 1154 { "SSMR3GetGCPtr", (void *)(uintptr_t)&SSMR3GetGCPtr, &g_aArgsSSMR3GetGCPtr[0], RT_ELEMENTS(g_aArgsSSMR3GetGCPtr), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1156 1155 { "SSMR3GetMem", (void *)(uintptr_t)&SSMR3GetMem, &g_aArgsSSMR3GetMem[0], RT_ELEMENTS(g_aArgsSSMR3GetMem), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, -
trunk/src/recompiler_new/VBoxRecompiler.c
r15272 r15284 637 637 } 638 638 else 639 { 639 { 640 640 switch (rc) 641 641 { … … 1283 1283 1284 1284 #ifndef REM_PHYS_ADDR_IN_TLB 1285 void* remR3GCPhys2HCVirt(CPUState *env1, target_ulong physAddr, target_ulong virtAddr) 1286 { 1287 void* rv = NULL; 1288 int rc; 1289 uint32_t flags = PGMPHYS_TRANSLATION_FLAG_CHECK_PHYS_MONITORED; 1290 1291 if (virtAddr != (target_ulong)-1) 1292 flags |= PGMPHYS_TRANSLATION_FLAG_CHECK_VIRT_MONITORED; 1293 1294 rc = PGMPhysGCPhys2R3PtrEx(env1->pVM, (RTGCPHYS)physAddr, (RTGCPTR)virtAddr, 1295 flags, &rv); 1296 1297 if (rc == VERR_PGM_PHYS_PAGE_RESERVED) 1298 { 1299 rv = (void*)((uintptr_t)rv | 1); 1300 rc = 0; 1301 } 1302 Assert (RT_SUCCESS(rc)); 1303 1304 return rv; 1285 void *remR3TlbGCPhys2Ptr(CPUState *env1, target_ulong physAddr, int fWritable) 1286 { 1287 void *pv; 1288 int rc = PGMR3PhysTlbGCPhys2Ptr(env1->pVM, physAddr, true /*fWritable*/, &pv); 1289 Assert( rc == VINF_SUCCESS 1290 || rc == VINF_PGM_PHYS_TLB_CATCH_WRITE 1291 || rc == VERR_PGM_PHYS_TLB_CATCH_ALL 1292 || rc == VERR_PGM_PHYS_TLB_UNASSIGNED); 1293 if (RT_FAILURE(rc)) 1294 return (void *)1; 1295 if (rc == VINF_PGM_PHYS_TLB_CATCH_WRITE) 1296 return (void *)((uintptr_t)pv | 2); 1297 return pv; 1305 1298 } 1306 1299 -
trunk/src/recompiler_new/cpu-all.h
r15278 r15284 264 264 uint64_t remR3PhysReadU64(RTGCPHYS SrcGCPhys); 265 265 int64_t remR3PhysReadS64(RTGCPHYS SrcGCPhys); 266 void remR3PhysWrite(RTGCPHYS DstGCPhys, const void *pvSrc, unsigned cb);267 void remR3PhysWriteU8(RTGCPHYS DstGCPhys, uint8_t val);268 void remR3PhysWriteU16(RTGCPHYS DstGCPhys, uint16_t val);269 void remR3PhysWriteU32(RTGCPHYS DstGCPhys, uint32_t val);270 void remR3PhysWriteU64(RTGCPHYS DstGCPhys, uint64_t val);266 void remR3PhysWrite(RTGCPHYS DstGCPhys, const void *pvSrc, unsigned cb); 267 void remR3PhysWriteU8(RTGCPHYS DstGCPhys, uint8_t val); 268 void remR3PhysWriteU16(RTGCPHYS DstGCPhys, uint16_t val); 269 void remR3PhysWriteU32(RTGCPHYS DstGCPhys, uint32_t val); 270 void remR3PhysWriteU64(RTGCPHYS DstGCPhys, uint64_t val); 271 271 272 272 #ifndef REM_PHYS_ADDR_IN_TLB 273 void *remR3TlbGCPhys2Ptr(CPUState *env1, target_ulong physAddr, int fWritable); 273 274 target_ulong remR3HCVirt2GCPhys(CPUState *env1, void *addr); 274 void* remR3GCPhys2HCVirt(CPUState *env1, target_ulong physAddr, target_ulong virtAddr);275 275 #endif 276 276 -
trunk/src/recompiler_new/exec.c
r14974 r15284 243 243 VirtualProtect(addr, size, 244 244 PAGE_EXECUTE_READWRITE, &old_protect); 245 245 246 246 } 247 247 #else … … 249 249 { 250 250 unsigned long start, end, page_size; 251 251 252 252 page_size = getpagesize(); 253 253 start = (unsigned long)addr; 254 254 start &= ~(page_size - 1); 255 255 256 256 end = (unsigned long)addr + size; 257 257 end += page_size - 1; 258 258 end &= ~(page_size - 1); 259 259 260 260 mprotect((void *)start, end - start, 261 261 PROT_READ | PROT_WRITE | PROT_EXEC); … … 308 308 #ifdef VBOX 309 309 /* We use other means to set reserved bit on our pages */ 310 #else 310 #else 311 311 #if !defined(_WIN32) && defined(CONFIG_USER_ONLY) 312 312 { … … 328 328 page_set_flags(startaddr & TARGET_PAGE_MASK, 329 329 TARGET_PAGE_ALIGN(endaddr), 330 PAGE_RESERVED); 330 PAGE_RESERVED); 331 331 } 332 332 } while (!feof(f)); … … 379 379 page_set_flags(addr & TARGET_PAGE_MASK, 380 380 TARGET_PAGE_ALIGN(addr + len), 381 PAGE_RESERVED); 381 PAGE_RESERVED); 382 382 } 383 383 #else … … 478 478 #endif 479 479 480 /* VBox allocates codegen buffer dynamically */ 480 /* VBox allocates codegen buffer dynamically */ 481 481 #ifndef VBOX 482 482 #ifdef USE_STATIC_CODE_GEN_BUFFER … … 508 508 #ifdef VBOX 509 509 code_gen_buffer = RTMemExecAlloc(code_gen_buffer_size); 510 510 511 511 if (!code_gen_buffer) { 512 LogRel(("REM: failed allocate codegen buffer %lld\n", 512 LogRel(("REM: failed allocate codegen buffer %lld\n", 513 513 code_gen_buffer_size)); 514 514 return; 515 515 } 516 516 #else //!VBOX 517 #if defined(__linux__) 517 #if defined(__linux__) 518 518 { 519 519 int flags; … … 556 556 #endif 557 557 code_gen_buffer = mmap(addr, code_gen_buffer_size, 558 PROT_WRITE | PROT_READ | PROT_EXEC, 558 PROT_WRITE | PROT_READ | PROT_EXEC, 559 559 flags, -1, 0); 560 560 if (code_gen_buffer == MAP_FAILED) { … … 580 580 #endif 581 581 582 code_gen_buffer_max_size = code_gen_buffer_size - 582 code_gen_buffer_max_size = code_gen_buffer_size - 583 583 code_gen_max_block_size(); 584 584 code_gen_max_blocks = code_gen_buffer_size / CODE_GEN_AVG_BLOCK_SIZE; … … 1282 1282 #else 1283 1283 DECLINLINE(void) tb_alloc_page(TranslationBlock *tb, 1284 unsigned int n, target_ulong page_addr) 1284 unsigned int n, target_ulong page_addr) 1285 1285 #endif 1286 1286 { … … 1346 1346 (code_gen_ptr - code_gen_buffer) >= code_gen_buffer_max_size) 1347 1347 #else 1348 (code_gen_ptr - code_gen_buffer) >= (int)code_gen_buffer_max_size) 1348 (code_gen_ptr - code_gen_buffer) >= (int)code_gen_buffer_max_size) 1349 1349 #endif 1350 1350 return NULL; … … 1831 1831 overlap the flushed page. */ 1832 1832 i = tb_jmp_cache_hash_page(addr - TARGET_PAGE_SIZE); 1833 memset (&env->tb_jmp_cache[i], 0, 1833 memset (&env->tb_jmp_cache[i], 0, 1834 1834 TB_JMP_PAGE_SIZE * sizeof(TranslationBlock *)); 1835 1835 1836 1836 i = tb_jmp_cache_hash_page(addr); 1837 memset (&env->tb_jmp_cache[i], 0, 1837 memset (&env->tb_jmp_cache[i], 0, 1838 1838 TB_JMP_PAGE_SIZE * sizeof(TranslationBlock *)); 1839 1839 … … 1929 1929 #endif 1930 1930 #endif 1931 1931 1932 1932 tlb_flush_jmp_cache(env, addr); 1933 1933 … … 1974 1974 1975 1975 #ifdef VBOX 1976 if (start & 1)1976 if (start & 3) 1977 1977 return; 1978 1978 #endif … … 2027 2027 start1 = start + (unsigned long)phys_ram_base; 2028 2028 #else 2029 start1 = (unsigned long)remR3 GCPhys2HCVirt(first_cpu, start, -1);2029 start1 = (unsigned long)remR3TlbGCPhys2Ptr(first_cpu, start, 1 /*fWritable*/); /** @todo this can be harmful with VBOX_WITH_NEW_PHYS_CODE, fix interface/whatever. */ 2030 2030 #endif 2031 2031 for(env = first_cpu; env != NULL; env = env->next_cpu) { … … 2176 2176 addend = (unsigned long)phys_ram_base + (pd & TARGET_PAGE_MASK); 2177 2177 #else 2178 addend = (unsigned long)remR3GCPhys2HCVirt(env, 2178 /** @todo this is racing the phys_page_find call above since it may register 2179 * a new chunk of memory... */ 2180 addend = (unsigned long)remR3TlbGCPhys2Ptr(env, 2179 2181 pd & TARGET_PAGE_MASK, 2180 vaddr & TARGET_PAGE_MASK);2182 !!(prot & PAGE_WRITE)); 2181 2183 #endif 2182 2184 if ((pd & ~TARGET_PAGE_MASK) <= IO_MEM_ROM) { … … 2201 2203 #ifdef VBOX 2202 2204 # if !defined(REM_PHYS_ADDR_IN_TLB) 2203 if (addend & 0x 1)2205 if (addend & 0x2) 2204 2206 { 2205 addend &= ~(target_ulong)0x1; 2206 if ((pd & ~TARGET_PAGE_MASK) == IO_MEM_RAM) 2207 /* catch write */ 2208 addend &= ~(target_ulong)0x3; 2209 if ((pd & ~TARGET_PAGE_MASK) <= IO_MEM_ROM) 2210 { 2211 /** @todo improve this, it's only avoid code reads right now! */ 2212 address |= TLB_MMIO; 2213 iotlb = env->pVM->rem.s.iHandlerMemType + paddr; 2214 } 2215 } 2216 else if (addend & 0x1) 2217 { 2218 /* catch all */ 2219 addend &= ~(target_ulong)0x3; 2220 if ((pd & ~TARGET_PAGE_MASK) <= IO_MEM_ROM) 2207 2221 { 2208 2222 address |= TLB_MMIO; 2209 iotlb = (pd & ~TARGET_PAGE_MASK) + paddr +env->pVM->rem.s.iHandlerMemType; 2223 code_address |= TLB_MMIO; 2224 iotlb = env->pVM->rem.s.iHandlerMemType + paddr; 2210 2225 } 2211 2226 } … … 2723 2738 unsigned long ram_addr; 2724 2739 int dirty_flags; 2725 #if defined(VBOX) 2740 #if defined(VBOX) 2726 2741 ram_addr = addr; 2727 2742 #elif … … 2770 2785 unsigned long ram_addr; 2771 2786 int dirty_flags; 2772 #if defined(VBOX) 2787 #if defined(VBOX) 2773 2788 ram_addr = addr; 2774 2789 #else … … 2818 2833 unsigned long ram_addr; 2819 2834 int dirty_flags; 2820 #if defined(VBOX) 2835 #if defined(VBOX) 2821 2836 ram_addr = addr; 2822 2837 #else … … 3104 3119 io_mem_nb = 5; 3105 3120 #endif 3106 3121 3107 3122 io_mem_watch = cpu_register_io_memory(0, watch_mem_read, 3108 3123 watch_mem_write, NULL); 3109 3124 3110 3125 #ifndef VBOX /* VBOX: we do this later when the RAM is allocated. */ 3111 3126 /* alloc dirty bits array */ … … 3637 3652 tb = tb_find_pc((unsigned long)retaddr); 3638 3653 if (!tb) { 3639 cpu_abort(env, "cpu_io_recompile: could not find TB for pc=%p", 3654 cpu_abort(env, "cpu_io_recompile: could not find TB for pc=%p", 3640 3655 retaddr); 3641 3656 } … … 3716 3731 cpu_fprintf(f, "gen code size %ld/%ld\n", 3717 3732 code_gen_ptr - code_gen_buffer, code_gen_buffer_max_size); 3718 cpu_fprintf(f, "TB count %d/%d\n", 3733 cpu_fprintf(f, "TB count %d/%d\n", 3719 3734 nb_tbs, code_gen_max_blocks); 3720 3735 cpu_fprintf(f, "TB avg target size %d max=%d bytes\n",
Note:
See TracChangeset
for help on using the changeset viewer.