[coreboot] global_vars

Kevin O'Connor kevin at koconnor.net
Tue Sep 9 03:18:11 CEST 2008


I was looking through the v3 code and came across this:

void *bottom_of_stack(void)
        /* -4 because CONFIG_CARBASE + CONFIG_CARSIZE - 4 is initial %esp */
        return (void *)(CONFIG_CARBASE + CONFIG_CARSIZE - 4);

struct global_vars *global_vars(void)
        return *(struct global_vars **)(bottom_of_stack() - sizeof(struct global_var\
s *));


void __attribute__((stdcall)) stage1_main(u32 bist, u32 init_detected)
        struct global_vars globvars;

If I understand the code correctly, the global_vars() function is
trying to get at the stack variable globvars declared in stage1_main.
It's not valid to do that - the compiler is free to re-order stack
variables, change them, or otherwise do funky things.

A better way to do this would be to have some assembler code prior to
stage1_main() reserve the space for globvars.


More information about the coreboot mailing list