[OpenBIOS] sparc32 __context initialization

Mark Cave-Ayland mark.cave-ayland at siriusit.co.uk
Wed Feb 9 18:25:29 CET 2011


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.


HTH,

Mark.

-- 
Mark Cave-Ayland - Senior Technical Architect
PostgreSQL - PostGIS
Sirius Corporation plc - control through freedom
http://www.siriusit.co.uk
t: +44 870 608 0063

Sirius Labs: http://www.siriusit.co.uk/labs



More information about the OpenBIOS mailing list