diff mbox series

[v4,2/3] target/i386/cpu: Restrict some of feature-words uses to system-mode

Message ID 20201001144152.1555659-3-philmd@redhat.com
State New
Headers show
Series target/i386: Restrict 'feature-words' property to x86 machines | expand

Commit Message

Philippe Mathieu-Daudé Oct. 1, 2020, 2:41 p.m. UTC
The feature-words properties are not used in user-mode emulation,
restrict it to system-mode.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 target/i386/cpu.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Philippe Mathieu-Daudé Oct. 1, 2020, 2:44 p.m. UTC | #1
On 10/1/20 4:41 PM, Philippe Mathieu-Daudé wrote:
> The feature-words properties are not used in user-mode emulation,

> restrict it to system-mode.

> 

> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---

>  target/i386/cpu.c | 8 +++++++-

>  1 file changed, 7 insertions(+), 1 deletion(-)

> 

> diff --git a/target/i386/cpu.c b/target/i386/cpu.c

> index 2eec53ca22..9f72342506 100644

> --- a/target/i386/cpu.c

> +++ b/target/i386/cpu.c

> @@ -4607,6 +4607,7 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, const char *name,

>      cpu->env.tsc_khz = cpu->env.user_tsc_khz = value / 1000;

>  }

>  

> +#if !defined(CONFIG_USER_ONLY)

>  /* Generic getter for "feature-words" and "filtered-features" properties */

>  static void x86_cpu_get_feature_words(Object *obj, Visitor *v,

>                                        const char *name, void *opaque,

> @@ -4666,6 +4667,7 @@ static const char *x86_cpu_feature_name(FeatureWord w, int bitnr)

>      assert(bitnr < 32 || !(name && feature_word_info[w].type == CPUID_FEATURE_WORD));

>      return name;

>  }

> +#endif /* CONFIG_USER_ONLY */

>  

>  /*

>   * Convert all '_' in a feature string option name to '-', to make feature

> @@ -4783,6 +4785,7 @@ static void x86_cpu_parse_featurestr(const char *typename, char *features,

>  static void x86_cpu_expand_features(X86CPU *cpu, Error **errp);

>  static void x86_cpu_filter_features(X86CPU *cpu, bool verbose);

>  

> +#if !defined(CONFIG_USER_ONLY)

>  /* Build a list with the name of all features on a feature word array */

>  static void x86_cpu_list_feature_names(FeatureWordArray features,

>                                         strList **feat_names)

> @@ -4853,6 +4856,7 @@ static void x86_cpu_class_check_missing_features(X86CPUClass *xcc,

>  

>      object_unref(OBJECT(xc));

>  }

> +#endif /* CONFIG_USER_ONLY */

>  

>  /* Print all cpuid feature names in featureset

>   */

> @@ -4987,7 +4991,9 @@ static void x86_cpu_definition_entry(gpointer data, gpointer user_data)

>  

>      info = g_malloc0(sizeof(*info));

>      info->name = x86_cpu_class_get_model_name(cc);

> +#if !defined(CONFIG_USER_ONLY)

>      x86_cpu_class_check_missing_features(cc, &info->unavailable_features);

> +#endif


Buh...

>      info->has_unavailable_features = true;


... I guess here goes the:

   #endif

>      info->q_typename = g_strdup(object_class_get_name(oc));

>      info->migration_safe = cc->migration_safe;

> @@ -6941,6 +6947,7 @@ static void x86_cpu_initfn(Object *obj)

>      object_property_add(obj, "tsc-frequency", "int",

>                          x86_cpuid_get_tsc_freq,

>                          x86_cpuid_set_tsc_freq, NULL, NULL);

> +#if !defined(CONFIG_USER_ONLY)

>      object_property_add(obj, "feature-words", "X86CPUFeatureWordInfo",

>                          x86_cpu_get_feature_words,

>                          NULL, NULL, (void *)env->features);

> @@ -6957,7 +6964,6 @@ static void x86_cpu_initfn(Object *obj)

>                          x86_cpu_get_unavailable_features,

>                          NULL, NULL, NULL);

>  

> -#if !defined(CONFIG_USER_ONLY)

>      object_property_add(obj, "crash-information", "GuestPanicInformation",

>                          x86_cpu_get_crash_info_qom, NULL, NULL, NULL);

>  #endif

>
Paolo Bonzini Oct. 1, 2020, 3:14 p.m. UTC | #2
On 01/10/20 16:41, Philippe Mathieu-Daudé wrote:
> The feature-words properties are not used in user-mode emulation,

> restrict it to system-mode.

> 

> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>


This seems a bit pointless honestly.  It's going to be a few KBs of code
at most.  I would end the work with the patches that have already been
queued.

Paolo

> ---

>  target/i386/cpu.c | 8 +++++++-

>  1 file changed, 7 insertions(+), 1 deletion(-)

> 

> diff --git a/target/i386/cpu.c b/target/i386/cpu.c

> index 2eec53ca22..9f72342506 100644

> --- a/target/i386/cpu.c

> +++ b/target/i386/cpu.c

> @@ -4607,6 +4607,7 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, const char *name,

>      cpu->env.tsc_khz = cpu->env.user_tsc_khz = value / 1000;

>  }

>  

> +#if !defined(CONFIG_USER_ONLY)

>  /* Generic getter for "feature-words" and "filtered-features" properties */

>  static void x86_cpu_get_feature_words(Object *obj, Visitor *v,

>                                        const char *name, void *opaque,

> @@ -4666,6 +4667,7 @@ static const char *x86_cpu_feature_name(FeatureWord w, int bitnr)

>      assert(bitnr < 32 || !(name && feature_word_info[w].type == CPUID_FEATURE_WORD));

>      return name;

>  }

> +#endif /* CONFIG_USER_ONLY */

>  

>  /*

>   * Convert all '_' in a feature string option name to '-', to make feature

> @@ -4783,6 +4785,7 @@ static void x86_cpu_parse_featurestr(const char *typename, char *features,

>  static void x86_cpu_expand_features(X86CPU *cpu, Error **errp);

>  static void x86_cpu_filter_features(X86CPU *cpu, bool verbose);

>  

> +#if !defined(CONFIG_USER_ONLY)

>  /* Build a list with the name of all features on a feature word array */

>  static void x86_cpu_list_feature_names(FeatureWordArray features,

>                                         strList **feat_names)

> @@ -4853,6 +4856,7 @@ static void x86_cpu_class_check_missing_features(X86CPUClass *xcc,

>  

>      object_unref(OBJECT(xc));

>  }

> +#endif /* CONFIG_USER_ONLY */

>  

>  /* Print all cpuid feature names in featureset

>   */

> @@ -4987,7 +4991,9 @@ static void x86_cpu_definition_entry(gpointer data, gpointer user_data)

>  

>      info = g_malloc0(sizeof(*info));

>      info->name = x86_cpu_class_get_model_name(cc);

> +#if !defined(CONFIG_USER_ONLY)

>      x86_cpu_class_check_missing_features(cc, &info->unavailable_features);

> +#endif

>      info->has_unavailable_features = true;

>      info->q_typename = g_strdup(object_class_get_name(oc));

>      info->migration_safe = cc->migration_safe;

> @@ -6941,6 +6947,7 @@ static void x86_cpu_initfn(Object *obj)

>      object_property_add(obj, "tsc-frequency", "int",

>                          x86_cpuid_get_tsc_freq,

>                          x86_cpuid_set_tsc_freq, NULL, NULL);

> +#if !defined(CONFIG_USER_ONLY)

>      object_property_add(obj, "feature-words", "X86CPUFeatureWordInfo",

>                          x86_cpu_get_feature_words,

>                          NULL, NULL, (void *)env->features);

> @@ -6957,7 +6964,6 @@ static void x86_cpu_initfn(Object *obj)

>                          x86_cpu_get_unavailable_features,

>                          NULL, NULL, NULL);

>  

> -#if !defined(CONFIG_USER_ONLY)

>      object_property_add(obj, "crash-information", "GuestPanicInformation",

>                          x86_cpu_get_crash_info_qom, NULL, NULL, NULL);

>  #endif

>
diff mbox series

Patch

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 2eec53ca22..9f72342506 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -4607,6 +4607,7 @@  static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, const char *name,
     cpu->env.tsc_khz = cpu->env.user_tsc_khz = value / 1000;
 }
 
+#if !defined(CONFIG_USER_ONLY)
 /* Generic getter for "feature-words" and "filtered-features" properties */
 static void x86_cpu_get_feature_words(Object *obj, Visitor *v,
                                       const char *name, void *opaque,
@@ -4666,6 +4667,7 @@  static const char *x86_cpu_feature_name(FeatureWord w, int bitnr)
     assert(bitnr < 32 || !(name && feature_word_info[w].type == CPUID_FEATURE_WORD));
     return name;
 }
+#endif /* CONFIG_USER_ONLY */
 
 /*
  * Convert all '_' in a feature string option name to '-', to make feature
@@ -4783,6 +4785,7 @@  static void x86_cpu_parse_featurestr(const char *typename, char *features,
 static void x86_cpu_expand_features(X86CPU *cpu, Error **errp);
 static void x86_cpu_filter_features(X86CPU *cpu, bool verbose);
 
+#if !defined(CONFIG_USER_ONLY)
 /* Build a list with the name of all features on a feature word array */
 static void x86_cpu_list_feature_names(FeatureWordArray features,
                                        strList **feat_names)
@@ -4853,6 +4856,7 @@  static void x86_cpu_class_check_missing_features(X86CPUClass *xcc,
 
     object_unref(OBJECT(xc));
 }
+#endif /* CONFIG_USER_ONLY */
 
 /* Print all cpuid feature names in featureset
  */
@@ -4987,7 +4991,9 @@  static void x86_cpu_definition_entry(gpointer data, gpointer user_data)
 
     info = g_malloc0(sizeof(*info));
     info->name = x86_cpu_class_get_model_name(cc);
+#if !defined(CONFIG_USER_ONLY)
     x86_cpu_class_check_missing_features(cc, &info->unavailable_features);
+#endif
     info->has_unavailable_features = true;
     info->q_typename = g_strdup(object_class_get_name(oc));
     info->migration_safe = cc->migration_safe;
@@ -6941,6 +6947,7 @@  static void x86_cpu_initfn(Object *obj)
     object_property_add(obj, "tsc-frequency", "int",
                         x86_cpuid_get_tsc_freq,
                         x86_cpuid_set_tsc_freq, NULL, NULL);
+#if !defined(CONFIG_USER_ONLY)
     object_property_add(obj, "feature-words", "X86CPUFeatureWordInfo",
                         x86_cpu_get_feature_words,
                         NULL, NULL, (void *)env->features);
@@ -6957,7 +6964,6 @@  static void x86_cpu_initfn(Object *obj)
                         x86_cpu_get_unavailable_features,
                         NULL, NULL, NULL);
 
-#if !defined(CONFIG_USER_ONLY)
     object_property_add(obj, "crash-information", "GuestPanicInformation",
                         x86_cpu_get_crash_info_qom, NULL, NULL, NULL);
 #endif