Skip to contentSkip to conversation

target-i386: Display i386 CPUID properties

RFC In review Valentin Rakush 3 participants 5 messages Jan 12, 2016 – Jan 25, 2016

lore
Share & tools
lore
#1 lore raw
In reply to Valentin Rakush
Quoted 11 lines · Valentin Rakush

This is RFC because implementation depends on the upcoming class properties
http://lists.nongnu.org/archive/html/qemu-devel/2015-08/msg03115.html
and also because this patch does not handle all x86_64 properties.

This RFC is in response to concerns pointed in this review but with changed subject line as recommended.
http://lists.nongnu.org/archive/html/qemu-devel/2016-01/msg00053.html

This RFC demonstrates the way for displaying cpu properties using -cpu help option.

The point of doing this with QOM class properties, is such that we can create a facility to query class properties for any QOM type in a consistent manner. I was expecting this would take the form of a QMP monitor command 'qom-type-properties' or something along those lines.

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#0 lore raw

RFC 1/1 target-i386: Display i386 CPUID properties

This is RFC because implementation depends on the upcoming class properties
http://lists.nongnu.org/archive/html/qemu-devel/2015-08/msg03115.html
and also because this patch does not handle all x86_64 properties.

This RFC is in response to concerns pointed in this review but with changed subject line as recommended.
http://lists.nongnu.org/archive/html/qemu-devel/2016-01/msg00053.html

This RFC demonstrates the way for displaying cpu properties using -cpu help option.

Advantages:
- It is flexible and could be extended to all targets.
- With object class properties it would be possible to display cpu properties from the single place with better granularity.
- displaying actual/default values for properties

There are things left TODO:
1. The patch from Daniel P. Berrange should be submitted.
- object properties now stored in hash table an dperhaps object class properties should be stored in hash table as well
- add more functions for object class properties like getters, iterators etc.
2. The code duplication in cpu_* functions should be refactored in final patch.
3. All target-i386 cpu properties should be reviewed and set during class initialization.
4. Output formatting:
- list cpu properties per CPUID
- list cpu properties along with values
5. and more ...

---
 include/qom/cpu.h    |   2 +
 include/qom/object.h |  46 +++++++++++
 qom/cpu.c            |  50 ++++++++++++
 qom/object.c         | 220 +++++++++++++++++++++++++++++++++++++++++++++++++++
 target-i386/cpu.c    |  29 +++++++
 vl.c                 |   2 +
 6 files changed, 349 insertions(+)
include/qom/cpu.h +2 -0
index 51a1323..4ec07ce 100644
@@ -761,6 +761,8 @@ void QEMU_NORETURN cpu_abort(CPUState *cpu, const char *fmt, ...)
     GCC_FMT_ATTR(2, 3);
 void cpu_exec_exit(CPUState *cpu);
 
+void cpu_properties_list(FILE *f, fprintf_function cpu_fprintf);
+
 #ifdef CONFIG_SOFTMMU
 extern const struct VMStateDescription vmstate_cpu_common;
 #else
include/qom/object.h +46 -0

124 lines not on this page · raw message

qom/cpu.c +50 -0

60 lines not on this page · raw message

qom/object.c +220 -0

302 lines not on this page · raw message

target-i386/cpu.c +29 -0
index 0d447b5..13c36a9 100644
@@ -3202,6 +3202,35 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
     cc->cpu_exec_enter = x86_cpu_exec_enter;
     cc->cpu_exec_exit = x86_cpu_exec_exit;
 
+
+    object_class_property_add(oc, "family", "int",
+                              x86_cpuid_version_get_family,
+                              x86_cpuid_version_set_family, NULL, NULL, NULL);
+    object_class_property_add(oc, "model", "int",
+                              x86_cpuid_version_get_model,
+                              x86_cpuid_version_set_model, NULL, NULL, NULL);
+    object_class_property_add(oc, "stepping", "int",
+                              x86_cpuid_version_get_stepping,
+                              x86_cpuid_version_set_stepping, NULL, NULL, NULL);
+    object_class_property_add_str(oc, "vendor",
+                              x86_cpuid_get_vendor,
+                              x86_cpuid_set_vendor, NULL);
+    object_class_property_add_str(oc, "model-id",
+                              x86_cpuid_get_model_id,
+                              x86_cpuid_set_model_id, NULL);
+    object_class_property_add(oc, "tsc-frequency", "int",
+                              x86_cpuid_get_tsc_freq,
+                              x86_cpuid_set_tsc_freq, NULL, NULL, NULL);
+    object_class_property_add(oc, "apic-id", "int",
+                              x86_cpuid_get_apic_id,
+                              x86_cpuid_set_apic_id, NULL, NULL, NULL);
+    object_class_property_add(oc, "feature-words", "X86CPUFeatureWordInfo",
+                              x86_cpu_get_feature_words,
+                              NULL, NULL, NULL, NULL);
+    object_class_property_add(oc, "filtered-features", "X86CPUFeatureWordInfo",
+                              x86_cpu_get_feature_words,
+                              NULL, NULL, NULL, NULL);
+
     /*
      * Reason: x86_cpu_initfn() calls cpu_exec_init(), which saves the
      * object in cpus -> dangling pointer after final object_unref().
vl.c +2 -0
index 5aaea77..ebe4552 100644
@@ -4092,6 +4092,8 @@ int main(int argc, char **argv, char **envp)
 
     if (cpu_model && is_help_option(cpu_model)) {
         list_cpus(stdout, &fprintf, cpu_model);
+        printf("\nRecognized CPUID properties:\n");
+        cpu_properties_list(stdout, &fprintf);
         exit(0);
     }
 
Signature · 1 line
1.8.3.1
#2 lore raw
In reply to Daniel P. Berrange
Quoted 11 lines · Daniel P. Berrange
Quoted 6 lines · Valentin Rakush

This is RFC because implementation depends on the upcoming class properties
http://lists.nongnu.org/archive/html/qemu-devel/2015-08/msg03115.html
and also because this patch does not handle all x86_64 properties.

This RFC is in response to concerns pointed in this review but with

changed

Quoted 3 lines

subject line as recommended.
http://lists.nongnu.org/archive/html/qemu-devel/2016-01/msg00053.html

Quoted 9 lines
Quoted 2 lines

This RFC demonstrates the way for displaying cpu properties using -cpu help option.

The point of doing this with QOM class properties, is such that we can create a facility to query class properties for any QOM type in a consistent manner. I was expecting this would take the form of a QMP monitor command 'qom-type-properties' or something along those lines.

Hi Daniel,

thank you for comments. I will add and implement the following qmp command. This is approximate sketch.

##
# @qom-type-list:
#
# This command will list any properties of a object class

# given a path in the object model.
#
# @path: the path within the object model.  See @qom-get for a description
of
#        this parameter.
#
# Returns: a list of @ObjectPropertyInfo that describe the properties of the
#          object.
#
# Since: 2.6
##
{ 'command': 'qom-type-list',
  'data': { 'path': 'str' },
  'returns': [ 'ObjectPropertyInfo' ] }                               |

Existing ObjectPropertyInfoList type will be reused for the returning value. I am not
going to create new ObjectClassPropertyInfoList type.

There are not much specs on the topic, so please let me know if something different
is expected.

Signature · 2 lines
Regards,
Valentin
#3 lore raw
In reply to Daniel P. Berrange
Quoted 10 lines · Daniel P. Berrange
Quoted 9 lines · Valentin Rakush

This is RFC because implementation depends on the upcoming class properties
http://lists.nongnu.org/archive/html/qemu-devel/2015-08/msg03115.html
and also because this patch does not handle all x86_64 properties.

This RFC is in response to concerns pointed in this review but with changed subject line as recommended.
http://lists.nongnu.org/archive/html/qemu-devel/2016-01/msg00053.html

Quoted 8 lines
Quoted 2 lines

This RFC demonstrates the way for displaying cpu properties using -cpu help option.

The point of doing this with QOM class properties, is such that we can create a facility to query class properties for any QOM type in a consistent manner. I was expecting this would take the form of a QMP monitor command 'qom-type-properties' or something along those lines.

Also, note that qmp_device_list_properties() already does what you want to do, without requiring class-properties.

This means you can implement the new interfaces (help output, QMP changes) without any new QOM core code. You can also propose QOM class-properties, if it helps making code simpler, but it's not a requirement for returning QOM properties on QMP/help output.

Signature · 1 line
Eduardo
#4 lore raw

Hi Eduardo,

I was not able to list cpu class properties with this command, but it might be that I am missing something. Daniel proposed the following patch for cpu class properties some time ago:
http://lists.gnu.org/archive/html/qemu-devel/2015-08/msg03117.html And my patch just implements a command that will return properties for any class, but not only for devices. There is another related thread
http://lists.nongnu.org/archive/html/qemu-devel/2016-01/msg04348.html

If there are any additional requirements or concerns, please let me know, and I will change the patch.

Regards,
Valentin

Quoted 32 lines · Eduardo Habkost
Quoted 7 lines · Daniel P. Berrange
Quoted 6 lines · Valentin Rakush

This is RFC because implementation depends on the upcoming class properties
http://lists.nongnu.org/archive/html/qemu-devel/2015-08/msg03115.html
and also because this patch does not handle all x86_64 properties.

This RFC is in response to concerns pointed in this review but with

changed

Quoted 11 lines
Quoted 5 lines

subject line as recommended.
http://lists.nongnu.org/archive/html/qemu-devel/2016-01/msg00053.html

This RFC demonstrates the way for displaying cpu properties using -cpu help option.

The point of doing this with QOM class properties, is such that we can create a facility to query class properties for any QOM type in a consistent manner. I was expecting this would take the form of a QMP monitor command 'qom-type-properties' or something along those lines.

Also, note that qmp_device_list_properties() already does what you want to do, without requiring class-properties.

This means you can implement the new interfaces (help output, QMP changes) without any new QOM core code. You can also propose QOM class-properties, if it helps making code simpler, but it's not a requirement for returning QOM properties on QMP/help output.

--
Eduardo

Signature · 2 lines
Best Regards,
Valentin Rakush.