Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: firmware/include/vboot_struct.h

Issue 6688035: Add VbSharedData debug output to LoadKernel() (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git@master
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | firmware/lib/vboot_kernel.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 1 /* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 * 4 *
5 * Data structure definitions for verified boot, for on-disk / in-eeprom 5 * Data structure definitions for verified boot, for on-disk / in-eeprom
6 * data. 6 * data.
7 */ 7 */
8 8
9 #ifndef VBOOT_REFERENCE_VBOOT_STRUCT_H_ 9 #ifndef VBOOT_REFERENCE_VBOOT_STRUCT_H_
10 #define VBOOT_REFERENCE_VBOOT_STRUCT_H_ 10 #define VBOOT_REFERENCE_VBOOT_STRUCT_H_
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 VbSignature body_signature; /* Signature for the kernel body */ 124 VbSignature body_signature; /* Signature for the kernel body */
125 } __attribute__((packed)) VbKernelPreambleHeader; 125 } __attribute__((packed)) VbKernelPreambleHeader;
126 /* This should be followed by: 126 /* This should be followed by:
127 * 2) The signature data for the kernel body, pointed to by 127 * 2) The signature data for the kernel body, pointed to by
128 * body_signature.sig_offset. 128 * body_signature.sig_offset.
129 * 3) The signature data for (VBFirmwarePreambleHeader + body signature 129 * 3) The signature data for (VBFirmwarePreambleHeader + body signature
130 * data), pointed to by preamble_signature.sig_offset. */ 130 * data), pointed to by preamble_signature.sig_offset. */
131 131
132 #define EXPECTED_VBKERNELPREAMBLEHEADER_SIZE 96 132 #define EXPECTED_VBKERNELPREAMBLEHEADER_SIZE 96
133 133
134 /* Constants and sub-structures for VbSharedDataHeader */
135
134 /* Magic number for recognizing VbSharedDataHeader ("VbSD") */ 136 /* Magic number for recognizing VbSharedDataHeader ("VbSD") */
135 #define VB_SHARED_DATA_MAGIC 0x44536256 137 #define VB_SHARED_DATA_MAGIC 0x44536256
136 138
137 /* Minimum and recommended size of shared_data_blob in bytes. */ 139 /* Minimum and recommended size of shared_data_blob in bytes. */
138 #define VB_SHARED_DATA_MIN_SIZE 3072 140 #define VB_SHARED_DATA_MIN_SIZE 3072
139 #define VB_SHARED_DATA_REC_SIZE 16384 141 #define VB_SHARED_DATA_REC_SIZE 16384
140 142
141 /* Flags for VbSharedDataHeader */ 143 /* Flags for VbSharedDataHeader */
142 /* LoadFirmware() tried firmware B because of VbNvStorage firmware B tries */ 144 /* LoadFirmware() tried firmware B because of VbNvStorage firmware B tries */
143 #define VBSD_FWB_TRIED 0x00000001 145 #define VBSD_FWB_TRIED 0x00000001
144 /* LoadKernel() verified the kernel keyblock using the kernel subkey from 146 /* LoadKernel() verified the good kernel keyblock using the kernel subkey from
145 * the firmware. If this flag is not present, it just used the hash of the 147 * the firmware. If this flag is not present, it just used the hash of the
146 * kernel keyblock. */ 148 * kernel keyblock. */
147 #define VBSD_KERNEL_KEY_VERIFIED 0x00000002 149 #define VBSD_KERNEL_KEY_VERIFIED 0x00000002
148 /* LoadFirmware() was told the developer switch was on */ 150 /* LoadFirmware() was told the developer switch was on */
149 #define VBSD_LF_DEV_SWITCH_ON 0x00000004 151 #define VBSD_LF_DEV_SWITCH_ON 0x00000004
150 152
151 /* Result codes for checking firmware A and B */ 153 /* Result codes for VbSharedDataHeader.check_fw_a_result (and b_result) */
152 #define VBSD_LF_CHECK_NOT_DONE 0 154 #define VBSD_LF_CHECK_NOT_DONE 0
153 #define VBSD_LF_CHECK_DEV_MISMATCH 1 155 #define VBSD_LF_CHECK_DEV_MISMATCH 1
154 #define VBSD_LF_CHECK_REC_MISMATCH 2 156 #define VBSD_LF_CHECK_REC_MISMATCH 2
155 #define VBSD_LF_CHECK_VERIFY_KEYBLOCK 3 157 #define VBSD_LF_CHECK_VERIFY_KEYBLOCK 3
156 #define VBSD_LF_CHECK_KEY_ROLLBACK 4 158 #define VBSD_LF_CHECK_KEY_ROLLBACK 4
157 #define VBSD_LF_CHECK_DATA_KEY_PARSE 5 159 #define VBSD_LF_CHECK_DATA_KEY_PARSE 5
158 #define VBSD_LF_CHECK_VERIFY_PREAMBLE 6 160 #define VBSD_LF_CHECK_VERIFY_PREAMBLE 6
159 #define VBSD_LF_CHECK_FW_ROLLBACK 7 161 #define VBSD_LF_CHECK_FW_ROLLBACK 7
160 #define VBSD_LF_CHECK_HEADER_VALID 8 162 #define VBSD_LF_CHECK_HEADER_VALID 8
161 #define VBSD_LF_CHECK_GET_FW_BODY 9 163 #define VBSD_LF_CHECK_GET_FW_BODY 9
162 #define VBSD_LF_CHECK_HASH_WRONG_SIZE 10 164 #define VBSD_LF_CHECK_HASH_WRONG_SIZE 10
163 #define VBSD_LF_CHECK_VERIFY_BODY 11 165 #define VBSD_LF_CHECK_VERIFY_BODY 11
164 #define VBSD_LF_CHECK_VALID 12 166 #define VBSD_LF_CHECK_VALID 12
165 167
168 /* Boot mode for VbSharedDataHeader.lk_boot_mode */
169 #define VBSD_LK_BOOT_MODE_RECOVERY 0
170 #define VBSD_LK_BOOT_MODE_NORMAL 1
171 #define VBSD_LK_BOOT_MODE_DEVELOPER 2
172
173 /* Flags for VbSharedDataKernelPart.flags */
174 #define VBSD_LKP_FLAG_KEY_BLOCK_VALID 0x01
175
176 /* Result codes for VbSharedDataKernelPart.check_result */
177 #define VBSD_LKP_CHECK_NOT_DONE 0
178 #define VBSD_LKP_CHECK_TOO_SMALL 1
179 #define VBSD_LKP_CHECK_READ_START 2
180 #define VBSD_LKP_CHECK_KEY_BLOCK_SIG 3
181 #define VBSD_LKP_CHECK_KEY_BLOCK_HASH 4
182 #define VBSD_LKP_CHECK_DEV_MISMATCH 5
183 #define VBSD_LKP_CHECK_REC_MISMATCH 6
184 #define VBSD_LKP_CHECK_KEY_ROLLBACK 7
185 #define VBSD_LKP_CHECK_DATA_KEY_PARSE 8
186 #define VBSD_LKP_CHECK_VERIFY_PREAMBLE 9
187 #define VBSD_LKP_CHECK_KERNEL_ROLLBACK 10
188 #define VBSD_LKP_CHECK_PREAMBLE_VALID 11
189 #define VBSD_LKP_CHECK_BODY_ADDRESS 12
190 #define VBSD_LKP_CHECK_BODY_OFFSET 13
191 #define VBSD_LKP_CHECK_BODY_EXCEEDS_MEM 15
192 #define VBSD_LKP_CHECK_BODY_EXCEEDS_PART 16
193 #define VBSD_LKP_CHECK_READ_DATA 17
194 #define VBSD_LKP_CHECK_VERIFY_DATA 18
195 #define VBSD_LKP_CHECK_KERNEL_GOOD 19
196
197
198 /* Information about a single kernel partition check in LoadKernel() */
199 typedef struct VbSharedDataKernelPart {
200 uint64_t sector_start; /* Start sector of partition */
201 uint64_t sector_count; /* Sector count of partition */
202 uint32_t combined_version; /* Combined key+kernel version */
203 uint8_t gpt_index; /* Index of partition in GPT */
204 uint8_t check_result; /* Check result; see VBSD_LKP_CHECK_* */
205 uint8_t flags; /* Flags (see VBSD_LKP_FLAG_* */
206 } VbSharedDataKernelPart;
207
208 /* Number of kernel partitions to track per call. Must be power of 2. */
209 #define VBSD_MAX_KERNEL_PARTS 8
210
211 /* Flags for VbSharedDataKernelCall.flags */
212 /* Error initializing TPM in recovery mode */
213 #define VBSD_LK_FLAG_REC_TPM_INIT_ERROR 0x00000001
214
215 /* Result codes for VbSharedDataKernelCall.check_result */
216 #define VBSD_LKC_CHECK_NOT_DONE 0
217 #define VBSD_LKC_CHECK_DEV_SWITCH_MISMATCH 1
218 #define VBSD_LKC_CHECK_GPT_READ_ERROR 2
219 #define VBSD_LKC_CHECK_GPT_PARSE_ERROR 3
220 #define VBSD_LKC_CHECK_GOOD_PARTITION 4
221 #define VBSD_LKC_CHECK_INVALID_PARTITIONS 5
222 #define VBSD_LKC_CHECK_NO_PARTITIONS 6
223
224 /* Information about a single call to LoadKernel() */
225 typedef struct VbSharedDataKernelCall {
226 uint32_t boot_flags; /* Bottom 32 bits of flags passed in
227 * LoadKernelParams.boot_flags */
228 uint32_t flags; /* Debug flags; see VBSD_LK_FLAG_* */
229 uint64_t sector_count; /* Number of sectors on drive */
230 uint32_t sector_size; /* Sector size in bytes */
231 uint8_t check_result; /* Check result; see VBSD_LKC_CHECK_* */
232 uint8_t boot_mode; /* Boot mode for LoadKernel(); see
233 * VBSD_LK_BOOT_MODE_* constants */
234 uint8_t test_error_num; /* Test error number, if non-zero */
235 uint8_t return_code; /* Return code from LoadKernel() */
236 uint8_t kernel_parts_found; /* Number of kernel partitions found */
237 VbSharedDataKernelPart parts[VBSD_MAX_KERNEL_PARTS]; /* Data on kernels */
238 } VbSharedDataKernelCall;
239
240 /* Number of kernel calls to track. Must be power of 2. */
241 #define VBSD_MAX_KERNEL_CALLS 4
242
166 /* Data shared between LoadFirmware(), LoadKernel(), and OS. 243 /* Data shared between LoadFirmware(), LoadKernel(), and OS.
167 * 244 *
168 * The boot process is: 245 * The boot process is:
169 * 1) Caller allocates buffer, at least VB_SHARED_DATA_MIN bytes, ideally 246 * 1) Caller allocates buffer, at least VB_SHARED_DATA_MIN bytes, ideally
170 * VB_SHARED_DATA_REC_SIZE bytes. 247 * VB_SHARED_DATA_REC_SIZE bytes.
171 * 2) If non-recovery boot, this is passed to LoadFirmware(), which 248 * 2) If non-recovery boot, this is passed to LoadFirmware(), which
172 * initializes the buffer, adding this header and some data. 249 * initializes the buffer, adding this header and some data.
173 * 3) Buffer is passed to LoadKernel(). If this is a recovery boot, 250 * 3) Buffer is passed to LoadKernel(). If this is a recovery boot,
174 * LoadKernel() initializes the buffer, adding this header. Regardless 251 * LoadKernel() initializes the buffer, adding this header. Regardless
175 * of boot type, LoadKernel() adds some data to the buffer. 252 * of boot type, LoadKernel() adds some data to the buffer.
(...skipping 17 matching lines...) Expand all
193 /* Timer values from VbGetTimer(). Unused values are set to 0. If a 270 /* Timer values from VbGetTimer(). Unused values are set to 0. If a
194 * function is called mutiple times, these are the times from the 271 * function is called mutiple times, these are the times from the
195 * most recent call. */ 272 * most recent call. */
196 uint64_t timer_load_firmware_start_enter; /* LoadFirmwareStart() - enter */ 273 uint64_t timer_load_firmware_start_enter; /* LoadFirmwareStart() - enter */
197 uint64_t timer_load_firmware_start_exit; /* LoadFirmwareStart() - exit */ 274 uint64_t timer_load_firmware_start_exit; /* LoadFirmwareStart() - exit */
198 uint64_t timer_load_firmware_enter; /* LoadFirmware() - enter */ 275 uint64_t timer_load_firmware_enter; /* LoadFirmware() - enter */
199 uint64_t timer_load_firmware_exit; /* LoadFirmware() - exit */ 276 uint64_t timer_load_firmware_exit; /* LoadFirmware() - exit */
200 uint64_t timer_load_kernel_enter; /* LoadKernel() - enter */ 277 uint64_t timer_load_kernel_enter; /* LoadKernel() - enter */
201 uint64_t timer_load_kernel_exit; /* LoadKernel() - exit */ 278 uint64_t timer_load_kernel_exit; /* LoadKernel() - exit */
202 279
280 /* Information stored in TPM, as retrieved by firmware */
281 uint32_t fw_version_tpm; /* Current firmware version in TPM */
282 uint32_t kernel_version_tpm; /* Current kernel version in TPM */
283
284 /* Debugging information from LoadFirmware() */
203 uint8_t check_fw_a_result; /* Result of checking RW firmware A */ 285 uint8_t check_fw_a_result; /* Result of checking RW firmware A */
204 uint8_t check_fw_b_result; /* Result of checking RW firmware B */ 286 uint8_t check_fw_b_result; /* Result of checking RW firmware B */
205 uint8_t firmware_index; /* Firmware index returned by 287 uint8_t firmware_index; /* Firmware index returned by
206 * LoadFirmware() or 0xFF if failure */ 288 * LoadFirmware() or 0xFF if failure */
207 uint32_t fw_version_tpm_start; /* Firmware TPM version at start of 289 uint32_t fw_version_tpm_start; /* Firmware TPM version at start of
208 * LoadFirmware() */ 290 * LoadFirmware() */
209 uint32_t fw_version_lowest; /* Firmware lowest version found */ 291 uint32_t fw_version_lowest; /* Firmware lowest version found */
210 292
211 uint32_t fw_version_tpm; /* Current firmware version in TPM */ 293 /* Debugging information from LoadKernel() */
212 uint32_t kernel_version_tpm; /* Current kernel version in TPM */ 294 uint32_t lk_call_count; /* Number of times LoadKernel() called */
295 VbSharedDataKernelCall lk_calls[VBSD_MAX_KERNEL_CALLS]; /* Info on calls */
296
297 /* Offset and size of supplemental kernel data. Reserve space for these
298 * fields now, so that future LoadKernel() versions can store information
299 * there without needing to shift down whatever data the original
300 * LoadFirmware() might have put immediately following its
301 * VbSharedDataHeader. */
302 uint64_t kernel_supplemental_offset;
303 uint64_t kernel_supplemental_size;
213 304
214 /* After read-only firmware which uses version 1 is released, any additional 305 /* After read-only firmware which uses version 1 is released, any additional
215 * fields must be added below, and the struct version must be increased. 306 * fields must be added below, and the struct version must be increased.
216 * Before reading/writing those fields, make sure that the struct being 307 * Before reading/writing those fields, make sure that the struct being
217 * accessed is at least version 2. 308 * accessed is at least version 2.
218 * 309 *
219 * It's always ok for an older firmware to access a newer struct, since all 310 * It's always ok for an older firmware to access a newer struct, since all
220 * the fields it knows about are present. Newer firmware needs to use 311 * the fields it knows about are present. Newer firmware needs to use
221 * reasonable defaults when accessing older structs. */ 312 * reasonable defaults when accessing older structs. */
222 313
223 } __attribute__((packed)) VbSharedDataHeader; 314 } __attribute__((packed)) VbSharedDataHeader;
224 315
225 #define VB_SHARED_DATA_VERSION 1 /* Version for struct_version */ 316 #define VB_SHARED_DATA_VERSION 1 /* Version for struct_version */
226 317
227 __pragma(pack(pop)) /* Support packing for MSVC. */ 318 __pragma(pack(pop)) /* Support packing for MSVC. */
228 319
229 #endif /* VBOOT_REFERENCE_VBOOT_STRUCT_H_ */ 320 #endif /* VBOOT_REFERENCE_VBOOT_STRUCT_H_ */
OLDNEW
« no previous file with comments | « no previous file | firmware/lib/vboot_kernel.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698