BACKPORT: x86: add cache-as-ram migration option
There are some boards that do a significant amount of work after cache-as-ram is torn down but before ramstage is loaded. For example, using vboot to verify the ramstage is one such operation. However, there are pieces of code that are executed that reference global variables that are linked in the cache-as-ram region. If those variables are referenced after cache-as-ram is torn down then the values observed will most likely be incorrect. Therefore provide a Kconfig option to select cache-as-ram migration to memory using cbmem. This option is named CAR_MIGRATION. When enabled, the address of cache-as-ram variables may be obtained dynamically. Additionally, when cache-as-ram migration occurs the cache-as-ram data region for global variables is copied into cbmem. There are also automatic callbacks for other modules to perform their own migration, if necessary. BUG=chrome-os-partner:19342 BRANCH=none TEST=Built and booted. Noted that CAR values are not read incorrectly. Change-Id: Ie0104a6e24cc6430a575ee3691671900c36db0d9 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/51386 Reviewed-by: Stefan Reinauer <reinauer@google.com>
This commit is contained in:
parent
3593f8f1ef
commit
2e9e50142f
10 changed files with 168 additions and 0 deletions
|
|
@ -69,6 +69,7 @@
|
|||
#define CBMEM_ID_RAMSTAGE_CACHE 0x9a3ca54e
|
||||
#define CBMEM_ID_ROOT 0xff4007ff
|
||||
#define CBMEM_ID_VBOOT_HANDOFF 0x780074f0
|
||||
#define CBMEM_ID_CAR_GLOBALS 0xcac4e6a3
|
||||
#define CBMEM_ID_NONE 0x00000000
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
|
|
|
|||
|
|
@ -28,4 +28,33 @@
|
|||
#define CAR_CBMEM
|
||||
#endif
|
||||
|
||||
#if CONFIG_CAR_MIGRATION && defined(__PRE_RAM__)
|
||||
#define CAR_MIGRATE_ATTR __attribute__ ((used,section (".car.migrate")))
|
||||
|
||||
/* Call migrate_fn_() when CAR globals are migrated. */
|
||||
#define CAR_MIGRATE(migrate_fn_) \
|
||||
static void (* const migrate_fn_ ## _ptr)(void) CAR_MIGRATE_ATTR = \
|
||||
migrate_fn_;
|
||||
|
||||
/* Get the correct pointer for the CAR global variable. */
|
||||
void *car_get_var_ptr(void *var);
|
||||
|
||||
/* Get and set a primitive type global variable. */
|
||||
#define car_get_var(var) \
|
||||
*(typeof(var) *)car_get_var_ptr(&(var))
|
||||
#define car_set_var(var, val) \
|
||||
do { car_get_var(var) = (val); } while(0)
|
||||
|
||||
/* Migrate the CAR variables to memory. */
|
||||
void car_migrate_variables(void);
|
||||
|
||||
#else
|
||||
#define CAR_MIGRATE(migrate_fn_)
|
||||
static inline void *car_get_var_ptr(void *var) { return var; }
|
||||
#define car_get_var(var) (var)
|
||||
#define car_set_var(var, val) do { (var) = (val); } while (0)
|
||||
static inline void car_migrate_variables(void) { }
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue