summaryrefslogtreecommitdiff
path: root/src/vendorcode/google
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@google.com>2016-06-29 11:26:27 -0700
committerDuncan Laurie <dlaurie@chromium.org>2016-06-30 20:54:04 +0200
commitbe87f73c68a81b48aec0d651a8bde52aa37f3690 (patch)
treef5c0af339b87563b734488a1a09468f9d768eaca /src/vendorcode/google
parent9a0c9ac912b4bc4248cdada2889a13e48a06d28d (diff)
downloadcoreboot-be87f73c68a81b48aec0d651a8bde52aa37f3690.tar.xz
vbnv: Do not initialize vbnv_copy in vbnv layer
If read_vbnv finds that the vbnv_copy is not valid, it initializes it with the correct HEADER_SIGNATURE and other attributes. However, the vbnv copy is checked for validity and initialized at the vboot layer as well. Since, vboot is the owner of this data, it should be the one initializing it. Thus, if read_vbnv sees that the data is not valid, simply reset it to all 0s and let vboot layer take care of it. This also removes the need for additional checks to ensure that the dirty vbnv copy is properly updated on storage. Change-Id: I6101ac41f31f720a6e357c9c56e571d62e0f2f47 Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://review.coreboot.org/15498 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'src/vendorcode/google')
-rw-r--r--src/vendorcode/google/chromeos/vbnv.c15
-rw-r--r--src/vendorcode/google/chromeos/vbnv.h7
-rw-r--r--src/vendorcode/google/chromeos/vboot2/vboot_logic.c8
3 files changed, 6 insertions, 24 deletions
diff --git a/src/vendorcode/google/chromeos/vbnv.c b/src/vendorcode/google/chromeos/vbnv.c
index baccb2313d..9fd97a0362 100644
--- a/src/vendorcode/google/chromeos/vbnv.c
+++ b/src/vendorcode/google/chromeos/vbnv.c
@@ -59,14 +59,9 @@ static uint8_t crc8_vbnv(const uint8_t *data, int len)
return (uint8_t) (crc >> 8);
}
-/* Reset header and CRC to defaults. */
static void reset_vbnv(uint8_t *vbnv_copy)
{
memset(vbnv_copy, 0, VBNV_BLOCK_SIZE);
- vbnv_copy[HEADER_OFFSET] = HEADER_SIGNATURE |
- HEADER_FIRMWARE_SETTINGS_RESET |
- HEADER_KERNEL_SETTINGS_RESET;
- vbnv_copy[CRC_OFFSET] = crc8_vbnv(vbnv_copy, CRC_OFFSET);
}
/* Read VBNV data into cache. */
@@ -88,9 +83,8 @@ int verify_vbnv(uint8_t *vbnv_copy)
/*
* Read VBNV data from configured storage backend.
* If VBNV verification fails, reset the vbnv copy.
- * Returns 1 if write-back of vbnv copy is required. Else, returns 0.
*/
-int read_vbnv(uint8_t *vbnv_copy)
+void read_vbnv(uint8_t *vbnv_copy)
{
if (IS_ENABLED(CONFIG_CHROMEOS_VBNV_CMOS))
read_vbnv_cmos(vbnv_copy);
@@ -100,11 +94,8 @@ int read_vbnv(uint8_t *vbnv_copy)
read_vbnv_flash(vbnv_copy);
/* Check data for consistency */
- if (verify_vbnv(vbnv_copy))
- return 0;
-
- reset_vbnv(vbnv_copy);
- return 1;
+ if (!verify_vbnv(vbnv_copy))
+ reset_vbnv(vbnv_copy);
}
/*
diff --git a/src/vendorcode/google/chromeos/vbnv.h b/src/vendorcode/google/chromeos/vbnv.h
index a66d687fe5..5d21cc8481 100644
--- a/src/vendorcode/google/chromeos/vbnv.h
+++ b/src/vendorcode/google/chromeos/vbnv.h
@@ -19,12 +19,7 @@
#include <types.h>
/* Generic functions */
-/*
- * Return value for read_vbnv:
- * 1 = write-back of vbnv copy is required.
- * 0 = otherwise
- */
-int read_vbnv(uint8_t *vbnv_copy);
+void read_vbnv(uint8_t *vbnv_copy);
void save_vbnv(const uint8_t *vbnv_copy);
int verify_vbnv(uint8_t *vbnv_copy);
int get_recovery_mode_from_vbnv(void);
diff --git a/src/vendorcode/google/chromeos/vboot2/vboot_logic.c b/src/vendorcode/google/chromeos/vboot2/vboot_logic.c
index 116c9498d9..4c799c9a4f 100644
--- a/src/vendorcode/google/chromeos/vboot2/vboot_logic.c
+++ b/src/vendorcode/google/chromeos/vboot2/vboot_logic.c
@@ -301,12 +301,8 @@ void verstage_main(void)
/* Set up context and work buffer */
vb2_init_work_context(&ctx);
- /*
- * Read nvdata from a non-volatile storage and mark data as changed
- * if instructed.
- */
- if (read_vbnv(ctx.nvdata))
- ctx.flags |= VB2_CONTEXT_NVDATA_CHANGED;
+ /* Read nvdata from a non-volatile storage. */
+ read_vbnv(ctx.nvdata);
/* Set S3 resume flag if vboot should behave differently when selecting
* which slot to boot. This is only relevant to vboot if the platform