[dpdk-dev] [PATCH v5] eal_common_cpuflags: Fix %rbx corruption, and simplify the code

Neil Horman nhorman at tuxdriver.com
Tue Apr 15 16:56:12 CEST 2014


On Tue, Apr 15, 2014 at 02:09:34PM +0000, De Lara Guarch, Pablo wrote:
> Hi,
> 
> I have checked that on gcc-4.5, I get a compilation error due to the following patch:
> 
> > > 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 at tuxdriver.com>
> > > Signed-off-by: H. Peter Anvin <hpa at linux.intel.com>
> > > Signed-off-by: Neil Horman <nhorman at tuxdriver.com>
> 
> The compilation error is:
> 
> /root/dpdk/lib/librte_eal/common/eal_common_cpuflags.c: In function 'rte_cpu_check_supported':
> /root/dpdk/lib/librte_eal/common/eal_common_cpuflags.c:271:48: error: array subscript is above array bounds
> make[7]: *** [eal_common_cpuflags.o] Error 1
> 
> This error is not present in newer gcc versions (4.6 and above).
> 
> Thanks,
> 
> Pablo de Lara
> DPDK SW Engineer
> 

What was the value of RTE_COMPILE_TIME_CPUFLAGS when you built your library?  If
you added defines for flag support that are not tested for yet in the
cpu_feature_table, that would be the error you would see I think

Regards
Neil


> --------------------------------------------------------------
> Intel Shannon Limited
> Registered in Ireland
> Registered Office: Collinstown Industrial Park, Leixlip, County Kildare Registered Number: 308263 Business address: Dromore House, East Park, Shannon, Co. Clare
> 
> 
> 


More information about the dev mailing list