History

efi: Introduce EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER and corresponding structures

Platform Firmware Runtime Update image starts with UEFI headers, and the headers are defined in UEFI specification, but some of them have not been defined in the kernel yet. For example, the header layout of a capsule file looks like this: EFI_CAPSULE_HEADER EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER EFI_FIRMWARE_IMAGE_AUTHENTICATION These structures would be used by the Platform Firmware Runtime Update driver to parse the format of capsule file to verify if the corresponding version number is valid. In this way, if the user provides an invalid capsule image, the kernel could be used as a guard to reject it, without switching to the Management Mode (which might be costly). EFI_CAPSULE_HEADER has been defined in the kernel, but the other structures have not been defined yet, so do that. Besides, EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER and EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER are required to be packed in the uefi specification. For this reason, use the __packed attribute to indicate to the compiler that the entire structure can appear misaligned in memory (as suggested by Ard) in case one of them follows the other directly in a capsule header.

Chen Yu committed 4 years ago

Commit 1882de71 parent fc74e0a1 file · +46 −0Browse files

Unified · Split

include/linux/efi.h+46−0
@@ -148,6 +148,52 @@ typedef struct { · 147 unmodified lines
148 u32 imagesize;148 u32 imagesize;
149} efi_capsule_header_t;149} efi_capsule_header_t;
150 150
151/* EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER */
152struct efi_manage_capsule_header {
153 u32 ver;
154 u16 emb_drv_cnt;
155 u16 payload_cnt;
156 /*
157 * Variable-size array of the size given by the sum of
158 * emb_drv_cnt and payload_cnt.
159 */
160 u64 offset_list[];
161} __packed;
162
163/* EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER */
164struct efi_manage_capsule_image_header {
165 u32 ver;
166 efi_guid_t image_type_id;
167 u8 image_index;
168 u8 reserved_bytes[3];
169 u32 image_size;
170 u32 vendor_code_size;
171 /* hw_ins was introduced in version 2 */
172 u64 hw_ins;
173 /* capsule_support was introduced in version 3 */
174 u64 capsule_support;
175} __packed;
176
177/* WIN_CERTIFICATE */
178struct win_cert {
179 u32 len;
180 u16 rev;
181 u16 cert_type;
182};
183
184/* WIN_CERTIFICATE_UEFI_GUID */
185struct win_cert_uefi_guid {
186 struct win_cert hdr;
187 efi_guid_t cert_type;
188 u8 cert_data[];
189};
190
191/* EFI_FIRMWARE_IMAGE_AUTHENTICATION */
192struct efi_image_auth {
193 u64 mon_count;
194 struct win_cert_uefi_guid auth_info;
195};
196
151/*197/*
152 * EFI capsule flags198 * EFI capsule flags
153 */199 */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t