[OpenBIOS] PPC: QEMU breaks static variables in OpenBIOS

Alexander Graf agraf at suse.de
Sat Jan 5 23:26:14 CET 2013


On 05.01.2013, at 23:13, Alexander Graf wrote:

> 
> On 05.01.2013, at 22:47, Mark Cave-Ayland wrote:
> 
>> On 05/01/13 21:23, Alexander Graf wrote:
>> 
>>>> I thought about that, but figured that because it was a hot-path I'd do it inline to save some cycles invoking another function. Since it uses the same OF_* constants as those functions then it should just work.
>>> 
>>> If the calculation function was provided through a static inline function in a header, this'd be a no-issue.
>>> 
>>> Alex
>> 
>> va2pa() looks like a good candidate for this, however it isn't marked as static inline because it's called from ofmem_common.c in libopenbios.
>> 
>> Then again I'm not sure this is important as I've heard in several places that most optimising compilers ignore the inline keyword, and will just inline whatever they think will run fastest based upon the current optimisation level.
>> 
>> Anyway let me know which way you'd prefer.
> 
> 
> Does the patch below work?

It looks pretty broken still:

    int *next_grab_slot_va;
    int r;

    next_grab_slot_va = (int*)(void*)va2pa((phys_addr_t)&next_grab_slot);
    r = *next_grab_slot_va;
    *next_grab_slot_va = (r + 1) % 8;
 340:   3d 60 00 00     lis     r11,0
                        342: R_PPC_ADDR16_HA    .bss
 344:   81 2b 00 00     lwz     r9,0(r11)
                        346: R_PPC_ADDR16_LO    .bss


Alex




More information about the OpenBIOS mailing list