Index: trunk/src/recompiler/new/VBoxRecompiler.c
===================================================================
--- trunk/src/recompiler/new/VBoxRecompiler.c	(revision 1147)
+++ trunk/src/recompiler/new/VBoxRecompiler.c	(revision 1182)
@@ -1361,5 +1361,5 @@
 #ifndef PGM_DYNAMIC_RAM_ALLOC
     target_ulong phys_addr;
-#endif 
+#endif
     target_ulong virt_addr, addend;
     if (env->pVM->rem.s.fIgnoreSetPage || env->pVM->rem.s.fIgnoreAll)
@@ -1413,5 +1413,5 @@
     Log2(("tlb_set_page_raw read (%x-%x) write (%x-%x) prot %x is_user %d phys\n",
           pRead->addr_read, pRead->addend, pWrite->addr_write, pWrite->addend, prot, is_user));
-#endif/* PGM_DYNAMIC_RAM_ALLOC */ 
+#endif/* PGM_DYNAMIC_RAM_ALLOC */
 
     if (prot & PAGE_WRITE)
@@ -1465,5 +1465,5 @@
 #else
         AssertMsgFailed(("RAWEx_SetPageEntry %x %x %x %d failed!!\n", virt_addr, phys_addr, prot, is_user));
-#endif 
+#endif
         VM_FF_SET(env->pVM, VM_FF_PGM_SYNC_CR3);
     }
@@ -2631,5 +2631,5 @@
     cpu_register_physical_memory(GCPhys, cb, ((uintptr_t)pvRam - (uintptr_t)phys_ram_base)
                                              | (fFlags & MM_RAM_FLAGS_RESERVED ? IO_MEM_UNASSIGNED : 0));
-#endif 
+#endif
     Assert(pVM->rem.s.fIgnoreAll);
     pVM->rem.s.fIgnoreAll = false;
@@ -2712,8 +2712,9 @@
 #else
     AssertReleaseFailed();
-#endif 
-}
-
-
+#endif
+}
+
+
+#ifdef PGM_DYNAMIC_RAM_ALLOC
 /**
  *  Convert GC physical address to HC virt
@@ -2725,5 +2726,4 @@
 void *remR3GCPhys2HCVirt(void *env, target_ulong addr)
 {
-#ifdef PGM_DYNAMIC_RAM_ALLOC
     PVM      pVM = ((CPUState *)env)->pVM;
     uint32_t i;
@@ -2742,7 +2742,4 @@
     Log(("remR3GCPhys2HCVirt: %x -> %x\n", addr, pVM->rem.s.paGCPhysToHCVirt[addr >> PGM_DYNAMIC_CHUNK_SHIFT] + (addr & PGM_DYNAMIC_CHUNK_OFFSET_MASK)));
     return (void *)(pVM->rem.s.paGCPhysToHCVirt[addr >> PGM_DYNAMIC_CHUNK_SHIFT] + (addr & PGM_DYNAMIC_CHUNK_OFFSET_MASK));
-#else
-    return (target_ulong)addr - (target_ulong)phys_ram_base;
-#endif
 }
 
@@ -2757,5 +2754,4 @@
 target_ulong remR3HCVirt2GCPhys(void *env, void *addr)
 {
-#ifdef PGM_DYNAMIC_RAM_ALLOC
     PVM         pVM    = ((CPUState *)env)->pVM;
     RTHCUINTPTR HCVirt = (RTHCUINTPTR)addr;
@@ -2766,5 +2762,5 @@
     off = HCVirt - pVM->rem.s.paHCVirtToGCPhys[idx].pChunk1;
 
-    if (    pVM->rem.s.paHCVirtToGCPhys[idx].pChunk1 
+    if (    pVM->rem.s.paHCVirtToGCPhys[idx].pChunk1
         &&  off < PGM_DYNAMIC_CHUNK_SIZE)
     {
@@ -2772,7 +2768,7 @@
         return pVM->rem.s.paHCVirtToGCPhys[idx].GCPhys1 + off;
     }
-    
+
     off = HCVirt - pVM->rem.s.paHCVirtToGCPhys[idx].pChunk2;
-    if (    pVM->rem.s.paHCVirtToGCPhys[idx].pChunk2 
+    if (    pVM->rem.s.paHCVirtToGCPhys[idx].pChunk2
         &&  off < PGM_DYNAMIC_CHUNK_SIZE)
     {
@@ -2793,7 +2789,4 @@
     AssertReleaseMsgFailed(("No translation for physical address %VHv???\n", addr));
     return 0;
-#else
-    return (target_ulong)addr - (target_ulong)phys_ram_base;
-#endif
 }
 
@@ -2820,4 +2813,5 @@
 }
 
+#endif /* PGM_DYNAMIC_RAM_ALLOC */
 
 
@@ -2875,5 +2869,5 @@
     AssertRelease(phys_ram_base);
     cpu_register_physical_memory(GCPhys, cb, ((uintptr_t)pvCopy - (uintptr_t)phys_ram_base) | IO_MEM_ROM);
-#endif 
+#endif
 
     Log2(("%.64Vhxd\n", (char *)pvCopy + cb - 64));
@@ -3143,5 +3137,5 @@
 #else
     uintptr_t off = pbSrcPhys - phys_ram_base;
-#endif 
+#endif
     if (off < (uintptr_t)phys_ram_size)
         PGMPhysRead(cpu_single_env->pVM, (RTGCPHYS)off, pvDst, cb);
Index: trunk/src/recompiler/new/cpu-all.h
===================================================================
--- trunk/src/recompiler/new/cpu-all.h	(revision 1147)
+++ trunk/src/recompiler/new/cpu-all.h	(revision 1182)
@@ -25,6 +25,7 @@
 #  include <VBox/log.h>
 #  define LOG_GROUP LOG_GROUP_REM
-# endif 
-#endif 
+# endif
+# include <VBox/pgm.h> /* PGM_DYNAMIC_RAM_ALLOC */
+#endif
 
 #if defined(__arm__) || defined(__sparc__)
@@ -197,7 +198,9 @@
 void     remR3PhysWriteU32(uint8_t *pbDstPhys, uint32_t val);
 void     remR3PhysWriteU64(uint8_t *pbDstPhys, uint64_t val);
+# ifdef PGM_DYNAMIC_RAM_ALLOC
 void    *remR3GCPhys2HCVirt(void *env, target_ulong addr);
 target_ulong remR3HCVirt2GCPhys(void *env, void *addr);
 void     remR3GrowDynRange(unsigned long physaddr);
+# endif
 #endif
 
@@ -984,5 +987,5 @@
 #define IO_MEM_UNASSIGNED  (2 << IO_MEM_SHIFT)
 #define IO_MEM_NOTDIRTY    (4 << IO_MEM_SHIFT) /* used internally, never use directly */
-#ifdef VBOX
+#if defined(VBOX) && defined(PGM_DYNAMIC_RAM_ALLOC)
 #define IO_MEM_RAM_MISSING (5 << IO_MEM_SHIFT) /* used internally, never use directly */
 #endif
@@ -1073,5 +1076,5 @@
         return;
     }
-#endif 
+#endif
     phys_ram_dirty[addr >> TARGET_PAGE_BITS] = 0xff;
 }
Index: trunk/src/recompiler/new/exec-all.h
===================================================================
--- trunk/src/recompiler/new/exec-all.h	(revision 1147)
+++ trunk/src/recompiler/new/exec-all.h	(revision 1182)
@@ -26,7 +26,8 @@
 #ifdef VBOX
 # include <VBox/tm.h>
+# include <VBox/pgm.h> /* PGM_DYNAMIC_RAM_ALLOC */
 # ifndef LOG_GROUP
 #  define LOG_GROUP LOG_GROUP_REM
-# endif 
+# endif
 # include <VBox/log.h>
 # include "REMInternal.h"
@@ -603,6 +604,8 @@
 # ifdef VBOX
 target_ulong remR3PhysGetPhysicalAddressCode(CPUState *env, target_ulong addr, CPUTLBEntry *pTLBEntry);
+#  ifdef PGM_DYNAMIC_RAM_ALLOC
 target_ulong remR3HCVirt2GCPhys(void *env, void *addr);
-# endif 
+#  endif
+# endif
 /* NOTE: this function can trigger an exception */
 /* NOTE2: the returned address is not exactly the physical address: it
@@ -636,14 +639,14 @@
 # ifdef VBOX
         /* deal with non-MMIO access handlers. */
-        return remR3PhysGetPhysicalAddressCode(env, addr, &env->tlb_table[is_user][index]); 
+        return remR3PhysGetPhysicalAddressCode(env, addr, &env->tlb_table[is_user][index]);
 # else
         cpu_abort(env, "Trying to execute code outside RAM or ROM at 0x%08lx\n", addr);
 # endif
     }
-# ifdef VBOX
+# if defined(VBOX) && defined(PGM_DYNAMIC_RAM_ALLOC)
     return remR3HCVirt2GCPhys(env, (void *)(addr + env->tlb_table[is_user][index].addend));
 # else
     return addr + env->tlb_table[is_user][index].addend - (unsigned long)phys_ram_base;
-# endif 
+# endif
 }
 #endif
Index: trunk/src/recompiler/new/exec.c
===================================================================
--- trunk/src/recompiler/new/exec.c	(revision 1147)
+++ trunk/src/recompiler/new/exec.c	(revision 1182)
@@ -40,4 +40,5 @@
 # include <iprt/string.h>
 # include <iprt/param.h>
+# include <VBox/pgm.h> /* PGM_DYNAMIC_RAM_ALLOC */
 #endif /* VBOX */
 
@@ -172,5 +173,5 @@
        TARGET_PAGE_SIZE */
 #ifdef VBOX
-    RTMemProtect(code_gen_buffer, sizeof(code_gen_buffer), 
+    RTMemProtect(code_gen_buffer, sizeof(code_gen_buffer),
                  RTMEM_PROT_EXEC | RTMEM_PROT_READ | RTMEM_PROT_WRITE);
     qemu_real_host_page_size = PAGE_SIZE;
@@ -276,5 +277,5 @@
           pd[i].phys_offset = IO_MEM_UNASSIGNED;
     }
-#ifdef VBOX
+#if defined(VBOX) && defined(PGM_DYNAMIC_RAM_ALLOC)
     pd = ((PhysPageDesc *)pd) + (index & (L2_SIZE - 1));
     if (RT_UNLIKELY((pd->phys_offset & ~TARGET_PAGE_MASK) == IO_MEM_RAM_MISSING))
@@ -1431,5 +1432,5 @@
                                     ram_addr + TARGET_PAGE_SIZE,
                                     CODE_DIRTY_FLAG);
-#ifdef VBOX && defined(REM_MONITOR_CODE_PAGES)
+#if defined(VBOX) && defined(REM_MONITOR_CODE_PAGES)
     /** @todo Retest this? This function has changed... */
     remR3ProtectCode(cpu_single_env, ram_addr);
@@ -1497,5 +1498,5 @@
     /* we modify the TLB cache so that the dirty bit will be set again
        when accessing the range */
-#ifndef VBOX
+#if !defined(VBOX) || !defined(PGM_DYNAMIC_RAM_ALLOC)
     start1 = start + (unsigned long)phys_ram_base;
 #else
@@ -1511,6 +1512,6 @@
 #if !defined(CONFIG_SOFTMMU)
 #ifdef VBOX /**@todo remove this check */
-# error "We shouldn't get here..." 
-#endif 
+# error "We shouldn't get here..."
+#endif
     /* XXX: this is expensive */
     {
@@ -1547,5 +1548,5 @@
     if ((tlb_entry->addr_write & ~TARGET_PAGE_MASK) == IO_MEM_RAM) {
         /* RAM case */
-#ifndef VBOX
+#if !defined(VBOX) || !defined(PGM_DYNAMIC_RAM_ALLOC)
         ram_addr = (tlb_entry->addr_write & TARGET_PAGE_MASK) + 
             tlb_entry->addend - (unsigned long)phys_ram_base;
@@ -1633,5 +1634,5 @@
             /* standard memory */
             address = vaddr;
-#ifndef VBOX
+#if !defined(VBOX) || !defined(PGM_DYNAMIC_RAM_ALLOC)
             addend = (unsigned long)phys_ram_base + (pd & TARGET_PAGE_MASK);
 #else
@@ -1754,5 +1755,5 @@
 #ifdef VBOX
     if (RT_LIKELY((vp->phys_addr >> TARGET_PAGE_BITS) < phys_ram_dirty_size))
-#endif 
+#endif
     phys_ram_dirty[vp->phys_addr >> TARGET_PAGE_BITS] = 0xff;
     /* flush the code inside */
@@ -1950,5 +1951,5 @@
         p = phys_page_find_alloc(addr >> TARGET_PAGE_BITS, 1);
         p->phys_offset = phys_offset;
-#ifndef VBOX
+#if !defined(VBOX) || !defined(PGM_DYNAMIC_RAM_ALLOC)
         if ((phys_offset & ~TARGET_PAGE_MASK) <= IO_MEM_ROM ||
             (phys_offset & IO_MEM_ROMD))
@@ -2012,5 +2013,5 @@
     unsigned long ram_addr;
     int dirty_flags;
-#ifndef VBOX
+#if !defined(VBOX) || !defined(PGM_DYNAMIC_RAM_ALLOC)
     ram_addr = addr - (unsigned long)phys_ram_base;
 #else
@@ -2055,5 +2056,5 @@
     unsigned long ram_addr;
     int dirty_flags;
-#ifndef VBOX
+#if !defined(VBOX) || !defined(PGM_DYNAMIC_RAM_ALLOC)
     ram_addr = addr - (unsigned long)phys_ram_base;
 #else
@@ -2086,5 +2087,5 @@
 #ifdef VBOX
     if (RT_LIKELY((ram_addr >> TARGET_PAGE_BITS) < phys_ram_dirty_size))
-#endif 
+#endif
     phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS] = dirty_flags;
     /* we remove the notdirty callback only if the code has been
@@ -2098,5 +2099,5 @@
     unsigned long ram_addr;
     int dirty_flags;
-#ifndef VBOX
+#if !defined(VBOX) || !defined(PGM_DYNAMIC_RAM_ALLOC)
     ram_addr = addr - (unsigned long)phys_ram_base;
 #else
@@ -2104,5 +2105,5 @@
 #endif
 #ifdef VBOX
-    if (RT_UNLIKELY((ram_addr >> TARGET_PAGE_BITS) >= phys_ram_dirty_size)) 
+    if (RT_UNLIKELY((ram_addr >> TARGET_PAGE_BITS) >= phys_ram_dirty_size))
         dirty_flags = 0xff;
     else
@@ -2113,5 +2114,5 @@
         tb_invalidate_phys_page_fast(ram_addr, 4);
 # ifdef VBOX
-        if (RT_UNLIKELY((ram_addr >> TARGET_PAGE_BITS) >= phys_ram_dirty_size)) 
+        if (RT_UNLIKELY((ram_addr >> TARGET_PAGE_BITS) >= phys_ram_dirty_size))
             dirty_flags = 0xff;
         else
@@ -2129,5 +2130,5 @@
 #ifdef VBOX
     if (RT_LIKELY((ram_addr >> TARGET_PAGE_BITS) < phys_ram_dirty_size))
-#endif 
+#endif
     phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS] = dirty_flags;
     /* we remove the notdirty callback only if the code has been
@@ -2154,5 +2155,5 @@
     cpu_register_io_memory(IO_MEM_UNASSIGNED >> IO_MEM_SHIFT, unassigned_mem_read, unassigned_mem_write, NULL);
     cpu_register_io_memory(IO_MEM_NOTDIRTY >> IO_MEM_SHIFT, error_mem_read, notdirty_mem_write, NULL);
-#ifdef VBOX
+#if defined(VBOX) && defined(PGM_DYNAMIC_RAM_ALLOC)
     cpu_register_io_memory(IO_MEM_RAM_MISSING >> IO_MEM_SHIFT, unassigned_mem_read, unassigned_mem_write, NULL);
     io_mem_nb = 6;
@@ -2293,5 +2294,9 @@
                 /* RAM case */
 #ifdef VBOX
+# ifdef PGM_DYNAMIC_RAM_ALLOC
                 ptr = remR3GCPhys2HCVirt(cpu_single_env, addr1);
+# else
+                ptr = phys_ram_base + addr1;
+# endif
                 remR3PhysWrite(ptr, buf, l);
 #else
@@ -2305,6 +2310,6 @@
 #ifdef VBOX
                     if (RT_LIKELY((addr1 >> TARGET_PAGE_BITS) < phys_ram_dirty_size))
-#endif 
-                    phys_ram_dirty[addr1 >> TARGET_PAGE_BITS] |= 
+#endif
+                    phys_ram_dirty[addr1 >> TARGET_PAGE_BITS] |=
                         (0xff & ~CODE_DIRTY_FLAG);
                 }
@@ -2334,5 +2339,10 @@
                 /* RAM case */
 #ifdef VBOX
+# ifdef PGM_DYNAMIC_RAM_ALLOC
                 ptr = remR3GCPhys2HCVirt(cpu_single_env, (pd & TARGET_PAGE_MASK) + (addr & ~TARGET_PAGE_MASK));
+# else
+                ptr = phys_ram_base + (pd & TARGET_PAGE_MASK) + 
+                    (addr & ~TARGET_PAGE_MASK);
+# endif
                 remR3PhysRead(ptr, buf, l);
 #else
@@ -2380,5 +2390,5 @@
             /* ROM/RAM case */
         /* RAM case */
-#ifndef VBOX
+#if !defined(VBOX) || !defined(PGM_DYNAMIC_RAM_ALLOC)
             ptr = phys_ram_base + addr1;
 #else
@@ -2417,5 +2427,5 @@
     } else {
         /* RAM case */
-#ifndef VBOX
+#if !defined(VBOX) || !defined(PGM_DYNAMIC_RAM_ALLOC)
         ptr = phys_ram_base + (pd & TARGET_PAGE_MASK) + 
             (addr & ~TARGET_PAGE_MASK);
@@ -2457,5 +2467,5 @@
     } else {
         /* RAM case */
-#ifndef VBOX
+#if !defined(VBOX) || !defined(PGM_DYNAMIC_RAM_ALLOC)
         ptr = phys_ram_base + (pd & TARGET_PAGE_MASK) + 
             (addr & ~TARGET_PAGE_MASK);
@@ -2505,5 +2515,5 @@
         io_mem_write[io_index][2](io_mem_opaque[io_index], addr, val);
     } else {
-#ifndef VBOX
+#if !defined(VBOX) || !defined(PGM_DYNAMIC_RAM_ALLOC)
         ptr = phys_ram_base + (pd & TARGET_PAGE_MASK) + 
             (addr & ~TARGET_PAGE_MASK);
@@ -2537,5 +2547,5 @@
         addr1 = (pd & TARGET_PAGE_MASK) + (addr & ~TARGET_PAGE_MASK);
         /* RAM case */
-#ifndef VBOX
+#if !defined(VBOX) || !defined(PGM_DYNAMIC_RAM_ALLOC)
         ptr = phys_ram_base + addr1;
 #else
@@ -2550,5 +2560,5 @@
 #ifdef VBOX
             if (RT_LIKELY((addr1 >> TARGET_PAGE_BITS) < phys_ram_dirty_size))
-#endif 
+#endif
             phys_ram_dirty[addr1 >> TARGET_PAGE_BITS] |=
                 (0xff & ~CODE_DIRTY_FLAG);
Index: trunk/src/recompiler/new/target-i386/helper2.c
===================================================================
--- trunk/src/recompiler/new/target-i386/helper2.c	(revision 1147)
+++ trunk/src/recompiler/new/target-i386/helper2.c	(revision 1182)
@@ -26,5 +26,7 @@
 #include <signal.h>
 #include <assert.h>
-#endif 
+#else
+# include <VBox/pgm.h> /* PGM_DYNAMIC_RAM_ALLOC */
+#endif
 
 #include "cpu.h"
@@ -539,5 +541,5 @@
 #ifdef VBOX
     remR3ChangeCpuMode(env);
-#endif 
+#endif
 }
 
@@ -575,5 +577,5 @@
 #ifdef VBOX
     remR3ChangeCpuMode(env);
-#endif 
+#endif
 }
 
@@ -586,5 +588,10 @@
 
     /* page directory entry */
+# ifdef PGM_DYNAMIC_RAM_ALLOC
     pde_ptr = remR3GCPhys2HCVirt(env, (((env->cr[3] & ~0xfff) + ((addr >> 20) & ~3)) & env->a20_mask));
+# else
+    pde_ptr = phys_ram_base + 
+        (((env->cr[3] & ~0xfff) + ((addr >> 20) & ~3)) & env->a20_mask);
+# endif
     pde = ldl_raw(pde_ptr);
     /* if PSE bit is set, then we use a 4MB page */
