Mailing List Archive

Bad code with __initfunc() and gcc-2.7.2.3
Hi
I am seing a really strange problem with one of my drivers (the AceNIC
Gigabit Ethernet one) when I compile it statically into the kernel using
2.2.0pre4 and gcc-2.7.2.3 as it comes with Red Hat 5.2. When compiled as
a module the code seems to be fine.
It looks to me as it is related to the use of __initfunc() and I am
wondering if we have a generic __initfunc() problem on the x86 .... if
it hits me I would think it could easily hit other people. Question is
whether we need to do something drastical like disabling __initfunc on
the x86 for gcc 2.7.2.3 and older for 2.2?
The code in question looks like this:
__initfunc(void ace_copy(struct ace_regs *regs, void *src, u32 dest, int size))
{
int tsize;
u32 tdest;
if (size <= 0)
return;
while(size > 0){
tsize = min(((~dest & (ACE_WINDOW_SIZE - 1)) + 1),
min(size, ACE_WINDOW_SIZE));
tdest = dest & (ACE_WINDOW_SIZE - 1);
regs->WinBase = dest & ~(ACE_WINDOW_SIZE - 1);
If I remove the __initfunc() from it the generated code looks like this
which works fine:
0x179c <ace_copy>: pushl %ebp
0x179d <ace_copy+1>: pushl %edi
0x179e <ace_copy+2>: pushl %esi
0x179f <ace_copy+3>: pushl %ebx
0x17a0 <ace_copy+4>: movl 0x1c(%esp,1),%ebp
0x17a4 <ace_copy+8>: cmpl $0x0,0x20(%esp,1)
0x17a9 <ace_copy+13>: jle 0x1816 <ace_copy+122>
0x17ab <ace_copy+15>: nop
0x17ac <ace_copy+16>: movl %ebp,%eax
0x17ae <ace_copy+18>: notl %eax
0x17b0 <ace_copy+20>: andl $0x7ff,%eax
0x17b5 <ace_copy+25>: incl %eax
0x17b6 <ace_copy+26>: movl 0x20(%esp,1),%ecx
0x17ba <ace_copy+30>: cmpl $0x800,%ecx
0x17c0 <ace_copy+36>: jbe 0x17c7 <ace_copy+43>
With the __initfunc() the code looks like this which has a certain
similarity with random garbage in some places:
0x35368 <ace_copy>: pushl %ebp
0x35369 <ace_copy+1>: pushl %edi
0x3536a <ace_copy+2>: pushl %esi
0x3536b <ace_copy+3>: pushl %ebx
0x3536c <ace_copy+4>: movl 0x1c(%esp,1),%ebp
0x35370 <ace_copy+8>: cmpl $0x0,0x20(%esp,1)
0x35375 <ace_copy+13>: jle 0x353e2 <ace_copy+122>
0x35377 <ace_copy+15>: addb %cl,0x25d0f7e8(%ecx) <------- !!!
0x3537d <ace_copy+21>: incl (%edi)
0x3537f <ace_copy+23>: addb %al,(%eax)
0x35381 <ace_copy+25>: incl %eax
0x35382 <ace_copy+26>: movl 0x20(%esp,1),%ecx
0x35386 <ace_copy+30>: cmpl $0x800,%ecx
0x3538c <ace_copy+36>: jbe 0x35393 <ace_copy+43>
It looks to me that it could be related to branch alignment or something
thus when put in the init section, the padding code (nop) after a branch
is not generated properly.
I would be happy to find that this is a bug in my particular code - but
I can't see how it would cause it. Oh and I've seen this on several
machines, I am pretty sure it is not bad memory on this particular box.
Jes
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
Re: Bad code with __initfunc() and gcc-2.7.2.3 [ In reply to ]
On Wed, Jan 06, 1999 at 05:53:27PM +0100, Jes Sorensen wrote:
> I am seing a really strange problem with one of my drivers (the AceNIC
> Gigabit Ethernet one) when I compile it statically into the kernel using
> 2.2.0pre4 and gcc-2.7.2.3 as it comes with Red Hat 5.2. When compiled as
> a module the code seems to be fine.
The problem is detected and reported by egcs --
drivers/net/acenic.c: In function `acenic_probe':
drivers/net/acenic.c:142: acenic_probe causes a section type conflict
drivers/net/acenic.c: In function `ace_init':
drivers/net/acenic.c:403: ace_init causes a section type conflict
drivers/net/acenic.c: In function `ace_copy':
drivers/net/acenic.c:1505: ace_copy causes a section type conflict
drivers/net/acenic.c: In function `ace_load_firmware':
drivers/net/acenic.c:1559: ace_load_firmware causes a section type conflict
The bug is in acenic_firmware.h --
u32 tigonFwText[(MAX_TEXT_LEN/4) + 1] __init = {
That should be __initdata. Since it is __init, .text.init gets
marked as being a data section rather than a code section, so
alignment pads with zeros instead of nops.
r~
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
Re: Bad code with __initfunc() and gcc-2.7.2.3 [ In reply to ]
>>>>> "Richard" == Richard Henderson <rth@cygnus.com> writes:
Richard> On Wed, Jan 06, 1999 at 05:53:27PM +0100, Jes Sorensen wrote:
>> I am seing a really strange problem with one of my drivers (the
>> AceNIC Gigabit Ethernet one) when I compile it statically into the
>> kernel using 2.2.0pre4 and gcc-2.7.2.3 as it comes with Red Hat
>> 5.2. When compiled as a module the code seems to be fine.
Richard> The problem is detected and reported by egcs --
Richard> drivers/net/acenic.c: In function `acenic_probe':
Richard> drivers/net/acenic.c:142: acenic_probe causes a section type
Richard> conflict drivers/net/acenic.c: In function `ace_init':
Richard> drivers/net/acenic.c:403: ace_init causes a section type
Richard> conflict drivers/net/acenic.c: In function `ace_copy':
Richard> drivers/net/acenic.c:1505: ace_copy causes a section type
Richard> conflict drivers/net/acenic.c: In function
Richard> `ace_load_firmware': drivers/net/acenic.c:1559:
Richard> ace_load_firmware causes a section type conflict
I actually tried compiling it with egcs but didn't really understand
the error message.
Richard> The bug is in acenic_firmware.h --
Richard> u32 tigonFwText[(MAX_TEXT_LEN/4) + 1] __init = {
Richard> That should be __initdata. Since it is __init, .text.init
Richard> gets marked as being a data section rather than a code
Richard> section, so alignment pads with zeros instead of nops.
Thanks a lot, I would never have figured this one out myself.
Jes
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
Re: Bad code with __initfunc() and gcc-2.7.2.3 [ In reply to ]
On Wed, Jan 06, 1999 at 06:15:40PM +0100, Jes Sorensen wrote:
> Thanks a lot, I would never have figured this one out myself.
I wonder if the egcs people can make the error message it spews a
little more informative (like which sections are conflicting).
-cw
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
Re: Linux/alpha hanging 2.2.0-pre4? [ In reply to ]
On Wed, 6 Jan 1999, Stephen Williams wrote:
> So it seems that Linux 2.2.0 isn't stable with loadable modules, at least
> not on the PC164. Any evidence to the contrary?
It's definately stable on the Intel architecture; my machine runs
2.2.0pre4 with all but the necessities compiled as modules, and it's been
rock-solid. I use the machine for cross-compiling 68k test kernels so it
gets a good workout too.
--
Network Administrator | FABRICATI DIEM, PVNC.
mich.com, Inc. | -- The motto of the Ankh-Morpork City Watch
248-442-1000 x212 | (Terry Pratchett, Guards! Guards!)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/