Index: exec.c =================================================================== RCS file: /cvsroot/qemu/qemu/exec.c,v retrieving revision 1.60 diff -u -r1.60 exec.c --- exec.c 24 Apr 2005 18:02:38 -0000 1.60 +++ exec.c 20 Jul 2005 11:36:49 -0000 @@ -95,9 +95,22 @@ #endif } VirtPageDesc; +#ifdef TARGET_X86_64 +/* XXX: this isn't exactly efficient, but we really need to maintain at least + 48bit virtual address space */ +#define L2_VIRT_BITS 18 +#define L1_VIRT_BITS (48 - L2_VIRT_BITS - TARGET_PAGE_BITS) #define L2_BITS 10 #define L1_BITS (32 - L2_BITS - TARGET_PAGE_BITS) +#else +#define L2_VIRT_BITS 10 +#define L1_VIRT_BITS (32 - L2_VIRT_BITS - TARGET_PAGE_BITS) +#define L2_BITS 10 +#define L1_BITS (32 - L2_BITS - TARGET_PAGE_BITS) +#endif +#define L1_VIRT_SIZE (1 << L1_VIRT_BITS) +#define L2_VIRT_SIZE (1 << L2_VIRT_BITS) #define L1_SIZE (1 << L1_BITS) #define L2_SIZE (1 << L2_BITS) @@ -113,7 +126,7 @@ PhysPageDesc **l1_phys_map; #if !defined(CONFIG_USER_ONLY) -static VirtPageDesc *l1_virt_map[L1_SIZE]; +static VirtPageDesc *l1_virt_map[L1_VIRT_SIZE]; static unsigned int virt_valid_tag; #endif @@ -234,33 +247,29 @@ static void tlb_protect_code(CPUState *env, target_ulong addr); static void tlb_unprotect_code_phys(CPUState *env, unsigned long phys_addr, target_ulong vaddr); -static inline VirtPageDesc *virt_page_find_alloc(unsigned int index) +static inline VirtPageDesc *virt_page_find_alloc(target_ulong index) { VirtPageDesc **lp, *p; - /* XXX: should not truncate for 64 bit addresses */ -#if TARGET_LONG_BITS > 32 - index &= (L1_SIZE - 1); -#endif - lp = &l1_virt_map[index >> L2_BITS]; + lp = &l1_virt_map[(index >> L2_VIRT_BITS) & (L1_VIRT_SIZE - 1)]; p = *lp; if (!p) { /* allocate if not found */ - p = qemu_malloc(sizeof(VirtPageDesc) * L2_SIZE); - memset(p, 0, sizeof(VirtPageDesc) * L2_SIZE); + p = qemu_malloc(sizeof(VirtPageDesc) * L2_VIRT_SIZE); + memset(p, 0, sizeof(VirtPageDesc) * L2_VIRT_SIZE); *lp = p; } - return p + (index & (L2_SIZE - 1)); + return p + (index & (L2_VIRT_SIZE - 1)); } -static inline VirtPageDesc *virt_page_find(unsigned int index) +static inline VirtPageDesc *virt_page_find(target_ulong index) { VirtPageDesc *p; - p = l1_virt_map[index >> L2_BITS]; + p = l1_virt_map[(index >> L2_VIRT_BITS) & (L1_VIRT_SIZE - 1)]; if (!p) return 0; - return p + (index & (L2_SIZE - 1)); + return p + (index & (L2_VIRT_SIZE - 1)); } static void virt_page_flush(void) @@ -272,10 +281,10 @@ if (virt_valid_tag == 0) { virt_valid_tag = 1; - for(i = 0; i < L1_SIZE; i++) { + for(i = 0; i < L1_VIRT_SIZE; i++) { p = l1_virt_map[i]; if (p) { - for(j = 0; j < L2_SIZE; j++) + for(j = 0; j < L2_VIRT_SIZE; j++) p[j].valid_tag = 0; } } @@ -367,6 +376,7 @@ /* verify that all the pages have correct rights for code */ static void tb_page_check(void) { +#ifndef _WIN32 TranslationBlock *tb; int i, flags1, flags2; @@ -380,6 +390,7 @@ } } } +#endif } void tb_jmp_check(TranslationBlock *tb) @@ -1572,7 +1583,7 @@ addend = (unsigned long)phys_ram_base + (pd & TARGET_PAGE_MASK); } - index = (vaddr >> 12) & (CPU_TLB_SIZE - 1); + index = (vaddr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); addend -= vaddr; if (prot & PAGE_READ) { env->tlb_read[is_user][index].address = address;