silo on qemu-system-sparc64
Hi!
I'm trying to boot gentoo install-sparc64-minimal-2008.0.iso using qemu-system-sparc64 and it stops with SI message.
The problem is with code in first-isofs/crt0.S where it tries to clear BSS, it is using %i3 register value to compute address. It occurs that openbios image does not really care about contents of %i3 before calling loaded silo code. So %i3 can have odd value and subsequent store is faulting with unaligned access.
Any hints on what does silo expect in %i3 are appreciated, so we could amend openbios code to provide good initial state to silo.
If I follow open firmware standard draft and clear %i3 before control is passed to silo then it even allows me to boot gentoo kernel (of course kernel crashes a bit later :) Still in this case it is not clear why silo does those computations in the first place.
The silo code excerpt in question is below. Note that %i3 is never assigned to in silo code before that 5 label. Fault is at last std instruction (which is at pc=0x4064), qemu trace below.
--- silo-1.4.13/first-isofs/crt0.S ---
.align 32
jumphere:
/* Clear BSS */
5: add %l0, %i3, %l0
add %i1, %i3, %i1
andcc %i1, 4, %g0
sub %l0, %i1, %i2 ! %i2 = BSS length
be 1f
mov %g0, %g1 st %g0, [%i1]
add %i1, 4, %i1
1:
subcc %i2, 32, %i2
std %g0, [%i1]---QEMU TRACE---
IN:
0x0000000000004060: subcc %i2, 0x20, %i2 0x0000000000004064: std %g0, [ %i1 ] 0x0000000000004068: std %g0, [ %i1 + 8 ] 0x000000000000406c: std %g0, [ %i1 + 0x10 ] 0x0000000000004070: std %g0, [ %i1 + 0x18 ] 0x0000000000004074: bgu 0x4060 0x0000000000004078: add %i1, 0x20, %i1
4254: Unaligned Memory Access (v 34) pc 00000000004064
npc 00000000004068 SP 000000ffe80201
pc: 0000000000004064 npc: 0000000000004068 General Registers:
%g0: 0000000000000000 %g1: 0000000000000000 %g2: 000001fe020003f8
%g3: 00000000ffe52ed0
%g4: 0000000000000000 %g5: 0000000000000020 %g6: 0000000000000000
%g7: 0000000000000000
Current Register Window:
%o0: 0000000000000000 %o1: 0000000000000000 %o2: 0000000000000000
%o3: 0000000000000000
%o4: 00000000ffd19928 %o5: 0000000000000001 %o6: 00000000ffe80201
%o7: 0000000000004000
%l0: 0000000000005db1 %l1: 0000000000005c30 %l2: 0000000000000000
%l3: 0000000000000000
%l4: 0000000000000000 %l5: 0000000000000000 %l6: 0000000000000000
%l7: 000000000000401c
%i0: 0000000000004000 %i1: 0000000000005c31 %i2: 0000000000000160
%i3: 0000000000000001
%i4: 00000000ffe808dc %i5: 0000000000000000 %i6: 00000000ffe802e1
%i7: 00000000ffd0bc90
Signature · 2 lines
Kind regards, Igor V. Kovalenko
From: Igor Kovalenko <[email protected]>
Date: Thu, 28 May 2009 00:47:14 +0400
Quoted 10 lines
The problem is with code in
first-isofs/crt0.Swhere it tries to clear BSS, it is using %i3 register value to compute address. It occurs that openbios image does not really care about contents of %i3 before calling loaded silo code. So %i3 can have odd value and subsequent store is faulting with unaligned access.Any hints on what does silo expect in %i3 are appreciated, so we could amend openbios code to provide good initial state to silo.
It looks like a bug, %i3 isn't initialized to anything.
It works, as you found, because openfirmware always clears this register upon jumping to client code. And therefore openbios should do so as well.
Quoted 14 lines · David Miller
From: Igor Kovalenko <[email protected]>
Date: Thu, 28 May 2009 00:47:14 +0400Quoted 10 lines
The problem is with code in
first-isofs/crt0.Swhere it tries to clear BSS, it is using %i3 register value to compute address. It occurs that openbios image does not really care about contents of %i3 before calling loaded silo code. So %i3 can have odd value and subsequent store is faulting with unaligned access.Any hints on what does silo expect in %i3 are appreciated, so we could amend openbios code to provide good initial state to silo.
Quoted 6 lines
It looks like a bug, %i3 isn't initialized to anything.
It works, as you found, because openfirmware always clears this register upon jumping to client code. And therefore openbios should do so as well.
Thanks!
By the way, currently we cannot use unoptimized openbios builds with linux kernel because there is not enough space for unoptimized code to store arguments. Kernel stores arguments array in 128 bytes below stack frame whereas at least 192 bytes are needed.
Do you think it makes sense to increase that 128 to 192 ?
Signature · 2 lines
Kind regards, Igor V. Kovalenko
From: Igor Kovalenko <[email protected]>
Date: Thu, 28 May 2009 23:10:12 +0400
Quoted 7 lines
By the way, currently we cannot use unoptimized openbios builds with linux kernel because there is not enough space for unoptimized code to store arguments. Kernel stores arguments array in 128 bytes below stack frame whereas at least 192 bytes are needed.
Do you think it makes sense to increase that 128 to 192 ?
I don't think this is going to change, sorry.
I even have plans to make GCC always use a 128 byte stack frame unless varargs are being used, via a special GCC command line option like -mkernel or similar.
There is no reason to pop arguments into that argument save area in the stack frame, unless varargs are being used.
This is assuming I understand what you're talking about. :-)