[OpenBIOS] sparc32 __context initialization
Blue Swirl
blauwirbel at gmail.com
Wed Feb 9 18:52:51 CET 2011
On Wed, Feb 9, 2011 at 7: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?
IIRC this variable is the first one in data segment, perhaps BSS
clearing overwrites it (but I think I already fixed that one once), or
copying the data from ROM skips one word?
More information about the OpenBIOS
mailing list