Re: [PATCH 19/19] kvm: x86: Add AMX CPUIDs support

From: Paolo Bonzini
Date: Fri Dec 10 2021 - 16:52:53 EST


On 12/8/21 01:03, Yang Zhong wrote:
@@ -914,7 +918,8 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
break;
/* Intel PT */
case 0x14:
- if (!kvm_cpu_cap_has(X86_FEATURE_INTEL_PT)) {
+ if ((function == 0x14 && !kvm_cpu_cap_has(X86_FEATURE_INTEL_PT)) ||
+ (function == 0x1d && !kvm_cpu_cap_has(X86_FEATURE_AMX_TILE))) {

This hunk is wrong.

entry->eax = entry->ebx = entry->ecx = entry->edx = 0;
break;
}
@@ -924,6 +929,11 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
goto out;
}
break;
+ /* Intel AMX TILE */
+ case 0x1d:
+ if (!kvm_cpu_cap_has(X86_FEATURE_AMX_TILE))
+ entry->eax = entry->ebx = entry->ecx = entry->edx = 0;
+ break;

This also needs a loop similar to the one in case 0x14; so the "break" goes inside the "if" and then you have

for (i = 1, max_idx = entry->eax; i <= max_idx; ++i) {
if (!do_host_cpuid(array, function, i))
goto out;
}


Same for 0x1e, which also needs to be marked conditional.

Paolo