Skip to content

Commit 85dfad2

Browse files
committed
Add offset when indexing cpu model, makes tests work on older python
1 parent 4873734 commit 85dfad2

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

include/unicorn/mips.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ typedef enum uc_cpu_mips32 {
4343

4444
//> MIPS64 CPUS
4545
typedef enum uc_cpu_mips64 {
46-
// This is used as an index into the array defined in "qemu/target/mips/translate_init.inc.c".
47-
// 64-bit CPU models are defined in the array directly after 32-bit models
48-
UC_CPU_MIPS64_R4000 = UC_CPU_MIPS32_ENDING,
46+
UC_CPU_MIPS64_R4000 = 0,
4947
UC_CPU_MIPS64_VR5432,
5048
UC_CPU_MIPS64_5KC,
5149
UC_CPU_MIPS64_5KF,

qemu/target/mips/cpu.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,12 @@ MIPSCPU *cpu_mips_init(struct uc_struct *uc)
194194
mips_cpu_initfn(uc, cs);
195195

196196
env = &cpu->env;
197-
env->cpu_model = &(mips_defs[uc->cpu_model]);
197+
if(uc->mode & UC_MODE_MIPS64){
198+
// 64-bit CPU models are defined in the array directly after 32-bit models
199+
env->cpu_model = &(mips_defs[uc->cpu_model + UC_CPU_MIPS32_ENDING])
200+
} else {
201+
env->cpu_model = &(mips_defs[uc->cpu_model]);
202+
}
198203

199204
if (env->cpu_model == NULL) {
200205
free(cpu);

tests/regress/mips64.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def run():
1414
# See https://github.com/unicorn-engine/unicorn/pull/2111 for more details
1515
uc.ctl_set_tlb_mode(UC_TLB_VIRTUAL)
1616

17-
ADDRESS = 0x01_2000_3000
17+
ADDRESS = 0x0120003000
1818

1919
uc.reg_write(UC_MIPS_REG_PC, ADDRESS)
2020
uc.reg_write(UC_MIPS_REG_GP, 0x123)

0 commit comments

Comments
 (0)