dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v5] eal_common_cpuflags: Fix %rbx corruption, and simplify the code
@ 2014-04-15 14:09 De Lara Guarch, Pablo
       [not found] ` <E115CCD9D858EF4F90C690B0DCB4D8970829CEB8-kPTMFJFq+rELt2AQoY/u9bfspsVTdybXVpNB7YpNyf8@public.gmane.org>
  0 siblings, 1 reply; 29+ messages in thread
From: De Lara Guarch, Pablo @ 2014-04-15 14:09 UTC (permalink / raw)
  To: dev-VfR2kkLFssw@public.gmane.org

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-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
> > Signed-off-by: H. Peter Anvin <hpa-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> > Signed-off-by: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>

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

--------------------------------------------------------------
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

^ permalink raw reply	[flat|nested] 29+ messages in thread
* Re: [PATCH v5] eal_common_cpuflags: Fix %rbx corruption, and simplify the code
@ 2014-04-16  8:58 De Lara Guarch, Pablo
       [not found] ` <E115CCD9D858EF4F90C690B0DCB4D8970829D14A-kPTMFJFq+rELt2AQoY/u9bfspsVTdybXVpNB7YpNyf8@public.gmane.org>
  0 siblings, 1 reply; 29+ messages in thread
From: De Lara Guarch, Pablo @ 2014-04-16  8:58 UTC (permalink / raw)
  To: Neil Horman; +Cc: dev-VfR2kkLFssw@public.gmane.org

Hi Neil,



>> 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



>RTE_COMPILE_TIME_CPUFLAGS= >RTE_CPUFLAG_SSE,RTE_CPUFLAG_SSE2,RTE_CPUFLAG_SSE3,RTE_CPUFLAG_SSSE3,RTE_CPUFLAG_SSE4_1,RTE_CPUFLAG_SSE4_2,RTE_CPUFLAG_AES,RTE_CPUFLAG_PCLMULQDQ,RTE_CPUFLAG_AVX



>For gcc_version >=4.6, that value is the same, of course (and all those flags are supported). So it has to be something else...



Silly me, I just saw what was hapenning. There are two missing brackets in the loop:



for (i = 0; i < sizeof(compile_time_flags)/sizeof(compile_time_flags[0]); i++) {

ret = rte_cpu_get_flag_enabled(compile_time_flags[i]);



if (ret < 0) {

fprintf(stderr,

  "ERROR: CPU feature flag lookup failed with error %d\n",

  ret);

exit(1);

}

if (!ret) {

fprintf(stderr,

  "ERROR: This system does not support \"%s\".\n"

  "Please check that RTE_MACHINE is set correctly.\n",

  cpu_feature_table[compile_time_flags[i]].name);

exit(1);

}

}



So, basically, "i" was size of the array +1 after the loop and only the return value was being checked for the last item. Not sure why higher versions of gcc do not catch this.



Thanks,



Pablo de Lara

DPDK SW Engineer



--------------------------------------------------------------

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

^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2014-04-16 12:53 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1395330830-1310-1-git-send-email-hpa@linux.intel.com>
     [not found] ` <1395330830-1310-1-git-send-email-hpa-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-03-20 16:39   ` [RFC UNTESTED PATCH] eal_common_cpuflags: Fix %rbx corruption, and simplify the code Neil Horman
     [not found]     ` <20140320163921.GC7721-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
2014-03-20 17:02       ` Thomas Monjalon
2014-03-20 18:04       ` Neil Horman
     [not found]         ` <20140320180443.GE7721-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
2014-03-20 18:59           ` Neil Horman
2014-03-21 14:49       ` [PATCH v2] " Neil Horman
     [not found]         ` <1395413340-27392-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
2014-03-21 15:03           ` H. Peter Anvin
     [not found]             ` <532C54C6.2060202-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-03-21 17:48               ` Neil Horman
     [not found]                 ` <20140321174839.GB21998-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
2014-03-24 11:18                   ` Thomas Monjalon
2014-03-24 17:44       ` [PATCH v3] " Neil Horman
     [not found]         ` <1395683088-19687-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
2014-03-24 18:09           ` H. Peter Anvin
     [not found]             ` <533074F0.3060204-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-03-24 19:52               ` Neil Horman
     [not found]                 ` <20140324195206.GG19368-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
2014-03-24 20:47                   ` H. Peter Anvin
     [not found]                     ` <533099FB.5030702-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-03-25 10:41                       ` Neil Horman
2014-03-25 17:03       ` [PATCH v4] " Neil Horman
     [not found]         ` <1395767000-28709-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
2014-03-25 17:06           ` Chris Wright
2014-03-25 17:37           ` H. Peter Anvin
2014-03-25 19:52       ` [PATCH v5] " Neil Horman
     [not found]         ` <1395777179-4345-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
2014-03-25 20:51           ` H. Peter Anvin
     [not found]             ` <5331EC38.2070901-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-04-02 11:16               ` Neil Horman
     [not found]                 ` <20140402111643.GB6974-0o1r3XBGOEbbgkc5XkKeNuvMHUBZFtU3YPYVAmT7z5s@public.gmane.org>
2014-04-02 11:53                   ` Thomas Monjalon
2014-04-02 12:42               ` Thomas Monjalon
2014-04-15 14:09 De Lara Guarch, Pablo
     [not found] ` <E115CCD9D858EF4F90C690B0DCB4D8970829CEB8-kPTMFJFq+rELt2AQoY/u9bfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-04-15 14:56   ` Neil Horman
     [not found]     ` <20140415145612.GE3557-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
2014-04-16  8:36       ` De Lara Guarch, Pablo
  -- strict thread matches above, loose matches on Subject: below --
2014-04-16  8:58 De Lara Guarch, Pablo
     [not found] ` <E115CCD9D858EF4F90C690B0DCB4D8970829D14A-kPTMFJFq+rELt2AQoY/u9bfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-04-16  9:06   ` Thomas Monjalon
2014-04-16 10:49   ` Neil Horman
     [not found]     ` <20140416104955.GA26829-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
2014-04-16 11:09       ` De Lara Guarch, Pablo
     [not found]         ` <E115CCD9D858EF4F90C690B0DCB4D8970829D24B-kPTMFJFq+rELt2AQoY/u9bfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-04-16 12:53           ` Neil Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).