[OpenBIOS] PPC: QEMU breaks static variables in OpenBIOS

Blue Swirl blauwirbel at gmail.com
Fri Jan 4 21:31:53 CET 2013


On Wed, Jan 2, 2013 at 1:45 PM, Mark Cave-Ayland
<mark.cave-ayland at ilande.co.uk> wrote:
> On 02/01/13 13:23, Programmingkid wrote:
>
>> I have noticed that a single register (r9) appears to be used at a base
>> register for all static variables. If we created our own memory region using
>> malloc for static and global variables, and set register r9 to this value,
>> we can make static variables work again. I know it is a hack, but I was able
>> to make static variables work this way.
>>
>> Early in the boot process, register r9 is set to 0x7c631a15. This address
>> is what I used to make next_grab_slot work. My guess is the address is a
>> static variable memory region. Register r9 might have been intended to be
>> some kind of base register, but I haven't found any documentation that
>> states this. I do know all static variables in ofmem.c use it for address
>> calculations.
>
>
> It would almost seem that either the QEMU ELF loader or something in
> arch/ppc/qemu/entry.S should be relocating the data section or entire ROM
> image into RAM before execution.
>
> Reading the comments for SPARC in arch/sparc32/entry.S, it looks as if the
> pages are marked writeable in the MMU and there is some kind of relocation
> into RAM occurring - Blue, can you comment on this?

At first, I tried to use ROM for .text and .rodata, eliminate all
.data and only put .bss in RAM, but because of some problems it was
easier to copy the whole ROM to RAM. It wastes some guest RAM but IIRC
Linux wanted to patch some areas.

I'd copy the ROM to RAM for PPC also. On Sparc, MMU is always enabled
and guests take care to preserve our mappings, but maybe this is not
the case for PPC. Then fully relocatable code would make sense there.

>
>
> ATB,
>
>
> Mark.
>
> --
> OpenBIOS                 http://openbios.org/
> Mailinglist:  http://lists.openbios.org/mailman/listinfo
> Free your System - May the Forth be with you



More information about the OpenBIOS mailing list