[PATCH 1/3] i386/cpu: Rename enable_cpuid_0x1f to force_cpuid_0x1f

Xiaoyao Li posted 3 patches 8 months, 1 week ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Zhao Liu <zhao1.liu@intel.com>, Marcelo Tosatti <mtosatti@redhat.com>
[PATCH 1/3] i386/cpu: Rename enable_cpuid_0x1f to force_cpuid_0x1f
Posted by Xiaoyao Li 8 months, 1 week ago
The name of "enable_cpuid_0x1f" isn't right to its behavior because the
leaf 0x1f can be enabled even when "enable_cpuid_0x1f" is false.

Rename it to "force_cpuid_0x1f" to better reflect its behavior.

Suggested-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
Suggested by Igor at https://lore.kernel.org/qemu-devel/20250513144515.37615651@imammedo.users.ipa.redhat.com/
---
 target/i386/cpu.h     | 4 ++--
 target/i386/kvm/tdx.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 1146465c8c62..aaef6a2a6767 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -2270,7 +2270,7 @@ struct ArchCPU {
     bool enable_cpuid_0xb;
 
     /* Force to enable cpuid 0x1f */
-    bool enable_cpuid_0x1f;
+    bool force_cpuid_0x1f;
 
     /* Enable auto level-increase for all CPUID leaves */
     bool full_cpuid_auto_level;
@@ -2540,7 +2540,7 @@ void mark_forced_on_features(X86CPU *cpu, FeatureWord w, uint64_t mask,
 
 static inline bool x86_has_cpuid_0x1f(X86CPU *cpu)
 {
-    return cpu->enable_cpuid_0x1f ||
+    return cpu->force_cpuid_0x1f ||
            x86_has_extended_topo(cpu->env.avail_cpu_topo);
 }
 
diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c
index 0a21ae555c5c..17e671f1710f 100644
--- a/target/i386/kvm/tdx.c
+++ b/target/i386/kvm/tdx.c
@@ -746,7 +746,7 @@ static void tdx_cpu_instance_init(X86ConfidentialGuest *cg, CPUState *cpu)
     /* invtsc is fixed1 for TD guest */
     object_property_set_bool(OBJECT(cpu), "invtsc", true, &error_abort);
 
-    x86cpu->enable_cpuid_0x1f = true;
+    x86cpu->force_cpuid_0x1f = true;
 }
 
 static uint32_t tdx_adjust_cpuid_features(X86ConfidentialGuest *cg,
-- 
2.43.0
Re: [PATCH 1/3] i386/cpu: Rename enable_cpuid_0x1f to force_cpuid_0x1f
Posted by Igor Mammedov 8 months, 1 week ago
On Tue,  3 Jun 2025 01:03:03 -0400
Xiaoyao Li <xiaoyao.li@intel.com> wrote:

> The name of "enable_cpuid_0x1f" isn't right to its behavior because the
> leaf 0x1f can be enabled even when "enable_cpuid_0x1f" is false.
> 
> Rename it to "force_cpuid_0x1f" to better reflect its behavior.
> 
> Suggested-by: Igor Mammedov <imammedo@redhat.com>
> Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
> Suggested by Igor at https://lore.kernel.org/qemu-devel/20250513144515.37615651@imammedo.users.ipa.redhat.com/
> ---
>  target/i386/cpu.h     | 4 ++--
>  target/i386/kvm/tdx.c | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/target/i386/cpu.h b/target/i386/cpu.h
> index 1146465c8c62..aaef6a2a6767 100644
> --- a/target/i386/cpu.h
> +++ b/target/i386/cpu.h
> @@ -2270,7 +2270,7 @@ struct ArchCPU {
>      bool enable_cpuid_0xb;
>  
>      /* Force to enable cpuid 0x1f */
> -    bool enable_cpuid_0x1f;
> +    bool force_cpuid_0x1f;
>  
>      /* Enable auto level-increase for all CPUID leaves */
>      bool full_cpuid_auto_level;
> @@ -2540,7 +2540,7 @@ void mark_forced_on_features(X86CPU *cpu, FeatureWord w, uint64_t mask,
>  
>  static inline bool x86_has_cpuid_0x1f(X86CPU *cpu)
>  {
> -    return cpu->enable_cpuid_0x1f ||
> +    return cpu->force_cpuid_0x1f ||
>             x86_has_extended_topo(cpu->env.avail_cpu_topo);
>  }
>  
> diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c
> index 0a21ae555c5c..17e671f1710f 100644
> --- a/target/i386/kvm/tdx.c
> +++ b/target/i386/kvm/tdx.c
> @@ -746,7 +746,7 @@ static void tdx_cpu_instance_init(X86ConfidentialGuest *cg, CPUState *cpu)
>      /* invtsc is fixed1 for TD guest */
>      object_property_set_bool(OBJECT(cpu), "invtsc", true, &error_abort);
>  
> -    x86cpu->enable_cpuid_0x1f = true;
> +    x86cpu->force_cpuid_0x1f = true;
>  }
>  
>  static uint32_t tdx_adjust_cpuid_features(X86ConfidentialGuest *cg,
Re: [PATCH 1/3] i386/cpu: Rename enable_cpuid_0x1f to force_cpuid_0x1f
Posted by Daniel P. Berrangé 8 months, 1 week ago
On Tue, Jun 03, 2025 at 01:03:03AM -0400, Xiaoyao Li wrote:
> The name of "enable_cpuid_0x1f" isn't right to its behavior because the
> leaf 0x1f can be enabled even when "enable_cpuid_0x1f" is false.
> 
> Rename it to "force_cpuid_0x1f" to better reflect its behavior.
> 
> Suggested-by: Igor Mammedov <imammedo@redhat.com>
> Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
> ---
> Suggested by Igor at https://lore.kernel.org/qemu-devel/20250513144515.37615651@imammedo.users.ipa.redhat.com/
> ---
>  target/i386/cpu.h     | 4 ++--
>  target/i386/kvm/tdx.c | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|