[coreboot] the eternal pre-post car debate in v3

Carl-Daniel Hailfinger c-d.hailfinger.devel.2006 at gmx.net
Fri Sep 12 21:20:53 CEST 2008

On 12.09.2008 18:19, ron minnich wrote:
> W.r.t. Kevin's question: if we wrote stage1 as follows:
> stage1(){
> .
> .
> .
>   disable_car();
>   stage1_after_car();
> }
> How would people feel about that?
> There are still real concerns in my mind about lingering addresses in
> registers that gcc might leave hanging around. The call nicely removes
> the worries.

In theory, gcc is free to reload esp from a cached register after
disable_car. That would cause pretty explosions due to the stack pointer
being in a now invalid location.

Although I really don't like it, I think a safe and still readable way
would be to rename stage1() to stage1_early(), rename stage1_after_car()
to stage1_late() and rename disable_car() to
disable_car_and_continue_at_stage1_late() would be pure asm (probably
even in a .S file and not just inline asm) and could take care of
setting up the stack correctly and using the right calling convention.
That would work regardless of gcc optimizations.

There is another related problem (but independent of CAR switching):
How do we find out where our global variables live? Their location
changes at a certain point in time (stack switch) and we need a function
which is short, fast and will always tell us about whether the stack is
at the in-CAR or post-CAR location. A one-bit variable would be enough,
and even better if it is independent from CAR so we can set it during
stack switch from asm.



More information about the coreboot mailing list