Message ID | 20170116140427.29283-27-sjg@chromium.org |
---|---|
State | Accepted |
Commit | fb92308b983d54f6275ae0ced0e6930dfcc5bdec |
Delegated to: | Bin Meng |
Headers | show |
On Mon, Jan 16, 2017 at 10:03 PM, Simon Glass <sjg@chromium.org> wrote: > Since 'gd' is just a normal variable on 64-bit x86, it is relocated by the > time we get to board_init_r(). The old 'gd' variable is passed in as > parameter to board_init_r(), presumably for this situation. > > Assign it on 64-bit x86 so that gd points to the correct data. > > Options to improve this: > - Make gd a fixed register and remove the board_init_r() parameter > - Make all archs use this board_init_r() parameter > > The second has a TODO in the code. The first has a TODO in a future commit > ('x86: Support global_data on x86_64') > > Signed-off-by: Simon Glass <sjg@chromium.org> > --- > > Changes in v3: > - Add a TODO to board_init_r() regarding the use of the new_gd parameter > > Changes in v2: None > > common/board_r.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
On Tue, Jan 17, 2017 at 10:29 AM, Bin Meng <bmeng.cn@gmail.com> wrote: > On Mon, Jan 16, 2017 at 10:03 PM, Simon Glass <sjg@chromium.org> wrote: >> Since 'gd' is just a normal variable on 64-bit x86, it is relocated by the >> time we get to board_init_r(). The old 'gd' variable is passed in as >> parameter to board_init_r(), presumably for this situation. >> >> Assign it on 64-bit x86 so that gd points to the correct data. >> >> Options to improve this: >> - Make gd a fixed register and remove the board_init_r() parameter >> - Make all archs use this board_init_r() parameter >> >> The second has a TODO in the code. The first has a TODO in a future commit >> ('x86: Support global_data on x86_64') >> >> Signed-off-by: Simon Glass <sjg@chromium.org> >> --- >> >> Changes in v3: >> - Add a TODO to board_init_r() regarding the use of the new_gd parameter >> >> Changes in v2: None >> >> common/board_r.c | 10 ++++++++++ >> 1 file changed, 10 insertions(+) >> > > Reviewed-by: Bin Meng <bmeng.cn@gmail.com> applied to u-boot-x86, thanks!
diff --git a/common/board_r.c b/common/board_r.c index 1bdd5a35366..ddfb1e1fcad 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -974,6 +974,16 @@ static init_fnc_t init_sequence_r[] = { void board_init_r(gd_t *new_gd, ulong dest_addr) { + /* + * Set up the new global data pointer. So far only x86 does this + * here. + * TODO(sjg@chromium.org): Consider doing this for all archs, or + * dropping the new_gd parameter. + */ +#if CONFIG_IS_ENABLED(X86_64) + arch_setup_gd(new_gd); +#endif + #ifdef CONFIG_NEEDS_MANUAL_RELOC int i; #endif
Since 'gd' is just a normal variable on 64-bit x86, it is relocated by the time we get to board_init_r(). The old 'gd' variable is passed in as parameter to board_init_r(), presumably for this situation. Assign it on 64-bit x86 so that gd points to the correct data. Options to improve this: - Make gd a fixed register and remove the board_init_r() parameter - Make all archs use this board_init_r() parameter The second has a TODO in the code. The first has a TODO in a future commit ('x86: Support global_data on x86_64') Signed-off-by: Simon Glass <sjg@chromium.org> --- Changes in v3: - Add a TODO to board_init_r() regarding the use of the new_gd parameter Changes in v2: None common/board_r.c | 10 ++++++++++ 1 file changed, 10 insertions(+)