diff mbox series

[v2,1/3] i386/cpuid: Decrease cpuid_i when skipping CPUID leaf 1F

Message ID 20230613131929.720453-2-xiaoyao.li@intel.com
State New
Headers show
Series i386: Minor fixes of building CPUIDs | expand

Commit Message

Xiaoyao Li June 13, 2023, 1:19 p.m. UTC
Decrease array index cpuid_i when CPUID leaf 1F is skipped, otherwise it
will get an all zero'ed CPUID entry with leaf 0 and subleaf 0. It
conflicts with correct leaf 0.

Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
 target/i386/kvm/kvm.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Yang, Weijiang June 27, 2023, 9:26 a.m. UTC | #1
On 6/13/2023 9:19 PM, Xiaoyao Li wrote:
> Decrease array index cpuid_i when CPUID leaf 1F is skipped, otherwise it
> will get an all zero'ed CPUID entry with leaf 0 and subleaf 0. It
> conflicts with correct leaf 0.

Maybe change the commit log like this:

Exiting code misses a decrement of cpuid_i when skip left 0x1F, so 
there's a blank CPUID

entry(with all fields stuffed 0s) left in the CPUID array.  Fix the 
issue to avoid the blank slot.

Reviewed-by:Yang Weijiang <weijiang.yang@intel.com>

>
> Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
> ---
>   target/i386/kvm/kvm.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
> index de531842f6b1..afa97799d89a 100644
> --- a/target/i386/kvm/kvm.c
> +++ b/target/i386/kvm/kvm.c
> @@ -1956,6 +1956,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
>           }
>           case 0x1f:
>               if (env->nr_dies < 2) {
> +                cpuid_i--;
>                   break;
>               }
>               /* fallthrough */
diff mbox series

Patch

diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index de531842f6b1..afa97799d89a 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -1956,6 +1956,7 @@  int kvm_arch_init_vcpu(CPUState *cs)
         }
         case 0x1f:
             if (env->nr_dies < 2) {
+                cpuid_i--;
                 break;
             }
             /* fallthrough */