[PATCH 1/4] i386/cpu: Mark EBX/ECX/EDX in CPUID 0x80000000 leaf as reserved for Intel

Zhao Liu posted 4 patches 5 months, 3 weeks ago
[PATCH 1/4] i386/cpu: Mark EBX/ECX/EDX in CPUID 0x80000000 leaf as reserved for Intel
Posted by Zhao Liu 5 months, 3 weeks ago
Per SDM,

80000000H EAX Maximum Input Value for Extended Function CPUID Information.
          EBX Reserved.
          ECX Reserved.
          EDX Reserved.

EBX/ECX/EDX in CPUID 0x80000000 leaf are reserved. Intel is using 0x0
leaf to encode vendor.

Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
 target/i386/cpu.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index c7f157a0f71c..867e08236540 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -8280,9 +8280,14 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
         break;
     case 0x80000000:
         *eax = env->cpuid_xlevel;
-        *ebx = env->cpuid_vendor1;
-        *edx = env->cpuid_vendor2;
-        *ecx = env->cpuid_vendor3;
+
+        if (cpu->vendor_cpuid_only_v2 && IS_INTEL_CPU(env)) {
+            *ebx = *ecx = *edx = 0;
+        } else {
+            *ebx = env->cpuid_vendor1;
+            *edx = env->cpuid_vendor2;
+            *ecx = env->cpuid_vendor3;
+        }
         break;
     case 0x80000001:
         *eax = env->cpuid_version;
-- 
2.34.1
Re: [PATCH 1/4] i386/cpu: Mark EBX/ECX/EDX in CPUID 0x80000000 leaf as reserved for Intel
Posted by Ewan Hai 5 months, 3 weeks ago

On 6/27/25 11:51 AM, Zhao Liu wrote:
> +        if (cpu->vendor_cpuid_only_v2 && IS_INTEL_CPU(env)) {

Please also add IS_ZHAOXIN_CPU(env), since Zhaoxin follows the SDM definition 
for CPUID leaf 0x80000000.

> +            *ebx = *ecx = *edx = 0;
> +        } else {
> +            *ebx = env->cpuid_vendor1;
> +            *edx = env->cpuid_vendor2;
> +            *ecx = env->cpuid_vendor3;
> +        }
Re: [PATCH 1/4] i386/cpu: Mark EBX/ECX/EDX in CPUID 0x80000000 leaf as reserved for Intel
Posted by Xiaoyao Li 5 months, 3 weeks ago
On 6/27/2025 11:51 AM, Zhao Liu wrote:
> Per SDM,
> 
> 80000000H EAX Maximum Input Value for Extended Function CPUID Information.
>            EBX Reserved.
>            ECX Reserved.
>            EDX Reserved.
> 
> EBX/ECX/EDX in CPUID 0x80000000 leaf are reserved. Intel is using 0x0
> leaf to encode vendor.
> 
> Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
> ---
>   target/i386/cpu.c | 11 ++++++++---
>   1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
> index c7f157a0f71c..867e08236540 100644
> --- a/target/i386/cpu.c
> +++ b/target/i386/cpu.c
> @@ -8280,9 +8280,14 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
>           break;
>       case 0x80000000:
>           *eax = env->cpuid_xlevel;
> -        *ebx = env->cpuid_vendor1;
> -        *edx = env->cpuid_vendor2;
> -        *ecx = env->cpuid_vendor3;
> +
> +        if (cpu->vendor_cpuid_only_v2 && IS_INTEL_CPU(env)) {
> +            *ebx = *ecx = *edx = 0;

"Reserved" is different to "Reserved to 0".

So you'd better provide justification like "set them to all zero as what 
real Intel processor returns"

> +        } else {
> +            *ebx = env->cpuid_vendor1;
> +            *edx = env->cpuid_vendor2;
> +            *ecx = env->cpuid_vendor3;
> +        }
>           break;
>       case 0x80000001:
>           *eax = env->cpuid_version;