VirtualBox

Changeset 15284 in vbox


Ignore:
Timestamp:
Dec 11, 2008 3:23:40 AM (16 years ago)
Author:
vboxsync
Message:

PGM, REM: Virtual address in TLB - this is what I meant...

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/err.h

    r14806 r15284  
    423423/** The expanding of the dynamic mapping cache failed. */
    424424#define VERR_PGM_DYNMAP_EXPAND_ERROR            (-1632)
     425/** The page is unassigned (akin to VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS). */
     426#define VERR_PGM_PHYS_TLB_UNASSIGNED            (-1633)
     427/** Catch any access and route it thru PGM. */
     428#define VERR_PGM_PHYS_TLB_CATCH_ALL             (-1634)
     429/** Catch write access and route it thru PGM. */
     430#define VINF_PGM_PHYS_TLB_CATCH_WRITE           1635
    425431
    426432/** @} */
  • trunk/include/VBox/pgm.h

    r15226 r15284  
    352352                                                 R3PTRTYPE(const char *) pszDesc);
    353353VMMDECL(int)        PGMHandlerPhysicalModify(PVM pVM, RTGCPHYS GCPhysCurrent, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast);
    354 VMMDECL(bool)       PGMHandlerVirtualIsRegistered(PVM pVM, RTGCPTR GCPtr);
    355354VMMDECL(int)        PGMHandlerPhysicalDeregister(PVM pVM, RTGCPHYS GCPhys);
    356355VMMDECL(int)        PGMHandlerPhysicalChangeCallbacks(PVM pVM, RTGCPHYS GCPhys,
     
    366365VMMDECL(int)        PGMHandlerPhysicalPageReset(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage);
    367366VMMDECL(bool)       PGMHandlerPhysicalIsRegistered(PVM pVM, RTGCPHYS GCPhys);
     367VMMDECL(bool)       PGMHandlerVirtualIsRegistered(PVM pVM, RTGCPTR GCPtr);
    368368VMMDECL(bool)       PGMPhysIsA20Enabled(PVM pVM);
    369369VMMDECL(bool)       PGMPhysIsGCPhysValid(PVM pVM, RTGCPHYS GCPhys);
     
    422422VMMDECL(int)        PGMPhysGCPhys2R3Ptr(PVM pVM, RTGCPHYS GCPhys, RTUINT cbRange, PRTR3PTR pR3Ptr);
    423423VMMDECL(RTR3PTR)    PGMPhysGCPhys2R3PtrAssert(PVM pVM, RTGCPHYS GCPhys, RTUINT cbRange);
    424 /** @PGMPhysGCPhys2R3PtrEx flags.
    425  * @{ */
    426 /** Default value of the flag, behaves the same way as PGMPhysGCPhys2R3Ptr. */
    427 #define PGMPHYS_TRANSLATION_FLAG_DEFAULT           0
    428 /** Indicates that for monitored pages with physical handlers
    429  * VERR_PGM_PHYS_PAGE_RESERVED error code should be returned,
    430  * so address translation routines must fallback to PGM functions for
    431  * access memory. */
    432 #define PGMPHYS_TRANSLATION_FLAG_CHECK_PHYS_MONITORED   RT_BIT_32(0)
    433 /** Indicates that for monitored pages with virtual handlers
    434  * VERR_PGM_PHYS_PAGE_RESERVED error code should be returned,
    435  * so address translation routines must fallback to PGM functions for
    436  * access memory. */
    437 #define PGMPHYS_TRANSLATION_FLAG_CHECK_VIRT_MONITORED   RT_BIT_32(1)
    438 /** @} */
    439 VMMDECL(int)        PGMPhysGCPhys2R3PtrEx(PVM pVM, RTGCPHYS GCPhys, RTGCPTR GCPtr, uint32_t flags, PRTR3PTR pR3Ptr);
    440424VMMDECL(int)        PGMPhysGCPtr2R3Ptr(PVM pVM, RTGCPTR GCPtr, PRTR3PTR pR3Ptr);
    441425VMMDECL(int)        PGMPhysGCPtr2R3PtrByGstCR3(PVM pVM, RTGCPTR GCPtr, uint64_t cr3, unsigned fFlags, PRTR3PTR pR3Ptr);
     
    601585VMMR3DECL(int)      PGMR3DumpHierarchyGC(PVM pVM, uint64_t cr3, uint64_t cr4, RTGCPHYS PhysSearch);
    602586
     587VMMR3DECL(int)      PGMR3PhysTlbGCPhys2Ptr(PVM pVM, RTGCPHYS GCPhys, bool fWritable, void **pvPtr);
    603588VMMR3DECL(uint8_t)  PGMR3PhysReadU8(PVM pVM, RTGCPHYS GCPhys);
    604589VMMR3DECL(uint16_t) PGMR3PhysReadU16(PVM pVM, RTGCPHYS GCPhys);
  • trunk/src/VBox/VMM/PGMPhys.cpp

    r14826 r15284  
    24242424}
    24252425
     2426
     2427/**
     2428 * Converts a GC physical address to a HC ring-3 pointer, with some
     2429 * additional checks.
     2430 *
     2431 * @returns VBox status code.
     2432 * @retval  VINF_SUCCESS on success.
     2433 * @retval  VINF_PGM_PHYS_TLB_CATCH_WRITE and *pvPtr set if the page has a write
     2434 *          access handler of some kind.
     2435 * @retval  VERR_PGM_PHYS_TLB_CATCH_ALL if the page has a handler catching all
     2436 *          accesses or is odd in any way.
     2437 * @retval  VERR_PGM_PHYS_TLB_UNASSIGNED if the page doesn't exist.
     2438 *
     2439 * @param   pVM         The VM handle.
     2440 * @param   GCPhys      The GC physical address to convert.
     2441 * @param   fWritable   Whether write access is required.
     2442 * @param   pR3Ptr      Where to store the R3 pointer on success.
     2443 */
     2444VMMR3DECL(int) PGMR3PhysTlbGCPhys2Ptr(PVM pVM, RTGCPHYS GCPhys, bool fWritable, void **pvPtr)
     2445{
     2446    pgmLock(pVM);
     2447
     2448    PPGMRAMRANGE pRam;
     2449    PPGMPAGE pPage;
     2450    int rc = pgmPhysGetPageAndRangeEx(&pVM->pgm.s, GCPhys, &pPage, &pRam);
     2451    if (RT_SUCCESS(rc))
     2452    {
     2453#if 0 /** @todo ifndef PGM_IGNORE_RAM_FLAGS_RESERVED */
     2454        if (RT_UNLIKELY(PGM_PAGE_IS_RESERVED(pPage)))
     2455            rc = VERR_PGM_PHYS_TLB_UNASSIGNED;
     2456#endif
     2457        {
     2458#if 0 /** @todo looks like the system ROM is registered incorrectly, 0xfe000 claims to be a zero page. */
     2459            if (fWritable && PGM_PAGE_GET_STATE(pPage) != PGM_PAGE_STATE_ALLOCATED)
     2460                rc = VERR_PGM_PHYS_TLB_UNASSIGNED; /** @todo VBOX_WITH_NEW_PHYS_CODE: remap it to a writeable page. */
     2461#else
     2462            if (0)
     2463                /* nothing */;
     2464#endif
     2465            else if (PGM_PAGE_HAS_ACTIVE_ALL_HANDLERS(pPage)) /* catches MMIO */
     2466                rc = VERR_PGM_PHYS_TLB_CATCH_ALL;
     2467            else if (fWritable && PGM_PAGE_HAS_ACTIVE_HANDLERS(pPage))
     2468                rc = VINF_PGM_PHYS_TLB_CATCH_WRITE;
     2469            else
     2470                rc = VINF_SUCCESS;
     2471            if (RT_SUCCESS(rc))
     2472            {
     2473                if (pRam->fFlags & MM_RAM_FLAGS_DYNAMIC_ALLOC)
     2474                {
     2475                    Assert(PGM_PAGE_GET_TYPE(pPage) == PGMPAGETYPE_RAM);
     2476                    RTGCPHYS off = GCPhys - pRam->GCPhys;
     2477                    unsigned iChunk = (off >> PGM_DYNAMIC_CHUNK_SHIFT);
     2478                    *pvPtr = (void *)(pRam->paChunkR3Ptrs[iChunk] + (off & PGM_DYNAMIC_CHUNK_OFFSET_MASK));
     2479                }
     2480                else if (RT_LIKELY(pRam->pvR3))
     2481                {
     2482                    Assert(PGM_PAGE_GET_TYPE(pPage) == PGMPAGETYPE_RAM);
     2483                    RTGCPHYS off = GCPhys - pRam->GCPhys;
     2484                    *pvPtr = (uint8_t *)pRam->pvR3 + off;
     2485                }
     2486                else
     2487                    rc = VERR_PGM_PHYS_TLB_UNASSIGNED;
     2488            }
     2489        }
     2490    }
     2491    else
     2492        rc = VERR_PGM_PHYS_TLB_UNASSIGNED;
     2493
     2494    pgmUnlock(pVM);
     2495    return rc;
     2496}
     2497
     2498
     2499
  • trunk/src/VBox/VMM/VMMAll/PGMAllHandler.cpp

    r14969 r15284  
    10321032 * @param   pVM         VM Handle.
    10331033 * @param   GCPhys      Start physical address earlier passed to PGMR3HandlerPhysicalRegister().
     1034 * @remarks Caller must take the PGM lock...
     1035 * @threads EMT.
    10341036 */
    10351037VMMDECL(bool) PGMHandlerPhysicalIsRegistered(PVM pVM, RTGCPHYS GCPhys)
     
    10541056}
    10551057
     1058
    10561059/**
    10571060 * Check if particular guest's VA is being monitored.
     
    10601063 * @param   pVM             VM handle.
    10611064 * @param   GCPtr           Virtual address.
     1065 * @remarks Will acquire the PGM lock.
     1066 * @threads Any.
    10621067 */
    10631068VMMDECL(bool) PGMHandlerVirtualIsRegistered(PVM pVM, RTGCPTR GCPtr)
     
    10671072    pgmUnlock(pVM);
    10681073
    1069     return pCur != 0;
    1070 }
     1074    return pCur != NULL;
     1075}
     1076
    10711077
    10721078/**
  • trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp

    r14974 r15284  
    913913}
    914914
    915 /**
    916  * Converts a GC physical address to a HC ring-3 pointer, with some
    917  * additional checks.
    918  *
    919  * @returns VINF_SUCCESS on success.
    920  * @returns VERR_PGM_PHYS_PAGE_RESERVED it it's a valid GC physical
    921  *          page but has no physical backing, or if partuclar
    922  *          memory access must always go via PGM, because of handlers.
    923  * @returns VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid
    924  *          GC physical address.
    925  *
    926  * @param   pVM         The VM handle.
    927  * @param   GCPhys      The GC physical address to convert.
    928  * @param   GCPtr       The guest VA, to check virtual handler on.
    929  * @param   flags       Flags controlling additional checks.
    930  * @param   pR3Ptr      Where to store the R3 pointer on success.
    931  */
    932 VMMDECL(int) PGMPhysGCPhys2R3PtrEx(PVM pVM, RTGCPHYS GCPhys, RTGCPTR GCPtr, uint32_t flags, PRTR3PTR pR3Ptr)
    933 {
    934   int rc;
    935 
    936   rc = PGMPhysGCPhys2R3Ptr(pVM, GCPhys, 1, pR3Ptr);
    937 
    938   if (RT_SUCCESS(rc) && (flags & PGMPHYS_TRANSLATION_FLAG_CHECK_PHYS_MONITORED))
    939   {
    940     /* Check if there's a physical handler for PA */
    941       if (PGMHandlerPhysicalIsRegistered(pVM, GCPhys))
    942         rc = VERR_PGM_PHYS_PAGE_RESERVED;
    943   }
    944 
    945   if (RT_SUCCESS(rc) && (flags & PGMPHYS_TRANSLATION_FLAG_CHECK_VIRT_MONITORED))
    946   {
    947     /* Check if there's a virtual handler for VA */
    948     if (PGMHandlerVirtualIsRegistered(pVM, GCPtr))
    949         rc = VERR_PGM_PHYS_PAGE_RESERVED;
    950   }
    951 
    952   return rc;
    953 }
     915
    954916/**
    955917 * PGMPhysGCPhys2R3Ptr convenience for use with assertions.
  • trunk/src/recompiler_new/VBoxREMWrapper.cpp

    r14969 r15284  
    718718    { REMPARMDESC_FLAGS_INT,        sizeof(PRTR3PTR), NULL }
    719719};
    720 static const REMPARMDESC g_aArgsPGMPhysGCPhys2R3PtrEx[] =
     720static const REMPARMDESC g_aArgsPGMR3PhysTlbGCPhys2Ptr[] =
    721721{
    722722    { REMPARMDESC_FLAGS_INT,        sizeof(PVM), NULL },
    723723    { 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 }
    727726};
    728727static const REMPARMDESC g_aArgsPGMPhysGCPtr2R3PtrByGstCR3[] =
     
    11511150    { "PGMR3PhysWriteU32",                      (void *)(uintptr_t)&PGMR3PhysWriteU32,              &g_aArgsPGMR3PhysWriteU32[0],               RT_ELEMENTS(g_aArgsPGMR3PhysWriteU32),                 REMFNDESC_FLAGS_RET_VOID,   0,                  NULL },
    11521151    { "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     { "PGMPhysGCPhys2R3PtrEx",          (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 },
    11551154    { "SSMR3GetGCPtr",                          (void *)(uintptr_t)&SSMR3GetGCPtr,                  &g_aArgsSSMR3GetGCPtr[0],                   RT_ELEMENTS(g_aArgsSSMR3GetGCPtr),                     REMFNDESC_FLAGS_RET_INT,    sizeof(int),        NULL },
    11561155    { "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  
    637637    }
    638638    else
    639     {       
     639    {
    640640        switch (rc)
    641641        {
     
    12831283
    12841284#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;
     1285void *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;
    13051298}
    13061299
  • trunk/src/recompiler_new/cpu-all.h

    r15278 r15284  
    264264uint64_t    remR3PhysReadU64(RTGCPHYS SrcGCPhys);
    265265int64_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);
     266void        remR3PhysWrite(RTGCPHYS DstGCPhys, const void *pvSrc, unsigned cb);
     267void        remR3PhysWriteU8(RTGCPHYS DstGCPhys, uint8_t val);
     268void        remR3PhysWriteU16(RTGCPHYS DstGCPhys, uint16_t val);
     269void        remR3PhysWriteU32(RTGCPHYS DstGCPhys, uint32_t val);
     270void        remR3PhysWriteU64(RTGCPHYS DstGCPhys, uint64_t val);
    271271
    272272#ifndef REM_PHYS_ADDR_IN_TLB
     273void       *remR3TlbGCPhys2Ptr(CPUState *env1, target_ulong physAddr, int fWritable);
    273274target_ulong remR3HCVirt2GCPhys(CPUState *env1, void *addr);
    274 void* remR3GCPhys2HCVirt(CPUState *env1, target_ulong physAddr, target_ulong virtAddr);
    275275#endif
    276276
  • trunk/src/recompiler_new/exec.c

    r14974 r15284  
    243243    VirtualProtect(addr, size,
    244244                   PAGE_EXECUTE_READWRITE, &old_protect);
    245    
     245
    246246}
    247247#else
     
    249249{
    250250    unsigned long start, end, page_size;
    251    
     251
    252252    page_size = getpagesize();
    253253    start = (unsigned long)addr;
    254254    start &= ~(page_size - 1);
    255    
     255
    256256    end = (unsigned long)addr + size;
    257257    end += page_size - 1;
    258258    end &= ~(page_size - 1);
    259    
     259
    260260    mprotect((void *)start, end - start,
    261261             PROT_READ | PROT_WRITE | PROT_EXEC);
     
    308308#ifdef VBOX
    309309    /* We use other means to set reserved bit on our pages */
    310 #else 
     310#else
    311311#if !defined(_WIN32) && defined(CONFIG_USER_ONLY)
    312312    {
     
    328328                    page_set_flags(startaddr & TARGET_PAGE_MASK,
    329329                                   TARGET_PAGE_ALIGN(endaddr),
    330                                    PAGE_RESERVED); 
     330                                   PAGE_RESERVED);
    331331                }
    332332            } while (!feof(f));
     
    379379            page_set_flags(addr & TARGET_PAGE_MASK,
    380380                           TARGET_PAGE_ALIGN(addr + len),
    381                            PAGE_RESERVED); 
     381                           PAGE_RESERVED);
    382382        }
    383383#else
     
    478478#endif
    479479
    480 /* VBox allocates codegen buffer dynamically */ 
     480/* VBox allocates codegen buffer dynamically */
    481481#ifndef VBOX
    482482#ifdef USE_STATIC_CODE_GEN_BUFFER
     
    508508#ifdef VBOX
    509509    code_gen_buffer = RTMemExecAlloc(code_gen_buffer_size);
    510    
     510
    511511    if (!code_gen_buffer) {
    512         LogRel(("REM: failed allocate codegen buffer %lld\n", 
     512        LogRel(("REM: failed allocate codegen buffer %lld\n",
    513513                code_gen_buffer_size));
    514514        return;
    515515    }
    516516#else //!VBOX
    517 #if defined(__linux__) 
     517#if defined(__linux__)
    518518    {
    519519        int flags;
     
    556556#endif
    557557        code_gen_buffer = mmap(addr, code_gen_buffer_size,
    558                                PROT_WRITE | PROT_READ | PROT_EXEC, 
     558                               PROT_WRITE | PROT_READ | PROT_EXEC,
    559559                               flags, -1, 0);
    560560        if (code_gen_buffer == MAP_FAILED) {
     
    580580#endif
    581581
    582     code_gen_buffer_max_size = code_gen_buffer_size - 
     582    code_gen_buffer_max_size = code_gen_buffer_size -
    583583        code_gen_max_block_size();
    584584    code_gen_max_blocks = code_gen_buffer_size / CODE_GEN_AVG_BLOCK_SIZE;
     
    12821282#else
    12831283DECLINLINE(void) tb_alloc_page(TranslationBlock *tb,
    1284                                  unsigned int n, target_ulong page_addr)                   
     1284                                 unsigned int n, target_ulong page_addr)
    12851285#endif
    12861286{
     
    13461346        (code_gen_ptr - code_gen_buffer) >= code_gen_buffer_max_size)
    13471347#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)
    13491349#endif
    13501350        return NULL;
     
    18311831       overlap the flushed page.  */
    18321832    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,
    18341834            TB_JMP_PAGE_SIZE * sizeof(TranslationBlock *));
    18351835
    18361836    i = tb_jmp_cache_hash_page(addr);
    1837     memset (&env->tb_jmp_cache[i], 0, 
     1837    memset (&env->tb_jmp_cache[i], 0,
    18381838            TB_JMP_PAGE_SIZE * sizeof(TranslationBlock *));
    18391839
     
    19291929#endif
    19301930#endif
    1931    
     1931
    19321932    tlb_flush_jmp_cache(env, addr);
    19331933
     
    19741974
    19751975#ifdef VBOX
    1976     if (start & 1)
     1976    if (start & 3)
    19771977        return;
    19781978#endif
     
    20272027    start1 = start + (unsigned long)phys_ram_base;
    20282028#else
    2029     start1 = (unsigned long)remR3GCPhys2HCVirt(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. */
    20302030#endif
    20312031    for(env = first_cpu; env != NULL; env = env->next_cpu) {
     
    21762176    addend = (unsigned long)phys_ram_base + (pd & TARGET_PAGE_MASK);
    21772177#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,
    21792181                                               pd & TARGET_PAGE_MASK,
    2180                                                vaddr & TARGET_PAGE_MASK);
     2182                                               !!(prot & PAGE_WRITE));
    21812183#endif
    21822184    if ((pd & ~TARGET_PAGE_MASK) <= IO_MEM_ROM) {
     
    22012203#ifdef VBOX
    22022204#  if !defined(REM_PHYS_ADDR_IN_TLB)
    2203     if (addend & 0x1)
     2205    if (addend & 0x2)
    22042206    {
    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)
    22072221        {
    22082222            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;
    22102225        }
    22112226    }
     
    27232738    unsigned long ram_addr;
    27242739    int dirty_flags;
    2725 #if defined(VBOX) 
     2740#if defined(VBOX)
    27262741    ram_addr = addr;
    27272742#elif
     
    27702785    unsigned long ram_addr;
    27712786    int dirty_flags;
    2772 #if defined(VBOX) 
     2787#if defined(VBOX)
    27732788    ram_addr = addr;
    27742789#else
     
    28182833    unsigned long ram_addr;
    28192834    int dirty_flags;
    2820 #if defined(VBOX) 
     2835#if defined(VBOX)
    28212836    ram_addr = addr;
    28222837#else
     
    31043119    io_mem_nb = 5;
    31053120#endif
    3106    
     3121
    31073122    io_mem_watch = cpu_register_io_memory(0, watch_mem_read,
    31083123                                          watch_mem_write, NULL);
    3109    
     3124
    31103125#ifndef VBOX /* VBOX: we do this later when the RAM is allocated. */
    31113126    /* alloc dirty bits array */
     
    36373652    tb = tb_find_pc((unsigned long)retaddr);
    36383653    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",
    36403655                  retaddr);
    36413656    }
     
    37163731    cpu_fprintf(f, "gen code size       %ld/%ld\n",
    37173732                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",
    37193734                nb_tbs, code_gen_max_blocks);
    37203735    cpu_fprintf(f, "TB avg target size  %d max=%d bytes\n",
Note: See TracChangeset for help on using the changeset viewer.

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