OLD | NEW |
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 Loading... |
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 /* Magic number for recognizing VbSharedDataHeader ("VbSD") */ |
| 135 #define VB_SHARED_DATA_MAGIC 0x44536256 |
| 136 |
134 /* Minimum and recommended size of shared_data_blob in bytes. */ | 137 /* Minimum and recommended size of shared_data_blob in bytes. */ |
135 #define VB_SHARED_DATA_MIN_SIZE 3072 | 138 #define VB_SHARED_DATA_MIN_SIZE 3072 |
136 #define VB_SHARED_DATA_REC_SIZE 16384 | 139 #define VB_SHARED_DATA_REC_SIZE 16384 |
137 | 140 |
| 141 /* Flags for VbSharedDataHeader */ |
| 142 /* LoadFirmware() tried firmware B because of VbNvStorage firmware B tries */ |
| 143 #define VBSD_FWB_TRIED 0x00000001 |
| 144 /* LoadKernel() verified the kernel keyblock using the kernel subkey from |
| 145 * the firmware. If this flag is not present, it just used the hash of the |
| 146 * kernel keyblock. */ |
| 147 #define VBSD_KERNEL_KEY_VERIFIED 0x00000002 |
| 148 /* LoadFirmware() was told the developer switch was on */ |
| 149 #define VBSD_LF_DEV_SWITCH_ON 0x00000004 |
| 150 |
| 151 /* Result codes for checking firmware A and B */ |
| 152 #define VBSD_LF_CHECK_NOT_DONE 0 |
| 153 #define VBSD_LF_CHECK_DEV_MISMATCH 1 |
| 154 #define VBSD_LF_CHECK_REC_MISMATCH 2 |
| 155 #define VBSD_LF_CHECK_VERIFY_KEYBLOCK 3 |
| 156 #define VBSD_LF_CHECK_KEY_ROLLBACK 4 |
| 157 #define VBSD_LF_CHECK_DATA_KEY_PARSE 5 |
| 158 #define VBSD_LF_CHECK_VERIFY_PREAMBLE 6 |
| 159 #define VBSD_LF_CHECK_FW_ROLLBACK 7 |
| 160 #define VBSD_LF_CHECK_HEADER_VALID 8 |
| 161 #define VBSD_LF_CHECK_GET_FW_BODY 9 |
| 162 #define VBSD_LF_CHECK_HASH_WRONG_SIZE 10 |
| 163 #define VBSD_LF_CHECK_VERIFY_BODY 11 |
| 164 #define VBSD_LF_CHECK_VALID 12 |
| 165 |
138 /* Data shared between LoadFirmware(), LoadKernel(), and OS. | 166 /* Data shared between LoadFirmware(), LoadKernel(), and OS. |
139 * | 167 * |
140 * The boot process is: | 168 * The boot process is: |
141 * 1) Caller allocates buffer, at least VB_SHARED_DATA_MIN bytes, ideally | 169 * 1) Caller allocates buffer, at least VB_SHARED_DATA_MIN bytes, ideally |
142 * VB_SHARED_DATA_REC_SIZE bytes. | 170 * VB_SHARED_DATA_REC_SIZE bytes. |
143 * 2) If non-recovery boot, this is passed to LoadFirmware(), which | 171 * 2) If non-recovery boot, this is passed to LoadFirmware(), which |
144 * initializes the buffer, adding this header and some data. | 172 * initializes the buffer, adding this header and some data. |
145 * 3) Buffer is passed to LoadKernel(). If this is a recovery boot, | 173 * 3) Buffer is passed to LoadKernel(). If this is a recovery boot, |
146 * LoadKernel() initializes the buffer, adding this header. Regardless | 174 * LoadKernel() initializes the buffer, adding this header. Regardless |
147 * of boot type, LoadKernel() adds some data to the buffer. | 175 * of boot type, LoadKernel() adds some data to the buffer. |
148 * 4) Caller makes data available to the OS in a platform-dependent manner. | 176 * 4) Caller makes data available to the OS in a platform-dependent manner. |
149 * For example, via ACPI or ATAGs. */ | 177 * For example, via ACPI or ATAGs. */ |
150 typedef struct VbSharedDataHeader { | 178 typedef struct VbSharedDataHeader { |
151 /* Fields present in version 1 */ | 179 /* Fields present in version 1 */ |
| 180 uint32_t magic; /* Magic number for struct |
| 181 * (VB_SHARED_DATA_MAGIC) */ |
152 uint32_t struct_version; /* Version of this structure */ | 182 uint32_t struct_version; /* Version of this structure */ |
153 uint64_t struct_size; /* Size of this structure in bytes */ | 183 uint64_t struct_size; /* Size of this structure in bytes */ |
154 uint64_t data_size; /* Size of shared data buffer in bytes */ | 184 uint64_t data_size; /* Size of shared data buffer in bytes */ |
155 uint64_t data_used; /* Amount of shared data used so far */ | 185 uint64_t data_used; /* Amount of shared data used so far */ |
| 186 uint32_t flags; /* Flags */ |
156 | 187 |
157 VbPublicKey kernel_subkey; /* Kernel subkey, from firmware */ | 188 VbPublicKey kernel_subkey; /* Kernel subkey, from firmware */ |
158 uint64_t kernel_subkey_data_offset; /* Offset of kernel subkey data from | 189 uint64_t kernel_subkey_data_offset; /* Offset of kernel subkey data from |
159 * start of this struct */ | 190 * start of this struct */ |
160 uint64_t kernel_subkey_data_size; /* Size of kernel subkey data */ | 191 uint64_t kernel_subkey_data_size; /* Size of kernel subkey data */ |
161 | 192 |
162 uint64_t flags; /* Flags */ | |
163 | |
164 /* Timer values from VbGetTimer(). Unused values are set to 0. If a | 193 /* Timer values from VbGetTimer(). Unused values are set to 0. If a |
165 * function is called mutiple times, these are the times from the | 194 * function is called mutiple times, these are the times from the |
166 * most recent call. */ | 195 * most recent call. */ |
167 uint64_t timer_load_firmware_start_enter; /* LoadFirmwareStart() - enter */ | 196 uint64_t timer_load_firmware_start_enter; /* LoadFirmwareStart() - enter */ |
168 uint64_t timer_load_firmware_start_exit; /* LoadFirmwareStart() - exit */ | 197 uint64_t timer_load_firmware_start_exit; /* LoadFirmwareStart() - exit */ |
169 uint64_t timer_load_firmware_enter; /* LoadFirmware() - enter */ | 198 uint64_t timer_load_firmware_enter; /* LoadFirmware() - enter */ |
170 uint64_t timer_load_firmware_exit; /* LoadFirmware() - exit */ | 199 uint64_t timer_load_firmware_exit; /* LoadFirmware() - exit */ |
171 uint64_t timer_load_kernel_enter; /* LoadKernel() - enter */ | 200 uint64_t timer_load_kernel_enter; /* LoadKernel() - enter */ |
172 uint64_t timer_load_kernel_exit; /* LoadKernel() - exit */ | 201 uint64_t timer_load_kernel_exit; /* LoadKernel() - exit */ |
173 | 202 |
| 203 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 */ |
| 205 uint8_t firmware_index; /* Firmware index returned by |
| 206 * LoadFirmware() or 0xFF if failure */ |
| 207 uint32_t fw_version_tpm_start; /* Firmware TPM version at start */ |
| 208 uint32_t fw_version_lowest; /* Firmware lowest version found */ |
| 209 |
174 /* After read-only firmware which uses version 1 is released, any additional | 210 /* After read-only firmware which uses version 1 is released, any additional |
175 * fields must be added below, and the struct version must be increased. | 211 * fields must be added below, and the struct version must be increased. |
176 * Before reading/writing those fields, make sure that the struct being | 212 * Before reading/writing those fields, make sure that the struct being |
177 * accessed is at least version 2. | 213 * accessed is at least version 2. |
178 * | 214 * |
179 * It's always ok for an older firmware to access a newer struct, since all | 215 * It's always ok for an older firmware to access a newer struct, since all |
180 * the fields it knows about are present. Newer firmware needs to use | 216 * the fields it knows about are present. Newer firmware needs to use |
181 * reasonable defaults when accessing older structs. */ | 217 * reasonable defaults when accessing older structs. */ |
182 | 218 |
183 } __attribute__((packed)) VbSharedDataHeader; | 219 } __attribute__((packed)) VbSharedDataHeader; |
184 | 220 |
185 #define VB_SHARED_DATA_VERSION 1 /* Version for struct_version */ | 221 #define VB_SHARED_DATA_VERSION 1 /* Version for struct_version */ |
186 | 222 |
187 __pragma(pack(pop)) /* Support packing for MSVC. */ | 223 __pragma(pack(pop)) /* Support packing for MSVC. */ |
188 | 224 |
189 #endif /* VBOOT_REFERENCE_VBOOT_STRUCT_H_ */ | 225 #endif /* VBOOT_REFERENCE_VBOOT_STRUCT_H_ */ |
OLD | NEW |