Fredrik Pettai | 1 Jul 2009 00:22
Favicon

Re: Crosscompiling NetBSD for Fonera not working with HEAD?

On Jun 30, 2009, at 10:53 PM, Arnaud Lacombe wrote:
> On Tue, Jun 30, 2009 at 4:40 PM, Fredrik Pettai<pettai <at> nordu.net>  
> wrote:
>> db> trace
>> PC 0x1bb958f6: not in kernel space
>> 0+1bb958f6 (a87f0000,b0000000,c003020,4) ra 0 sz 0
>> User-level: pid 0.1
>>
> could you dumps register contents ? with a bit of luck, we will be
> able to get the stack pointer and examine further.

Is this what you asked for?

db> show registers
at          0xffffffe0
v0          0
v1          0x2000
a0          0xa87f0000
a1          0xb0000000
a2          0xc003020
a3          0x4
t0          0
t1          0x2
t2          0x14
t3          0xffffffff
t4          0
t5          0
t6          0xffffffff
t7          0xffffffff
s0          0x6004
(Continue reading)

David Holland | 1 Jul 2009 10:50
Picon

Re: Crosscompiling NetBSD for Fonera not working with HEAD?

On Wed, Jul 01, 2009 at 12:22:22AM +0200, Fredrik Pettai wrote:
>> could you dumps register contents ? with a bit of luck, we will be
>> able to get the stack pointer and examine further.
>
> Is this what you asked for?
>
> db> show registers
> [snip]

Yes, it was, same as I asked for in the PR :-)

Since the broken address is also in t9, it looks like it's gotten a
bogus function pointer from the GOT. Which is probably because the
kernel doesn't have one. Kernel bits are supposed to be compiled with
-mno-abicalls, which is normally handled by Makefile.MIPS.

Is there something involved that's compiled with custom CFLAGS?

(Finding out where ra is pointing like I suggested in the PR will
probably identify it.)

--

-- 
David A. Holland
dholland <at> netbsd.org

Fredrik Pettai | 1 Jul 2009 21:28
Favicon

Re: Crosscompiling NetBSD for Fonera not working with HEAD?

On Jul 1, 2009, at 10:50 AM, David Holland wrote:
> On Wed, Jul 01, 2009 at 12:22:22AM +0200, Fredrik Pettai wrote:
>
> Since the broken address is also in t9, it looks like it's gotten a
> bogus function pointer from the GOT. Which is probably because the
> kernel doesn't have one. Kernel bits are supposed to be compiled with
> -mno-abicalls, which is normally handled by Makefile.MIPS.

Should I try it manually in CFLAGS?

> Is there something involved that's compiled with custom CFLAGS?

Not that I've set. /etc/mk.conf is empty, and no CFLAGS variable is set.

> (Finding out where ra is pointing like I suggested in the PR will
> probably identify it.)

I updated the PR with the output of objdump -d netbsd and disassembly  
of the function which contained 8006a524.
The kernel is compiled (standard) with makeoptions DEBUG="-g", but I'm  
not familiar with how to accomplish this, (which you wrote in the PR).  
"If it's a kernel with debugging symbols you can get it from gdb"

Is it the same thing?

Re,
/P

David Holland | 5 Jul 2009 23:31
Picon

Re: Crosscompiling NetBSD for Fonera not working with HEAD?

On Wed, Jul 01, 2009 at 09:28:43PM +0200, Fredrik Pettai wrote:
>> Since the broken address is also in t9, it looks like it's gotten a
>> bogus function pointer from the GOT. Which is probably because the
>> kernel doesn't have one. Kernel bits are supposed to be compiled with
>> -mno-abicalls, which is normally handled by Makefile.MIPS.
>
> Should I try it manually in CFLAGS?

No, it should be there anyway.

>> Is there something involved that's compiled with custom CFLAGS?
>
> Not that I've set. /etc/mk.conf is empty, and no CFLAGS variable is set.

I mean its own custom CFLAGS. The Atheros HAL is in particular what
I'm thinking of, since from what you've sent it looks like it's dying
inside that.

--

-- 
David A. Holland
dholland <at> netbsd.org

Fredrik Pettai | 5 Jul 2009 23:58
Favicon

Re: Crosscompiling NetBSD for Fonera not working with HEAD?

On Jul 5, 2009, at 11:31 PM, David Holland wrote:
> On Wed, Jul 01, 2009 at 09:28:43PM +0200, Fredrik Pettai wrote:
>>> Is there something involved that's compiled with custom CFLAGS?
>>
>> Not that I've set. /etc/mk.conf is empty, and no CFLAGS variable is  
>> set.
>
> I mean its own custom CFLAGS. The Atheros HAL is in particular what
> I'm thinking of, since from what you've sent it looks like it's dying
> inside that.

This is how it's look like then running build.sh -N 2 -m .... =MERAKI
I just cut out the output from building ar5312_reset.c, which contains  
the code where it bails out.

#    create  FON2100/ar5312_reset.d
CC=/usr/src/obj/tooldir.NetBSD-5.99.11-i386/bin/mipseb--netbsd-gcc / 
usr/src/obj/
tooldir.NetBSD-5.99.11-i386/bin/nbmkdep -f ar5312_reset.d --  -G 0 - 
mno-abicalls
  -msoft-float -ffixed-23 -ffreestanding -fno-zero-initialized-in-bss - 
g -Os -std
=gnu99 -fno-strict-aliasing   -Werror -Wall -Wno-main -Wno-format-zero- 
length -W
pointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wswitch - 
Wshadow -Wcast-
qual -Wwrite-strings -Wno-unreachable-code -Wno-sign-compare -Wno- 
pointer-sign -
Wno-attributes  -Werror    -Devbmips -I.  -I/usr/src/sys/../common/ 
include -I/us
(Continue reading)

David Holland | 6 Jul 2009 00:59
Picon

Re: Crosscompiling NetBSD for Fonera not working with HEAD?

On Sun, Jul 05, 2009 at 11:58:32PM +0200, Fredrik Pettai wrote:
> This is how it's look like then running build.sh -N 2 -m .... =MERAKI
> I just cut out the output from building ar5312_reset.c, which contains  
> the code where it bails out.
>
> #    create  FON2100/ar5312_reset.d

That's from make depend :-/

--

-- 
David A. Holland
dholland <at> netbsd.org

David Holland | 6 Jul 2009 00:59
Picon

Re: Crosscompiling NetBSD for Fonera not working with HEAD?

On Sun, Jul 05, 2009 at 10:59:32PM +0000, David Holland wrote:
 > That's from make depend :-/

oops, n/m, itchy send finger

--

-- 
David A. Holland
dholland <at> netbsd.org

Fredrik Pettai | 6 Jul 2009 00:41
Favicon

Re: Crosscompiling NetBSD for Fonera not working with HEAD?

On Jul 5, 2009, at 11:58 PM, Fredrik Pettai wrote:
> On Jul 5, 2009, at 11:31 PM, David Holland wrote:
>> On Wed, Jul 01, 2009 at 09:28:43PM +0200, Fredrik Pettai wrote:
>>>> Is there something involved that's compiled with custom CFLAGS?
>>>
>>> Not that I've set. /etc/mk.conf is empty, and no CFLAGS variable  
>>> is set.
>>
>> I mean its own custom CFLAGS. The Atheros HAL is in particular what
>> I'm thinking of, since from what you've sent it looks like it's dying
>> inside that.
>
> This is how it's look like then running build.sh -N 2 -m .... =MERAKI
> I just cut out the output from building ar5312_reset.c, which  
> contains the code where it bails out.
>
> #    create  FON2100/ar5312_reset.d
> CC=/usr/src/obj/tooldir.NetBSD-5.99.11-i386/bin/mipseb--netbsd-gcc / 
> usr/src/obj/
> tooldir.NetBSD-5.99.11-i386/bin/nbmkdep -f ar5312_reset.d --  -G 0 - 
> mno-abicalls
> -msoft-float -ffixed-23 -ffreestanding -fno-zero-initialized-in-bss - 
> g -Os -std
> =gnu99 -fno-strict-aliasing   -Werror -Wall -Wno-main -Wno-format- 
> zero-length -W
> pointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wswitch - 
> Wshadow -Wcast-
> qual -Wwrite-strings -Wno-unreachable-code -Wno-sign-compare -Wno- 
> pointer-sign -
> Wno-attributes  -Werror    -Devbmips -I.  -I/usr/src/sys/../common/ 
(Continue reading)

David Holland | 6 Jul 2009 01:38
Picon

Re: Crosscompiling NetBSD for Fonera not working with HEAD?

On Mon, Jul 06, 2009 at 12:41:43AM +0200, Fredrik Pettai wrote:
> As you can see -no-abicalls is in there...

Indeed it is. And the disassembly of the call whose return address is
in ra shows that it's not making an abicall.

But it does really really look like something did an indirect jump
through t9 after loading trash into it.

Can you post the disassembly of the function that call site is
calling? (ath_hal_reg_read)

Maybe there's a tail-call optimization so it's actually coming from
further down. (And maybe something is confusing gcc into issuing an
abicall in that context in spite of -mno-abicalls? But you'd think
that would make the kernel blow up right and left...)

Today's tree doesn't even compile for me:
../../../../arch/mips/atheros/ar5315_board.c:69:75: error: contrib/dev/ath/ah_soc.h: No such
file or directory

--

-- 
David A. Holland
dholland <at> netbsd.org

Fredrik Pettai | 6 Jul 2009 07:03
Favicon

Re: Crosscompiling NetBSD for Fonera not working with HEAD?

On Jul 6, 2009, at 1:38 AM, David Holland wrote:
>
> Today's tree doesn't even compile for me:
> ../../../../arch/mips/atheros/ar5315_board.c:69:75: error: contrib/ 
> dev/ath/ah_soc.h: No such file or directory

That's looks like this old problem again.
http://mail-index.netbsd.org/port-evbmips/2009/05/16/msg000054.html

(I thought it was committed already).

Re,
/P

David Holland | 6 Jul 2009 04:02
Picon

Re: Crosscompiling NetBSD for Fonera not working with HEAD?

On Sun, Jul 05, 2009 at 11:38:28PM +0000, David Holland wrote:
 > Can you post the disassembly of the function that call site is
 > calling? (ath_hal_reg_read)

n/m, Arnaud fixed the build and I got my own.

It's not an abicall, just a call through a function pointer, but I
guess gcc prefers to prepare function pointers in t9 even when
-mno-abicalls is in effect. And it *is* a tail call, which is why we
see what we do in ra.

It looks as if the problem is that the bus space tag is bogus, and so
the bus_space_read inside ath_hal_reg_read is fetching a garbage
function pointer from it and jumping off into the weeds.

--

-- 
David A. Holland
dholland <at> netbsd.org

Arnaud Lacombe | 5 Jul 2009 23:55
Picon
Gravatar

Re: Crosscompiling NetBSD for Fonera not working with HEAD?

Hi David,

On Sun, Jul 5, 2009 at 5:31 PM, David Holland<dholland-mips <at> netbsd.org> wrote:
>> Not that I've set. /etc/mk.conf is empty, and no CFLAGS variable is set.
>
> I mean its own custom CFLAGS. The Atheros HAL is in particular what
> I'm thinking of, since from what you've sent it looks like it's dying
> inside that.
>
AFAIK, it doesn't touch anything. The only variable touched by
files.ath_hal is CPPFLAGS to add reference to the good include
directories. Everything else is handled by the kernel's Makefile.

 - Arnaud

Fredrik Pettai | 1 Jul 2009 21:51
Favicon

Re: Crosscompiling NetBSD for Fonera not working with HEAD?

On Jul 1, 2009, at 9:28 PM, Fredrik Pettai wrote:
> On Jul 1, 2009, at 10:50 AM, David Holland wrote:
>> On Wed, Jul 01, 2009 at 12:22:22AM +0200, Fredrik Pettai wrote:
>>
>> Since the broken address is also in t9, it looks like it's gotten a
>> bogus function pointer from the GOT. Which is probably because the
>> kernel doesn't have one. Kernel bits are supposed to be compiled with
>> -mno-abicalls, which is normally handled by Makefile.MIPS.
>
> Should I try it manually in CFLAGS?

Interesting. I built the kernel once and did a grep on the output for - 
mno-abicalls.
It compiled with that option, but in the end I actually catch a error.
SYMTAB_SPACE was too small. I never caught this error because my  
terminal is just 80x24, and the summary from build.sh pushes this  
outside the visible window. I increased it to 300000 and recompiled.

>> Is there something involved that's compiled with custom CFLAGS?
>
> Not that I've set. /etc/mk.conf is empty, and no CFLAGS variable is  
> set.
>
>> (Finding out where ra is pointing like I suggested in the PR will
>> probably identify it.)
>
> I updated the PR with the output of objdump -d netbsd and  
> disassembly of the function which contained 8006a524.
> The kernel is compiled (standard) with makeoptions DEBUG="-g", but  
> I'm not familiar with how to accomplish this, (which you wrote in  
(Continue reading)

Fredrik Pettai | 5 Jul 2009 21:51
Favicon

Re: Crosscompiling NetBSD for Fonera not working with HEAD?

On Jul 1, 2009, at 9:51 PM, Fredrik Pettai wrote:
> On Jul 1, 2009, at 9:28 PM, Fredrik Pettai wrote:
>> On Jul 1, 2009, at 10:50 AM, David Holland wrote:
>>
>>> (Finding out where ra is pointing like I suggested in the PR will
>>> probably identify it.)

Here's the output from gdb ./netbsd.gdb -> list *0x8006a520, now then  
I recompiled the kernel with larger SYMTAB_SPACE.

(gdb) list *0x8006a520
0x8006a520 is in ar5312MacReset (/usr/src/sys/external/isc/atheros_hal/ 
dist/ar5312/ar5312_reset.c:882).
877                                     return(AH_FALSE);
878                             }
879                             regMask = ~(resetBB | resetBits);
880
881                             /* read before */
882                             reg = OS_REG_READ(ah,
883                                                                
(AR5312_RSTIMER_BASE - ((uint32_t) ah->ah_sh) + AR5312_RESET));
884
885                             if (RCMask == AR_RC_BB) {
886                                     /* Put baseband in reset */


Gmane