[Skiboot] [PATCH] nvram: run nvram_validate() after nvram_reformat()

Nicholas Piggin npiggin at gmail.com
Mon Mar 26 16:02:44 AEDT 2018


nvram_reformat() sets nvram_valid = true, but it does not set
skiboot_part_hdr. Call nvram_validate() instead, which sets
everything up properly.

Reviewed-by: Oliver O'Halloran <oohall at gmail.com>
Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
---

This replaces "[PATCH 1/2] nvram: nvram_query do not run if no nvram
was found". Patch 2/2 in that series should still be good.

Thanks,
Nick

 core/nvram-format.c | 3 +++
 core/nvram.c        | 8 +++++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/core/nvram-format.c b/core/nvram-format.c
index 3d030a30..42c5cbbb 100644
--- a/core/nvram-format.c
+++ b/core/nvram-format.c
@@ -180,6 +180,7 @@ int nvram_check(void *nvram_image, const uint32_t nvram_size)
 	}
 
 	prlog(PR_INFO, "NVRAM: Layout appears sane\n");
+	assert(skiboot_part_hdr);
 	return 0;
  failed:
 	return -1;
@@ -234,6 +235,8 @@ const char *nvram_query(const char *key)
 	if (!nvram_validate())
 		return NULL;
 
+	assert(skiboot_part_hdr);
+
 	part_end = (const char *) skiboot_part_hdr
 		+ be16_to_cpu(skiboot_part_hdr->len) * 16 - 1;
 
diff --git a/core/nvram.c b/core/nvram.c
index de6cbddf..1c3cdfaf 100644
--- a/core/nvram.c
+++ b/core/nvram.c
@@ -69,8 +69,10 @@ opal_call(OPAL_WRITE_NVRAM, opal_write_nvram, 3);
 
 bool nvram_validate(void)
 {
-	if (!nvram_valid)
-		nvram_valid = !nvram_check(nvram_image, nvram_size);
+	if (!nvram_valid) {
+		if (!nvram_check(nvram_image, nvram_size))
+			nvram_valid = true;
+	}
 
 	return nvram_valid;
 }
@@ -87,7 +89,7 @@ static void nvram_reformat(void)
 	if (platform.nvram_write)
 		platform.nvram_write(0, nvram_image, nvram_size);
 
-	nvram_valid = true;
+	nvram_validate();
 }
 
 void nvram_reinit(void)
-- 
2.16.1



More information about the Skiboot mailing list