On 18/07/2017 13:29, Igor Mammedov wrote: >> It may add a few additional CPU cycles, but I really doubt we can >> find a workload where CPUID speed has measurable impact. See, >> for example, how expensive the kernel KVM CPUID code >> (kvm_cpuid(), kvm_find_cpuid_entry()) is. > > I don't expect that it would affect KVM, but for TCG any instruction > execution is 'fast' path, so I'd leave current cpu_x86_cpuid() > not to loose those few cycles, it's not worth sacrifice for the sake of > cleanup.
It's not like this does a QOM property lookup or anything. I think the patch is a good idea. Even simpler way to write the cpuid code: int base = (index - 0x80000002) * 16; char model[16]; if (strnlen(env->model_id, base) < base) { memset(model, 0, sizeof(model)); } else { strncpy(model, env->model_id + base, sizeof(model)); } *eax = ldl_le_p(&model[0]); *ebx = ldl_le_p(&model[4]); *ecx = ldl_le_p(&model[8]); *edx = ldl_le_p(&model[12]); Paolo