Support changing cpu model for x86

This commit is contained in:
lazymio 2021-11-04 19:10:29 +01:00
parent 837c3be347
commit 435ac71f47
No known key found for this signature in database
GPG Key ID: DFF27E34A47CB873
3 changed files with 15 additions and 18 deletions

View File

@ -4776,27 +4776,29 @@ static void x86_cpu_common_class_init(struct uc_struct *uc, CPUClass *oc, void *
cc->tlb_fill = x86_cpu_tlb_fill;
}
X86CPU *cpu_x86_init(struct uc_struct *uc, const char *cpu_model)
X86CPU *cpu_x86_init(struct uc_struct *uc)
{
int i;
X86CPU *cpu;
CPUState *cs;
CPUClass *cc;
X86CPUClass *xcc;
if (cpu_model == NULL) {
#ifdef TARGET_X86_64
cpu_model = "qemu64";
#else
cpu_model = "qemu32";
#endif
}
cpu = calloc(1, sizeof(*cpu));
if (cpu == NULL) {
return NULL;
}
if (uc->cpu_model == INT_MAX) {
#ifdef TARGET_X86_64
uc->cpu_model = 0; // qemu64
#else
uc->cpu_model = 4; // qemu32
#endif
} else if (uc->cpu_model >= ARRAY_SIZE(builtin_x86_defs)) {
free(cpu);
return NULL;
}
cs = (CPUState *)cpu;
cc = (CPUClass *)&cpu->cc;
cs->cc = cc;
@ -4822,12 +4824,7 @@ X86CPU *cpu_x86_init(struct uc_struct *uc, const char *cpu_model)
}
xcc->model->version = CPU_VERSION_AUTO;
for (i = 0; i < ARRAY_SIZE(builtin_x86_defs); i++) {
if (strcmp(cpu_model, builtin_x86_defs[i].name) == 0) {
xcc->model->cpudef = &builtin_x86_defs[i];
break;
}
}
xcc->model->cpudef = &builtin_x86_defs[uc->cpu_model];
if (xcc->model->cpudef == NULL) {
free(xcc->model);

View File

@ -2129,6 +2129,6 @@ void x86_cpu_xsave_all_areas(X86CPU *cpu, X86XSaveArea *buf);
void x86_update_hflags(CPUX86State* env);
int uc_check_cpu_x86_load_seg(CPUX86State *env, int seg_reg, int sel);
X86CPU *cpu_x86_init(struct uc_struct *uc, const char *cpu_model);
X86CPU *cpu_x86_init(struct uc_struct *uc);
#endif /* I386_CPU_H */

View File

@ -1596,7 +1596,7 @@ static int x86_cpus_init(struct uc_struct *uc, const char *cpu_model)
X86CPU *cpu;
cpu = cpu_x86_init(uc, cpu_model);
cpu = cpu_x86_init(uc);
if (cpu == NULL) {
return -1;
}