Stefan Reinauer (stefan.reinauer(a)coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/9565
-gerrit
commit 707e20e1d9f16910923f1bb042fdb252212fdc20
Author: Julius Werner <jwerner(a)chromium.org>
Date: Thu Jan 29 17:50:58 2015 -0800
vboot2: Fill vboot1 handoff with correct TPM firmware version
sd->fw_version represents the version of the *current* firmware, which
is not necessarily the same as the one stored in the TPM (and may be 0
in recovery mode). Use the newly added sd->fw_version_secdata instead
which contains a more correct value.
CQ-DEPEND=CL:244601
BRANCH=veyron
BUG=chrome-os-partner:35941
TEST=Booted Jerry in recovery mode, confirmed crossystem tpm_fwver was
corrent (and not 0).
Change-Id: I30f5998da5ac518d6fcb7a651eba4e1fabc14478
Signed-off-by: Stefan Reinauer <reinauer(a)chromium.org>
Original-Commit-Id: eb8142f69cea34e11f9081caafcaae7a15cc3801
Original-Change-Id: Id95bd8c6412f2e8b2ae643c3b5a3dee13d0d47be
Original-Signed-off-by: Julius Werner <jwerner(a)chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/244591
Original-Reviewed-by: Randall Spangler <rspangler(a)chromium.org>
---
src/vendorcode/google/chromeos/vboot2/vboot_handoff.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/vendorcode/google/chromeos/vboot2/vboot_handoff.c b/src/vendorcode/google/chromeos/vboot2/vboot_handoff.c
index 33ff79a..87ea289 100644
--- a/src/vendorcode/google/chromeos/vboot2/vboot_handoff.c
+++ b/src/vendorcode/google/chromeos/vboot2/vboot_handoff.c
@@ -79,7 +79,7 @@ static void fill_vboot_handoff(struct vboot_handoff *vboot_handoff,
vb_sd->struct_size = sizeof(VbSharedDataHeader);
vb_sd->data_size = VB_SHARED_DATA_MIN_SIZE;
vb_sd->data_used = sizeof(VbSharedDataHeader);
- vb_sd->fw_version_tpm = vb2_sd->fw_version;
+ vb_sd->fw_version_tpm = vb2_sd->fw_version_secdata;
if (get_write_protect_state())
vb_sd->flags |= VBSD_BOOT_FIRMWARE_WP_ENABLED;
Stefan Reinauer (stefan.reinauer(a)coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/9563
-gerrit
commit 3ce2998b8447ebefc83b669c8580a8f623dcb789
Author: David Hendricks <dhendrix(a)chromium.org>
Date: Fri Jan 2 15:46:57 2015 -0800
chromeos: add get_recovery_mode_from_vbnv() to vbnv_flash
The first platform that used flash-backed VBNV data has a physical
recovery switch, get_recovery_mode_from_vbnv() was never implemented.
This patch adds get_recovery_mode_from_vbnv() similarly to how it's
implemented for other vbnv storage in other places.
BUG=chrome-os-partner:34436
BRANCH=none
TEST=needs testing
Change-Id: Ifd795c5c1ff0f23619fd2125b4795571af03ece1
Signed-off-by: Stefan Reinauer <reinauer(a)chromium.org>
Original-Commit-Id: 09f1bf96089bf9d159e4220c1f4d99388d709545
Original-Signed-off-by: David Hendricks <dhendrix(a)chromium.org>
Original-Change-Id: I9cf18c988eaa4b7e720d6c66a02b1c5c63b473e9
Original-Reviewed-on: https://chromium-review.googlesource.com/239978
Original-Reviewed-by: Julius Werner <jwerner(a)chromium.org>
---
src/vendorcode/google/chromeos/vbnv_flash.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/vendorcode/google/chromeos/vbnv_flash.c b/src/vendorcode/google/chromeos/vbnv_flash.c
index e880ed4..97a2a82 100644
--- a/src/vendorcode/google/chromeos/vbnv_flash.c
+++ b/src/vendorcode/google/chromeos/vbnv_flash.c
@@ -15,6 +15,8 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * TODO: Make this CAR-friendly in case we use it on x86 some day.
*/
#include <cbfs.h>
@@ -25,6 +27,7 @@
#include <vb2_api.h>
#include <vboot_nvstorage.h>
#include "chromeos.h"
+#include "vbnv_layout.h"
#if IS_ENABLED(CONFIG_VBOOT_VERIFY_FIRMWARE)
#define BLOB_SIZE VBNV_BLOCK_SIZE
@@ -189,3 +192,10 @@ void save_vbnv(const uint8_t *vbnv_copy)
printk(BIOS_ERR, "failed to save nvdata\n");
}
}
+
+int get_recovery_mode_from_vbnv(void)
+{
+ if (!is_initialized())
+ init_vbnv();
+ return cache[RECOVERY_OFFSET];
+}
Stefan Reinauer (stefan.reinauer(a)coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/9562
-gerrit
commit f678db79ff9030daf4b93c21ebf59923ac623e75
Author: Julius Werner <jwerner(a)chromium.org>
Date: Wed Jan 14 13:12:10 2015 -0800
chromeos: Reverse FMAP signature constant to avoid having it in .rodata
Even though coreboot always hardcodes the FMAP offset, the same is not
possible for all other tools that manipulate ROM images. Some need to
manually find the FMAP by searching for it's magic number (ASCII
"__FMAP__"). If we do something like 'memcmp(fmap_buffer, "__FMAP__",
...) in coreboot code, it has the unfortunate side effect that the
compiler will output that very same magic number as a constant in the
.rodata section to compare against. Other tools may mistake this for the
"real" FMAP location and get confused.
This patch reverses the constant defined in coreboot and changes the
only use of it correspondingly. It is not impossible but extremely
unlikely (at the current state of the art) that any compiler would be
clever enough to understand this pattern and optimize it back to a
straight memcmp() (GCC 4.9 definitely doesn't), so it should solve the
problem at least for another few years/decades.
BRANCH=veyron
BUG=chromium:447051
TEST=Made sure the new binaries actually contain "__PAMF__" in their
.rodata. Booted Pinky. Independently corrupted both the first and the
last byte of the FMAP signature with a hex editor and confirmed that
signature check fails in both cases.
Change-Id: I314b5e7e4d78352f409e73a3ed0e71d1b56fe774
Signed-off-by: Stefan Reinauer <reinauer(a)chromium.org>
Original-Commit-Id: 1359d2d4502eb34a043dffab35cf4a5b033ed65a
Original-Change-Id: I725652ef2a77f7f99884b46498428c3d68cd0945
Original-Signed-off-by: Julius Werner <jwerner(a)chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/240723
Original-Reviewed-by: Daisuke Nojiri <dnojiri(a)chromium.org>
Original-Reviewed-by: David Hendricks <dhendrix(a)chromium.org>
---
src/vendorcode/google/chromeos/fmap.c | 13 +++++++++----
src/vendorcode/google/chromeos/fmap.h | 2 +-
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/vendorcode/google/chromeos/fmap.c b/src/vendorcode/google/chromeos/fmap.c
index 50b0248..21d439e 100644
--- a/src/vendorcode/google/chromeos/fmap.c
+++ b/src/vendorcode/google/chromeos/fmap.c
@@ -26,10 +26,15 @@
static int is_fmap_signature_valid(const struct fmap *fmap)
{
- if (memcmp(fmap, FMAP_SIGNATURE, sizeof(FMAP_SIGNATURE) - 1)) {
- printk(BIOS_ERR, "No FMAP found at %p.\n", fmap);
- return 1;
- }
+ const char reversed_sig[] = FMAP_REVERSED_SIGNATURE;
+ const char *p2 = reversed_sig + sizeof(FMAP_REVERSED_SIGNATURE) - 2;
+ const char *p1 = (char *)fmap;
+
+ while (p2 >= reversed_sig)
+ if (*p1++ != *p2--) {
+ printk(BIOS_ERR, "No FMAP found at %p.\n", fmap);
+ return 1;
+ }
printk(BIOS_DEBUG, "FMAP: Found \"%s\" version %d.%d at %p.\n",
fmap->name, fmap->ver_major, fmap->ver_minor, fmap);
diff --git a/src/vendorcode/google/chromeos/fmap.h b/src/vendorcode/google/chromeos/fmap.h
index a3d2abd..05d3fb6 100644
--- a/src/vendorcode/google/chromeos/fmap.h
+++ b/src/vendorcode/google/chromeos/fmap.h
@@ -38,7 +38,7 @@
#include <stdint.h>
-#define FMAP_SIGNATURE "__FMAP__"
+#define FMAP_REVERSED_SIGNATURE "__PAMF__" /* avoid magic number in .rodata */
#define FMAP_VER_MAJOR 1 /* this header's FMAP minor version */
#define FMAP_VER_MINOR 1 /* this header's FMAP minor version */
#define FMAP_STRLEN 32 /* maximum length for strings, */
Stefan Reinauer (stefan.reinauer(a)coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/9561
-gerrit
commit f1156e389082ec109c742f91e5c3d30aa72771cb
Author: Vadim Bendebury <vbendeb(a)chromium.org>
Date: Sat Jan 10 23:11:43 2015 -0800
vbnv flash: use proper SPI flash offset for NVRAM
The current vbnv flash code mistakenly uses the offset into the NVRAM
area as the absolute offset into the SPI NOR. This causes overwrites
RO section of the flash (when it is not protected) and causes failures
to retrieve the NVRAM contents by the user space apps.
This patch makes sure that the correct offset is used when accessing
NVRAM area in the SPI flash.
BRANCH=storm
BUG=chrome-os-partner:35316
TEST=run the update code on storm.
- no more RO section corruption observed
- running 'crossystem recovery_request=1' at Linux prompt causes the
next boot happen in recovery mode
Change-Id: Iba96cd2e0e5e01c990f8c1de8d2a2233cd9e9bc9
Signed-off-by: Stefan Reinauer <reinauer(a)chromium.org>
Original-Commit-Id: 9fd15ff4b7aa77536723edbb94fa81f0ae767aed
Original-Change-Id: I86fe4b9a35f7c16b72abf49cfbfcd42cc87937e3
Original-Signed-off-by: Vadim Bendebury <vbendeb(a)chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/240143
Original-Reviewed-by: Daisuke Nojiri <dnojiri(a)chromium.org>
---
src/vendorcode/google/chromeos/vbnv_flash.c | 45 +++++++++++++++--------------
1 file changed, 24 insertions(+), 21 deletions(-)
diff --git a/src/vendorcode/google/chromeos/vbnv_flash.c b/src/vendorcode/google/chromeos/vbnv_flash.c
index 3d4581f..e880ed4 100644
--- a/src/vendorcode/google/chromeos/vbnv_flash.c
+++ b/src/vendorcode/google/chromeos/vbnv_flash.c
@@ -37,9 +37,12 @@
/* FMAP descriptor of the NVRAM area */
static struct vboot_region nvram_region;
-/* offset of the current nvdata in nvram */
+/* offset of the current nvdata in SPI flash */
static int blob_offset = -1;
+/* Offset of the topmost nvdata blob in SPI flash */
+static int top_offset;
+
/* cache of the current nvdata */
static uint8_t cache[BLOB_SIZE];
@@ -83,13 +86,16 @@ static int init_vbnv(void)
for (i = 0; i < BLOB_SIZE; i++)
empty_blob[i] = erase_value();
+ offset = nvram_region.offset_addr;
+ top_offset = nvram_region.offset_addr + nvram_region.size - BLOB_SIZE;
+
/*
- * after the loop, offset is supposed to point the blob right before the
- * first empty blob, the last blob in the nvram if there is no empty
- * blob, or 0 if the nvram has never been used.
+ * after the loop, offset is supposed to point the blob right before
+ * the first empty blob, the last blob in the nvram if there is no
+ * empty blob, or the base of the region if the nvram has never been
+ * used.
*/
- for (i = 0, offset = 0; i <= nvram_region.size - BLOB_SIZE;
- i += BLOB_SIZE) {
+ for (i = offset; i <= top_offset; i += BLOB_SIZE) {
if (vboot_get_region(i, BLOB_SIZE, buf) == NULL) {
printk(BIOS_ERR, "failed to read nvdata\n");
return 1;
@@ -147,7 +153,7 @@ void read_vbnv(uint8_t *vbnv_copy)
void save_vbnv(const uint8_t *vbnv_copy)
{
- int new_offset = blob_offset;
+ int new_offset;
int i;
if (!is_initialized())
@@ -158,31 +164,28 @@ void save_vbnv(const uint8_t *vbnv_copy)
if (!memcmp(vbnv_copy, cache, BLOB_SIZE))
return;
+ new_offset = blob_offset;
+
/* See if we can overwrite the current blob with the new one */
for (i = 0; i < BLOB_SIZE; i++) {
if (!can_overwrite(cache[i], vbnv_copy[i])) {
/* unable to overwrite. need to use the next blob */
new_offset += BLOB_SIZE;
- if (new_offset > nvram_region.size - BLOB_SIZE) {
+ if (new_offset > top_offset) {
if (erase_nvram())
return; /* error */
- new_offset = 0;
+ new_offset = nvram_region.offset_addr;
}
break;
}
}
- if (vbnv_flash_probe())
- return; /* error */
-
- if (spi_flash->write(spi_flash, new_offset, BLOB_SIZE, vbnv_copy)) {
- printk(BIOS_ERR, "failed to write nvdata\n");
- return; /* error */
+ if (!vbnv_flash_probe() &&
+ !spi_flash->write(spi_flash, new_offset, BLOB_SIZE, vbnv_copy)) {
+ /* write was successful. safely move pointer forward */
+ blob_offset = new_offset;
+ memcpy(cache, vbnv_copy, BLOB_SIZE);
+ } else {
+ printk(BIOS_ERR, "failed to save nvdata\n");
}
-
- /* write was successful. safely move pointer forward */
- blob_offset = new_offset;
- memcpy(cache, vbnv_copy, BLOB_SIZE);
-
- return;
}
Stefan Reinauer (stefan.reinauer(a)coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/9560
-gerrit
commit 5be1dd8fdaa3ea24a45a4ae5d61c65d8e1059de5
Author: David Hendricks <dhendrix(a)chromium.org>
Date: Fri Jan 2 15:16:41 2015 -0800
chromeos: Move common VBNV offsets to a header
Some common VBNV variable offsets were defined in multiple vbnv_*
source files. This moves them to a header so that we can avoid
duplicating them in the future.
BUG=none
BRANCH=none
TEST=compiled for nyan_blaze and rambi
Change-Id: Ic292e546b665b40678b4de598783c1f6bfa35426
Signed-off-by: Stefan Reinauer <reinauer(a)chromium.org>
Original-Commit-Id: fd776f303a3d057d4b70997e7bb6bc85767e2278
Original-Signed-off-by: David Hendricks <dhendrix(a)chromium.org>
Original-Change-Id: Ifcc13c90a910b86d4f9bb0027d913572c1d6d00b
Original-Reviewed-on: https://chromium-review.googlesource.com/239977
Original-Reviewed-by: Aaron Durbin <adurbin(a)chromium.org>
Original-Reviewed-by: Julius Werner <jwerner(a)chromium.org>
Original-Reviewed-by: Randall Spangler <rspangler(a)chromium.org>
---
src/vendorcode/google/chromeos/vbnv_cmos.c | 29 +---------------
src/vendorcode/google/chromeos/vbnv_ec.c | 29 +---------------
src/vendorcode/google/chromeos/vbnv_layout.h | 51 ++++++++++++++++++++++++++++
3 files changed, 53 insertions(+), 56 deletions(-)
diff --git a/src/vendorcode/google/chromeos/vbnv_cmos.c b/src/vendorcode/google/chromeos/vbnv_cmos.c
index 7c22c6b..f87eab7 100644
--- a/src/vendorcode/google/chromeos/vbnv_cmos.c
+++ b/src/vendorcode/google/chromeos/vbnv_cmos.c
@@ -27,34 +27,7 @@
#if IS_ENABLED(CONFIG_VBOOT_VERIFY_FIRMWARE)
#include "vboot_handoff.h"
#endif
-
-#define VBNV_BLOCK_SIZE 16 /* Size of NV storage block in bytes */
-
-/* Constants for NV storage. We use this rather than structs and
- * bitfields so the data format is consistent across platforms and
- * compilers.
- */
-#define HEADER_OFFSET 0
-#define HEADER_MASK 0xC0
-#define HEADER_SIGNATURE 0x40
-#define HEADER_FIRMWARE_SETTINGS_RESET 0x20
-#define HEADER_KERNEL_SETTINGS_RESET 0x10
-
-#define BOOT_OFFSET 1
-#define BOOT_DEBUG_RESET_MODE 0x80
-#define BOOT_DISABLE_DEV_REQUEST 0x40
-#define BOOT_OPROM_NEEDED 0x20
-#define BOOT_TRY_B_COUNT_MASK 0x0F
-
-#define RECOVERY_OFFSET 2
-#define LOCALIZATION_OFFSET 3
-
-#define DEV_FLAGS_OFFSET 4
-#define DEV_BOOT_USB_MASK 0x01
-#define DEV_BOOT_SIGNED_ONLY_MASK 0x02
-
-#define KERNEL_FIELD_OFFSET 11
-#define CRC_OFFSET 15
+#include "vbnv_layout.h"
static int vbnv_initialized CAR_GLOBAL;
static uint8_t vbnv[CONFIG_VBNV_SIZE] CAR_GLOBAL;
diff --git a/src/vendorcode/google/chromeos/vbnv_ec.c b/src/vendorcode/google/chromeos/vbnv_ec.c
index 78da541..403b4c3 100644
--- a/src/vendorcode/google/chromeos/vbnv_ec.c
+++ b/src/vendorcode/google/chromeos/vbnv_ec.c
@@ -23,34 +23,7 @@
#include <arch/early_variables.h>
#include <ec/google/chromeec/ec.h>
#include "chromeos.h"
-
-#define VBNV_BLOCK_SIZE 16 /* Size of NV storage block in bytes */
-
-/* Constants for NV storage. We use this rather than structs and
- * bitfields so the data format is consistent across platforms and
- * compilers.
- */
-#define HEADER_OFFSET 0
-#define HEADER_MASK 0xC0
-#define HEADER_SIGNATURE 0x40
-#define HEADER_FIRMWARE_SETTINGS_RESET 0x20
-#define HEADER_KERNEL_SETTINGS_RESET 0x10
-
-#define BOOT_OFFSET 1
-#define BOOT_DEBUG_RESET_MODE 0x80
-#define BOOT_DISABLE_DEV_REQUEST 0x40
-#define BOOT_OPROM_NEEDED 0x20
-#define BOOT_TRY_B_COUNT_MASK 0x0F
-
-#define RECOVERY_OFFSET 2
-#define LOCALIZATION_OFFSET 3
-
-#define DEV_FLAGS_OFFSET 4
-#define DEV_BOOT_USB_MASK 0x01
-#define DEV_BOOT_SIGNED_ONLY_MASK 0x02
-
-#define KERNEL_FIELD_OFFSET 11
-#define CRC_OFFSET 15
+#include "vbnv_layout.h"
static int vbnv_initialized CAR_GLOBAL;
static uint8_t vbnv[VBNV_BLOCK_SIZE] CAR_GLOBAL;
diff --git a/src/vendorcode/google/chromeos/vbnv_layout.h b/src/vendorcode/google/chromeos/vbnv_layout.h
new file mode 100644
index 0000000..66de405
--- /dev/null
+++ b/src/vendorcode/google/chromeos/vbnv_layout.h
@@ -0,0 +1,51 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2015 The ChromiumOS Authors. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef VBNV_LAYOUT_H
+#define VBNV_LAYOUT_H
+
+#define VBNV_BLOCK_SIZE 16 /* Size of NV storage block in bytes */
+
+/* Constants for NV storage. We use this rather than structs and
+ * bitfields so the data format is consistent across platforms and
+ * compilers.
+ */
+#define HEADER_OFFSET 0
+#define HEADER_MASK 0xC0
+#define HEADER_SIGNATURE 0x40
+#define HEADER_FIRMWARE_SETTINGS_RESET 0x20
+#define HEADER_KERNEL_SETTINGS_RESET 0x10
+
+#define BOOT_OFFSET 1
+#define BOOT_DEBUG_RESET_MODE 0x80
+#define BOOT_DISABLE_DEV_REQUEST 0x40
+#define BOOT_OPROM_NEEDED 0x20
+#define BOOT_TRY_B_COUNT_MASK 0x0F
+
+#define RECOVERY_OFFSET 2
+#define LOCALIZATION_OFFSET 3
+
+#define DEV_FLAGS_OFFSET 4
+#define DEV_BOOT_USB_MASK 0x01
+#define DEV_BOOT_SIGNED_ONLY_MASK 0x02
+
+#define KERNEL_FIELD_OFFSET 11
+#define CRC_OFFSET 15
+
+#endif /* VBNV_LAYOUT_H */
Stefan Reinauer (stefan.reinauer(a)coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/9559
-gerrit
commit 92c08213119e3e8c31756d417e56e3754ecd3cdc
Author: Duncan Laurie <dlaurie(a)chromium.org>
Date: Wed Nov 19 14:14:07 2014 -0800
vboot1: Set BEFORE_OPROM_LOAD flag for VbInit()
This sets the new VB_INIT_FLAG_BEFORE_OPROM_LOAD flag for VbInit()
to indicate that we are running from early firmware before option
rom loading has occurred so it can do the right thing when it
checks whether or not to tell the system to reboot after setting
the VbNv flag.
BUG=chrome-os-partner:32379
BRANCH=samus
TEST=pass FAFT tests on samus
Change-Id: Id432dc154736baa799d9ddf5a6a25bccc66217ef
Signed-off-by: Stefan Reinauer <reinauer(a)chromium.org>
Original-Commit-Id: 8a576b0bf4b912f85a4e82bfe2cf13c838a069cc
Original-Signed-off-by: Duncan Laurie <dlaurie(a)chromium.org>
Original-Change-Id: I6968fcb6cda74e88f56bea6ea9bbf77cc795b8d6
Original-Reviewed-on: https://chromium-review.googlesource.com/230887
Original-Reviewed-by: Aaron Durbin <adurbin(a)chromium.org>
---
src/vendorcode/google/chromeos/vboot1/vboot_loader.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/vendorcode/google/chromeos/vboot1/vboot_loader.c b/src/vendorcode/google/chromeos/vboot1/vboot_loader.c
index 97ca902..a297262 100644
--- a/src/vendorcode/google/chromeos/vboot1/vboot_loader.c
+++ b/src/vendorcode/google/chromeos/vboot1/vboot_loader.c
@@ -234,6 +234,7 @@ static void vboot_invoke_wrapper(struct vboot_handoff *vboot_handoff)
*iflags |= VB_INIT_FLAG_EC_SLOW_UPDATE;
if (CONFIG_VBOOT_OPROM_MATTERS) {
*iflags |= VB_INIT_FLAG_OPROM_MATTERS;
+ *iflags |= VB_INIT_FLAG_BEFORE_OPROM_LOAD;
/* Will load VGA option rom during this boot */
if (developer_mode_enabled() || recovery_mode_enabled() ||
vboot_wants_oprom()) {
Stefan Reinauer (stefan.reinauer(a)coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/9557
-gerrit
commit 5aa4bf02815a5cc6dd404d125b2370877486bd4c
Author: Julius Werner <jwerner(a)chromium.org>
Date: Tue Jan 27 15:40:47 2015 -0800
elog: Correct behavior when FMAP section doesn't exist on ChromeOS
The elog driver has a really stupid bug that checks a result which is
stored in an unsigned variable for < 0. Surprisingly GCC does not catch
this nonsense right now, and I spent an hour trying out different
warning options without finding one that doesn't also bring a load of
stupid and unavoidable false positives (the biggest offender being
-Wtype-limits, which does exactly what we'd want except for flagging
things like if ((u8)var >= CONFIG_VAR_MIN) where the VAR_MIN Kconfig may
or may not be 0).
So, the only thing we can do is fix this one and wait for the next time
something like that blows up. -.- Also change some more code to make the
behavior more explicit (the old code already intended to work this way
since flash_base is statically initialized to 0, never assigned in the
error path and checked later in elog_init()... but there was an error
message that incorrectly claimed a different fallback behavior, and
explicitly assigning the values makes this easier to see). Finally, add
another state to the elog_initialized variable to avoid trying to
reinitialize a broken eventlog on every event (if it doesn't work the
first time, chances are that it won't work later on during the same boot
either).
BRANCH=None
BUG=chrome-os-partner:35940
TEST=Flashed Jerry with RO 6588.4 and RW 6588.23, observed how it now
cleanly enters recovery mode without blowing its bootblock away with
stray eventlog entries.
Change-Id: I0e5348ba961ce4835c30f7108a2453522095f2ee
Signed-off-by: Stefan Reinauer <reinauer(a)chromium.org>
Original-Commit-Id: f9798dbf0c2b2e337062ecd84d0f45434343c0d9
Original-Change-Id: I4d93f48d2d01d75a04550d419e023aa42ca95a7a
Original-Signed-off-by: Julius Werner <jwerner(a)chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/243671
Original-Reviewed-by: Duncan Laurie <dlaurie(a)chromium.org>
---
src/drivers/elog/elog.c | 38 +++++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/src/drivers/elog/elog.c b/src/drivers/elog/elog.c
index f6b0006..76e8cf7 100644
--- a/src/drivers/elog/elog.c
+++ b/src/drivers/elog/elog.c
@@ -75,9 +75,13 @@ static elog_event_buffer_state event_buffer_state;
static u16 next_event_offset;
static u16 event_count;
-static int elog_initialized;
static struct spi_flash *elog_spi;
+static enum {
+ ELOG_UNINITIALIZED = 0,
+ ELOG_INITIALIZED,
+ ELOG_BROKEN,
+} elog_initialized = ELOG_UNINITIALIZED;
static inline u32 get_rom_size(void)
{
@@ -522,25 +526,18 @@ int elog_clear(void)
static void elog_find_flash(void)
{
-#if CONFIG_CHROMEOS
- u8 *flash_base_ptr;
-#endif
-
elog_debug("elog_find_flash()\n");
#if CONFIG_CHROMEOS
/* Find the ELOG base and size in FMAP */
- total_size = find_fmap_entry("RW_ELOG", (void **)&flash_base_ptr);
- if (total_size < 0) {
- printk(BIOS_WARNING, "ELOG: Unable to find RW_ELOG in FMAP, "
- "using CONFIG_ELOG_FLASH_BASE instead\n");
- total_size = CONFIG_ELOG_AREA_SIZE;
+ u8 *flash_base_ptr;
+ int fmap_size = find_fmap_entry("RW_ELOG", (void **)&flash_base_ptr);
+ if (fmap_size < 0) {
+ printk(BIOS_WARNING, "ELOG: Unable to find RW_ELOG in FMAP\n");
+ flash_base = total_size = 0;
} else {
flash_base = elog_flash_address_to_offset(flash_base_ptr);
-
- /* Use configured size if smaller than FMAP size */
- if (total_size > CONFIG_ELOG_AREA_SIZE)
- total_size = CONFIG_ELOG_AREA_SIZE;
+ total_size = MIN(fmap_size, CONFIG_ELOG_AREA_SIZE);
}
#else
flash_base = CONFIG_ELOG_FLASH_BASE;
@@ -554,8 +551,15 @@ static void elog_find_flash(void)
*/
int elog_init(void)
{
- if (elog_initialized)
+ switch (elog_initialized) {
+ case ELOG_UNINITIALIZED:
+ break;
+ case ELOG_INITIALIZED:
return 0;
+ case ELOG_BROKEN:
+ return -1;
+ }
+ elog_initialized = ELOG_BROKEN;
elog_debug("elog_init()\n");
@@ -600,8 +604,6 @@ int elog_init(void)
return -1;
}
- elog_initialized = 1;
-
printk(BIOS_INFO, "ELOG: FLASH @0x%p [SPI 0x%08x]\n",
elog_area, flash_base);
@@ -637,6 +639,8 @@ int elog_init(void)
#endif
#endif
+ elog_initialized = ELOG_INITIALIZED;
+
return 0;
}
Stefan Reinauer (stefan.reinauer(a)coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/9503
-gerrit
commit 556b5a53c4a416fec2bf10d16fcdd542b2b6ac47
Author: Julius Werner <jwerner(a)chromium.org>
Date: Thu Feb 5 12:55:45 2015 -0800
elog: Fix regression that caused elog to omit "System boot" event
CL:243671 moved the initialization of elog_initialized around, which is
now unfortunately so late that the ELOG_TYPE_BOOT event gets omitted
because the code believes the log to be broken at that time. Good thing
we now have a FAFT test for these things that I had of course been too
lazy to run. -.-
The real reason for moving that line was to put it after any point in
elog_init() that could still error out. The problem is that we might add
the "cleared" event before we try to shrink (which can fail and cause an
error)... but those two things cannot happen at the same time, so it
should be okay to flip them around and mark the elog as initialized in
between.
BRANCH=none
BUG=chrome-os-partner:35940
TEST=Ran firmware_EventLog on a Pinky, manually confirmed that I once
again get "System boot" events.
Change-Id: I12dcf4a8e47d302f6cd317194912c31db502bbaf
Signed-off-by: Stefan Reinauer <reinauer(a)chromium.org>
Original-Commit-Id: 4a1c0b861017ca25229b1042c4b37dda33e869f9
Original-Change-Id: I4103779790e1a8a53ecabffd4316724035928ce6
Original-Signed-off-by: Julius Werner <jwerner(a)chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/246715
Original-Reviewed-by: Duncan Laurie <dlaurie(a)chromium.org>
---
src/drivers/elog/elog.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/drivers/elog/elog.c b/src/drivers/elog/elog.c
index 76e8cf7..f5135d9 100644
--- a/src/drivers/elog/elog.c
+++ b/src/drivers/elog/elog.c
@@ -611,15 +611,17 @@ int elog_init(void)
" shrink size %d\n", total_size,
CONFIG_ELOG_FULL_THRESHOLD, CONFIG_ELOG_SHRINK_SIZE);
- /* Log a clear event if necessary */
- if (event_count == 0)
- elog_add_event_word(ELOG_TYPE_LOG_CLEAR, total_size);
+ elog_initialized = ELOG_INITIALIZED;
/* Shrink the log if we are getting too full */
if (next_event_offset >= CONFIG_ELOG_FULL_THRESHOLD)
if (elog_shrink() < 0)
return -1;
+ /* Log a clear event if necessary */
+ if (event_count == 0)
+ elog_add_event_word(ELOG_TYPE_LOG_CLEAR, total_size);
+
#if !defined(__SMM__)
/* Log boot count event except in S3 resume */
#if CONFIG_ELOG_BOOT_COUNT == 1