eal: fix %rbx corruption and simplify the code
authorNeil Horman <nhorman@tuxdriver.com>
Tue, 25 Mar 2014 19:52:59 +0000 (15:52 -0400)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Wed, 2 Apr 2014 12:38:40 +0000 (14:38 +0200)
commit99f2cdf9ca10cac4af9a01f4934ea23d8d1bdacb
tree4bfd64a25c637647e3dbe78112c0c79a85a7870d
parent4b38b32eb756e2faedd3622c28d7454ae4299237
eal: fix %rbx corruption and simplify the code

Neil Horman reported that on x86-64 the upper half of %rbx would get
clobbered when the code was compiled PIC or PIE, because the
i386-specific code to preserve %ebx was incorrectly compiled.

However, the code is really way more complex than it needs to be.  For
one thing, the CPUID instruction only needs %eax (leaf) and %ecx
(subleaf) as parameters, and since we are testing for bits, we might
as well list the bits explicitly.  Furthermore, we can use an array
rather than doing a switch statement inside a structure.

Reported-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Reviewed-by: H. Peter Anvin <hpa@linux.intel.com>
lib/librte_eal/common/eal_common_cpuflags.c