[OpenBIOS] sparc32 __context initialization
Artyom Tarasenko
atar4qemu at gmail.com
Wed Feb 9 19:15:37 CET 2011
On Wed, Feb 9, 2011 at 6:25 PM, Mark Cave-Ayland
<mark.cave-ayland at siriusit.co.uk> wrote:
> On 09/02/11 17:10, Artyom Tarasenko wrote:
>
>> Surprisingly, with this modification a null pointer dereference
>> happens much earlier than I'd expected: for some reason __context
>> doesn't get initialized in arch/sparc32/context.c, so OpenBIOS dies
>> before saying hello.
>>
>> If I initialize it in start_main the same way it should have been
>> initialized statically,
>>
>> start_main(void)
>> {
>> + __context =&main_ctx;
>>
>> then OpenBIOS starts and is able to boot at least Debian.
>> Any idea what might be wrong with the current static initialization?
>> For convenience I paste the code from arch/sparc32/context.c :
>>
>> static struct context main_ctx = {
>> .regs[REG_SP] = (uint32_t)&_estack - 96,
>> .pc = (uint32_t) start_main,
>> .npc = (uint32_t) start_main + 4,
>> .return_addr = (uint32_t) __exit_context,
>> };
>>
>> /* This is used by assembly routine to load/store the context which
>> * it is to switch/switched. */
>> struct context *__context =&main_ctx;
>
> Hmmm possibly this could be an overflow in the setup of main_ctx which
> causes it to scribble over __context?
>
> Note that with gdb/Qemu you can set watchpoints on a variable so that gdb
> breaks when the value at a particular memory location changes. This is
> really useful and how we found the dictionary overflow problem in SPARC64.
>
Thanks for the hints! You are right, it is properly initialized and
then gets corrupted:
Old value = (struct context *) 0xffd78000
New value = (struct context *) 0x0
__switch_context_nosave () at ../arch/sparc32/switch.S:89
89 ld [%fp + 4], %g1
__switch_context_nosave shouldn't change __context. I'll make a patch.
Artyom
--
Regards,
Artyom Tarasenko
solaris/sparc under qemu blog: http://tyom.blogspot.com/
More information about the OpenBIOS
mailing list