quirks.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. #define pr_fmt(fmt) "efi: " fmt
  2. #include <linux/init.h>
  3. #include <linux/kernel.h>
  4. #include <linux/string.h>
  5. #include <linux/time.h>
  6. #include <linux/types.h>
  7. #include <linux/efi.h>
  8. #include <linux/slab.h>
  9. #include <linux/memblock.h>
  10. #include <linux/bootmem.h>
  11. #include <linux/acpi.h>
  12. #include <linux/dmi.h>
  13. #include <asm/e820/api.h>
  14. #include <asm/efi.h>
  15. #include <asm/uv/uv.h>
  16. #include <asm/cpu_device_id.h>
  17. #define EFI_MIN_RESERVE 5120
  18. #define EFI_DUMMY_GUID \
  19. EFI_GUID(0x4424ac57, 0xbe4b, 0x47dd, 0x9e, 0x97, 0xed, 0x50, 0xf0, 0x9f, 0x92, 0xa9)
  20. #define QUARK_CSH_SIGNATURE 0x5f435348 /* _CSH */
  21. #define QUARK_SECURITY_HEADER_SIZE 0x400
  22. /*
  23. * Header prepended to the standard EFI capsule on Quark systems the are based
  24. * on Intel firmware BSP.
  25. * @csh_signature: Unique identifier to sanity check signed module
  26. * presence ("_CSH").
  27. * @version: Current version of CSH used. Should be one for Quark A0.
  28. * @modulesize: Size of the entire module including the module header
  29. * and payload.
  30. * @security_version_number_index: Index of SVN to use for validation of signed
  31. * module.
  32. * @security_version_number: Used to prevent against roll back of modules.
  33. * @rsvd_module_id: Currently unused for Clanton (Quark).
  34. * @rsvd_module_vendor: Vendor Identifier. For Intel products value is
  35. * 0x00008086.
  36. * @rsvd_date: BCD representation of build date as yyyymmdd, where
  37. * yyyy=4 digit year, mm=1-12, dd=1-31.
  38. * @headersize: Total length of the header including including any
  39. * padding optionally added by the signing tool.
  40. * @hash_algo: What Hash is used in the module signing.
  41. * @cryp_algo: What Crypto is used in the module signing.
  42. * @keysize: Total length of the key data including including any
  43. * padding optionally added by the signing tool.
  44. * @signaturesize: Total length of the signature including including any
  45. * padding optionally added by the signing tool.
  46. * @rsvd_next_header: 32-bit pointer to the next Secure Boot Module in the
  47. * chain, if there is a next header.
  48. * @rsvd: Reserved, padding structure to required size.
  49. *
  50. * See also QuartSecurityHeader_t in
  51. * Quark_EDKII_v1.2.1.1/QuarkPlatformPkg/Include/QuarkBootRom.h
  52. * from https://downloadcenter.intel.com/download/23197/Intel-Quark-SoC-X1000-Board-Support-Package-BSP
  53. */
  54. struct quark_security_header {
  55. u32 csh_signature;
  56. u32 version;
  57. u32 modulesize;
  58. u32 security_version_number_index;
  59. u32 security_version_number;
  60. u32 rsvd_module_id;
  61. u32 rsvd_module_vendor;
  62. u32 rsvd_date;
  63. u32 headersize;
  64. u32 hash_algo;
  65. u32 cryp_algo;
  66. u32 keysize;
  67. u32 signaturesize;
  68. u32 rsvd_next_header;
  69. u32 rsvd[2];
  70. };
  71. static const efi_char16_t efi_dummy_name[] = L"DUMMY";
  72. static bool efi_no_storage_paranoia;
  73. /*
  74. * Some firmware implementations refuse to boot if there's insufficient
  75. * space in the variable store. The implementation of garbage collection
  76. * in some FW versions causes stale (deleted) variables to take up space
  77. * longer than intended and space is only freed once the store becomes
  78. * almost completely full.
  79. *
  80. * Enabling this option disables the space checks in
  81. * efi_query_variable_store() and forces garbage collection.
  82. *
  83. * Only enable this option if deleting EFI variables does not free up
  84. * space in your variable store, e.g. if despite deleting variables
  85. * you're unable to create new ones.
  86. */
  87. static int __init setup_storage_paranoia(char *arg)
  88. {
  89. efi_no_storage_paranoia = true;
  90. return 0;
  91. }
  92. early_param("efi_no_storage_paranoia", setup_storage_paranoia);
  93. /*
  94. * Deleting the dummy variable which kicks off garbage collection
  95. */
  96. void efi_delete_dummy_variable(void)
  97. {
  98. efi.set_variable_nonblocking((efi_char16_t *)efi_dummy_name,
  99. &EFI_DUMMY_GUID,
  100. EFI_VARIABLE_NON_VOLATILE |
  101. EFI_VARIABLE_BOOTSERVICE_ACCESS |
  102. EFI_VARIABLE_RUNTIME_ACCESS, 0, NULL);
  103. }
  104. /*
  105. * In the nonblocking case we do not attempt to perform garbage
  106. * collection if we do not have enough free space. Rather, we do the
  107. * bare minimum check and give up immediately if the available space
  108. * is below EFI_MIN_RESERVE.
  109. *
  110. * This function is intended to be small and simple because it is
  111. * invoked from crash handler paths.
  112. */
  113. static efi_status_t
  114. query_variable_store_nonblocking(u32 attributes, unsigned long size)
  115. {
  116. efi_status_t status;
  117. u64 storage_size, remaining_size, max_size;
  118. status = efi.query_variable_info_nonblocking(attributes, &storage_size,
  119. &remaining_size,
  120. &max_size);
  121. if (status != EFI_SUCCESS)
  122. return status;
  123. if (remaining_size - size < EFI_MIN_RESERVE)
  124. return EFI_OUT_OF_RESOURCES;
  125. return EFI_SUCCESS;
  126. }
  127. /*
  128. * Some firmware implementations refuse to boot if there's insufficient space
  129. * in the variable store. Ensure that we never use more than a safe limit.
  130. *
  131. * Return EFI_SUCCESS if it is safe to write 'size' bytes to the variable
  132. * store.
  133. */
  134. efi_status_t efi_query_variable_store(u32 attributes, unsigned long size,
  135. bool nonblocking)
  136. {
  137. efi_status_t status;
  138. u64 storage_size, remaining_size, max_size;
  139. if (!(attributes & EFI_VARIABLE_NON_VOLATILE))
  140. return 0;
  141. if (nonblocking)
  142. return query_variable_store_nonblocking(attributes, size);
  143. status = efi.query_variable_info(attributes, &storage_size,
  144. &remaining_size, &max_size);
  145. if (status != EFI_SUCCESS)
  146. return status;
  147. /*
  148. * We account for that by refusing the write if permitting it would
  149. * reduce the available space to under 5KB. This figure was provided by
  150. * Samsung, so should be safe.
  151. */
  152. if ((remaining_size - size < EFI_MIN_RESERVE) &&
  153. !efi_no_storage_paranoia) {
  154. /*
  155. * Triggering garbage collection may require that the firmware
  156. * generate a real EFI_OUT_OF_RESOURCES error. We can force
  157. * that by attempting to use more space than is available.
  158. */
  159. unsigned long dummy_size = remaining_size + 1024;
  160. void *dummy = kzalloc(dummy_size, GFP_KERNEL);
  161. if (!dummy)
  162. return EFI_OUT_OF_RESOURCES;
  163. status = efi.set_variable((efi_char16_t *)efi_dummy_name,
  164. &EFI_DUMMY_GUID,
  165. EFI_VARIABLE_NON_VOLATILE |
  166. EFI_VARIABLE_BOOTSERVICE_ACCESS |
  167. EFI_VARIABLE_RUNTIME_ACCESS,
  168. dummy_size, dummy);
  169. if (status == EFI_SUCCESS) {
  170. /*
  171. * This should have failed, so if it didn't make sure
  172. * that we delete it...
  173. */
  174. efi_delete_dummy_variable();
  175. }
  176. kfree(dummy);
  177. /*
  178. * The runtime code may now have triggered a garbage collection
  179. * run, so check the variable info again
  180. */
  181. status = efi.query_variable_info(attributes, &storage_size,
  182. &remaining_size, &max_size);
  183. if (status != EFI_SUCCESS)
  184. return status;
  185. /*
  186. * There still isn't enough room, so return an error
  187. */
  188. if (remaining_size - size < EFI_MIN_RESERVE)
  189. return EFI_OUT_OF_RESOURCES;
  190. }
  191. return EFI_SUCCESS;
  192. }
  193. EXPORT_SYMBOL_GPL(efi_query_variable_store);
  194. /*
  195. * The UEFI specification makes it clear that the operating system is
  196. * free to do whatever it wants with boot services code after
  197. * ExitBootServices() has been called. Ignoring this recommendation a
  198. * significant bunch of EFI implementations continue calling into boot
  199. * services code (SetVirtualAddressMap). In order to work around such
  200. * buggy implementations we reserve boot services region during EFI
  201. * init and make sure it stays executable. Then, after
  202. * SetVirtualAddressMap(), it is discarded.
  203. *
  204. * However, some boot services regions contain data that is required
  205. * by drivers, so we need to track which memory ranges can never be
  206. * freed. This is done by tagging those regions with the
  207. * EFI_MEMORY_RUNTIME attribute.
  208. *
  209. * Any driver that wants to mark a region as reserved must use
  210. * efi_mem_reserve() which will insert a new EFI memory descriptor
  211. * into efi.memmap (splitting existing regions if necessary) and tag
  212. * it with EFI_MEMORY_RUNTIME.
  213. */
  214. void __init efi_arch_mem_reserve(phys_addr_t addr, u64 size)
  215. {
  216. phys_addr_t new_phys, new_size;
  217. struct efi_mem_range mr;
  218. efi_memory_desc_t md;
  219. int num_entries;
  220. void *new;
  221. if (efi_mem_desc_lookup(addr, &md) ||
  222. md.type != EFI_BOOT_SERVICES_DATA) {
  223. pr_err("Failed to lookup EFI memory descriptor for %pa\n", &addr);
  224. return;
  225. }
  226. if (addr + size > md.phys_addr + (md.num_pages << EFI_PAGE_SHIFT)) {
  227. pr_err("Region spans EFI memory descriptors, %pa\n", &addr);
  228. return;
  229. }
  230. size += addr % EFI_PAGE_SIZE;
  231. size = round_up(size, EFI_PAGE_SIZE);
  232. addr = round_down(addr, EFI_PAGE_SIZE);
  233. mr.range.start = addr;
  234. mr.range.end = addr + size - 1;
  235. mr.attribute = md.attribute | EFI_MEMORY_RUNTIME;
  236. num_entries = efi_memmap_split_count(&md, &mr.range);
  237. num_entries += efi.memmap.nr_map;
  238. new_size = efi.memmap.desc_size * num_entries;
  239. new_phys = efi_memmap_alloc(num_entries);
  240. if (!new_phys) {
  241. pr_err("Could not allocate boot services memmap\n");
  242. return;
  243. }
  244. new = early_memremap(new_phys, new_size);
  245. if (!new) {
  246. pr_err("Failed to map new boot services memmap\n");
  247. return;
  248. }
  249. efi_memmap_insert(&efi.memmap, new, &mr);
  250. early_memunmap(new, new_size);
  251. efi_memmap_install(new_phys, num_entries);
  252. e820__range_update(addr, size, E820_TYPE_RAM, E820_TYPE_RESERVED);
  253. e820__update_table(e820_table);
  254. }
  255. /*
  256. * Helper function for efi_reserve_boot_services() to figure out if we
  257. * can free regions in efi_free_boot_services().
  258. *
  259. * Use this function to ensure we do not free regions owned by somebody
  260. * else. We must only reserve (and then free) regions:
  261. *
  262. * - Not within any part of the kernel
  263. * - Not the BIOS reserved area (E820_TYPE_RESERVED, E820_TYPE_NVS, etc)
  264. */
  265. static bool can_free_region(u64 start, u64 size)
  266. {
  267. if (start + size > __pa_symbol(_text) && start <= __pa_symbol(_end))
  268. return false;
  269. if (!e820__mapped_all(start, start+size, E820_TYPE_RAM))
  270. return false;
  271. return true;
  272. }
  273. void __init efi_reserve_boot_services(void)
  274. {
  275. efi_memory_desc_t *md;
  276. for_each_efi_memory_desc(md) {
  277. u64 start = md->phys_addr;
  278. u64 size = md->num_pages << EFI_PAGE_SHIFT;
  279. bool already_reserved;
  280. if (md->type != EFI_BOOT_SERVICES_CODE &&
  281. md->type != EFI_BOOT_SERVICES_DATA)
  282. continue;
  283. already_reserved = memblock_is_region_reserved(start, size);
  284. /*
  285. * Because the following memblock_reserve() is paired
  286. * with free_bootmem_late() for this region in
  287. * efi_free_boot_services(), we must be extremely
  288. * careful not to reserve, and subsequently free,
  289. * critical regions of memory (like the kernel image) or
  290. * those regions that somebody else has already
  291. * reserved.
  292. *
  293. * A good example of a critical region that must not be
  294. * freed is page zero (first 4Kb of memory), which may
  295. * contain boot services code/data but is marked
  296. * E820_TYPE_RESERVED by trim_bios_range().
  297. */
  298. if (!already_reserved) {
  299. memblock_reserve(start, size);
  300. /*
  301. * If we are the first to reserve the region, no
  302. * one else cares about it. We own it and can
  303. * free it later.
  304. */
  305. if (can_free_region(start, size))
  306. continue;
  307. }
  308. /*
  309. * We don't own the region. We must not free it.
  310. *
  311. * Setting this bit for a boot services region really
  312. * doesn't make sense as far as the firmware is
  313. * concerned, but it does provide us with a way to tag
  314. * those regions that must not be paired with
  315. * free_bootmem_late().
  316. */
  317. md->attribute |= EFI_MEMORY_RUNTIME;
  318. }
  319. }
  320. void __init efi_free_boot_services(void)
  321. {
  322. phys_addr_t new_phys, new_size;
  323. efi_memory_desc_t *md;
  324. int num_entries = 0;
  325. void *new, *new_md;
  326. for_each_efi_memory_desc(md) {
  327. unsigned long long start = md->phys_addr;
  328. unsigned long long size = md->num_pages << EFI_PAGE_SHIFT;
  329. size_t rm_size;
  330. if (md->type != EFI_BOOT_SERVICES_CODE &&
  331. md->type != EFI_BOOT_SERVICES_DATA) {
  332. num_entries++;
  333. continue;
  334. }
  335. /* Do not free, someone else owns it: */
  336. if (md->attribute & EFI_MEMORY_RUNTIME) {
  337. num_entries++;
  338. continue;
  339. }
  340. /*
  341. * Nasty quirk: if all sub-1MB memory is used for boot
  342. * services, we can get here without having allocated the
  343. * real mode trampoline. It's too late to hand boot services
  344. * memory back to the memblock allocator, so instead
  345. * try to manually allocate the trampoline if needed.
  346. *
  347. * I've seen this on a Dell XPS 13 9350 with firmware
  348. * 1.4.4 with SGX enabled booting Linux via Fedora 24's
  349. * grub2-efi on a hard disk. (And no, I don't know why
  350. * this happened, but Linux should still try to boot rather
  351. * panicing early.)
  352. */
  353. rm_size = real_mode_size_needed();
  354. if (rm_size && (start + rm_size) < (1<<20) && size >= rm_size) {
  355. set_real_mode_mem(start, rm_size);
  356. start += rm_size;
  357. size -= rm_size;
  358. }
  359. free_bootmem_late(start, size);
  360. }
  361. if (!num_entries)
  362. return;
  363. new_size = efi.memmap.desc_size * num_entries;
  364. new_phys = efi_memmap_alloc(num_entries);
  365. if (!new_phys) {
  366. pr_err("Failed to allocate new EFI memmap\n");
  367. return;
  368. }
  369. new = memremap(new_phys, new_size, MEMREMAP_WB);
  370. if (!new) {
  371. pr_err("Failed to map new EFI memmap\n");
  372. return;
  373. }
  374. /*
  375. * Build a new EFI memmap that excludes any boot services
  376. * regions that are not tagged EFI_MEMORY_RUNTIME, since those
  377. * regions have now been freed.
  378. */
  379. new_md = new;
  380. for_each_efi_memory_desc(md) {
  381. if (!(md->attribute & EFI_MEMORY_RUNTIME) &&
  382. (md->type == EFI_BOOT_SERVICES_CODE ||
  383. md->type == EFI_BOOT_SERVICES_DATA))
  384. continue;
  385. memcpy(new_md, md, efi.memmap.desc_size);
  386. new_md += efi.memmap.desc_size;
  387. }
  388. memunmap(new);
  389. if (efi_memmap_install(new_phys, num_entries)) {
  390. pr_err("Could not install new EFI memmap\n");
  391. return;
  392. }
  393. }
  394. /*
  395. * A number of config table entries get remapped to virtual addresses
  396. * after entering EFI virtual mode. However, the kexec kernel requires
  397. * their physical addresses therefore we pass them via setup_data and
  398. * correct those entries to their respective physical addresses here.
  399. *
  400. * Currently only handles smbios which is necessary for some firmware
  401. * implementation.
  402. */
  403. int __init efi_reuse_config(u64 tables, int nr_tables)
  404. {
  405. int i, sz, ret = 0;
  406. void *p, *tablep;
  407. struct efi_setup_data *data;
  408. if (!efi_setup)
  409. return 0;
  410. if (!efi_enabled(EFI_64BIT))
  411. return 0;
  412. data = early_memremap(efi_setup, sizeof(*data));
  413. if (!data) {
  414. ret = -ENOMEM;
  415. goto out;
  416. }
  417. if (!data->smbios)
  418. goto out_memremap;
  419. sz = sizeof(efi_config_table_64_t);
  420. p = tablep = early_memremap(tables, nr_tables * sz);
  421. if (!p) {
  422. pr_err("Could not map Configuration table!\n");
  423. ret = -ENOMEM;
  424. goto out_memremap;
  425. }
  426. for (i = 0; i < efi.systab->nr_tables; i++) {
  427. efi_guid_t guid;
  428. guid = ((efi_config_table_64_t *)p)->guid;
  429. if (!efi_guidcmp(guid, SMBIOS_TABLE_GUID))
  430. ((efi_config_table_64_t *)p)->table = data->smbios;
  431. p += sz;
  432. }
  433. early_memunmap(tablep, nr_tables * sz);
  434. out_memremap:
  435. early_memunmap(data, sizeof(*data));
  436. out:
  437. return ret;
  438. }
  439. static const struct dmi_system_id sgi_uv1_dmi[] = {
  440. { NULL, "SGI UV1",
  441. { DMI_MATCH(DMI_PRODUCT_NAME, "Stoutland Platform"),
  442. DMI_MATCH(DMI_PRODUCT_VERSION, "1.0"),
  443. DMI_MATCH(DMI_BIOS_VENDOR, "SGI.COM"),
  444. }
  445. },
  446. { } /* NULL entry stops DMI scanning */
  447. };
  448. void __init efi_apply_memmap_quirks(void)
  449. {
  450. /*
  451. * Once setup is done earlier, unmap the EFI memory map on mismatched
  452. * firmware/kernel architectures since there is no support for runtime
  453. * services.
  454. */
  455. if (!efi_runtime_supported()) {
  456. pr_info("Setup done, disabling due to 32/64-bit mismatch\n");
  457. efi_memmap_unmap();
  458. }
  459. /* UV2+ BIOS has a fix for this issue. UV1 still needs the quirk. */
  460. if (dmi_check_system(sgi_uv1_dmi))
  461. set_bit(EFI_OLD_MEMMAP, &efi.flags);
  462. }
  463. /*
  464. * For most modern platforms the preferred method of powering off is via
  465. * ACPI. However, there are some that are known to require the use of
  466. * EFI runtime services and for which ACPI does not work at all.
  467. *
  468. * Using EFI is a last resort, to be used only if no other option
  469. * exists.
  470. */
  471. bool efi_reboot_required(void)
  472. {
  473. if (!acpi_gbl_reduced_hardware)
  474. return false;
  475. efi_reboot_quirk_mode = EFI_RESET_WARM;
  476. return true;
  477. }
  478. bool efi_poweroff_required(void)
  479. {
  480. return acpi_gbl_reduced_hardware || acpi_no_s5;
  481. }
  482. #ifdef CONFIG_EFI_CAPSULE_QUIRK_QUARK_CSH
  483. static int qrk_capsule_setup_info(struct capsule_info *cap_info, void **pkbuff,
  484. size_t hdr_bytes)
  485. {
  486. struct quark_security_header *csh = *pkbuff;
  487. /* Only process data block that is larger than the security header */
  488. if (hdr_bytes < sizeof(struct quark_security_header))
  489. return 0;
  490. if (csh->csh_signature != QUARK_CSH_SIGNATURE ||
  491. csh->headersize != QUARK_SECURITY_HEADER_SIZE)
  492. return 1;
  493. /* Only process data block if EFI header is included */
  494. if (hdr_bytes < QUARK_SECURITY_HEADER_SIZE +
  495. sizeof(efi_capsule_header_t))
  496. return 0;
  497. pr_debug("Quark security header detected\n");
  498. if (csh->rsvd_next_header != 0) {
  499. pr_err("multiple Quark security headers not supported\n");
  500. return -EINVAL;
  501. }
  502. *pkbuff += csh->headersize;
  503. cap_info->total_size = csh->headersize;
  504. /*
  505. * Update the first page pointer to skip over the CSH header.
  506. */
  507. cap_info->phys[0] += csh->headersize;
  508. /*
  509. * cap_info->capsule should point at a virtual mapping of the entire
  510. * capsule, starting at the capsule header. Our image has the Quark
  511. * security header prepended, so we cannot rely on the default vmap()
  512. * mapping created by the generic capsule code.
  513. * Given that the Quark firmware does not appear to care about the
  514. * virtual mapping, let's just point cap_info->capsule at our copy
  515. * of the capsule header.
  516. */
  517. cap_info->capsule = &cap_info->header;
  518. return 1;
  519. }
  520. #define ICPU(family, model, quirk_handler) \
  521. { X86_VENDOR_INTEL, family, model, X86_FEATURE_ANY, \
  522. (unsigned long)&quirk_handler }
  523. static const struct x86_cpu_id efi_capsule_quirk_ids[] = {
  524. ICPU(5, 9, qrk_capsule_setup_info), /* Intel Quark X1000 */
  525. { }
  526. };
  527. int efi_capsule_setup_info(struct capsule_info *cap_info, void *kbuff,
  528. size_t hdr_bytes)
  529. {
  530. int (*quirk_handler)(struct capsule_info *, void **, size_t);
  531. const struct x86_cpu_id *id;
  532. int ret;
  533. if (hdr_bytes < sizeof(efi_capsule_header_t))
  534. return 0;
  535. cap_info->total_size = 0;
  536. id = x86_match_cpu(efi_capsule_quirk_ids);
  537. if (id) {
  538. /*
  539. * The quirk handler is supposed to return
  540. * - a value > 0 if the setup should continue, after advancing
  541. * kbuff as needed
  542. * - 0 if not enough hdr_bytes are available yet
  543. * - a negative error code otherwise
  544. */
  545. quirk_handler = (typeof(quirk_handler))id->driver_data;
  546. ret = quirk_handler(cap_info, &kbuff, hdr_bytes);
  547. if (ret <= 0)
  548. return ret;
  549. }
  550. memcpy(&cap_info->header, kbuff, sizeof(cap_info->header));
  551. cap_info->total_size += cap_info->header.imagesize;
  552. return __efi_capsule_setup_info(cap_info);
  553. }
  554. #endif