Commit 89fc88da4c8be493c978cf587fb5f4cc0114d23b

Authored by ths
1 parent ea6fd42f

Fix off-by-one in address check.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3382 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 8 additions and 11 deletions
target-mips/helper.c
@@ -131,18 +131,14 @@ static int get_physical_address (CPUState *env, target_ulong *physical, @@ -131,18 +131,14 @@ static int get_physical_address (CPUState *env, target_ulong *physical,
131 ret = env->tlb->map_address(env, physical, prot, address, rw, access_type); 131 ret = env->tlb->map_address(env, physical, prot, address, rw, access_type);
132 } 132 }
133 #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64) 133 #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
134 -/*  
135 - XXX: Assuming :  
136 - - PABITS = 36 (correct for MIPS64R1)  
137 -*/  
138 - } else if (address < 0x3FFFFFFFFFFFFFFFULL) { 134 + } else if (address < 0x4000000000000000ULL) {
139 /* xuseg */ 135 /* xuseg */
140 if (UX && address < (0x3FFFFFFFFFFFFFFFULL & env->SEGMask)) { 136 if (UX && address < (0x3FFFFFFFFFFFFFFFULL & env->SEGMask)) {
141 ret = env->tlb->map_address(env, physical, prot, address, rw, access_type); 137 ret = env->tlb->map_address(env, physical, prot, address, rw, access_type);
142 } else { 138 } else {
143 ret = TLBRET_BADADDR; 139 ret = TLBRET_BADADDR;
144 } 140 }
145 - } else if (address < 0x7FFFFFFFFFFFFFFFULL) { 141 + } else if (address < 0x8000000000000000ULL) {
146 /* xsseg */ 142 /* xsseg */
147 if ((supervisor_mode || kernel_mode) && 143 if ((supervisor_mode || kernel_mode) &&
148 SX && address < (0x7FFFFFFFFFFFFFFFULL & env->SEGMask)) { 144 SX && address < (0x7FFFFFFFFFFFFFFFULL & env->SEGMask)) {
@@ -150,16 +146,17 @@ static int get_physical_address (CPUState *env, target_ulong *physical, @@ -150,16 +146,17 @@ static int get_physical_address (CPUState *env, target_ulong *physical,
150 } else { 146 } else {
151 ret = TLBRET_BADADDR; 147 ret = TLBRET_BADADDR;
152 } 148 }
153 - } else if (address < 0xBFFFFFFFFFFFFFFFULL) { 149 + } else if (address < 0xC000000000000000ULL) {
154 /* xkphys */ 150 /* xkphys */
  151 + /* XXX: Assumes PABITS = 36 (correct for MIPS64R1) */
155 if (kernel_mode && KX && 152 if (kernel_mode && KX &&
156 - (address & 0x07FFFFFFFFFFFFFFULL) < 0X0000000FFFFFFFFFULL) {  
157 - *physical = address & 0X0000000FFFFFFFFFULL; 153 + (address & 0x07FFFFFFFFFFFFFFULL) < 0x0000000FFFFFFFFFULL) {
  154 + *physical = address & 0x0000000FFFFFFFFFULL;
158 *prot = PAGE_READ | PAGE_WRITE; 155 *prot = PAGE_READ | PAGE_WRITE;
159 } else { 156 } else {
160 ret = TLBRET_BADADDR; 157 ret = TLBRET_BADADDR;
161 } 158 }
162 - } else if (address < 0xFFFFFFFF7FFFFFFFULL) { 159 + } else if (address < 0xFFFFFFFF80000000ULL) {
163 /* xkseg */ 160 /* xkseg */
164 if (kernel_mode && KX && 161 if (kernel_mode && KX &&
165 address < (0xFFFFFFFF7FFFFFFFULL & env->SEGMask)) { 162 address < (0xFFFFFFFF7FFFFFFFULL & env->SEGMask)) {
@@ -185,7 +182,7 @@ static int get_physical_address (CPUState *env, target_ulong *physical, @@ -185,7 +182,7 @@ static int get_physical_address (CPUState *env, target_ulong *physical,
185 ret = TLBRET_BADADDR; 182 ret = TLBRET_BADADDR;
186 } 183 }
187 } else if (address < (int32_t)0xE0000000UL) { 184 } else if (address < (int32_t)0xE0000000UL) {
188 - /* sseg */ 185 + /* sseg (kseg2) */
189 if (supervisor_mode || kernel_mode) { 186 if (supervisor_mode || kernel_mode) {
190 ret = env->tlb->map_address(env, physical, prot, address, rw, access_type); 187 ret = env->tlb->map_address(env, physical, prot, address, rw, access_type);
191 } else { 188 } else {