diff mbox series

[v2,3/3] i386/cpuid: Move leaf 7 to correct group

Message ID 20230613131929.720453-4-xiaoyao.li@intel.com (mailing list archive)
State New, archived
Headers show
Series i386: Minor fixes of building CPUIDs | expand

Commit Message

Xiaoyao Li June 13, 2023, 1:19 p.m. UTC
CPUID leaf 7 was grouped together with SGX leaf 0x12 by commit
b9edbadefb9e ("i386: Propagate SGX CPUID sub-leafs to KVM") by mistake.

SGX leaf 0x12 has its specific logic to check if subleaf (starting from 2)
is valid or not by checking the bit 0:3 of corresponding EAX is 1 or
not.

Leaf 7 follows the logic that EAX of subleaf 0 enumerates the maximum
valid subleaf.

Fixes: b9edbadefb9e ("i386: Propagate SGX CPUID sub-leafs to KVM")
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
 target/i386/kvm/kvm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Yang Weijiang June 27, 2023, 9:30 a.m. UTC | #1
On 6/13/2023 9:19 PM, Xiaoyao Li wrote:
> CPUID leaf 7 was grouped together with SGX leaf 0x12 by commit
> b9edbadefb9e ("i386: Propagate SGX CPUID sub-leafs to KVM") by mistake.
>
> SGX leaf 0x12 has its specific logic to check if subleaf (starting from 2)
> is valid or not by checking the bit 0:3 of corresponding EAX is 1 or
> not.
>
> Leaf 7 follows the logic that EAX of subleaf 0 enumerates the maximum
> valid subleaf.
>
> Fixes: b9edbadefb9e ("i386: Propagate SGX CPUID sub-leafs to KVM")
> Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
> ---
>   target/i386/kvm/kvm.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
> index d7e235ce35a6..86aab9ca4ba2 100644
> --- a/target/i386/kvm/kvm.c
> +++ b/target/i386/kvm/kvm.c
> @@ -1993,7 +1993,6 @@ int kvm_arch_init_vcpu(CPUState *cs)
>                   c = &cpuid_data.entries[cpuid_i++];
>               }
>               break;
> -        case 0x7:
>           case 0x12:
>               for (j = 0; ; j++) {
>                   c->function = i;
> @@ -2013,6 +2012,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
>                   c = &cpuid_data.entries[cpuid_i++];
>               }
>               break;
> +        case 0x7:
>           case 0x14:
>           case 0x1d:
>           case 0x1e: {

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

Patch

diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index d7e235ce35a6..86aab9ca4ba2 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -1993,7 +1993,6 @@  int kvm_arch_init_vcpu(CPUState *cs)
                 c = &cpuid_data.entries[cpuid_i++];
             }
             break;
-        case 0x7:
         case 0x12:
             for (j = 0; ; j++) {
                 c->function = i;
@@ -2013,6 +2012,7 @@  int kvm_arch_init_vcpu(CPUState *cs)
                 c = &cpuid_data.entries[cpuid_i++];
             }
             break;
+        case 0x7:
         case 0x14:
         case 0x1d:
         case 0x1e: {