* [Qemu-devel] [PATCH qom-cpu v10 0/2] target-i386: X86CPU subclasses @ 2014-02-25 7:36 Andreas Färber 2014-02-25 7:36 ` [Qemu-devel] [PATCH qom-cpu v10 1/2] target-i386: Prepare CPUClass::class_by_name for X86CPU Andreas Färber ` (2 more replies) 0 siblings, 3 replies; 7+ messages in thread From: Andreas Färber @ 2014-02-25 7:36 UTC (permalink / raw) To: qemu-devel Cc: Paolo Bonzini, Andreas Färber, Eduardo Habkost, Anthony Liguori, Igor Mammedov Hello, Here's my cleaned up version of slim x86 CPU subclasses. Second patch didn't get a lot of testing yet. Loading cpudef is still in main initfn since otherwise the host type would need to be relocated. Can be cleaned up as follow-ups. I wonder whether we are intentionally registering the host type even for !CONFIG_KVM? Instantiating it will then always lead to assertion failure. Available for testing here: git://github.com/afaerber/qemu-cpu.git qom-cpu-x86-subclasses.v10 https://github.com/afaerber/qemu-cpu/commits/qom-cpu-x86-subclasses.v10 Regards, Andreas v9 -> v10: * Cleaned up documentation comments. * Prepended patch to implement CPUClass::class_by_name(), rebased on it. * Cleaned up naming (..._class_init, ..._initfn, type vs. class). * Dropped duplicate white line. * Dropped unnecessary .abstract, .instance_size, .class_size fields. * Aligned model type registration with other targets by having the registration function operate on one model only. * Relocated cpudef-based types to after x86_cpu_load_cpudef(). * Moved assignment of cpu_def into cpudef-specific class_init. (went through various hands, last ehabkost's) v2 -> v3: * Instead of re-coding all CPU definitions as class_init functions, leave the built-in definition array in place and place x86_def_t in the class. * Use kvm_arch_init() hook to assure class_init succeeds for -cpu host. Suggested by Eduardo. v1-> v2: * Instead of turning x86_def_t into X86CPUInfo to initialize classes, drop it completely and register types manually with customizable TypeInfos * Use new list facilities for printing -cpu ? models * Adopt new name scheme suggested by Eduardo and ideas from my alpha series * Keep short names in -cpu ? output for alignment reasons * Merge cpu_x86_init() into cpu.c:cpu_x86_register() * Append patch showing Haswell as subclass of SandyBridge Cc: Eduardo Habkost <ehabkost@redhat.com> Cc: Igor Mammedov <imammedo@redhat.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Anthony Liguori <anthony@codemonkey.ws> Andreas Färber (1): target-i386: Prepare CPUClass::class_by_name for X86CPU Eduardo Habkost (1): target-i386: X86CPU model subclasses target-i386/cpu-qom.h | 15 ++++ target-i386/cpu.c | 197 +++++++++++++++++++++++++++++++------------------- 2 files changed, 138 insertions(+), 74 deletions(-) -- 1.8.4.5 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH qom-cpu v10 1/2] target-i386: Prepare CPUClass::class_by_name for X86CPU 2014-02-25 7:36 [Qemu-devel] [PATCH qom-cpu v10 0/2] target-i386: X86CPU subclasses Andreas Färber @ 2014-02-25 7:36 ` Andreas Färber 2014-03-04 19:48 ` Eduardo Habkost 2014-02-25 7:36 ` [Qemu-devel] [PATCH qom-cpu v10 2/2] target-i386: X86CPU model subclasses Andreas Färber 2014-03-03 16:50 ` [Qemu-devel] [PATCH qom-cpu v10 0/2] target-i386: X86CPU subclasses Andreas Färber 2 siblings, 1 reply; 7+ messages in thread From: Andreas Färber @ 2014-02-25 7:36 UTC (permalink / raw) To: qemu-devel Cc: Paolo Bonzini, Andreas Färber, Eduardo Habkost, Anthony Liguori, Igor Mammedov Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de> --- target-i386/cpu.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index a8b8e88..1c009bb 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -484,6 +484,15 @@ static void add_flagname_to_bitmaps(const char *flagname, } } +static ObjectClass *x86_cpu_class_by_name(const char *cpu_model) +{ + if (cpu_model == NULL) { + return NULL; + } + + return object_class_by_name(TYPE_X86_CPU); +} + typedef struct X86CPUDefinition { const char *name; uint32_t level; @@ -1881,6 +1890,7 @@ X86CPU *cpu_x86_create(const char *cpu_model, DeviceState *icc_bridge, Error **errp) { X86CPU *cpu = NULL; + ObjectClass *oc; gchar **model_pieces; char *name, *features; char *typename; @@ -1894,7 +1904,12 @@ X86CPU *cpu_x86_create(const char *cpu_model, DeviceState *icc_bridge, name = model_pieces[0]; features = model_pieces[1]; - cpu = X86_CPU(object_new(TYPE_X86_CPU)); + oc = x86_cpu_class_by_name(name); + if (oc == NULL) { + error_setg(&error, "Unable to find CPU definition: %s", name); + goto out; + } + cpu = X86_CPU(object_new(object_class_get_name(oc))); x86_cpu_load_def(cpu, name, &error); if (error) { goto out; @@ -1925,8 +1940,10 @@ X86CPU *cpu_x86_create(const char *cpu_model, DeviceState *icc_bridge, out: if (error != NULL) { error_propagate(errp, error); - object_unref(OBJECT(cpu)); - cpu = NULL; + if (cpu) { + object_unref(OBJECT(cpu)); + cpu = NULL; + } } g_strfreev(model_pieces); return cpu; @@ -2739,6 +2756,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->reset = x86_cpu_reset; cc->reset_dump_flags = CPU_DUMP_FPU | CPU_DUMP_CCOP; + cc->class_by_name = x86_cpu_class_by_name; cc->has_work = x86_cpu_has_work; cc->do_interrupt = x86_cpu_do_interrupt; cc->dump_state = x86_cpu_dump_state; -- 1.8.4.5 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH qom-cpu v10 1/2] target-i386: Prepare CPUClass::class_by_name for X86CPU 2014-02-25 7:36 ` [Qemu-devel] [PATCH qom-cpu v10 1/2] target-i386: Prepare CPUClass::class_by_name for X86CPU Andreas Färber @ 2014-03-04 19:48 ` Eduardo Habkost 0 siblings, 0 replies; 7+ messages in thread From: Eduardo Habkost @ 2014-03-04 19:48 UTC (permalink / raw) To: Andreas Färber Cc: Paolo Bonzini, qemu-devel, Anthony Liguori, Igor Mammedov On Tue, Feb 25, 2014 at 08:36:26AM +0100, Andreas Färber wrote: > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> > Signed-off-by: Andreas Färber <afaerber@suse.de> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Tested-by: Eduardo Habkost <ehabkost@redhat.com> -- Eduardo ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH qom-cpu v10 2/2] target-i386: X86CPU model subclasses 2014-02-25 7:36 [Qemu-devel] [PATCH qom-cpu v10 0/2] target-i386: X86CPU subclasses Andreas Färber 2014-02-25 7:36 ` [Qemu-devel] [PATCH qom-cpu v10 1/2] target-i386: Prepare CPUClass::class_by_name for X86CPU Andreas Färber @ 2014-02-25 7:36 ` Andreas Färber 2014-03-04 19:53 ` Eduardo Habkost 2014-03-03 16:50 ` [Qemu-devel] [PATCH qom-cpu v10 0/2] target-i386: X86CPU subclasses Andreas Färber 2 siblings, 1 reply; 7+ messages in thread From: Andreas Färber @ 2014-02-25 7:36 UTC (permalink / raw) To: qemu-devel Cc: Paolo Bonzini, Andreas Färber, Eduardo Habkost, Anthony Liguori, Igor Mammedov From: Eduardo Habkost <ehabkost@redhat.com> Register separate QOM types for each x86 CPU model. This will allow management code to more easily probe what each CPU model provides, by simply creating objects using the appropriate class name, without having to restart QEMU. This also allows us to eliminate the qdev_prop_set_globals_for_type() hack to set CPU-model-specific global properties. Instead of creating separate class_init functions for each class, I just used class_data to store a pointer to the X86CPUDefinition struct for each CPU model. This should make the patch shorter and easier to review. Later we can gradually convert each X86CPUDefinition field to lists of per-class property defaults. The "host" CPU model is special, as the feature flags depend on KVM being initialized. So it has its own class_init and instance_init function, and feature flags are set on instance_init instead of class_init. Signed-off-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de> --- target-i386/cpu-qom.h | 15 +++++ target-i386/cpu.c | 177 +++++++++++++++++++++++++++++--------------------- 2 files changed, 119 insertions(+), 73 deletions(-) diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h index 722f11a..e9b3d57 100644 --- a/target-i386/cpu-qom.h +++ b/target-i386/cpu-qom.h @@ -38,7 +38,17 @@ OBJECT_GET_CLASS(X86CPUClass, (obj), TYPE_X86_CPU) /** + * X86CPUDefinition: + * + * CPU model definition data that was not converted to QOM per-subclass + * property defaults yet. + */ +typedef struct X86CPUDefinition X86CPUDefinition; + +/** * X86CPUClass: + * @cpu_def: CPU model definition + * @kvm_required: Whether CPU model requires KVM to be enabled. * @parent_realize: The parent class' realize handler. * @parent_reset: The parent class' reset handler. * @@ -49,6 +59,11 @@ typedef struct X86CPUClass { CPUClass parent_class; /*< public >*/ + /* Should be eventually replaced by subclass-specific property defaults. */ + X86CPUDefinition *cpu_def; + + bool kvm_required; + DeviceRealize parent_realize; void (*parent_reset)(CPUState *cpu); } X86CPUClass; diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 1c009bb..d891188 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -484,16 +484,35 @@ static void add_flagname_to_bitmaps(const char *flagname, } } +/* CPU class name definitions: */ + +#define X86_CPU_TYPE_SUFFIX "-" TYPE_X86_CPU +#define X86_CPU_TYPE_NAME(name) (name X86_CPU_TYPE_SUFFIX) + +/* Return type name for a given CPU model name + * Caller is responsible for freeing the returned string. + */ +static char *x86_cpu_type_name(const char *model_name) +{ + return g_strdup_printf(X86_CPU_TYPE_NAME("%s"), model_name); +} + static ObjectClass *x86_cpu_class_by_name(const char *cpu_model) { + ObjectClass *oc; + char *typename; + if (cpu_model == NULL) { return NULL; } - return object_class_by_name(TYPE_X86_CPU); + typename = x86_cpu_type_name(cpu_model); + oc = object_class_by_name(typename); + g_free(typename); + return oc; } -typedef struct X86CPUDefinition { +struct X86CPUDefinition { const char *name; uint32_t level; uint32_t xlevel; @@ -506,7 +525,7 @@ typedef struct X86CPUDefinition { FeatureWordArray features; char model_id[48]; bool cache_info_passthrough; -} X86CPUDefinition; +}; #define I486_FEATURES (CPUID_FP87 | CPUID_VME | CPUID_PSE) #define PENTIUM_FEATURES (I486_FEATURES | CPUID_DE | CPUID_TSC | \ @@ -556,8 +575,6 @@ typedef struct X86CPUDefinition { CPUID_7_0_EBX_ERMS, CPUID_7_0_EBX_INVPCID, CPUID_7_0_EBX_RTM, CPUID_7_0_EBX_RDSEED */ -/* built-in CPU model definitions - */ static X86CPUDefinition builtin_x86_defs[] = { { .name = "qemu64", @@ -1144,44 +1161,66 @@ static int cpu_x86_fill_model_id(char *str) return 0; } -/* Fill a X86CPUDefinition struct with information about the host CPU, and - * the CPU features supported by the host hardware + host kernel +static X86CPUDefinition host_cpudef; + +/* class_init for the "host" CPU model * - * This function may be called only if KVM is enabled. + * This function may be called before KVM is initialized. */ -static void kvm_cpu_fill_host(X86CPUDefinition *x86_cpu_def) +static void host_x86_cpu_class_init(ObjectClass *oc, void *data) { - KVMState *s = kvm_state; + X86CPUClass *xcc = X86_CPU_CLASS(oc); uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0; - FeatureWord w; - assert(kvm_enabled()); + xcc->kvm_required = true; - x86_cpu_def->name = "host"; - x86_cpu_def->cache_info_passthrough = true; host_cpuid(0x0, 0, &eax, &ebx, &ecx, &edx); - x86_cpu_vendor_words2str(x86_cpu_def->vendor, ebx, edx, ecx); + x86_cpu_vendor_words2str(host_cpudef.vendor, ebx, edx, ecx); host_cpuid(0x1, 0, &eax, &ebx, &ecx, &edx); - x86_cpu_def->family = ((eax >> 8) & 0x0F) + ((eax >> 20) & 0xFF); - x86_cpu_def->model = ((eax >> 4) & 0x0F) | ((eax & 0xF0000) >> 12); - x86_cpu_def->stepping = eax & 0x0F; + host_cpudef.family = ((eax >> 8) & 0x0F) + ((eax >> 20) & 0xFF); + host_cpudef.model = ((eax >> 4) & 0x0F) | ((eax & 0xF0000) >> 12); + host_cpudef.stepping = eax & 0x0F; + + cpu_x86_fill_model_id(host_cpudef.model_id); - x86_cpu_def->level = kvm_arch_get_supported_cpuid(s, 0x0, 0, R_EAX); - x86_cpu_def->xlevel = kvm_arch_get_supported_cpuid(s, 0x80000000, 0, R_EAX); - x86_cpu_def->xlevel2 = - kvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX); + xcc->cpu_def = &host_cpudef; + host_cpudef.cache_info_passthrough = true; - cpu_x86_fill_model_id(x86_cpu_def->model_id); + /* level, xlevel, xlevel2, and the feature words are initialized on + * instance_init, because they require KVM to be initialized. + */ +} + +static void host_x86_cpu_initfn(Object *obj) +{ + X86CPU *cpu = X86_CPU(obj); + CPUX86State *env = &cpu->env; + KVMState *s = kvm_state; + FeatureWord w; + + assert(kvm_enabled()); + + env->cpuid_level = kvm_arch_get_supported_cpuid(s, 0x0, 0, R_EAX); + env->cpuid_xlevel = kvm_arch_get_supported_cpuid(s, 0x80000000, 0, R_EAX); + env->cpuid_xlevel2 = kvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX); for (w = 0; w < FEATURE_WORDS; w++) { FeatureWordInfo *wi = &feature_word_info[w]; - x86_cpu_def->features[w] = + env->features[w] = kvm_arch_get_supported_cpuid(s, wi->cpuid_eax, wi->cpuid_ecx, wi->cpuid_reg); } + object_property_set_bool(OBJECT(cpu), true, "pmu", &error_abort); } +static const TypeInfo host_x86_cpu_type_info = { + .name = X86_CPU_TYPE_NAME("host"), + .parent = TYPE_X86_CPU, + .instance_init = host_x86_cpu_initfn, + .class_init = host_x86_cpu_class_init, +}; + static int unavailable_host_feature(FeatureWordInfo *f, uint32_t mask) { int i; @@ -1592,32 +1631,6 @@ static PropertyInfo qdev_prop_spinlocks = { .set = x86_set_hv_spinlocks, }; -static int cpu_x86_find_by_name(X86CPU *cpu, X86CPUDefinition *x86_cpu_def, - const char *name) -{ - X86CPUDefinition *def; - int i; - - if (name == NULL) { - return -1; - } - if (kvm_enabled() && strcmp(name, "host") == 0) { - kvm_cpu_fill_host(x86_cpu_def); - object_property_set_bool(OBJECT(cpu), true, "pmu", &error_abort); - return 0; - } - - for (i = 0; i < ARRAY_SIZE(builtin_x86_defs); i++) { - def = &builtin_x86_defs[i]; - if (strcmp(name, def->name) == 0) { - memcpy(x86_cpu_def, def, sizeof(*def)); - return 0; - } - } - - return -1; -} - /* Convert all '_' in a feature string option name to '-', to make feature * name conform to QOM property naming rule, which uses '-' instead of '_'. */ @@ -1827,22 +1840,14 @@ static void filter_features_for_kvm(X86CPU *cpu) } } -/* Load CPU definition for a given CPU model name +/* Load data from X86CPUDefinition */ -static void x86_cpu_load_def(X86CPU *cpu, const char *name, Error **errp) +static void x86_cpu_load_def(X86CPU *cpu, X86CPUDefinition *def, Error **errp) { CPUX86State *env = &cpu->env; - X86CPUDefinition def1, *def = &def1; const char *vendor; char host_vendor[CPUID_VENDOR_SZ + 1]; - memset(def, 0, sizeof(*def)); - - if (cpu_x86_find_by_name(cpu, def, name) < 0) { - error_setg(errp, "Unable to find CPU definition: %s", name); - return; - } - object_property_set_int(OBJECT(cpu), def->level, "level", errp); object_property_set_int(OBJECT(cpu), def->family, "family", errp); object_property_set_int(OBJECT(cpu), def->model, "model", errp); @@ -1890,10 +1895,10 @@ X86CPU *cpu_x86_create(const char *cpu_model, DeviceState *icc_bridge, Error **errp) { X86CPU *cpu = NULL; + X86CPUClass *xcc; ObjectClass *oc; gchar **model_pieces; char *name, *features; - char *typename; Error *error = NULL; model_pieces = g_strsplit(cpu_model, ",", 2); @@ -1909,12 +1914,15 @@ X86CPU *cpu_x86_create(const char *cpu_model, DeviceState *icc_bridge, error_setg(&error, "Unable to find CPU definition: %s", name); goto out; } - cpu = X86_CPU(object_new(object_class_get_name(oc))); - x86_cpu_load_def(cpu, name, &error); - if (error) { + xcc = X86_CPU_CLASS(oc); + + if (xcc->kvm_required && !kvm_enabled()) { + error_setg(&error, "CPU model '%s' requires KVM", name); goto out; } + cpu = X86_CPU(object_new(object_class_get_name(oc))); + #ifndef CONFIG_USER_ONLY if (icc_bridge == NULL) { error_setg(&error, "Invalid icc-bridge value"); @@ -1924,14 +1932,6 @@ X86CPU *cpu_x86_create(const char *cpu_model, DeviceState *icc_bridge, object_unref(OBJECT(cpu)); #endif - /* Emulate per-model subclasses for global properties */ - typename = g_strdup_printf("%s-" TYPE_X86_CPU, name); - qdev_prop_set_globals_for_type(DEVICE(cpu), typename, &error); - g_free(typename); - if (error) { - goto out; - } - cpu_x86_parse_featurestr(cpu, features, &error); if (error) { goto out; @@ -1973,6 +1973,28 @@ out: return cpu; } +static void x86_cpu_cpudef_class_init(ObjectClass *oc, void *data) +{ + X86CPUDefinition *cpudef = data; + X86CPUClass *xcc = X86_CPU_CLASS(oc); + + xcc->cpu_def = cpudef; +} + +static void x86_register_cpudef_type(X86CPUDefinition *def) +{ + char *typename = x86_cpu_type_name(def->name); + TypeInfo ti = { + .name = typename, + .parent = TYPE_X86_CPU, + .class_init = x86_cpu_cpudef_class_init, + .class_data = def, + }; + + type_register(&ti); + g_free(typename); +} + #if !defined(CONFIG_USER_ONLY) void cpu_clear_apic_feature(CPUX86State *env) @@ -2634,6 +2656,7 @@ static void x86_cpu_initfn(Object *obj) { CPUState *cs = CPU(obj); X86CPU *cpu = X86_CPU(obj); + X86CPUClass *xcc = X86_CPU_GET_CLASS(obj); CPUX86State *env = &cpu->env; static int inited; @@ -2677,6 +2700,8 @@ static void x86_cpu_initfn(Object *obj) cpu->hyperv_spinlock_attempts = HYPERV_SPINLOCK_NEVER_RETRY; env->cpuid_apic_id = x86_cpu_apic_id_from_index(cs->cpu_index); + x86_cpu_load_def(cpu, xcc->cpu_def, &error_abort); + /* init various static tables used in TCG mode */ if (tcg_enabled() && !inited) { inited = 1; @@ -2783,14 +2808,20 @@ static const TypeInfo x86_cpu_type_info = { .parent = TYPE_CPU, .instance_size = sizeof(X86CPU), .instance_init = x86_cpu_initfn, - .abstract = false, + .abstract = true, .class_size = sizeof(X86CPUClass), .class_init = x86_cpu_common_class_init, }; static void x86_cpu_register_types(void) { + int i; + type_register_static(&x86_cpu_type_info); + for (i = 0; i < ARRAY_SIZE(builtin_x86_defs); i++) { + x86_register_cpudef_type(&builtin_x86_defs[i]); + } + type_register_static(&host_x86_cpu_type_info); } type_init(x86_cpu_register_types) -- 1.8.4.5 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH qom-cpu v10 2/2] target-i386: X86CPU model subclasses 2014-02-25 7:36 ` [Qemu-devel] [PATCH qom-cpu v10 2/2] target-i386: X86CPU model subclasses Andreas Färber @ 2014-03-04 19:53 ` Eduardo Habkost 2014-03-09 15:49 ` Andreas Färber 0 siblings, 1 reply; 7+ messages in thread From: Eduardo Habkost @ 2014-03-04 19:53 UTC (permalink / raw) To: Andreas Färber Cc: Paolo Bonzini, qemu-devel, Anthony Liguori, Igor Mammedov On Tue, Feb 25, 2014 at 08:36:27AM +0100, Andreas Färber wrote: > From: Eduardo Habkost <ehabkost@redhat.com> > > Register separate QOM types for each x86 CPU model. > > This will allow management code to more easily probe what each CPU model > provides, by simply creating objects using the appropriate class name, > without having to restart QEMU. > > This also allows us to eliminate the qdev_prop_set_globals_for_type() > hack to set CPU-model-specific global properties. > > Instead of creating separate class_init functions for each class, I just > used class_data to store a pointer to the X86CPUDefinition struct for > each CPU model. This should make the patch shorter and easier to review. > Later we can gradually convert each X86CPUDefinition field to lists of > per-class property defaults. > > The "host" CPU model is special, as the feature flags depend on KVM > being initialized. So it has its own class_init and instance_init > function, and feature flags are set on instance_init instead of > class_init. > > Signed-off-by: Andreas Färber <afaerber@suse.de> > Signed-off-by: Igor Mammedov <imammedo@redhat.com> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> > Signed-off-by: Andreas Färber <afaerber@suse.de> For the changes you introduced: Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Tested-by: Eduardo Habkost <ehabkost@redhat.com> After hacking the code to allow device_add on CPUs, I could use the classes to instantiate CPUs from different models using device_add (which would be useful to allow probing of CPU model information in a single QEMU instance). -- Eduardo ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH qom-cpu v10 2/2] target-i386: X86CPU model subclasses 2014-03-04 19:53 ` Eduardo Habkost @ 2014-03-09 15:49 ` Andreas Färber 0 siblings, 0 replies; 7+ messages in thread From: Andreas Färber @ 2014-03-09 15:49 UTC (permalink / raw) To: Eduardo Habkost; +Cc: Paolo Bonzini, qemu-devel, Anthony Liguori, Igor Mammedov Am 04.03.2014 20:53, schrieb Eduardo Habkost: > On Tue, Feb 25, 2014 at 08:36:27AM +0100, Andreas Färber wrote: >> From: Eduardo Habkost <ehabkost@redhat.com> >> >> Register separate QOM types for each x86 CPU model. >> >> This will allow management code to more easily probe what each CPU model >> provides, by simply creating objects using the appropriate class name, >> without having to restart QEMU. >> >> This also allows us to eliminate the qdev_prop_set_globals_for_type() >> hack to set CPU-model-specific global properties. >> >> Instead of creating separate class_init functions for each class, I just >> used class_data to store a pointer to the X86CPUDefinition struct for >> each CPU model. This should make the patch shorter and easier to review. >> Later we can gradually convert each X86CPUDefinition field to lists of >> per-class property defaults. >> >> The "host" CPU model is special, as the feature flags depend on KVM >> being initialized. So it has its own class_init and instance_init >> function, and feature flags are set on instance_init instead of >> class_init. >> >> Signed-off-by: Andreas Färber <afaerber@suse.de> >> Signed-off-by: Igor Mammedov <imammedo@redhat.com> >> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> >> Signed-off-by: Andreas Färber <afaerber@suse.de> > > For the changes you introduced: > > Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> > Tested-by: Eduardo Habkost <ehabkost@redhat.com> > > After hacking the code to allow device_add on CPUs, I could use the > classes to instantiate CPUs from different models using device_add > (which would be useful to allow probing of CPU model information in a > single QEMU instance). Thanks a lot, I'm proceeding to staging this on qom-cpu-next: https://github.com/afaerber/qemu-cpu/commits/qom-cpu-next Features parsing needs minor merges. Goal is still 2.0. Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH qom-cpu v10 0/2] target-i386: X86CPU subclasses 2014-02-25 7:36 [Qemu-devel] [PATCH qom-cpu v10 0/2] target-i386: X86CPU subclasses Andreas Färber 2014-02-25 7:36 ` [Qemu-devel] [PATCH qom-cpu v10 1/2] target-i386: Prepare CPUClass::class_by_name for X86CPU Andreas Färber 2014-02-25 7:36 ` [Qemu-devel] [PATCH qom-cpu v10 2/2] target-i386: X86CPU model subclasses Andreas Färber @ 2014-03-03 16:50 ` Andreas Färber 2 siblings, 0 replies; 7+ messages in thread From: Andreas Färber @ 2014-03-03 16:50 UTC (permalink / raw) To: qemu-devel; +Cc: Paolo Bonzini, Eduardo Habkost, Anthony Liguori, Igor Mammedov Am 25.02.2014 08:36, schrieb Andreas Färber: > Hello, > > Here's my cleaned up version of slim x86 CPU subclasses. > Second patch didn't get a lot of testing yet. > > Loading cpudef is still in main initfn since otherwise the host type > would need to be relocated. Can be cleaned up as follow-ups. > > I wonder whether we are intentionally registering the host type even for > !CONFIG_KVM? Instantiating it will then always lead to assertion failure. Ping! Did anyone review or test? Still applies after new x2apic patches. Andreas > Available for testing here: > git://github.com/afaerber/qemu-cpu.git qom-cpu-x86-subclasses.v10 > https://github.com/afaerber/qemu-cpu/commits/qom-cpu-x86-subclasses.v10 > > Regards, > Andreas > > v9 -> v10: > * Cleaned up documentation comments. > * Prepended patch to implement CPUClass::class_by_name(), rebased on it. > * Cleaned up naming (..._class_init, ..._initfn, type vs. class). > * Dropped duplicate white line. > * Dropped unnecessary .abstract, .instance_size, .class_size fields. > * Aligned model type registration with other targets by having the > registration function operate on one model only. > * Relocated cpudef-based types to after x86_cpu_load_cpudef(). > * Moved assignment of cpu_def into cpudef-specific class_init. > > (went through various hands, last ehabkost's) > > v2 -> v3: > * Instead of re-coding all CPU definitions as class_init functions, leave > the built-in definition array in place and place x86_def_t in the class. > * Use kvm_arch_init() hook to assure class_init succeeds for -cpu host. > Suggested by Eduardo. > > v1-> v2: > * Instead of turning x86_def_t into X86CPUInfo to initialize classes, > drop it completely and register types manually with customizable TypeInfos > * Use new list facilities for printing -cpu ? models > * Adopt new name scheme suggested by Eduardo and ideas from my alpha series > * Keep short names in -cpu ? output for alignment reasons > * Merge cpu_x86_init() into cpu.c:cpu_x86_register() > * Append patch showing Haswell as subclass of SandyBridge > > Cc: Eduardo Habkost <ehabkost@redhat.com> > Cc: Igor Mammedov <imammedo@redhat.com> > Cc: Paolo Bonzini <pbonzini@redhat.com> > Cc: Anthony Liguori <anthony@codemonkey.ws> > > Andreas Färber (1): > target-i386: Prepare CPUClass::class_by_name for X86CPU > > Eduardo Habkost (1): > target-i386: X86CPU model subclasses > > target-i386/cpu-qom.h | 15 ++++ > target-i386/cpu.c | 197 +++++++++++++++++++++++++++++++------------------- > 2 files changed, 138 insertions(+), 74 deletions(-) -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-03-09 15:50 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-02-25 7:36 [Qemu-devel] [PATCH qom-cpu v10 0/2] target-i386: X86CPU subclasses Andreas Färber 2014-02-25 7:36 ` [Qemu-devel] [PATCH qom-cpu v10 1/2] target-i386: Prepare CPUClass::class_by_name for X86CPU Andreas Färber 2014-03-04 19:48 ` Eduardo Habkost 2014-02-25 7:36 ` [Qemu-devel] [PATCH qom-cpu v10 2/2] target-i386: X86CPU model subclasses Andreas Färber 2014-03-04 19:53 ` Eduardo Habkost 2014-03-09 15:49 ` Andreas Färber 2014-03-03 16:50 ` [Qemu-devel] [PATCH qom-cpu v10 0/2] target-i386: X86CPU subclasses Andreas Färber
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).