mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-23 14:35:34 +00:00
target-i386: x86_cpu_load_features() function
When probing for CPU model information, we need to reuse the code that initializes CPUID fields, but not the remaining side-effects of x86_cpu_realizefn(). Move that code to a separate function that can be reused later. Backports commit 41f3d4d69a423dadb8431fda65d8d7c68c0de0fc from qemu
This commit is contained in:
parent
aa98c8a93f
commit
4096ce0184
|
@ -3030,25 +3030,12 @@ static void x86_cpu_enable_xsave_components(X86CPU *cpu)
|
|||
env->features[FEAT_XSAVE_COMP_HI] = mask >> 32;
|
||||
}
|
||||
|
||||
#define IS_INTEL_CPU(env) ((env)->cpuid_vendor1 == CPUID_VENDOR_INTEL_1 && \
|
||||
(env)->cpuid_vendor2 == CPUID_VENDOR_INTEL_2 && \
|
||||
(env)->cpuid_vendor3 == CPUID_VENDOR_INTEL_3)
|
||||
#define IS_AMD_CPU(env) ((env)->cpuid_vendor1 == CPUID_VENDOR_AMD_1 && \
|
||||
(env)->cpuid_vendor2 == CPUID_VENDOR_AMD_2 && \
|
||||
(env)->cpuid_vendor3 == CPUID_VENDOR_AMD_3)
|
||||
static int x86_cpu_realizefn(struct uc_struct *uc, DeviceState *dev, Error **errp)
|
||||
/* Load CPUID data based on configured features */
|
||||
static void x86_cpu_load_features(struct uc_struct *uc, X86CPU *cpu, Error **errp)
|
||||
{
|
||||
CPUState *cs = CPU(dev);
|
||||
X86CPU *cpu = X86_CPU(uc, dev);
|
||||
X86CPUClass *xcc = X86_CPU_GET_CLASS(uc, dev);
|
||||
CPUX86State *env = &cpu->env;
|
||||
Error *local_err = NULL;
|
||||
FeatureWord w;
|
||||
|
||||
if (cpu->apic_id == UNASSIGNED_APIC_ID) {
|
||||
error_setg(errp, "apic-id property was not initialized properly");
|
||||
return -1;
|
||||
}
|
||||
Error *local_err = NULL;
|
||||
|
||||
/*TODO: cpu->host_features incorrectly overwrites features
|
||||
* set using "feat=on|off". Once we fix this, we can convert
|
||||
|
@ -3104,6 +3091,44 @@ static int x86_cpu_realizefn(struct uc_struct *uc, DeviceState *dev, Error **err
|
|||
env->cpuid_xlevel2 = env->cpuid_min_xlevel2;
|
||||
}
|
||||
|
||||
if (local_err != NULL) {
|
||||
error_propagate(errp, local_err);
|
||||
}
|
||||
}
|
||||
|
||||
#define IS_INTEL_CPU(env) ((env)->cpuid_vendor1 == CPUID_VENDOR_INTEL_1 && \
|
||||
(env)->cpuid_vendor2 == CPUID_VENDOR_INTEL_2 && \
|
||||
(env)->cpuid_vendor3 == CPUID_VENDOR_INTEL_3)
|
||||
#define IS_AMD_CPU(env) ((env)->cpuid_vendor1 == CPUID_VENDOR_AMD_1 && \
|
||||
(env)->cpuid_vendor2 == CPUID_VENDOR_AMD_2 && \
|
||||
(env)->cpuid_vendor3 == CPUID_VENDOR_AMD_3)
|
||||
|
||||
static int x86_cpu_realizefn(struct uc_struct *uc, DeviceState *dev, Error **errp)
|
||||
{
|
||||
CPUState *cs = CPU(dev);
|
||||
X86CPU *cpu = X86_CPU(uc, dev);
|
||||
X86CPUClass *xcc = X86_CPU_GET_CLASS(uc, dev);
|
||||
CPUX86State *env = &cpu->env;
|
||||
Error *local_err = NULL;
|
||||
|
||||
/* Unicorn: commented out
|
||||
if (xcc->kvm_required && !kvm_enabled()) {
|
||||
char *name = x86_cpu_class_get_model_name(xcc);
|
||||
error_setg(&local_err, "CPU model '%s' requires KVM", name);
|
||||
g_free(name);
|
||||
goto out;
|
||||
}*/
|
||||
|
||||
if (cpu->apic_id == UNASSIGNED_APIC_ID) {
|
||||
error_setg(errp, "apic-id property was not initialized properly");
|
||||
return -1;
|
||||
}
|
||||
|
||||
x86_cpu_load_features(uc, cpu, &local_err);
|
||||
if (local_err) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (x86_cpu_filter_features(cpu) &&
|
||||
(cpu->check_cpuid || cpu->enforce_cpuid)) {
|
||||
x86_cpu_report_filtered_features(cpu);
|
||||
|
@ -3196,8 +3221,9 @@ static int x86_cpu_realizefn(struct uc_struct *uc, DeviceState *dev, Error **err
|
|||
}
|
||||
#endif
|
||||
|
||||
if (qemu_init_vcpu(cs))
|
||||
if (qemu_init_vcpu(cs)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
x86_cpu_apic_realize(cpu, &local_err);
|
||||
if (local_err != NULL) {
|
||||
|
@ -3206,6 +3232,7 @@ static int x86_cpu_realizefn(struct uc_struct *uc, DeviceState *dev, Error **err
|
|||
cpu_reset(cs);
|
||||
|
||||
xcc->parent_realize(uc, dev, &local_err);
|
||||
|
||||
out:
|
||||
if (local_err != NULL) {
|
||||
error_propagate(errp, local_err);
|
||||
|
|
Loading…
Reference in a new issue