Support changing cpu model for x86
This commit is contained in:
parent
837c3be347
commit
435ac71f47
|
@ -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;
|
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;
|
X86CPU *cpu;
|
||||||
CPUState *cs;
|
CPUState *cs;
|
||||||
CPUClass *cc;
|
CPUClass *cc;
|
||||||
X86CPUClass *xcc;
|
X86CPUClass *xcc;
|
||||||
|
|
||||||
if (cpu_model == NULL) {
|
|
||||||
#ifdef TARGET_X86_64
|
|
||||||
cpu_model = "qemu64";
|
|
||||||
#else
|
|
||||||
cpu_model = "qemu32";
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
cpu = calloc(1, sizeof(*cpu));
|
cpu = calloc(1, sizeof(*cpu));
|
||||||
if (cpu == NULL) {
|
if (cpu == NULL) {
|
||||||
return 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;
|
cs = (CPUState *)cpu;
|
||||||
cc = (CPUClass *)&cpu->cc;
|
cc = (CPUClass *)&cpu->cc;
|
||||||
cs->cc = 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;
|
xcc->model->version = CPU_VERSION_AUTO;
|
||||||
for (i = 0; i < ARRAY_SIZE(builtin_x86_defs); i++) {
|
xcc->model->cpudef = &builtin_x86_defs[uc->cpu_model];
|
||||||
if (strcmp(cpu_model, builtin_x86_defs[i].name) == 0) {
|
|
||||||
xcc->model->cpudef = &builtin_x86_defs[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xcc->model->cpudef == NULL) {
|
if (xcc->model->cpudef == NULL) {
|
||||||
free(xcc->model);
|
free(xcc->model);
|
||||||
|
|
|
@ -2129,6 +2129,6 @@ void x86_cpu_xsave_all_areas(X86CPU *cpu, X86XSaveArea *buf);
|
||||||
void x86_update_hflags(CPUX86State* env);
|
void x86_update_hflags(CPUX86State* env);
|
||||||
|
|
||||||
int uc_check_cpu_x86_load_seg(CPUX86State *env, int seg_reg, int sel);
|
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 */
|
#endif /* I386_CPU_H */
|
||||||
|
|
|
@ -1596,7 +1596,7 @@ static int x86_cpus_init(struct uc_struct *uc, const char *cpu_model)
|
||||||
|
|
||||||
X86CPU *cpu;
|
X86CPU *cpu;
|
||||||
|
|
||||||
cpu = cpu_x86_init(uc, cpu_model);
|
cpu = cpu_x86_init(uc);
|
||||||
if (cpu == NULL) {
|
if (cpu == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue