Skip to contentSkip to conversation

Clean up and enhance of feature_word_description()

PATCH Applied Xiaoyao Li 3 participants 7 messages Dec 17, 2024 – May 28, 2025

lore
Share & tools
lore

Xiaoyao Li

author
#0 lore raw

cover Clean up and enhance of feature_word_description()

This series grabs two patches related to feature_word_description() from two different old threads, they are simple and straightforward.

Patch 1 is grabbed from [1] while patch 2 is grabbed from [2].

[1]: https://lore.kernel.org/qemu-devel/[email protected]/
[2]: https://lore.kernel.org/qemu-devel/[email protected]/

Lei Wang (1):
i386: Remove unused parameter "uint32_t bit" in
feature_word_description()

Xiaoyao Li (1):
target/i386: Print CPUID subleaf info for unsupported feature

 target/i386/cpu.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 1/2 i386: Remove unused parameter "uint32_t bit" in feature_word_description()

From: Lei Wang <[email protected]>

Parameter "uint32_t bit" is not used in function feature_word_description(), so remove it.

---
 target/i386/cpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/i386/cpu.c +2 -2
index 525339945920..d09e2f868c35 100644
@@ -5451,7 +5451,7 @@ static const TypeInfo max_x86_cpu_type_info = {
     .class_init = max_x86_cpu_class_init,
 };
 
-static char *feature_word_description(FeatureWordInfo *f, uint32_t bit)
+static char *feature_word_description(FeatureWordInfo *f)
 {
     assert(f->type == CPUID_FEATURE_WORD || f->type == MSR_FEATURE_WORD);
 
@@ -5490,6 +5490,7 @@ static void mark_unavailable_features(X86CPU *cpu, FeatureWord w, uint64_t mask,
     CPUX86State *env = &cpu->env;
     FeatureWordInfo *f = &feature_word_info[w];
     int i;
+    g_autofree char *feat_word_str = feature_word_description(f);
 
     if (!cpu->force_features) {
         env->features[w] &= ~mask;
@@ -5502,7 +5503,6 @@ static void mark_unavailable_features(X86CPU *cpu, FeatureWord w, uint64_t mask,
 
     for (i = 0; i < 64; ++i) {
         if ((1ULL << i) & mask) {
-            g_autofree char *feat_word_str = feature_word_description(f, i);
             warn_report("%s: %s%s%s [bit %d]",
                         verbose_prefix,
                         feat_word_str,
Signature · 1 line
2.34.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] i386: Remove unused parameter "uint32_t bit" in feature_word_description()

Quoted 11 lines · Xiaoyao Li

Date: Tue, 17 Dec 2024 07:39:31 -0500
From: Xiaoyao Li <[email protected]>
Subject: [PATCH 1/2] i386: Remove unused parameter "uint32_t bit" in
feature_word_description()
X-Mailer: git-send-email 2.34.1

From: Lei Wang <[email protected]>

Parameter "uint32_t bit" is not used in function feature_word_description(), so remove it.

Quoted 8 lines
---
 target/i386/cpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
author
#3 lore raw

PATCH 2/2 target/i386: Print CPUID subleaf info for unsupported feature

In reply to Xiaoyao Li

Some CPUID leaves have meaningful subleaf index. Print the subleaf info in feature_word_description for CPUID features.

---
 target/i386/cpu.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
target/i386/cpu.c +3 -2
index d09e2f868c35..3a697834e3ad 100644
@@ -5460,8 +5460,9 @@ static char *feature_word_description(FeatureWordInfo *f)
         {
             const char *reg = get_register_name_32(f->cpuid.reg);
             assert(reg);
-            return g_strdup_printf("CPUID.%02XH:%s",
-                                   f->cpuid.eax, reg);
+            return g_strdup_printf("CPUID.%02XH_%02XH:%s",
+                                   f->cpuid.eax,
+                                   f->cpuid.needs_ecx ? f->cpuid.ecx : 0, reg);
         }
     case MSR_FEATURE_WORD:
         return g_strdup_printf("MSR(%02XH)",
Signature · 1 line
2.34.1
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] target/i386: Print CPUID subleaf info for unsupported feature

Quoted 6 lines · Xiaoyao Li

Date: Tue, 17 Dec 2024 07:39:32 -0500
From: Xiaoyao Li <[email protected]>
Subject: [PATCH 2/2] target/i386: Print CPUID subleaf info for unsupported
feature
X-Mailer: git-send-email 2.34.1

Quoted 8 lines

Some CPUID leaves have meaningful subleaf index. Print the subleaf info in feature_word_description for CPUID features.

---
 target/i386/cpu.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
author
#5 lore raw
In reply to Xiaoyao Li
Quoted 4 lines · Xiaoyao Li

This series grabs two patches related to feature_word_description() from two different old threads, they are simple and straightforward.

Patch 1 is grabbed from [1] while patch 2 is grabbed from [2].

Ping...

Quoted 13 lines

[1]: https://lore.kernel.org/qemu-devel/[email protected]/
[2]: https://lore.kernel.org/qemu-devel/[email protected]/

Lei Wang (1):
i386: Remove unused parameter "uint32_t bit" in
feature_word_description()

Xiaoyao Li (1):
target/i386: Print CPUID subleaf info for unsupported feature

  target/i386/cpu.c | 9 +++++----
  1 file changed, 5 insertions(+), 4 deletions(-)
#6 lore raw
Quoted 7 lines · Xiaoyao Li
Quoted 4 lines · Xiaoyao Li

This series grabs two patches related to feature_word_description() from two different old threads, they are simple and straightforward.

Patch 1 is grabbed from [1] while patch 2 is grabbed from [2].

Ping...

Applied, thanks---with a slightly fancier formatting for patch 2:

target/i386/cpu.c +7 -4
index 8589391023d..446924be90f 100644
@@ -5780,12 +5780,15 @@ static char *feature_word_description(FeatureWordInfo *f)
         {
             const char *reg = get_register_name_32(f->cpuid.reg);
             assert(reg);
-            return g_strdup_printf("CPUID.%02XH_%02XH:%s",
-                                   f->cpuid.eax,
-                                   f->cpuid.needs_ecx ? f->cpuid.ecx : 0, reg);
+            if (!f->cpuid.needs_ecx) {
+                return g_strdup_printf("CPUID[eax=%02Xh].%s", f->cpuid.eax, reg);
+            } else {
+                return g_strdup_printf("CPUID[eax=%02Xh,ecx=%02Xh].%s",
+                                       f->cpuid.eax, f->cpuid.ecx : 0, reg);
+            }
         }
     case MSR_FEATURE_WORD:
-        return g_strdup_printf("MSR(%02XH)",
+        return g_strdup_printf("MSR(%02Xh)",
                                f->msr.index);
     }
 

Paolo