[dpdk-dev] [PATCH v3] eal_common_cpuflags: Fix %rbx corruption, and simplify the code
H. Peter Anvin
hpa at linux.intel.com
Mon Mar 24 21:47:55 CET 2014
On 03/24/2014 12:52 PM, Neil Horman wrote:
> To add an extra sanity check in rte_get_flag_enabled. If we were moving to the
> use of C99 initalizers, I wanted something to catch the possibility that we skip
> a flag by accident (i.e. leave a zero initalized hole in the array). Except 0
> from my read is a valid value for all the fields of the array. So I bumped up
> the cpuid register enum by one and wrapped it in a macro. That way we can test
> for !feat->reg as an indicator that we're requesting feature support for a flag
> thats not listed in the array.
It actually isn't: there aren't any flags in CPUID leaf 0, so since the
code only looks for bits it'd be perfectly okay to reject leaf 0.
Another thing that I noted is that the code doesn't actually check that
any particular leaf is valid (by checking the maximum leaf number in
CPUID leaf 0xXXXX0000:EAX). Especially for the leaf 7 features this
could result in false positives, which obviously would be disastrous.
More information about the dev