]> git.proxmox.com Git - mirror_qemu.git/commit - target/i386/cpu.c
target-i386: Use #defines instead of magic numbers for CPUID cache info
authorEduardo Habkost <ehabkost@redhat.com>
Tue, 27 Aug 2013 15:24:37 +0000 (12:24 -0300)
committerAndreas Färber <afaerber@suse.de>
Tue, 3 Sep 2013 10:25:56 +0000 (12:25 +0200)
commit5e891bf8fd509c4d83cb95d352d88effb20720b1
tree56b74f3fbe5c90df8d15fb00581862c519921471
parent38fcbd3f08375eb2986b9b63ccd4f593e71aa99d
target-i386: Use #defines instead of magic numbers for CPUID cache info

This is an attempt to make the CPUID cache topology code clearer, by
replacing the magic numbers in the code with #defines, and moving all
the cache information to the same place in the file.

I took care of comparing the assembly output of compiling
target-i386/cpu.c before and after applying this change, to make sure
not a single bit was changed on cpu_x86_cpuid() before and after
applying this patch (unfortunately I had to manually check existing
differences, because of __LINE__ expansions on
object_class_dynamic_cast_assert() calls).

This even keeps the code bug-compatible with the previous version: today
the cache information returned on AMD cache information leaves (CPUID
0x80000005 & 0x80000006) do not match the information returned on CPUID
leaves 2 and 4. The L2 cache information on CPUID leaf 2 also doesn't
match the information on CPUID leaf 2. The new constants should make it
easier to eventually fix those inconsistencies. All inconsistencies I
have found are documented in code comments.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: liguang <lig.fnst@cn.fujitsu.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
target-i386/cpu.c