summaryrefslogtreecommitdiff
path: root/include/flash_log.h
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2019-02-01 10:19:51 -0800
committerchrome-bot <chrome-bot@chromium.org>2019-04-04 05:40:01 -0700
commit574e131187492b0e5ba1af06d9a6baee22a2302e (patch)
tree3d8bac1e9d431bac227dc03cec0909b0c9513390 /include/flash_log.h
parentfd2a6277b4b2262efda3d22e46ec9a48bc7339b2 (diff)
downloadchrome-ec-574e131187492b0e5ba1af06d9a6baee22a2302e.tar.gz
cr50: New NVMEM flash storage implementation
This patch is a proposed implementation of the new TPM NVMEM flash layer. There is a big comment block in common/new_nvmem.c describing the approach taken, changes to the API and outstanding issues. This implementation follows the design document attached to b:69907320. With all required changes to the rest of the code this new flash storage scheme consumes 7816(!) bytes of code storage. One of the more important aspects of this implementation is that the (key, value) pair objects are stored in the flash only, they are not duplicated in the SRAM cache. The advantage of this is that there could be more space dedicated to these objects. Soft limit is set to 1K as opposed to 272 bytes available with the legacy scheme. The major disadvantage is the need for the user not to forget to release the (key, value) pair retrieved from NVMEM, as it occupies space on the heap. BRANCH=cr50, cr50-mp BUG=b:69907320, b:129710256 TEST=with the rest of the patches applied the following tests pass: - test cases in ./test (completely reworked for the new scheme) - TCG suite (passes on par with the existing Cr50 code with the reduced code footprint TPM2 library) - Chrome OS device migrates from legacy to new implementation with user account maintained. - Chrome OS user account is maintained over AP and H1 reboots and deep sleep cycles. Change-Id: I6252649597c03abd4a08e2d55d61e384fe037ef7 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1450277 Reviewed-by: Andrey Pronin <apronin@chromium.org>
Diffstat (limited to 'include/flash_log.h')
-rw-r--r--include/flash_log.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/include/flash_log.h b/include/flash_log.h
index 19093ba40b..b4882ebe36 100644
--- a/include/flash_log.h
+++ b/include/flash_log.h
@@ -17,6 +17,7 @@ enum flash_event_type {
FE_TPM_I2C_ERROR = 2,
FE_LOG_OVERFLOWS = 3, /* A single byte, overflow counter. */
FE_LOG_LOCKS = 4, /* A single byte, lock failures counter. */
+ FE_LOG_NVMEM = 5, /* NVMEM failure, variable structure. */
/*
* Fixed padding value makes it easier to parse log space
@@ -45,6 +46,37 @@ struct flash_log_entry {
uint8_t payload[0]; /* optional additional data payload: 0..63 bytes. */
} __packed;
+/* Payloads for various log events. */
+/* NVMEM failures. */
+enum nvmem_failure_type {
+ NVMEMF_MALLOC = 0,
+ NVMEMF_PH_SIZE_MISMATCH = 1,
+ NVMEMF_READ_UNDERRUN = 2,
+ NVMEMF_INCONSISTENT_FLASH_CONTENTS = 3,
+ NVMEMF_MIGRATION_FAILURE = 4,
+ NVMEMF_LEGACY_ERASE_FAILURE = 5,
+ NVMEMF_EXCESS_DELETE_OBJECTS = 6,
+ NVMEMF_UNEXPECTED_LAST_OBJ = 7,
+ NVMEMF_MISSING_OBJECT = 8,
+ NVMEMF_SECTION_VERIFY = 9,
+ NVMEMF_PRE_ERASE_MISMATCH = 10,
+ NVMEMF_PAGE_LIST_OVERFLOW = 11
+};
+
+/* Not all nvmem failures require payload. */
+struct nvmem_failure_payload {
+ uint8_t failure_type;
+ union {
+ uint16_t size; /* How much memory was requested. */
+ struct {
+ uint16_t ph_offset;
+ uint16_t expected;
+ } ph __packed;
+ uint16_t underrun_size; /* How many bytes short. */
+ uint8_t last_obj_type;
+ } __packed;
+} __packed;
+
/* Returned in the "type" field, when there is no entry available */
#define FLASH_LOG_NO_ENTRY 0xff
#define MAX_FLASH_LOG_PAYLOAD_SIZE ((1 << 6) - 1)