diff options
author | Oliver O'Halloran <oohall@gmail.com> | 2016-08-17 15:32:50 +1000 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2016-08-30 16:59:47 +1000 |
commit | e9833175edd7a5a63841bd6c7e8e63c50604e480 (patch) | |
tree | bc40245cd7379a68c5b63d0abf22344f436b1cbd /core/nvram.c | |
parent | 6024e93adf62fab2fb725e9e98fd853b57a35bc4 (diff) | |
download | skiboot-e9833175edd7a5a63841bd6c7e8e63c50604e480.zip skiboot-e9833175edd7a5a63841bd6c7e8e63c50604e480.tar.gz skiboot-e9833175edd7a5a63841bd6c7e8e63c50604e480.tar.bz2 |
core/init: recheck nvram on fast reboot
If the previously running OS modifies the NVRAM it may be left in an
invalid state. To prevent errors we need to re-validate the nvram format
in the fast-reboot path.
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'core/nvram.c')
-rw-r--r-- | core/nvram.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/core/nvram.c b/core/nvram.c index 9a9a6ff..3ae0f12 100644 --- a/core/nvram.c +++ b/core/nvram.c @@ -59,6 +59,28 @@ static int64_t opal_write_nvram(uint64_t buffer, uint64_t size, uint64_t offset) } opal_call(OPAL_WRITE_NVRAM, opal_write_nvram, 3); +static void nvram_validate(void) +{ + /* Check and maybe format nvram */ + if (nvram_check(nvram_image, nvram_size)) { + if (nvram_format(nvram_image, nvram_size)) + prerror("NVRAM: Failed to format NVRAM!\n"); + + /* Write the whole thing back */ + if (platform.nvram_write) + platform.nvram_write(0, nvram_image, nvram_size); + } +} + +void nvram_reinit(void) +{ + /* It's possible we failed to load nvram at boot. */ + if (!nvram_ready) + nvram_init(); + else + nvram_validate(); +} + void nvram_read_complete(bool success) { struct dt_node *np; @@ -70,15 +92,7 @@ void nvram_read_complete(bool success) return; } - /* Check and maybe format nvram */ - if (nvram_check(nvram_image, nvram_size)) { - if (nvram_format(nvram_image, nvram_size)) - prerror("NVRAM: Failed to format NVRAM!\n"); - - /* Write the whole thing back */ - if (platform.nvram_write) - platform.nvram_write(0, nvram_image, nvram_size); - } + nvram_validate(); /* Add nvram node */ np = dt_new(opal_node, "nvram"); |