On Tue, Oct 29, 2024 at 04:18:54PM +0100, Paolo Bonzini wrote:
> From: Tao Su <[email protected]>
[ ... ]
> static void max_x86_cpu_realize(DeviceState *dev, Error **errp)
> {
> Object *obj = OBJECT(dev);
> + X86CPU *cpu = X86_CPU(dev);
> + CPUX86State *env = &cpu->env;
>
> if (!object_property_get_int(obj, "family", &error_abort)) {
> if (X86_CPU(obj)->env.features[FEAT_8000_0001_EDX] & CPUID_EXT2_LM) {
> @@ -5351,6 +5357,14 @@ static void max_x86_cpu_realize(DeviceState *dev,
> Error **errp)
> }
> }
>
> + if ((env->features[FEAT_7_1_EDX] & CPUID_7_1_EDX_AVX10) &&
> !env->avx10_version) {
CPUID_7_1_EDX_AVX10 is not set now and will be set in x86_cpu_realizefn().
How about just checking !env->avx10_version? Because cpu_x86_cpuid will
also check (env->features[FEAT_7_1_EDX] & CPUID_7_1_EDX_AVX10).
> + uint32_t eax, ebx, ecx, edx;
> + x86_cpu_get_supported_cpuid(0x24, 0,
> + &eax, &ebx, &ecx, &edx);
> +
> + env->avx10_version = ebx & 0xff;
> + }
> +
> x86_cpu_realizefn(dev, errp);
> }
>
> @@ -6331,6 +6345,9 @@ static void x86_cpu_load_model(X86CPU *cpu, X86CPUModel
> *model)
> */
> object_property_set_str(OBJECT(cpu), "vendor", def->vendor,
> &error_abort);
>
> + object_property_set_int(OBJECT(cpu), "avx10-version", def->avx10_version,
> + &error_abort);
NIT: avx10-version is defined as UINT8, is it better to use
object_property_set_uint?
> +
> x86_cpu_apply_version_props(cpu, model);
>
> /*
> @@ -6859,6 +6876,16 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
> uint32_t count,
> }
> break;
> }
> + case 0x24: {
> + *eax = 0;
> + *ebx = 0;
> + *ecx = 0;
> + *edx = 0;
> + if (env->features[FEAT_7_1_EDX] & CPUID_7_1_EDX_AVX10) {
> + *ebx = env->avx10_version;
> + }
The CPUIDs of vector lengths are missing here, according to your previous
comment, it should be:
+ if ((env->features[FEAT_7_1_EDX] & CPUID_7_1_EDX_AVX10) && count == 0)
{
+ *ebx = env->features[FEAT_24_0_EBX] | env->avx10_version;
+ }
[ ... ]